$this->fields['articlesFont'] = ['type' => 'combo', 'label' => __('Police des articles'), 'default' => 'OpenSans', 'datas' => [
'Open Sans (police du Fluidbook)' => 'OpenSans', 'Montserrat' => 'Montserrat'], 'editable' => 'true', 'grade' => 3];
$this->fields['articlesImages'] = ['type' => 'freefile', 'label' => __('Images des articles'), 'default' => '', 'hint' => __('Les noms des fichiers doivent être les même que ceux des balises <image> du XML'), 'editable' => true, 'grade' => 3, 'dir' => 'articles'];
+ $this->fields['articlesShare'] = ['type' => 'boolean', 'default' => true, 'editable' => true, 'label' => 'Activer le partage', 'grade' => 3];
- $this->forms['articles'] = ['label' => __('Articles'), 'fieldsnames' => ['articlesFile', 'articlesFont', 'articlesImages']];
+ $this->forms['articles'] = ['label' => __('Articles'), 'fieldsnames' => ['articlesFile', 'articlesShare', 'articlesFont', 'articlesImages']];
//.
$this->fields['externalArchives'] = array('type' => 'freefile', 'default' => '', 'editable' => true,
$linkData['hidden'] = in_array($linkData['uid'], $hiddenLinks);
if ($linkData['type'] == 28) {
- $this->addSEOArticle($linkData['page'], $linkData['to'], $linkData['extra'], $linkData['image']);
+ $this->addSEOArticle('#/page/' . $linkData['page'], $linkData['to'], $linkData['extra'], $linkData['image']);
continue;
}
$link = wsHTML5Link::getInstance($this->base62($i), $linkData, $this);
return $css;
}
- public function addSEOArticle($page, $title, $intro, $image)
+ public function addSEOArticle($page, $title, $intro, $image, $id = null, $url = null, $content = '')
{
- $this->seoArticles[$title] = ['title' => $title, 'description' => $intro, 'image' => $image, 'content' => '', 'page' => $page, 'url' => CubeIT_Text::str2URL($title) . '.html'];
+ if (null === $url) {
+ $url = CubeIT_Text::str2URL($title) . '.html';
+ }
+ if (null === $id) {
+ $id = $title;
+ }
+
+ $this->seoArticles[$id] = ['title' => $title, 'description' => $intro, 'image' => $image, 'content' => $content, 'page' => $page, 'url' => $url, 'id' => $id];
}
public function _sortLinks($a, $b)
public function getConfigZIP($d)
{
- $res = array('type'=>'zip','width' => 0, 'height' => 0);
+ $res = array('type' => 'zip', 'width' => 0, 'height' => 0);
if (file_exists($d . '/index.html')) {
$doc = new DOMDocument();
@$doc->loadHTMLFile($d . '/index.html');
$inner = '<article data-id="' . $article['id'] . '" class="menu-article" id="article_' . $article['id'] . '">';
$inner .= '<style type="text/css">' . str_replace('##', '#article_' . $article['id'], $specificStyles) . '</style>';
- $inner .= '<a href="#" class="print"><svg viewBox="0 0 512 512" class="nav-print nav-icon svg-icon"><use xlink:href="#nav-print"></use></svg></a>';
+ $inner .= '<div class="actions">';
+ if ($this->book->parametres->articlesShare && $this->book->parametres->share) {
+ $inner .= '<a data-id="' . $article['id'] . '" data-url="' . $url . '" href="#" class="articlesShare"><svg viewBox="0 0 512 512" class="nav-share nav-icon svg-icon"><use xlink:href="#nav-share"></use></svg></a>';
+ }
+ $inner .= '<a href="#" class="articlesPrint"><svg viewBox="0 0 512 512" class="nav-print nav-icon svg-icon"><use xlink:href="#nav-print"></use></svg></a>';
+ $inner .= '</div>';
+
+ $title = '';
+ $lead = '';
+ $image = '';
+
foreach ($a->children() as $child) {
$tag = $child->getName();
if ($tag === 'image') {
+
$file = (string)$child['file'];
+ if ($image === '') {
+ $image = 'articles/' . $file;
+ }
$this->vdir->copy($this->wdir . '/articles/' . $file, 'data/articles/' . $file);
$legend = (string)$child;
$inner .= '<figure><img src="data/articles/' . $file . '" alt="' . $legend . '"><figcaption>' . $legend . '</figcaption></figure>';
} else {
+ $c = trim(((string)$child));
+ if (!$c) {
+ continue;
+ }
+ if (!$title && $tag === 'title') {
+ $title = $c;
+ }
+ if (!$lead && $tag === 'lead') {
+ $lead = $c;
+ }
$m = $markupMap[$tag] ?? $tag;
$e = explode('.', $m);
$markup = $e[0];
if (count($e) === 2) {
$class = ' class="' . $e[1] . '"';
}
- $inner .= '<' . $markup . $class . '>' . ((string)$child) . '</' . $markup . '>';
+ $inner .= '<' . $markup . $class . '>' . $c . '</' . $markup . '>';
}
}
$inner .= '</article>';
$content .= '</body></html>';
$article['print'] = $content;
$list[] = $article;
+
+ $this->addSEOArticle('#/article/' . $article['url'], $title, $lead, $image, $article['id'], $article['url'], $inner);
}
$list[0]['prev'] = $prevurl;
$list[count($list) - 1]['next'] = $firsturl;