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