\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
\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
->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
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
$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
--- /dev/null
+<?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
$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
$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
}\r
}\r
\r
+ fb($featured);\r
+ fb($normal);\r
+\r
\r
$nb_featured = count($featured);\r
if ($nb_featured < $max_featured) {\r
* @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
$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
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
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