]> _ Git - fluidbook-v3.git/commitdiff
done #655 @4.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 2 Sep 2016 16:13:24 +0000 (16:13 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 2 Sep 2016 16:13:24 +0000 (16:13 +0000)
.htaccess
framework/application/controllers/MaintenanceController.php
framework/application/forms/CMS/Sub/Exemples/Fluidbook.php
framework/application/forms/CMS/Sub/Home/Services/Example.php
framework/application/forms/CMS/Sub/Home/Services/References.php [new file with mode: 0644]
framework/application/models/Reference.php
framework/application/views/helpers/Exemples.php
framework/application/views/helpers/HomeReferences.php
framework/application/views/helpers/HomeServices.php

index 57e4523720e647b3f6e5e2fb840d681a5b8d56cc..d5a4959ab8bc04dbfc800a6df3faba5e32ebd268 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -40,6 +40,7 @@
        RewriteRule ^js/ - [NC,L]
        RewriteRule ^images/ - [NC,L]
        RewriteRule ^files/ - [NC,L]
+       RewriteRule ^references/ - [NC,L]
        # Redirect CMS files to the right URL
        RewriteRule ^([a-f0-9]{6,})-([a-z0-9-._])([a-z0-9-._])([a-z0-9-._]*)$ files/$2/$3/$1-$2$3$4 [NC,L]
        # Ignore static files or directories
index ab8f4f7490753044aaa7c5f40529d55d69f83221..d171279b3cc2fbdd8cb152a752ef95bac962c8ec 100644 (file)
@@ -8,9 +8,38 @@ class MaintenanceController extends CubeIT_Controller_MaintenanceController {
                return $url;
        }
 
-       public function importEn() {
-               $import = new CubeIT_Translate_Import_Excel('fr', 'en');
-               $import->import(PUBLIC_PATH . '/translations_en.xlsx');
-               Bootstrap::getInstance()->getCache()->clean();
+       //      public function importEn() {
+       //              $import = new CubeIT_Translate_Import_Excel('fr', 'en');
+       //              $import->import(PUBLIC_PATH . '/translations_en.xlsx');
+       //              Bootstrap::getInstance()->getCache()->clean();
+       //      }
+
+       public function importReferences() {
+               set_time_limit(0);
+
+               $ws = new CubeIT_Services_Fluidbook('vincent@cubedesigners.com', 'iquique');
+               $references = Fluidbook_Model_Reference::factory()->find();
+
+               $fluidbooks = array();
+               foreach ($references as $reference) {
+                       $ids = $reference->getFluidbookId();
+                       foreach ($ids as $locale => $id) {
+                               if (!$id) {
+                                       continue;
+                               }
+                               $fluidbooks[] = $id;
+                       }
+               }
+               $fluidbooks = array_values(array_unique($fluidbooks));
+
+               foreach ($fluidbooks as $fluidbook) {
+                       $meta = $ws->getMetadata($fluidbook);
+                       $dir = PUBLIC_PATH . '/references/' . $fluidbook . '-' . CubeIT_Text::str2URL($meta->title);
+                       try {
+                               $ws->installBookIfNeeded($fluidbook, $dir, $meta->date);
+                       } catch (exception $e) {
+                       }
+
+               }
        }
 }
index 4bed9b216be366d223cda41123330dfc73baa7ed..c663a07b943437f8de6d1fe20d7ced06e769a113 100644 (file)
@@ -58,4 +58,8 @@ class Fluidbook_Form_CMS_Sub_Exemples_Fluidbook extends CubeIT_Form_List_Model {
                        ->setAdditionnalColumns(array('fluidbook_id', 'featured', 'homeimage', 'date'))\r
                        ->setSearchColumns(array('text', 'fluidbook_id', 'title'));\r
        }\r
+\r
+       function getTitle() {\r
+               return parent::getTitle() . ' (#' . $this->getIdValue() . ')';\r
+       }\r
 }
\ No newline at end of file
index 386043d83535f51d6f7f2559109e76e925e8d879..8bf4a75c2a53a796a98df5dd30653dfdab8976c9 100644 (file)
@@ -2,19 +2,19 @@
 
 class Fluidbook_Form_CMS_Sub_Home_Services_Example extends CubeIT_Form_SubForm {
 
-    public function init() {
-        parent::init();
+       public function init() {
+               parent::init();
 
-        $title = new CubeIT_Form_Element_Text('title');
-        $title->setLabel('Titre du exemple');
-        $this->addElement($title);
+               $title = new CubeIT_Form_Element_Text('title');
+               $title->setLabel('Titre du exemple');
+               $this->addElement($title);
 
-        $link = new CubeIT_Form_Element_Url('link');
-        $link->setLabel('URL du Fluidbook exemple');
-        $this->addElement($link);
+               $exemple = new Fluidbook_Form_CMS_Sub_Home_Services_References('exemple');
+               $exemple->setLabel('Exemple');
+               $this->addElement($exemple);
 
-        $image = new CubeIT_Form_Element_File_Image('image');
-        $image->setLabel('Image');
-        $this->addElement($image);
-    }
+               $image = new CubeIT_Form_Element_File_Image('image');
+               $image->setLabel('Image');
+               $this->addElement($image);
+       }
 }
