]> _ Git - fluidbook-v3.git/commitdiff
wip #487 @5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 1 Jul 2016 16:18:26 +0000 (16:18 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 1 Jul 2016 16:18:26 +0000 (16:18 +0000)
framework/application/forms/CMS/Sub/Exemples/Fluidbook.php
framework/application/models/Reference.php
framework/application/views/helpers/ExemplePublication.php [new file with mode: 0644]
framework/application/views/helpers/Exemples.php
images/exemples/publications/dark.png [new file with mode: 0644]
images/exemples/publications/light.png [new file with mode: 0644]
images/exemples/publications/shadow.png [new file with mode: 0644]
js/101-header.js

index e175a343d8d1c834e8b9818f14cdea24f2231e95..de0de44d5318779392be4db725f06564ff0e59d3 100644 (file)
@@ -9,11 +9,11 @@ class Fluidbook_Form_CMS_Sub_Exemples_Fluidbook extends CubeIT_Form_List_Model {
 \r
                $title = new Zend_Form_Element_Text('title');\r
                $title->setLabel('Titre');\r
-               $this->addElementLocalized($title,false);\r
+               $this->addElementLocalized($title, false);\r
 \r
                $text = new Zend_Form_Element_Textarea('text');\r
                $text->setLabel('Texte');\r
-               $this->addElementLocalized($text,false);\r
+               $this->addElementLocalized($text, false);\r
 \r
                $date = new CubeIT_Form_Element_Date('date');\r
                $date->setLabel('Date');\r
@@ -26,11 +26,15 @@ class Fluidbook_Form_CMS_Sub_Exemples_Fluidbook extends CubeIT_Form_List_Model {
 \r
                $url = new CubeIT_Form_Element_Url('url');\r
                $url->setLabel('URL');\r
-               $this->addElementLocalized($url,false);\r
+               $this->addElementLocalized($url, false);\r
 \r
                $fluidbook = new CubeIT_Form_Element_Int('fluidbook_id');\r
                $fluidbook->setLabel('Identifiant du Fluidbook');\r
-               $this->addElementLocalized($fluidbook,false);\r
+               $this->addElementLocalized($fluidbook, false);\r
+\r
+               $page = new CubeIT_Form_Element_Int('fluidbook_page');\r
+               $page->setLabel('Page du fluidbook');\r
+               $this->addElementLocalized($page, false);\r
 \r
                $categories = new Fluidbook_Form_CMS_Element_Exemple_Categories('categories');\r
                $categories->setLabel('Catégories');\r
@@ -45,7 +49,7 @@ class Fluidbook_Form_CMS_Sub_Exemples_Fluidbook extends CubeIT_Form_List_Model {
                        ->setEditTitle('Edition de l\'exemple « $title »')\r
                        ->setModel('Fluidbook_Model_Reference')\r
                        ->setTitleColumn("title")\r
-                       ->setAdditionnalColumns(array('fluidbook_id', 'featured','date'))\r
+                       ->setAdditionnalColumns(array('fluidbook_id', 'featured', 'date'))\r
                        ->setSearchColumns(array('text', 'fluidbook_id'));\r
        }\r
 }
\ No newline at end of file
index 42f38035c564c509b637183c59f10b9c267f9990..6853b70cf19006d383b21a9bf5b2ff065557d87c 100644 (file)
@@ -9,11 +9,12 @@ class Fluidbook_Model_Reference extends CubeIT_Model_Data_Table {
        protected $date;\r
        protected $url;\r
        protected $fluidbook_id;\r
+       protected $fluidbook_page;\r
        protected $image;\r
        protected $featured;\r
        protected $categories;\r
 \r
-       protected $_types = array('categories' => 'json', 'title' => 'json', 'text' => 'json', 'image' => 'json');\r
+       protected $_types = array('categories' => 'list', 'title' => 'json', 'text' => 'json', 'image' => 'json');\r
 \r
        public static function getSchema($schema) {\r
                $table = parent::getSchema($schema);\r
@@ -22,6 +23,7 @@ class Fluidbook_Model_Reference extends CubeIT_Model_Data_Table {
                $table->addColumn('url', 'text');\r
                $table->addColumn('date', 'date');\r
                $table->addColumn('fluidbook_id', 'text');\r
+               $table->addColumn('fluidbook_page', 'string', array("default" => '{"fr":2,"en":0}', "length" => 128));\r
                $table->addColumn('featured', 'boolean');\r
                $table->addColumn('image', 'string', array('length' => 64));\r
                $table->addColumn('categories', 'string', array('length' => 64));\r
diff --git a/framework/application/views/helpers/ExemplePublication.php b/framework/application/views/helpers/ExemplePublication.php
new file mode 100644 (file)
index 0000000..74770f0
--- /dev/null
@@ -0,0 +1,63 @@
+<?php\r
+\r
+class Fluidbook_View_Helper_ExemplePublication extends CubeIT_View_Helper_Abstract {\r
+       /**\r
+        * @return string\r
+        */\r
+       public function exemplePublication($fluidbook_id, $page) {\r
+               if ($page % 2 == 1) {\r
+                       $page--;\r
+               }\r
+\r
+               $cssid = 'exemple-publication-' . $fluidbook_id . '-' . $page;\r
+\r
+               $cssprops = array('image' => array('prop' => 'background-image', 'format' => 'url("%s")'),\r
+                                 'size' => array('prop' => 'background-size', 'format' => '%s'),\r
+                                 'position' => array('prop' => 'background-position', 'format' => '%s'),\r
+                                 'blendmode' => array('prop' => 'background-blend-mode', 'format' => '%s'),\r
+               );\r
+\r
+               $backgrounds = array();\r
+               $backgrounds[] = array('image' => $this->_getPage($fluidbook_id, $page, array('class' => 'left')), 'size' => '', 'position' => '0,0', 'blendmode' => null);\r
+               $backgrounds[] = array('image' => $this->_getPage($fluidbook_id, $page + 1, array('class' => 'right')), 'size' => '', 'position' => '0,100%', 'blendmode' => 'normal');\r
+               $backgrounds[] = array('image' => '/images/exemples/publications/dark.png', 'size' => '', 'position' => '', 'blendmode' => '');\r
+               $backgrounds[] = array('image' => '/images/exemples/publications/light.png', 'size' => '', 'position' => '', 'blendmode' => '');\r
+               $backgrounds[] = array('image' => '/images/exemples/publications/shadow.png', 'size' => '', 'position' => '', 'blendmode' => '');\r
+\r
+\r
+               $res = '<style type="text/css">';\r
+               $res .= "#" . $cssid . '{';\r
+               foreach ($cssprops as $k => $cssprop) {\r
+                       $res .= $cssprop['prop'] . ':';\r
+                       $format = $cssprop['format'];\r
+                       $p = array();\r
+                       foreach ($backgrounds as $background) {\r
+                               $v = $background[$k];\r
+                               if (null !== $v) {\r
+                                       $p[] = sprintf($format, $v);\r
+                               }\r
+                       }\r
+                       $res .= implode(', ', $p);\r
+                       $res .= ';' . "\n";\r
+               }\r
+\r
+               $res .= '}';\r
+               $res .= '</style>';\r
+               $res .= $this->htmlElement('', 'div', array('class' => 'exemple-fluidbook', 'id' => $cssid));\r
+               return $res;\r
+       }\r
+\r
+       protected function _getPage($fluidbook_id, $page) {\r
+               $path = 'fluidbook/' . $fluidbook_id . '/';\r
+               $dir = PUBLIC_PATH . $path;\r
+               if (!file_exists($dir)) {\r
+                       mkdir($dir, 0777, true);\r
+               }\r
+               $url = '/files/' . $path . $page . '.jpg';\r
+               $file = $dir . $page . '.jpg';\r
+               if (!file_exists($file)) {\r
+                       file_put_contents($file, file_get_contents('https://workshop.fluidbook.com/viewerh/' . $fluidbook_id . '_bcf26f9cf4a795ec00b9a44f42750d58_1234567890/data/background/150/t' . $page . '.jpg'));\r
+               }\r
+               return $url;\r
+       }\r
+}
\ No newline at end of file
index 1f0cc1af6207ef530f6058bdf70d1422c9c799d5..9063568462c632ec432e63c8dc32eb2c817f5310 100644 (file)
@@ -8,7 +8,7 @@ class Fluidbook_View_Helper_Exemples extends CubeIT_View_Helper_Abstract {
                $this->headScript()->addScriptAndStyle('220-exemples');\r
                $this->headScript()->addMasonry();\r
 \r
-               $exemples = Fluidbook_Model_Reference::factory()->order('date', 'DESC')->find();\r
+               $exemples = Fluidbook_Model_Reference::factory()->order('date DESC')->find();\r
 \r
                $max_featured = floor($nb / 5);\r
                $normal_per_featured = 4;\r
@@ -17,7 +17,10 @@ class Fluidbook_View_Helper_Exemples extends CubeIT_View_Helper_Abstract {
                $featured = array();\r
                $normal = array();\r
                foreach ($exemples as $id => $exemple) {\r
-                       if (!in_array($category, $exemple->getCategories())) {\r
+\r
+                       fb($exemple->getCategories());\r
+\r
+                       if ($category > 0 && !in_array($category, $exemple->getCategories())) {\r
                                continue;\r
                        }\r
 \r
@@ -28,6 +31,9 @@ class Fluidbook_View_Helper_Exemples extends CubeIT_View_Helper_Abstract {
                        }\r
                }\r
 \r
+               fb($featured);\r
+               fb($normal);\r
+\r
 \r
                $nb_featured = count($featured);\r
                if ($nb_featured < $max_featured) {\r
@@ -68,6 +74,9 @@ class Fluidbook_View_Helper_Exemples extends CubeIT_View_Helper_Abstract {
         * @param bool $featured\r
         */\r
        protected function _publication($f, $featured = false) {\r
+               if (null === $f) {\r
+                       return;\r
+               }\r
                $f = $f->unserialize();\r
 \r
                $res = '';\r
@@ -77,10 +86,15 @@ class Fluidbook_View_Helper_Exemples extends CubeIT_View_Helper_Abstract {
                        $res .= $this->htmlElement($f->getText(), 'p');\r
                }\r
 \r
-               $res .= $this->htmlElement('', 'div',\r
-                       array('style' => 'background-image:url(' . $this->imageProcess()->imageProcessGetURL($f->getImage(), $f->getTitle() . ' - ' . $f->getText(), 660, 440, array(), 'R') . ');',\r
-                             'class' => 'img')\r
-               );\r
+\r
+               if ($f->getFluidbookId()) {\r
+                       $res .= $this->exemplePublication($f->getFluidbookId(), $f->getFluidbookPage());\r
+               } else {\r
+                       $res .= $this->htmlElement('', 'div',\r
+                               array('style' => 'background-image:url(' . $this->imageProcess()->imageProcessGetURL($f->getImage(), $f->getTitle() . ' - ' . $f->getText(), 660, 440, array(), 'R') . ');',\r
+                                     'class' => 'img')\r
+                       );\r
+               }\r
                $attrs = array();\r
                if ($featured) {\r
                        $attrs['class'] = 'featured';\r
diff --git a/images/exemples/publications/dark.png b/images/exemples/publications/dark.png
new file mode 100644 (file)
index 0000000..4447ae4
Binary files /dev/null and b/images/exemples/publications/dark.png differ
diff --git a/images/exemples/publications/light.png b/images/exemples/publications/light.png
new file mode 100644 (file)
index 0000000..890b8db
Binary files /dev/null and b/images/exemples/publications/light.png differ
diff --git a/images/exemples/publications/shadow.png b/images/exemples/publications/shadow.png
new file mode 100644 (file)
index 0000000..5d6b537
Binary files /dev/null and b/images/exemples/publications/shadow.png differ
index 3d01db4cca1081d552a3fb892a555cba4a4acb8f..1353e54d24a7de57a3551b545c388244270a2237 100644 (file)
@@ -24,7 +24,7 @@ function load_header() {
     htl.add(TweenMax.fromTo($(logo).find('.text'), 1, {opacity: 1}, {opacity: 0}), 1.5);\r
     // Menu position\r
     htl.add(TweenMax.fromTo(nav, 1, {left: '50%'}, {left: 312}), 2);\r
-    htl.add(TweenMax.fromTo(h, 1, {backgroundColor: 'transparent'}, {backgroundColor: "rgba(255, 255, 255, 0.75)"}), 2);\r
+    htl.add(TweenMax.fromTo(h, 1, {backgroundColor: 'transparent'}, {backgroundColor: "rgba(255, 255, 255, 0.8)"}), 2);\r
     htl.stop();\r
 \r
     $(window).on('cubeitresize', resizeHeader);\r
@@ -63,7 +63,7 @@ function headerScroll() {
         scrolledDistance = Math.abs(lastDirChange - s);\r
     }\r
 \r
-    var progress = Math.max(0, Math.min(3, s / 300));\r
+    var progress = Math.max(0, Math.min(3, s / 80));\r
     htl.time(progress);\r
 \r
     var htop;\r