]> _ Git - cubeextranet.git/commitdiff
wait #4426 @2
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 27 Apr 2021 11:16:41 +0000 (11:16 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 27 Apr 2021 11:16:41 +0000 (11:16 +0000)
inc/ws/Controlleur/class.ws.flash.php
inc/ws/Controlleur/class.ws.services.php
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Metier/class.ws.book.parametres.php
inc/ws/Metier/class.ws.book.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php
inc/ws/Util/html5/master/class.ws.html5.links.php
inc/ws/Util/packager/class.ws.packager.php

index f26656af1f7c24b35eddb854f78a10660db74fde..da40f93fde83ef257da3591f806aae3217ce7b8e 100644 (file)
@@ -257,6 +257,10 @@ class wsFlash extends cubeFlashGateway
 
     public function uploadLinkContent()
     {
+        global $core;
+        $daoBook=new wsDAOBook($core->con);
+        $book=$daoBook->selectById($this->args['book_id'] );
+
         foreach ($_FILES as $varname => $infos) {
             if ($infos['error']) {
                 continue;
@@ -273,7 +277,7 @@ class wsFlash extends cubeFlashGateway
             }
 
             $fname = cubeFiles::tidyName($infos['name']);
-            $dir = WS_BOOKS . '/working/' . $this->args['book_id'] . '/' . $dir;
+            $dir = $book->getAssetDir($dir);
             if (!file_exists($dir)) {
                 mkdir($dir, 0777, true);
             }
@@ -677,9 +681,9 @@ class wsFlash extends cubeFlashGateway
                 $dim = CubeIT_Image::getimagesize($themeRoot . $p->$param);
                 $url = 'https://' . $_SERVER['HTTP_HOST'] . WEBROOT . '/fluidbook/themes/' . $theme->theme_id . '/' . $p->$param;
             } else {
-                $bookRoot = WS_BOOKS . '/working/' . $book->book_id . '/';
+                $bookRoot = $book->getAssetDir();
                 $dim = CubeIT_Image::getimagesize($bookRoot . $p->$param);
-                $url = 'https://' . $_SERVER['HTTP_HOST'] . WEBROOT . '/fluidbook/books/working/' . $book->book_id . '/' . $p->$param;
+                $url = 'https://' . $_SERVER['HTTP_HOST'] . WEBROOT . '/fluidbook/books/working/' . $book->getAssetDirId() . '/' . $p->$param;
             }
 
             if ($this->json) {
index b96b9556732542645a7a280a88e7c14f569ea3db..6515221b4b9711adec3ec38fad495d9312caf06c 100644 (file)
@@ -183,12 +183,13 @@ class wsServices extends cubeFlashGateway
         }
 
         $id = $book->book_id;
+        $wid=$book->getAssetDir();
 
         if (isset($this->args['image'])) {
-            $cover = WS_BOOKS . '/working/' . $id . '/' . $this->args['image'];
+            $cover = $wid . $this->args['image'];
         } else {
             if (isset($book->parametres->facebook_image) && $book->parametres->facebook_image != '') {
-                $c = WS_BOOKS . '/working/' . $id . '/' . $book->parametres->facebook_image;
+                $c =$wid. $book->parametres->facebook_image;
                 if (file_exists($c)) {
                     $cover = $c;
                 }
@@ -447,12 +448,13 @@ class wsServices extends cubeFlashGateway
     {
         global $core;
         $mode = $force ? $force : $book->parametres->bookmarkUsePDF;
+        $wid=$book->getAssetDir();
         switch ($mode) {
             case 'download':
-                $res = WS_BOOKS . '/working/' . $book->book_id . '/' . $book->parametres->pdfReplace;
+                $res = $wid . $book->parametres->pdfReplace;
                 break;
             case 'thumbnails':
-                $res = WS_BOOKS . '/working/' . $book->book_id . '/' . $book->parametres->pdfThumbnails;
+                $res = $wid . $book->parametres->pdfThumbnails;
                 break;
             case 'pages':
             default:
@@ -646,154 +648,6 @@ class wsServices extends cubeFlashGateway
         $mail->send();
     }
 
-    public function grdfCoupon2015()
-    {
-        $id = $this->args['id'];
-
-        $this->outputXML = false;
-        $couponsRoot = WS_BOOKS . '/working/' . $id . '/commerce/';
-
-        $xml = simplexml_load_file($couponsRoot . 'references.xml');
-        // Check hash
-        $hash = md5('ae' . $_GET['nom'] . '25' . $_GET['ref']);
-        if ($hash != $_GET['h']) {
-            exit;
-        }
-        $refs = explode(',', $_GET['ref']);
-
-        $tmp = cubeFiles::tempnam();
-        $pdftk = new CubeIT_CommandLine('pdftk');
-        $pdftk->setPath(CONVERTER_PATH);
-        foreach ($refs as $ref) {
-            $file = $couponsRoot . $ref . '.pdf';
-            $pdftk->setArg(null, $file);
-        }
-        $pdftk->setArg(null, 'output');
-        $pdftk->setArg(null, $tmp);
-        $pdftk->execute();
-
-        header('Content-Type: application/pdf');
-        header('Content-Disposition: inline; filename="CouponChequier.pdf"');
-
-        readfile($tmp);
-        unlink($tmp);
-        exit;
-    }
-
-    public function grdfCoupon()
-    {
-
-        $id = $this->args['id'];
-
-        if ($id == 13372) {
-            return $this->grdfCoupon2015();
-        }
-
-        $this->outputXML = false;
-        $couponsRoot = WS_BOOKS . '/working/' . $id . '/commerce/';
-
-        $xml = simplexml_load_file($couponsRoot . 'references.xml');
-        // Check hash
-        $hash = md5('ae' . $_GET['nom'] . '25' . $_GET['ref']);
-        if ($hash != $_GET['h']) {
-            exit;
-        }
-        $refs = explode(',', $_GET['ref']);
-        $pdf = new FPDI();
-        foreach ($refs as $ref) {
-
-            foreach ($xml->xpath('//item[@reference=\'' . $ref . '\']') as $item) {
-                $code = (string)$item['code'];
-            }
-
-            $file = $couponsRoot . $ref . '.pdf';
-
-            $pdf->setSourceFile($file);
-            $idx = $pdf->importPage(1);
-            $pdf->AddPage();
-            $pdf->useTemplate($idx);
-            $pdf->SetXY(11, 12);
-            $pdf->SetFont('Helvetica', '', 12);
-            $pdf->SetTextColor(0, 0, 0);
-            $pdf->Cell(180, 10, utf8_decode(trim($_GET['civilite'] . ' ' . $_GET['prenom'] . ' ' . $_GET['nom']) . ','));
-            $pdf->SetXY(135, 203);
-            $pdf->SetFont('Helvetica', 'B', 16);
-            $pdf->Cell(50, 15, $code, 0, 1, "C");
-        }
-        $pdf->Output('coupon.pdf', 'I');
-    }
-
-    public function grdfExcel12568()
-    {
-        global $core;
-        $this->outputXML = false;
-
-        if (!isset($_GET['annee'])) {
-            $_GET['annee'] = 2014;
-        }
-        $annee = $_GET['annee'];
-
-        if ($annee == 2013) {
-            $id = 11222;
-        } elseif ($annee == 2014) {
-            $id = 12779;
-        }
-
-
-        $couponsRoot = WS_BOOKS . '/working/' . $id . '/commerce/';
-
-        $xml = simplexml_load_file($couponsRoot . 'references.xml');
-
-        $cols = array('Date' => 'date', 'Civilité' => 'civilite', 'Prénom' => 'prenom', 'Nom' => 'nom',
-            'E-mail' => 'email', 'Adresse' => 'adresse', 'Code postal' => 'codepostal', 'Ville' => 'ville',
-            'Téléphone' => 'telephone', 'Connu par' => 'connu', 'Energie' => 'energie', 'Type de logement' => 'logement',
-            'Echéance travaux' => 'echeance',
-            'Optin' => 'optin', 'Optin partenaires' => 'optin_partenaires');
-        $refs = array();
-        foreach ($xml->xpath('//item') as $i) {
-            $refs[(string)$i['reference']] = $i['name'];
-        }
-
-        //
-        $h = '<table>';
-        $h .= '<tr>';
-        foreach ($cols as $l => $k) {
-            $h .= '<th>' . utf8_decode($l) . '</th>';
-        }
-        foreach ($refs as $k => $l) {
-            $h .= '<th>' . utf8_decode($l) . '</th>';
-        }
-        $h .= '</tr>';
-
-        $r = $core->con->select('SELECT * FROM grdf' . $annee);
-        while ($r->fetch()) {
-            $d = json_decode($r->datas);
-            $rl = explode(',', $d->reflist);
-            $h .= '<tr>';
-            foreach ($cols as $l => $k) {
-                $v = $d->$k;
-                if ($k == 'date') {
-                    $v = date('Y-m-d H:i', $v);
-                }
-                $h .= '<td>' . utf8_decode($v) . '</td>';
-            }
-            foreach ($refs as $k => $l) {
-                $v = in_array($k, $rl) ? '1' : '0';
-                $h .= '<td>' . utf8_decode($v) . '</td>';
-            }
-            $h .= '</tr>';
-        }
-
-        $h .= '</table>';
-
-        if (!file_exists(ROOT . '/cache/12568/')) {
-            mkdir(ROOT . '/cache/12568/', 0777, true);
-        }
-        file_put_contents(ROOT . '/cache/12568/chequieravantage.xls', $h);
-        http::redirect('/cache/12568/chequieravantage.xls');
-        exit;
-    }
-
     public function proxy()
     {
         ob_end_clean();
index 8759df48b3fa3798ec9383ec764480faf0bfc25b..5cbc585064b4fc8f2b2513b64c5bd8017f9cca83 100644 (file)
@@ -847,6 +847,11 @@ class wsDAOBook extends commonDAO
         $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
     }
 
+    /**
+     * @param $book wsBook
+     * @param $version
+     * @return bool
+     */
     public function isUpToDate($book, $version)
     {
         $version = (string)$version;
@@ -868,7 +873,7 @@ class wsDAOBook extends commonDAO
         } else if ($version == 'html5') {
             return false;
             // HTML5
-            $checks = array($book->changedate, cubeFiles::filemtimeRecursive(WS_BOOKS . '/working/' . $book->book_id), cubeFiles::filemtimeRecursive(WS_COMPILE_ASSETS . '/_html5'), cubeFiles::filemtimeRecursive(ROOT . '/inc/ws/Util/html5'));
+            $checks = array($book->changedate, cubeFiles::filemtimeRecursive($book->getAssetDir()), cubeFiles::filemtimeRecursive(WS_COMPILE_ASSETS . '/_html5'), cubeFiles::filemtimeRecursive(ROOT . '/inc/ws/Util/html5'));
             foreach ($checks as $check) {
                 if ($check > $book->compilehtml5date) {
                     return false;
@@ -1226,8 +1231,7 @@ class wsDAOBook extends commonDAO
             return $path;
         }
 
-        $workingDir = WS_BOOKS . '/working/' . $book_id . '/';
-        return $workingDir . trim($dir, '/') . '/' . $path;
+        return wsBook::getAssetDirOfBook($book_id, $dir) . $path;
     }
 
     public function compileHTML5($book_id, $book, $dev = false, $delete = true)
index ca2e45117637a7ab3126f7f3dc5447e822200849..ea207076d8008540732d41fe98afe86f1e77550a 100644 (file)
@@ -110,6 +110,7 @@ class wsBookParametres extends wsParametres
         );
 
         // Deprecated
+        $this->fields['version'] = array('type' => 'combo', 'default' => '2', 'editable' => true, 'label' => __('Version'), 'datas' => array('1' => '1', '2' => '2'), 'grade' => 3);
         $this->fields['email_editable'] = array('type' => 'boolean', 'default' => true, 'editable' => false, 'label' => __("Permettre au lecteur de modifier le corps de l'email"));
         $this->fields['askAcknowledge'] = array('type' => 'boolean', 'default' => false, 'editable' => false, 'label' => __("Demander au destinataire un accusé de réception"), 'grade' => 3);
         $this->fields['sendasfluidbook'] = array('type' => 'boolean', 'default' => false, 'editable' => false, 'label' => __("Envoyer le mail comme Fluidbook"), 'grade' => 3, 'hint' => __("L'expéditeur apparaîtra en reply-to"));
@@ -201,15 +202,24 @@ class wsBookParametres extends wsParametres
                 __('PDF') => 'pdf'));
         /** **/
 
-        $this->fields['version'] = array('type' => 'combo', 'default' => '2', 'editable' => true, 'label' => __('Version'), 'datas' => array('1' => '1', '2' => '2'), 'grade' => 3);
+
         $this->fields['title'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Titre de la publication"), 'embed' => false);
         $this->fields['url_link'] = array('type' => 'text', 'default' => 'http://', 'editable' => true, 'label' => __("URL du lien de retour au site"));
         $this->fields['signature'] = array('type' => 'combo', 'default' => '1', 'editable' => true, 'label' => __('Signature'), 'grade' => 3, 'datas' => wsDroits::getSignatures());
         $this->forms['important'] = array('label' => __('Description de la publication'),
-            'fieldsnames' => array('version', 'mobileLVersion', 'mobileVersion', 'title', 'url_link', 'signature'));
+            'fieldsnames' => array('mobileLVersion', 'mobileVersion', 'title', 'url_link', 'signature'));
         // .
         // .
 
+        $this->fields['assetsDir'] = ['type' => 'text', 'label' => __('Utiliser le dossier d\'assets du fluidbook'), 'default' => '', 'editable' => true, 'grade' => 5];
+        $this->fields['linksAssets'] = ['type' => 'freefile', 'label' => __('Charger ou remplacer des fichiers de liens'), 'default' => '', 'editable' => true, 'grade' => 3, 'multiple' => true];
+
+        $this->forms['assets'] = [
+            'label' => __('Assets'),
+            'fieldsnames' => ['assetsDir', 'linksAssets']
+        ];
+        /** * */
+
         $this->fields['email_title'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Titre de l'email") . ' "' . __('Envoyer à un ami') . '"', 'hint' => __('Laisser vide pour utiliser la valeur par défaut'));
         $this->fields['email_body'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __("Corps de l'email") . ' "' . __('Envoyer à un ami') . '"', 'hint' => __('Laisser vide pour utiliser la valeur par défaut'));
 
@@ -493,7 +503,7 @@ class wsBookParametres extends wsParametres
             'fieldsnames' => ['tabsHTML5', 'tabsPages', 'tabsSections', 'tabsPagesNumbers', '|', 'tabsSide', 'tabsMargin', '|', 'tabsHideOnPages', 'tabsHideOnCover', 'tabsHideOnLastPage', 'tabsHideEdges', '|', 'tabsPriority', 'tabsLinkWidth', 'tabsHideWhenOverlapingArrows', 'tabsHideOnPortrait', 'tabsHideOnZoom']];
 
         /*** **/
-        $this->fields['linksAssets'] = ['type' => 'freefile', 'label' => __('Charger ou remplacer des fichiers de liens'), 'default' => '', 'editable' => true, 'grade' => 3, 'multiple' => true];
+
         $this->fields['customLinkClass'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Classe pour les liens personnalisés'), 'grade' => 5);
         $this->fields['ignoreLinksTypes'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Ignorer les liens de type'), 'hint' => __('Liste des numéros séparés par des virgules'), 'grade' => 5);
         $this->fields['mobileLinksRevealAnim'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Animer les liens après un changement de page"), 'grade' => 3);
@@ -507,7 +517,7 @@ class wsBookParametres extends wsParametres
 
         $this->fields['mobileIgnoreBackgroundLinks'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Ignorer les liens de background'));
         $this->forms['links'] = array('label' => __('Liens'),
-            'fieldsnames' => array('linksAssets', '|', 'permanentLinks', 'mobileLinksRevealAnim', 'linkBlinkTime', 'linkBlinkRepetition', '|', 'openLinkAtStartup', '|', 'customLinkClass', 'ignoreLinksTypes', 'mobileIgnoreBackgroundLinks', 'linkTooltipManager', 'linkCornerSize', 'linkTooltipMaxWidth', '|', 'linkTracker', 'linkTrackerRegexp', '|', 'linkFilePrefix'));
+            'fieldsnames' => array('permanentLinks', 'mobileLinksRevealAnim', 'linkBlinkTime', 'linkBlinkRepetition', '|', 'openLinkAtStartup', '|', 'customLinkClass', 'ignoreLinksTypes', 'mobileIgnoreBackgroundLinks', 'linkTooltipManager', 'linkCornerSize', 'linkTooltipMaxWidth', '|', 'linkTracker', 'linkTrackerRegexp', '|', 'linkFilePrefix'));
         //.
 
         $this->fields['textPopupStylesheet'] = ['type' => 'freefile', 'default' => '', 'editable' => true, 'label' => __('Feuille de style des popups de texte'), 'fileFilter' => $cssFilter];
index 8f3d9f6f30ee688542fd2a037c5b7bad92728dc6..7e4fd5a865a8136debf83629b42d41f07ece6838 100644 (file)
@@ -84,7 +84,7 @@ class wsBook extends cubeMetier
         return $this->$varname;\r
     }\r
 \r
-    public function getFile($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html',$force=false)\r
+    public function getFile($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html', $force = false)\r
     {\r
         $p = wsDAOBook::getDocumentPage($this->book_id, $page);\r
         if (!isset($this->_docs[$p['document_id']])) {\r
@@ -93,15 +93,34 @@ class wsBook extends cubeMetier
             $this->_docs[$p['document_id']] = $dao->selectById($p['document_id']);\r
         }\r
         $doc = $this->_docs[$p['document_id']];\r
-        return $doc->getFile($p['document_page'], $format, $resolution, $withText, $withGraphics, $version,$force);\r
+        return $doc->getFile($p['document_page'], $format, $resolution, $withText, $withGraphics, $version, $force);\r
     }\r
 \r
     public function getThumbFile($page, $format)\r
     {\r
-        $thumbpdf = WS_BOOKS . '/working/' . $this->book_id . '/' . $this->parametres->pdfThumbnails;\r
+        $thumbpdf = $this->getAssetDir(). $this->parametres->pdfThumbnails;\r
         if ($this->parametres->pdfThumbnails && file_exists($thumbpdf)) {\r
             return wsPDFConvert::getThumbFromPDF($thumbpdf, $page, $format);\r
         }\r
         return $this->getFile($page, $format, 'thumb');\r
     }\r
+\r
+    public function getAssetDir($sub = '')\r
+    {\r
+        return rtrim(WS_BOOKS . '/working/' . $this->getAssetDirId() . '/' . trim($sub, '/'), '/') . '/';\r
+    }\r
+\r
+    public function getAssetDirId()\r
+    {\r
+        return $this->parametres->assetsDir === '' ? $this->book_id : trim($this->parametres->assetsDir);\r
+    }\r
+\r
+    public static function getAssetDirOfBook($book_id, $sub = '')\r
+    {\r
+        global $core;\r
+        $dao = new wsDAOBook($core->con);\r
+        $book = $dao->selectById($book_id);\r
+\r
+        return $book->getAssetDir($sub);\r
+    }\r
 }
\ No newline at end of file
index fe98025ea2236eeba9a72f16b545dc34980ddfe2..c8048cb363b07ec37266eea5a15da4a8aba5246a 100644 (file)
@@ -271,7 +271,7 @@ class wsHTML5Compiler
             $this->dir = $dir;
         }
         $this->vdir = new CubeIT_Files_VirtualDirectory($this->dir);
-        $this->wdir = WS_BOOKS . '/working/' . $this->book_id . '/';
+
 
         $this->daoBook = new wsDAOBook($core->con);
         if (null === $book) {
@@ -280,6 +280,8 @@ class wsHTML5Compiler
             $this->book = $book;
         }
 
+        $this->wdir = $this->book->getAssetDir();
+
         $this->widget = !$this->phonegap && $this->book->parametres->widget;
 
         $this->pages = $this->daoBook->getPagesOfBook($book_id);
index 7637b0964b49599e77ef6f181a758c1145dc23ff..7149cab3dcb6756a41f10d04bfb4f2dc7f589e14 100644 (file)
@@ -369,7 +369,7 @@ class wsHTML5Link
         if ($this->target == '') {
             $this->target = '_blank';
         }
-        $this->wdir = WS_BOOKS . '/working/' . $compiler->book_id . '/';
+        $this->wdir = $this->compiler->wdir;
         $this->id = $id;
         $this->compiler = $compiler;
         $this->init();
@@ -678,6 +678,7 @@ class anchorLink extends wsHTML5Link
 
     public function getHTMLContainer()
     {
+        $this->to = self::normalizeAnchor($this->to);
         $this->compiler->addPageLabel($this->page, $this->to);
         return '<div aria-hidden="false" data-anchor="' . trim($this->to, '# ') . '" class="anchor ' . $this->getHTMLContainerClass() . '" data-hidden="' . $this->hidden . '" data-scorm="' . $this->scorm . '" data-id="' . $this->uid . '" id="l_' . $this->id . '"' . $this->getAdditionnalContent() . '>' . $this->getHTMLContent() . '</div>';
     }
@@ -686,6 +687,11 @@ class anchorLink extends wsHTML5Link
     {
         return '';
     }
+
+    public static function normalizeAnchor($anchor)
+    {
+        return mb_strtolower(CubeIT_Text::str2URL($anchor));
+    }
 }
 
 class triggerLink extends normalLink
@@ -1045,7 +1051,7 @@ class internalLink extends normalLink
             $anchor = trim($e[1], '# ');
         }
         if ($anchor) {
-            $res = $anchor;
+            $res = anchorLink::normalizeAnchor($anchor);
         } else if ($this->numerotation === 'physical') {
             $res = $p;
         } else {
@@ -1164,11 +1170,7 @@ class videoLink extends wsHTML5Link
             $attr['height'] = $h;
         } else if (!is_null($compiler) && CubeIT_Util_Url::isLocal($data->to)) {
             // Get video dimensions from thumbnail if possible (locally uploaded files)
-//            $path = WS_BOOKS . '/working/' . $compiler->book_id . '/' . $basename . '.jpg';
-//            $dim = getimagesize($path);
-//            $attr['width'] = $dim[0];
-//            $attr['height'] = $dim[1];
-            $path = WS_BOOKS . '/working/' . $compiler->book_id . '/' . $data->to;
+            $path = $compiler->wdir . '/' . $data->to;
             $e = explode(',', `ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 $path`);
             $attr['width'] = $e[0];
             $attr['height'] = $e[1];
index 89a971ad4ee7c7573a4e5837c6ac4f00b44d48c3..10b8d02fe2852b413b9404815fbc93ed760a185f 100644 (file)
@@ -71,7 +71,7 @@ class wsPackager
         $this->theme = $daoTheme->getThemeOfBook($book_id, true);
         $this->themeRoot = WS_THEMES . '/' . $this->theme->theme_id . '/';
 
-        $this->workingDir = WS_BOOKS . '/working/' . $book_id . '/';
+        $this->workingDir = $this->book->getAssetDir();
 
         $this->compile();
     }