public $writeLinksData = false;
public $content_lock = [];
public $cssfont = [];
+ public $lessVariables = [];
protected $_indexVars = null;
public $_signature;
$this->writeImages();
$this->log('Images written');
$this->writeCartConfig();
+ $this->writeArticles();
+ $this->log('Articles written');
$linksCSS = $this->writeLinks();
$this->log('Links written');
$this->writeLangs();
$this->log('Langs written');
- $this->writeArticles();
- $this->log('Articles written');
$this->writeSEO();
$this->log('SEO written');
$this->writeWidget();
$lessContents = '';
- $lessVariables = array();
- $lessVariables['css-scale'] = $this->cssScale;
- $lessVariables['slider-display'] = $this->_lessBoolean($this->theme->parametres->pagesBar);
- $lessVariables['slider-thumb-background'] = wsHTML5::colorToCSS($this->theme->parametres->pageBarThumbBack);
+ $this->lessVariables['css-scale'] = $this->cssScale;
+ $this->lessVariables['slider-display'] = $this->_lessBoolean($this->theme->parametres->pagesBar);
+ $this->lessVariables['slider-thumb-background'] = wsHTML5::colorToCSS($this->theme->parametres->pageBarThumbBack);
// General theme
$cssWidth = $this->cssWidth;
$navTop = ($cssHeight - 40 - 100) / 2;
$leftOfRightPage = (floor($cssWidth) - 1) . 'px';
- $lessVariables['z'] = $this->z;
- $lessVariables['book-page-width'] = $w;
+ $this->lessVariables['z'] = $this->z;
+ $this->lessVariables['book-page-width'] = $w;
if ($this->book->parametres->correctCenter && !$this->isMobileFirst()) {
- $lessVariables['book-page-correct-width'] = ceil($w) + 1;
- $lessVariables['book-page-correct-height'] = ceil($h) + 1;
+ $this->lessVariables['book-page-correct-width'] = ceil($w) + 1;
+ $this->lessVariables['book-page-correct-height'] = ceil($h) + 1;
} else {
- $lessVariables['book-page-correct-width'] = $w;
- $lessVariables['book-page-correct-height'] = $h;
+ $this->lessVariables['book-page-correct-width'] = $w;
+ $this->lessVariables['book-page-correct-height'] = $h;
}
- $lessVariables['book-page-height'] = $h;
- $lessVariables['book-page-ratio'] = floatval($w) / floatval($h);
+ $this->lessVariables['book-page-height'] = $h;
+ $this->lessVariables['book-page-ratio'] = floatval($w) / floatval($h);
- $lessVariables['shadow-opacity'] = wsHTML5::colorToArray($this->theme->parametres->bookShadeColor)['opacity'] * 1.2;
- $lessVariables['edges-display'] = $this->_lessBoolean($this->theme->parametres->usePageEdges);
- $lessVariables['edge-left-offset'] = $this->theme->parametres->pageEdgeLeftOffset;
- $lessVariables['edge-right-offset'] = $this->theme->parametres->pageEdgeRightOffset;
- $lessVariables['edges-opacity'] = $this->theme->parametres->pageEdgeOpacity / 100;
+ $this->lessVariables['shadow-opacity'] = wsHTML5::colorToArray($this->theme->parametres->bookShadeColor)['opacity'] * 1.2;
+ $this->lessVariables['edges-display'] = $this->_lessBoolean($this->theme->parametres->usePageEdges);
+ $this->lessVariables['edge-left-offset'] = $this->theme->parametres->pageEdgeLeftOffset;
+ $this->lessVariables['edge-right-offset'] = $this->theme->parametres->pageEdgeRightOffset;
+ $this->lessVariables['edges-opacity'] = $this->theme->parametres->pageEdgeOpacity / 100;
- $lessVariables['page-number-color'] = wsHTML5::colorToCSS($this->theme->parametres->colorPageNumber);
- $lessVariables['display-page-number'] = $this->_lessBoolean($this->theme->parametres->displayPageNumber);
- $lessVariables['page-transition-duration'] = $this->book->parametres->mobileTransitionDuration . 's';
+ $this->lessVariables['page-number-color'] = wsHTML5::colorToCSS($this->theme->parametres->colorPageNumber);
+ $this->lessVariables['display-page-number'] = $this->_lessBoolean($this->theme->parametres->displayPageNumber);
+ $this->lessVariables['page-transition-duration'] = $this->book->parametres->mobileTransitionDuration . 's';
$corrText = $this->isMobileFirst() ? 0 : 4;
$res[] = 'footer,footer a{color:' . wsHTML5::colorToCSS($this->theme->parametres->creditsColor) . ';}';
// Arrows
- $lessVariables['arrows-background'] = wsHTML5::colorToCSS($this->theme->parametres->couleurA);
- $lessVariables['arrows-color'] = wsHTML5::colorToCSS($this->theme->parametres->arrowsColor);
+ $this->lessVariables['arrows-background'] = wsHTML5::colorToCSS($this->theme->parametres->couleurA);
+ $this->lessVariables['arrows-color'] = wsHTML5::colorToCSS($this->theme->parametres->arrowsColor);
// Loader
- $lessVariables['loader-background-color'] = wsHTML5::colorToCSS($this->theme->parametres->couleurL);
- $lessVariables['loader-foreground-color'] = wsHTML5::colorToCSS($this->theme->parametres->loadingSecColor);
+ $this->lessVariables['loader-background-color'] = wsHTML5::colorToCSS($this->theme->parametres->couleurL);
+ $this->lessVariables['loader-foreground-color'] = wsHTML5::colorToCSS($this->theme->parametres->loadingSecColor);
// Audio description buttons
- $lessVariables['audiodescription-background'] = wsHTML5::colorToCSS($this->theme->parametres->couleurA);
- $lessVariables['audiodescription-color'] = wsHTML5::colorToCSS($this->theme->parametres->couleurA);
+ $this->lessVariables['audiodescription-background'] = wsHTML5::colorToCSS($this->theme->parametres->couleurA);
+ $this->lessVariables['audiodescription-color'] = wsHTML5::colorToCSS($this->theme->parametres->couleurA);
// Links Styles
- $lessVariables['links-color'] = wsHTML5::colorToCSS($this->theme->parametres->linksColor);
- $lessVariables['inlineslideshow-transition-time'] = (floatval($this->book->parametres->inlineSlideshowTransitionDuration) * 1000) . 'ms';
+ $this->lessVariables['links-color'] = wsHTML5::colorToCSS($this->theme->parametres->linksColor);
+ $this->lessVariables['inlineslideshow-transition-time'] = (floatval($this->book->parametres->inlineSlideshowTransitionDuration) * 1000) . 'ms';
$res = array_merge($res, $links);
// Bookmarks
$this->book->parametres->bookmarkCornerSize = 10;
}
- $lessVariables['bookmark-star-disabled-color'] = wsHTML5::colorToCSS($this->theme->parametres->bookmarkStarDisabledColor);
- $lessVariables['bookmark-star-enabled-color'] = wsHTML5::colorToCSS($this->theme->parametres->bookmarkStarEnabledColor);
- $lessVariables['bookmark-color'] = wsHTML5::colorToCSS($this->theme->parametres->bookmarkBackgroundColor);
- $lessVariables['bookmark-corner-size'] = round($this->width * $this->book->parametres->bookmarkCornerSize * 0.0075 * $this->z) . 'px';
- $lessVariables['bookmark-corner-offset'] = $this->book->parametres->bookmarkOffset . 'px';
+ $this->lessVariables['bookmark-star-disabled-color'] = wsHTML5::colorToCSS($this->theme->parametres->bookmarkStarDisabledColor);
+ $this->lessVariables['bookmark-star-enabled-color'] = wsHTML5::colorToCSS($this->theme->parametres->bookmarkStarEnabledColor);
+ $this->lessVariables['bookmark-color'] = wsHTML5::colorToCSS($this->theme->parametres->bookmarkBackgroundColor);
+ $this->lessVariables['bookmark-corner-size'] = round($this->width * $this->book->parametres->bookmarkCornerSize * 0.0075 * $this->z) . 'px';
+ $this->lessVariables['bookmark-corner-offset'] = $this->book->parametres->bookmarkOffset . 'px';
// Menus
$menuColor = new CubeIT_Graphics_Color($this->theme->parametres->couleurB);
$menuTextColor = wsHTML5::colorToCSS($this->theme->parametres->subTextColor);
$menuBreakpoint = empty($this->book->parametres->menuBreakpoint) ? '1023px' : $this->book->parametres->menuBreakpoint;
- $lessVariables['menu-breakpoint'] = $menuBreakpoint;
- $lessVariables['menu-background'] = $menuColor->toCSS();
+ $this->lessVariables['menu-breakpoint'] = $menuBreakpoint;
+ $this->lessVariables['menu-background'] = $menuColor->toCSS();
if ($this->theme->parametres->subSecondaryColor) {
- $lessVariables['menu-button-background'] = wsHTML5::colorToCSS($this->theme->parametres->subSecondaryColor);
+ $this->lessVariables['menu-button-background'] = wsHTML5::colorToCSS($this->theme->parametres->subSecondaryColor);
} else {
- $lessVariables['menu-background-green'] = 'max(45, min(255-45, green(@menu-background)))';
- $lessVariables['menu-background-red'] = 'max(45, min(255-45, red(@menu-background)))';
- $lessVariables['menu-background-blue'] = 'max(45, min(255-45, blue(@menu-background)))';
- $lessVariables['menu-button-background'] = 'overlay(rgb(@menu-background-red, @menu-background-green, @menu-background-blue), #c0c0c0)';
+ $this->lessVariables['menu-background-green'] = 'max(45, min(255-45, green(@menu-background)))';
+ $this->lessVariables['menu-background-red'] = 'max(45, min(255-45, red(@menu-background)))';
+ $this->lessVariables['menu-background-blue'] = 'max(45, min(255-45, blue(@menu-background)))';
+ $this->lessVariables['menu-button-background'] = 'overlay(rgb(@menu-background-red, @menu-background-green, @menu-background-blue), #c0c0c0)';
}
- $lessVariables['menu-text'] = $menuTextColor;
- $lessVariables['menu-field-background'] = wsHTML5::colorToCSS($this->theme->parametres->subFieldColor);
- $lessVariables['menu-field-text'] = wsHTML5::colorToCSS($this->theme->parametres->subTextFieldColor);
- $lessVariables['menu-select-background'] = wsHTML5::colorToCSS($this->theme->parametres->subSelectColor);
- $lessVariables['menu-select-text'] = wsHTML5::colorToCSS($this->theme->parametres->subTextSelectColor);
- $lessVariables['icon-color'] = wsHTML5::colorToCSS($this->theme->parametres->couleurI);
- $lessVariables['menu-overlay'] = wsHTML5::colorToCSS($this->theme->parametres->popupVideoOverlay);
+ $this->lessVariables['menu-text'] = $menuTextColor;
+ $this->lessVariables['menu-field-background'] = wsHTML5::colorToCSS($this->theme->parametres->subFieldColor);
+ $this->lessVariables['menu-field-text'] = wsHTML5::colorToCSS($this->theme->parametres->subTextFieldColor);
+ $this->lessVariables['menu-select-background'] = wsHTML5::colorToCSS($this->theme->parametres->subSelectColor);
+ $this->lessVariables['menu-select-text'] = wsHTML5::colorToCSS($this->theme->parametres->subTextSelectColor);
+ $this->lessVariables['icon-color'] = wsHTML5::colorToCSS($this->theme->parametres->couleurI);
+ $this->lessVariables['menu-overlay'] = wsHTML5::colorToCSS($this->theme->parametres->popupVideoOverlay);
// Chapters
- $lessVariables['menu-chapters-columns-count'] = max(1, min(6, $this->book->parametres->chaptersColumns));
- $lessVariables['menu-chapters-columns-width'] = $this->book->parametres->chaptersColMaxWidth;
- $lessVariables['menu-chapters-font-size'] = $this->book->parametres->chaptersFontSize;
+ $this->lessVariables['menu-chapters-columns-count'] = max(1, min(6, $this->book->parametres->chaptersColumns));
+ $this->lessVariables['menu-chapters-columns-width'] = $this->book->parametres->chaptersColMaxWidth;
+ $this->lessVariables['menu-chapters-font-size'] = $this->book->parametres->chaptersFontSize;
foreach ($this->book->chapters as $chapter) {
if (substr($chapter->page, 0, 1) != '#') {
$ratio = $this->width / $this->height;
$thumbh = round(100 / $ratio);
$this->config->thumbHeight = $thumbh;
- $lessVariables['thumb-height'] = $thumbh . 'px';
+ $this->lessVariables['thumb-height'] = $thumbh . 'px';
#tooltip
- $lessVariables['tooltip-background'] = wsHTML5::colorToCSS($this->theme->parametres->tooltipBackColor);
- $lessVariables['tooltip-color'] = wsHTML5::colorToCSS($this->theme->parametres->tooltipTextColor);
- $lessVariables['tooltip-font-size'] = 14 * ($this->theme->parametres->tooltipTextSize / 100);
+ $this->lessVariables['tooltip-background'] = wsHTML5::colorToCSS($this->theme->parametres->tooltipBackColor);
+ $this->lessVariables['tooltip-color'] = wsHTML5::colorToCSS($this->theme->parametres->tooltipTextColor);
+ $this->lessVariables['tooltip-font-size'] = 14 * ($this->theme->parametres->tooltipTextSize / 100);
#fonts
foreach ($this->cssfont as $hash => $item) {
$res[] = file_get_contents($this->wdir . '/' . $this->book->parametres->textPopupStylesheet);
}
- $this->_writeLess($lessVariables, $lessContents);
+ $this->_writeLess($this->lessVariables, $lessContents);
$this->stylesheets[] = 'data/style/style.css';
$this->vdir->file_put_contents('data/style/style.css', implode("\n", $res));
$this->log('Write CSS');
public function addFontKit($font)
{
- $path = 'style/fonts/Montserrat';
+ $path = 'style/fonts/' . $font;
$this->stylesheets[] = $path . '/font.css';
$this->vdir->copyDirectory($this->assets . '/' . $path, $path);
+ return $path . '/font.css';
}
public function writeArticles()
return;
}
+ $this->addLess('articles');
+
+ $this->lessVariables['articles-title-color'] = '#565657';
+ $this->lessVariables['articles-font'] = $this->book->parametres->articlesFont;
if ($this->book->parametres->articlesFont !== 'OpenSans') {
- $this->addFontKit($this->book->parametres->articlesFont);
+ $fontPath = $this->addFontKit($this->book->parametres->articlesFont);
}
+ $svg = '<svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><symbol id="nav-print" viewBox="0 0 512 512">
+ <path d="m424 186l-39 0 0-114c0-9-6-15-14-15l-230 0c-8 0-14 6-14 15l0 114-39 0c-22 0-41 19-41 41l0 121c0 23 19 41 41 41l39 0 0 49c0 8 6 15 14 15l230 0c8 0 14-7 14-15l0-49 39 0c22 0 41-18 41-41l0-121c0-22-19-41-41-41z m-268-100l200 0 0 100-200 0z m200 340l-200 0 0-88 200 0z m80-76c0 6-6 12-12 12l-39 0 0-38c0-9-6-15-14-15l-230 0c-8 0-14 6-14 15l0 38-39 0c-6 0-12-6-12-12l0-121c0-6 6-12 12-12l336 0c6 0 12 6 12 12z m-278-96l-33 0c-8 0-14 6-14 14 0 8 6 15 14 15l35 0c8 0 14-7 14-15 0-8-8-14-16-14z m32 139l132 0c8 0 14-6 14-14 0-8-6-14-14-14l-132 0c-8 0-14 6-14 14 0 8 6 14 14 14z"/>
+ </symbol></svg>';
+
$markupMap = ['category' => 'h3', 'subtitle' => 'h2', 'title' => 'h1', 'lead' => 'div.chapo', 'paragraph' => 'p', 'note' => 'div.note', 'quote' => 'blockquote', 'signature' => 'div.author'];
$x = simplexml_load_string(file_get_contents($f));
+ $prevurl = '';
foreach ($x->xpath('/articles/article') as $k => $a) {
+ $url = (string)$a['url'];
$article = ['id' => (string)$a['id'],
- 'url' => (string)$a['url'],
+ 'url' => $url,
'color' => (string)$a['color'],
- 'contents' => ''];
+ 'contents' => '',
+ 'prev' => $prevurl,
+ 'next' => ''];
- $id = 'article_' . $k;
+ if ($prevurl !== '') {
+ $list[count($list) - 1]['next'] = $url;
+ } else {
+ $firsturl = $url;
+ }
+
+ $prevurl = $url;
- $content = '<article id="' . $id . '">';
+ $specificStyles = '## h3, ## figure figcaption{background-color:' . $article['color'] . '}';
+ $specificStyles .= '## .chapo, ## blockquote{color:' . $article['color'] . ';}';
+
+ $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>';
foreach ($a->children() as $child) {
$tag = $child->getName();
if ($tag === 'image') {
$file = (string)$child['file'];
+ $this->vdir->copy($this->wdir . '/articles/' . $file, 'data/articles/' . $file);
$legend = (string)$child;
- $content .= '<figure><img src="data/articles/' . $file . '" alt="' . $legend . '"><figcation>' . $legend . '</figcation></figure>';
+ $inner .= '<figure><img src="data/articles/' . $file . '" alt="' . $legend . '"><figcaption>' . $legend . '</figcaption></figure>';
} else {
$m = $markupMap[$tag] ?? $tag;
$e = explode('.', $m);
if (count($e) === 2) {
$class = ' class="' . $e[1] . '"';
}
- $content .= '<' . $markup . $class . '>' . ((string)$child) . '</' . $markup . '>';
+ $inner .= '<' . $markup . $class . '>' . ((string)$child) . '</' . $markup . '>';
}
}
- $content .= '</article>';
- $article['contents'] = $content;
+ $inner .= '</article>';
+
+ $article['contents'] = $inner;
+ $content = '<html><head>';
+ $content .= '<link rel="stylesheet" type="text/css" href="' . $fontPath . '">';
+ $content .= '<link rel="stylesheet" type="text/css" href="style/articles.css">';
+ $content .= '<style type="text/css">';
+ $content .= str_replace('## ', '', $specificStyles);
+ $content .= '</style>';
+ $content .= '<style type="text/css" media="screen">*{visibility:hidden}</style>';
+ $content .= '</head><body>';
+ $content .= $svg;
+ $content .= $inner;
+ $content .= '</body></html>';
+ $article['print'] = $content;
$list[] = $article;
}
+ $list[0]['prev'] = $prevurl;
+ $list[count($list) - 1]['next'] = $firsturl;
- $this->config->articlesList = $list;
+ $idlist = [];
+ foreach ($list as $item) {
+ $idlist[$item['id']] = $item;
+ }
+ $this->config->articlesList = $idlist;
}
}