]> _ Git - cubeextranet.git/commitdiff
#1802
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 20 Nov 2017 17:58:47 +0000 (17:58 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 20 Nov 2017 17:58:47 +0000 (17:58 +0000)
inc/ws/Util/html5/socialarticles/class.ws.html5.compiler.php
inc/ws/Util/html5/socialarticles/class.ws.html5.links.php

index 5363ab4c480224776115da97f66b99b9d3fc7adb..0aa3ba70822228908ba0ca48e6023a5f8bdcb80a 100644 (file)
@@ -156,7 +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) {
@@ -260,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[] = "<div id=\"fb-root\"></div>
+<script>(function(d, s, id) {
+  var js, fjs = d.getElementsByTagName(s)[0];
+  if (d.getElementById(id)) return;
+  js = d.createElement(s); js.id = id;
+  js.src = 'https://connect.facebook.net/" . $lang . "/sdk.js#xfbml=1&version=v2.11&appId=132006430233560';
+  fjs.parentNode.insertBefore(js, fjs);
+}(document, 'script', 'facebook-jssdk'));</script>";
+               $this->securityPolicyWhitelist[] = '*.facebook.net';
+               $this->securityPolicyWhitelist[] = 'data:';
+       }
+
        public function addPageLabel($page, $label) {
                $this->pageLabels[$label] = $page;
        }
@@ -474,11 +495,9 @@ class wsHTML5Compiler {
                $style = implode("\n\t\t", $style);
 
                $pagesContents = '';
-
                $cache = '';
-               if ($this->appcache) {
-                       $cache = ' manifest="cache.appcache"';
-               }
+
+               $beginbody = implode("\n", array_unique($this->beginBody));
 
                $iscript = '';
                if (count($this->htmlmultimedia)) {
@@ -532,8 +551,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 . ' -->', $$v, $html);
                }
index a82a41555b8f26525ffa2a0de590b30ad0f6ced3..ada28e3abdc01a97b74bea102323e50dfc3cc9a6 100644 (file)
@@ -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;
                }
@@ -816,6 +819,13 @@ class fileLink extends normalLink {
 
 }
 
+class facebookLikeLink extends wsHTML5Link {
+       public function getHTMLContent() {
+               $this->compiler->addFacebookSDK();
+               return '<div class="fb-like" data-href="' . $this->to . '" data-layout="standard" data-action="like" data-size="large" data-show-faces="true" data-share="true"></div>';
+       }
+}
+
 class htmlMultimediaLink extends wsHTML5Link {
 
        protected $_config = null;