From: vincent@cubedesigners.com Date: Tue, 21 Nov 2017 13:55:15 +0000 (+0000) Subject: #1802 #1799 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=317c94b33d448e7a1a6dca2cc520bbd17826170a;p=cubeextranet.git #1802 #1799 --- diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index bdf3e605a..eb3e27e50 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -156,6 +156,9 @@ class wsHTML5Compiler { protected $stylesheets = array(); protected $logfp = null; protected $logtime = null; + protected $beginBody = array(); + protected $seoArticles = []; + protected $securityPolicyWhitelist = ['*.google-analytics.com', '*.youtube.com', '*.ytimg.com']; function __construct($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false) { @@ -259,6 +262,25 @@ class wsHTML5Compiler { $this->logtime = $currenttime; } + public function addFacebookSDK() { + $lang = str_replace('-', '_', $this->book->lang); + $e = explode('_', $lang); + if (count($e) > 1) { + $e[1] = mb_strtoupper($lang); + } + $lang = implode('_', $e); + $this->beginBody[] = "
+"; + $this->securityPolicyWhitelist[] = '*.facebook.net'; + $this->securityPolicyWhitelist[] = 'data:'; + } + public function addPageLabel($page, $label) { $this->pageLabels[$label] = $page; } @@ -324,6 +346,7 @@ class wsHTML5Compiler { $this->log('Extras written'); $this->writeJs(); $this->log('Js written'); + $this->writeSEO(); $this->vdir->sync($delete); $this->log('Files Synced'); } @@ -474,9 +497,8 @@ class wsHTML5Compiler { $pagesContents = ''; $cache = ''; - if ($this->appcache) { - $cache = ' manifest="cache.appcache"'; - } + + $beginbody = implode("\n", array_unique($this->beginBody)); $iscript = ''; if (count($this->htmlmultimedia)) { @@ -530,8 +552,9 @@ class wsHTML5Compiler { } } + $securitypolicywhitelist = implode(' ', array_unique($this->securityPolicyWhitelist)); - $vars = array('titre', 'credits', 'statsfooter', 'ga', 'style', 'script', 'pagesContents', 'description', 'print', 'hiddenContents', 'splash', 'cache', 'bgcolor', 'message', 'favicon', 'svg'); + $vars = array('titre', 'credits', 'statsfooter', 'ga', 'style', 'script', 'pagesContents', 'description', 'print', 'hiddenContents', 'splash', 'cache', 'bgcolor', 'message', 'favicon', 'svg', 'beginbody', 'securitypolicywhitelist'); foreach ($vars as $v) { $html = str_replace('', $$v, $html); } @@ -590,6 +613,25 @@ class wsHTML5Compiler { } } + function writeSEO() { + foreach ($this->seoArticles as $seoArticle) { + $html = file_get_contents($this->assets . '/_seo.html'); + $a = $seoArticle; + unset($a['image']); + $a['imageurl'] = 'https://workshop.fluidbook.com/services/facebook_thumbnail?id=15793&j=' . time(); + if ($seoArticle['image']) { + $a['imageurl'] .= '&image=' . $seoArticle['image']; + } + $dim = getimagesize($a['imageurl']); + $a['imagewidth'] = $dim[0]; + $a['imageheight'] = $dim[1]; + foreach ($a as $k => $v) { + $html = str_replace('$' . $k, $v, $html); + } + $this->vdir->file_put_contents('p/' . $seoArticle['url'], $html); + } + } + protected function writeScorm() { $manifest = file_get_contents($this->assets . '/_imsmanifest.xml'); if (!$this->book->parametres->scorm_title) { @@ -753,7 +795,7 @@ class wsHTML5Compiler { foreach ($links as $linkData) { - if (isset($linkData['image']) && $linkData['image']) { + if (isset($linkData['image']) && $linkData['image'] && $linkData['type'] != 28) { $dupData = $linkData; $dupData['image'] = ''; $dupData['to'] = $linkData['image']; @@ -773,6 +815,10 @@ class wsHTML5Compiler { if (in_array($linkData['type'], $ignore)) { continue; } + if ($linkData['type'] == 28) { + $this->addSEOArticle($linkData['page'], $linkData['to'], $linkData['extra'], $linkData['image']); + continue; + } $link = wsHTML5Link::getInstance($this->base62($i), $linkData, $this); if (is_null($link)) { continue; @@ -826,6 +872,10 @@ class wsHTML5Compiler { return $css; } + public function addSEOArticle($page, $title, $intro, $image) { + $this->seoArticles[$title] = ['title' => $title, 'description' => $intro, 'image' => $image, 'content' => '', 'page' => $page, 'url' => CubeIT_Text::str2URL($title) . '.html']; + } + public function _sortLinks($a, $b) { $priorities = array(26 => 1); @@ -1007,6 +1057,7 @@ class wsHTML5Compiler { } } $this->config->rasterizePages = cubeArray::parseRange($this->config->rasterizePages); + $this->config->seoArticles = $this->seoArticles; return 'var DATAS=' . json_encode($this->config) . ';' . "\n"; } diff --git a/inc/ws/Util/html5/master/class.ws.html5.links.php b/inc/ws/Util/html5/master/class.ws.html5.links.php index 76305d856..ab2fc24cf 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -128,6 +128,9 @@ class wsHTML5Link { case 27: return new eventOverlayLink($id, $init, $compiler); break; + case 29: + return new facebookLikeLink($id, $init, $compiler); + break; default: return null; } @@ -750,12 +753,18 @@ class actionLink extends internalLink { } public function getAdditionnalContent() { + $res = parent::getAdditionnalContent(); + if ($this->extra) { + $res .= ' data-extra="' . $this->extra . '"'; + } + if (in_array($this->to, $this->_share)) { - return parent::getAdditionnalContent() . ' data-service="' . $this->to . '" '; + $res .= ' data-service="' . $this->to . '" '; } else { - return /*parent::getClasses()*/ + $res .= /*parent::getClasses()*/ ' data-action="' . $this->to . '" '; } + return $res; } public function getDefaultTooltip() { @@ -810,6 +819,13 @@ class fileLink extends normalLink { } +class facebookLikeLink extends wsHTML5Link { + public function getHTMLContent() { + $this->compiler->addFacebookSDK(); + return '
'; + } +} + class htmlMultimediaLink extends wsHTML5Link { protected $_config = null;