\ No newline at end of file
diff --git a/framework/application/forms/CMS/Sub/Home/Services/References.php b/framework/application/forms/CMS/Sub/Home/Services/References.php
new file mode 100644 (file)
index 0000000..dd9a038
--- /dev/null
@@ -0,0 +1,11 @@
+<?php\r
+\r
+\r
+class Fluidbook_Form_CMS_Sub_Home_Services_References extends CubeIT_Form_Element_SelectList {\r
+       public function init() {\r
+               parent::init();\r
+\r
+               $this->setBaseForm(new Fluidbook_Form_CMS_Sub_Exemples_Fluidbook());\r
+               $this->setDisplayListManagement(false);\r
+       }\r
+}
\ No newline at end of file
index d26d094ce22ce657900e1a91eca427e821cb8ada..38e852bb4aea3664a20c7bd28889c390c9683f47 100644 (file)
@@ -15,7 +15,7 @@ class Fluidbook_Model_Reference extends CubeIT_Model_Data_Table {
        protected $categories;\r
        protected $homeimage;\r
 \r
-       protected $_types = array('categories' => 'list', 'title' => 'json', 'text' => 'json', 'image' => 'json');\r
+       protected $_types = array('categories' => 'list', 'title' => 'json', 'text' => 'json', 'image' => 'json', 'homeimage' => 'json', 'fluidbook_id' => 'json', 'fluidbook_page' => 'json');\r
 \r
        public static function getSchema($schema) {\r
                $table = parent::getSchema($schema);\r
@@ -32,21 +32,77 @@ class Fluidbook_Model_Reference extends CubeIT_Model_Data_Table {
                return $table;\r
        }\r
 \r
-       public function getUrl() {\r
-               $res = parent::getUrl();\r
+       public function getFinalFluidbookId() {\r
+               $res = parent::getFluidbookId();\r
+               return $this->_setFrDefault($res);\r
+       }\r
+\r
+       protected function _setFrDefault($res) {\r
                if (CubeIT_Util_Json::isJson($res)) {\r
                        $res = CubeIT_Util_Json::decode($res);\r
                }\r
-               if (is_string($res)) {\r
+               if (!is_array($res) && !is_object($res)) {\r
                        return $res;\r
                }\r
                if (!$res->en) {\r
                        $res->en = $res->fr;\r
                }\r
+\r
+               return $res;\r
+       }\r
+\r
+       protected function _getFinalURL($url, $locale = null) {\r
+               if ($url) {\r
+                       return $url;\r
+               }\r
+               if (null === $locale) {\r
+                       return $this->_getLocalReference($this->getFinalFluidbookId());\r
+               } else {\r
+                       return $this->_getLocalReference($this->getFinalFluidbookId()->$locale);\r
+               }\r
+       }\r
+\r
+       protected function _getLocalReference($id) {\r
+               $dirs = CubeIT_Files::getDirectoryIterator(PUBLIC_PATH . '/references');\r
+               $d = null;\r
+               foreach ($dirs as $dir) {\r
+                       if (!$dir->isDir()) {\r
+                               continue;\r
+                       }\r
+                       $e = explode('-', $dir->getBasename(), 2);\r
+                       if ($e[0] == $id) {\r
+                               $d = $dir->getBasename();\r
+                               break;\r
+                       }\r
+               }\r
+               if (null === $d) {\r
+                       return;\r
+               }\r
+\r
+               return '/references/' . $d . '/';\r
+       }\r
+\r
+       public function getFinalFluidbookPage() {\r
+               $res = parent::getFluidbookPage();\r
+               return $this->_setFrDefault($res);\r
+       }\r
+\r
+       public function getFinalUrl() {\r
+               $res = parent::getUrl();\r
+               $res = $this->_setFrDefault($res);\r
+\r
+               if (!is_array($res) && !is_object($res)) {\r
+                       return $this->_getFinalURL($res);\r
+               }\r
+\r
+               $res->fr = $this->_getFinalURL($res->fr, 'fr');\r
+               $res->fr = $this->_getFinalURL($res->en, 'en');\r
+\r
                return $res;\r
        }\r
 \r
        public function hasUrl() {\r
-               return $this->getUrl() != '';\r
+               $furl = $this->getFinalUrl();\r
+               return $furl && $furl != '-';\r
        }\r
 }
\ No newline at end of file
index 1cb83c1e750191033360318fd1bb7fd9405bb12a..93345d1cbed5d26874f132bb4c8de9bcdbc594db 100644 (file)
@@ -101,10 +101,6 @@ class Fluidbook_View_Helper_Exemples extends CubeIT_View_Helper_Abstract {
                $fr = $f->unserialize('fr');\r
                $f = $f->unserialize();\r
 \r
-               fb($fr->toArray());\r
-               fb($f->toArray());\r
-\r
-\r
                $res = '';\r
 \r
                $res .= $this->htmlElement($f->getTitle(), 'h3');\r
@@ -115,18 +111,8 @@ class Fluidbook_View_Helper_Exemples extends CubeIT_View_Helper_Abstract {
 \r
                $image = CubeIT_Util_Cms::extractFile($f->getImage());\r
 \r
-               $fluibdookId = $f->getFluidbookId();\r
-               $fluidbookPage = $f->getFluidbookPage();\r
-               if (!$fluibdookId) {\r
-                       $fluibdookId = $fr->getFluidbookId();\r
-                       $fluidbookPage = $fr->getFluidbookPage();\r
-               }\r
-               if ($fluidbookPage == 0) {\r
-                       $fluidbookPage = $fr->getFluidbookPage();\r
-               }\r
-\r
-               if (!$image && $fluibdookId) {\r
-                       $res .= $this->exemplePublication($fluibdookId, $fluidbookPage);\r
+               if (!$image && $f->getFinalFluidbookId()) {\r
+                       $res .= $this->exemplePublication($f->getFinalFluidbookId(), $f->getFinalFluidbookPage());\r
                } else {\r
                        $res .= $this->htmlElement('', 'div',\r
                                array('style' => 'background-image:url(' . $this->imageProcess()->imageProcessGetURL($image, $f->getTitle() . ' - ' . $f->getText(), 660, 440, array(), 'R') . ');',\r
@@ -140,14 +126,15 @@ class Fluidbook_View_Helper_Exemples extends CubeIT_View_Helper_Abstract {
                        $attrs['class'] = 'no-featured';\r
                }\r
 \r
-               $res .= $this->_rollover($f, $category);\r
+               $res .= $this->_rollover($f, $category, $f->getFinalUrl());\r
                return $this->htmlElement($res, 'article', $attrs);\r
        }\r
 \r
-       protected function _rollover($f, $category) {\r
+       protected function _rollover($f, $category, $url) {\r
                $res = '';\r
-               if ($f->getUrl()) {\r
-                       $res = $this->link(__('Voir le Fluidbook'), $f->getUrl(), array('class' => 'button', 'data-event' => array('category' => 'exemple', 'action' => 'see', 'label' => $f->getTitle())));\r
+\r
+               if ($url) {\r
+                       $res = $this->linkTruePopupFullscreen(__('Voir le Fluidbook'), $url, array('class' => 'button', 'data-event' => array('category' => 'exemple', 'action' => 'see', 'label' => $f->getTitle())));\r
                }\r
                if ($category == 3) {\r
                        $firstCat = 0;\r
index 8b9c63c7148fb26c2b1e18075ff91b9e411e76e7..580107d804cdbb110d21c32953eac33b971ad369 100644 (file)
@@ -44,7 +44,7 @@ class Fluidbook_View_Helper_HomeReferences extends Fluidbook_View_Helper_HomeLay
                );\r
                if ($fluidbook->hasUrl()) {\r
                        $rollover = $this->htmlElement($fluidbook->getTitle(), 'h3');\r
-                       $rollover .= $this->link(__('Voir le Fluidbook'), $fluidbook->getUrl());\r
+                       $rollover .= $this->linkTruePopupFullscreen(__('Voir le Fluidbook'), $fluidbook->getFinalUrl());\r
                        $res .= $this->htmlElement($this->htmlElement($rollover, 'div', array('class' => 'content')), 'div', array('class' => 'hover'));\r
                }\r
 \r
index ec12c988b99357650b2fcb1d10b8ec721ad9af5e..90dd7e6b2569eb8b2b1f340ed115012b32904c32 100644 (file)
@@ -6,62 +6,65 @@ class Fluidbook_View_Helper_HomeServices extends Fluidbook_View_Helper_HomeLayer
         */\r
        public function homeServices($data) {\r
 \r
-        $this->headScript()->addScriptAndStyle('214-home-services');\r
+               $this->headScript()->addScriptAndStyle('214-home-services');\r
 \r
                $this->data = $data;\r
 \r
-        $res = '<div class="text">';\r
-        $res .= $this->_leftText();\r
-        $res .= '</div>'; // .text\r
+               $res = '<div class="text">';\r
+               $res .= $this->_leftText();\r
+               $res .= '</div>'; // .text\r
 \r
-        $res .= '<div class="carousel">';\r
-        $res .= '<div class="window-top-wrapper">';\r
-//        $res .= '<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\r
-//                  viewBox="0 0 755 24" xml:space="preserve">\r
-//                <style type="text/css">\r
-//                    .st0{fill-rule:evenodd;clip-rule:evenodd;fill:#475462;}\r
-//                    .st1{fill-rule:evenodd;clip-rule:evenodd;fill:#151E26;}\r
-//                </style>\r
-//                <path class="st0" d="M0,24V5c0-2.8,2.2-5,5-5h745c2.8,0,5,2.2,5,5v19"/>\r
-//                <circle class="st1" cx="16" cy="12" r="3"/>\r
-//                <circle class="st1" cx="26" cy="12" r="3"/>\r
-//                <circle class="st1" cx="36" cy="12" r="3"/>\r
-//                </svg>';\r
-//        $res .= '<span></span><span></span><span></span>'; // Dot elements\r
-        $res .= '</div>'; // .window-top-wrapper\r
+               $res .= '<div class="carousel">';\r
+               $res .= '<div class="window-top-wrapper">';\r
+               //        $res .= '<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\r
+               //                   viewBox="0 0 755 24" xml:space="preserve">\r
+               //                <style type="text/css">\r
+               //                    .st0{fill-rule:evenodd;clip-rule:evenodd;fill:#475462;}\r
+               //                    .st1{fill-rule:evenodd;clip-rule:evenodd;fill:#151E26;}\r
+               //                </style>\r
+               //                <path class="st0" d="M0,24V5c0-2.8,2.2-5,5-5h745c2.8,0,5,2.2,5,5v19"/>\r
+               //                <circle class="st1" cx="16" cy="12" r="3"/>\r
+               //                <circle class="st1" cx="26" cy="12" r="3"/>\r
+               //                <circle class="st1" cx="36" cy="12" r="3"/>\r
+               //                </svg>';\r
+               //        $res .= '<span></span><span></span><span></span>'; // Dot elements\r
+               $res .= '</div>'; // .window-top-wrapper\r
 \r
-        $res .= '<img src="/images/home/window-top.png" class="window-top">';\r
+               $res .= '<img src="/images/home/window-top.png" class="window-top">';\r
 \r
-        $res .= '<div class="services-examples">';\r
+               $res .= '<div class="services-examples">';\r
 \r
-        foreach ($data['examples'] as $example) {\r
-            $img = $this->imageCms($example['image'], $example['title']);\r
-            $rollover = $this->_rollover($example);\r
-            $res .= $this->htmlElement($img . $rollover, 'div', ['data-title' => $example['title']]);\r
-        }\r
+               foreach ($data['examples'] as $example) {\r
+                       $img = $this->imageCms($example['image'], $example['title']);\r
+                       $rollover = $this->_rollover($example);\r
+                       $res .= $this->htmlElement($img . $rollover, 'div', ['data-title' => $example['title']]);\r
+               }\r
 \r
-        $res .= '</div>'; // .services-examples\r
+               $res .= '</div>'; // .services-examples\r
 \r
-        $res .= '<ul class="services-examples-nav" style="color: '. $data['themecolor'] .'"></ul>'; // Populated by JS\r
+               $res .= '<ul class="services-examples-nav" style="color: ' . $data['themecolor'] . '"></ul>'; // Populated by JS\r
 \r
-        $res .= '</div>'; // .carousel\r
+               $res .= '</div>'; // .carousel\r
 \r
 \r
-        return $this->_layer($res, 'services');\r
+               return $this->_layer($res, 'services');\r
        }\r
 \r
 \r
-    public function _rollover($example) {\r
+       public function _rollover($example) {\r
 \r
-        $res  = '';\r
+               $res = '';\r
 \r
-        if (!empty($example['link'])) {\r
-            $res .= $this->link(__('Voir le Fluidbook'), $example['link'], ['class' => 'button']);\r
-        }\r
+               $model = Fluidbook_Model_Reference::findOneById($example['exemple']);\r
+               $ex = $model->unserialize();\r
 \r
-        $res = $this->htmlElement($res, 'div', ['class' => 'inner']); // Wrapper for vertical centering\r
+               if ($ex->hasUrl()) {\r
+                       $res .= $this->linkTruePopupFullscreen(__('Voir le Fluidbook'), $ex->getFinalUrl(), ['class' => 'button']);\r
+               }\r
 \r
-        return $this->htmlElement($res, 'div', ['class' => 'more']);\r
+               $res = $this->htmlElement($res, 'div', ['class' => 'inner']); // Wrapper for vertical centering\r
+\r
+               return $this->htmlElement($res, 'div', ['class' => 'more']);\r
        }\r
 \r
 }
\ No newline at end of file