<?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(!is_numeric($page)){\r
- $page=2;\r
- }\r
+class Fluidbook_View_Helper_ExemplePublication extends CubeIT_View_Helper_Abstract\r
+{\r
+ /**\r
+ * @return string\r
+ */\r
+ public function exemplePublication($fluidbook_id, $page)\r
+ {\r
+ if (!is_numeric($page)) {\r
+ $page = 2;\r
+ }\r
\r
- if ($page % 2 == 1) {\r
- $page--;\r
- }\r
+ if ($page % 2 == 1) {\r
+ $page--;\r
+ }\r
\r
- $cssid = 'exemple-publication-' . $fluidbook_id . '-' . $page;\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
+ $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
\r
-\r
- $left = $this->_getPage($fluidbook_id, $page);\r
- $right = $this->_getPage($fluidbook_id, $page + 1);\r
+ $left = $this->_getPage($fluidbook_id, $page);\r
+ $right = $this->_getPage($fluidbook_id, $page + 1);\r
\r
// Sometimes a page might not return a valid size (eg. Page 0 with no graphic)\r
// If the left page doesn't work, use the right page\r
$width = ($left['width'] == -1) ? $right['width'] : $left['width'];\r
$height = ($left['height'] == -1) ? $right['height'] : $left['height'];\r
\r
- $ratio = $width / $height;\r
+ $ratio = $width / $height;\r
\r
- $backgrounds = array();\r
- // $backgrounds[] = array('image' => '/images/exemples/publications/shadow.png', 'size' => '100% 10%', 'position' => '0 95%', 'blendmode' => null);\r
- $backgrounds[] = array('image' => $left['url'], 'size' => '50% 100%', 'position' => '1px 0', 'blendmode' => 'normal');\r
- $backgrounds[] = array('image' => $right['url'], 'size' => '50% 100%', 'position' => '100% 0', 'blendmode' => 'normal');\r
- $backgrounds[] = array('image' => '/images/exemples/publications/light.png', 'size' => '30% 100%', 'position' => '50% 0', 'blendmode' => 'soft-light');\r
- $backgrounds[] = array('image' => '/images/exemples/publications/dark.png', 'size' => '20% 100%', 'position' => '50% 0', 'blendmode' => 'multiply');\r
+ $backgrounds = array();\r
+ // $backgrounds[] = array('image' => '/images/exemples/publications/shadow.png', 'size' => '100% 10%', 'position' => '0 95%', 'blendmode' => null);\r
+ $backgrounds[] = array('image' => $left['url'], 'size' => '50% 100%', 'position' => '1px 0', 'blendmode' => 'normal');\r
+ $backgrounds[] = array('image' => $right['url'], 'size' => '50% 100%', 'position' => '100% 0', 'blendmode' => 'normal');\r
+ $backgrounds[] = array('image' => '/images/exemples/publications/light.png', 'size' => '30% 100%', 'position' => '50% 0', 'blendmode' => 'soft-light');\r
+ $backgrounds[] = array('image' => '/images/exemples/publications/dark.png', 'size' => '20% 100%', 'position' => '50% 0', 'blendmode' => 'multiply');\r
\r
- $backgrounds = array_reverse($backgrounds);\r
+ $backgrounds = array_reverse($backgrounds);\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
+ $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($this->htmlElement('', 'div', array('class' => 'shadow')), 'div', array(\r
- 'class' => 'exemple-fluidbook',\r
+ $res .= '}';\r
+ $res .= '</style>';\r
+ $res .= $this->htmlElement($this->htmlElement('', 'div', array('class' => 'shadow')), 'div', array(\r
+ 'class' => 'exemple-fluidbook',\r
'id' => $cssid,\r
'data-width' => $width * 2,\r
'data-height' => $height));\r
- return $res;\r
- }\r
+ return $res;\r
+ }\r
\r
- protected function _getPage($fluidbook_id, $page) {\r
- $path = 'fluidbook/' . $fluidbook_id . '/';\r
- $dir = FILES_PATH . '/' . $path;\r
- if (!file_exists($dir)) {\r
- mkdir($dir, 0777, true);\r
- }\r
+ protected function _getPage($fluidbook_id, $page)\r
+ {\r
+ $path = 'fluidbook/' . $fluidbook_id . '/';\r
+ $dir = FILES_PATH . '/' . $path;\r
+ if (!file_exists($dir)) {\r
+ mkdir($dir, 0777, true);\r
+ }\r
\r
- $url = '/files/' . $path . $page . '.jpg';\r
- $file = $dir . $page . '.jpg';\r
- if (!file_exists($file) || !filesize($file)) {\r
- $wsurl = 'https://workshop.fluidbook.com/services/getFluidbookPage/' . $fluidbook_id . '/' . $page;\r
- file_put_contents($file, file_get_contents($wsurl));\r
- }\r
- $size = CubeIT_Image::getDimensions($file, $width, $height);\r
- return array('url' => $url, 'width' => $width, 'height' => $height);\r
- }\r
+ $url = '/files/' . $path . $page . '.jpg';\r
+ $file = $dir . $page . '.jpg';\r
+ if (!file_exists($file) || !filesize($file)) {\r
+ $toolbox = 'https://toolbox.fluidbook.com/services/getFluidbookPageFromWebsiteV3/' . $fluidbook_id . '/' . $page;\r
+ file_put_contents($file, file_get_contents($toolbox));\r
+ }\r
+ CubeIT_Image::getDimensions($file, $width, $height);\r
+ return array('url' => $url, 'width' => $width, 'height' => $height);\r
+ }\r
}
\ No newline at end of file
<?php\r
\r
-class Fluidbook_View_Helper_Exemples extends CubeIT_View_Helper_Abstract {\r
-\r
- protected $_categories;\r
- protected $_j = 0;\r
-\r
- /**\r
- * @return string\r
- */\r
- public function exemples($category, $title, $nb) {\r
- $this->headScript()\r
- ->addMasonry()\r
- ->addJQueryTransform()\r
- ->addTinysort()\r
- ->addDotDotDot()\r
- ->addScriptAndStyle('220-exemples');\r
-\r
- $exemples = Fluidbook_Model_Reference::factory()->order('date DESC')->find();\r
- $this->_categories = Fluidbook_Model_Reference_Category::factory()->find();\r
-\r
- $perline = 5.0;\r
-\r
- $featured = array();\r
- $normal = array();\r
- $c = 0;\r
-\r
- $okexemples = array();\r
-\r
- foreach ($exemples as $id => $exemple) {\r
- if ($category > 0 && !in_array($category, $exemple->getCategories()) && !in_array($category, $exemple->getFeaturedCategories())) {\r
- continue;\r
- }\r
- $okexemples[$id] = $exemple;\r
- $c++;\r
- }\r
-\r
- $c = CubeIT_Math::round($c, $perline, 'floor');\r
- $nb = min($c, CubeIT_Math::round($nb, $perline, 'floor'));\r
- $max_featured = floor($nb / $perline);\r
- $normal_per_featured = $perline - 1;\r
- $max_normal = $max_featured * $normal_per_featured;\r
-\r
- foreach ($okexemples as $id => $exemple) {\r
- if (in_array($category, $exemple->getFeaturedCategories())) {\r
- $featured[] = $id;\r
- } else {\r
- $normal[] = $id;\r
- }\r
- }\r
-\r
- $nb_featured = count($featured);\r
- if ($nb_featured < $max_featured) {\r
- for ($i = $nb_featured; $i < $max_featured; $i++) {\r
- $featured[] = array_shift($normal);\r
- }\r
- }\r
- $nb_featured = count($featured);\r
-\r
- if ($nb_featured > $max_featured) {\r
- for ($i = $max_featured; $i < $nb_featured; $i++) {\r
- $normal[] = array_pop($featured);\r
- }\r
- }\r
- $nb_featured = count($featured);\r
-\r
- $featured = array_slice($featured, 0, $max_featured);\r
- $normal = array_slice($normal, 0, $max_normal);\r
-\r
- $res = $this->title($title, 'h2', array('class' => 'col-2'));\r
-\r
- $e = 0;\r
-\r
- $publications = '';\r
- for ($i = 0; $i < $max_featured; $i++) {\r
- if ($i % 2 == 0) {\r
- $publications .= $this->_publication($exemples[$featured[$i]], $category, 1 + $i * 7, true);\r
- }\r
- for ($j = 0; $j < $normal_per_featured; $j++) {\r
- $k = ($i * $normal_per_featured) + $j;\r
- if ($j == 2 && $i % 2 == 1) {\r
- $publications .= $this->_publication($exemples[$featured[$i]], $category, 1 + $i * 7, true);\r
- }\r
- $publications .= $this->_publication($exemples[$normal[$k]], $category, ($i * 7) + $j + 2, false);\r
- }\r
- }\r
-\r
- $res .= $this->htmlElement($publications, 'div', array('class' => 'publications col-6'));\r
- return $this->htmlElement($res, 'section', array('class' => "exemples content-wrapper grid wrap"));\r
- }\r
-\r
- /**\r
- * @param $f Fluidbook_Model_Reference\r
- * @param bool $featured\r
- */\r
- protected function _publication($f, $category, $i, $featured = false) {\r
- if (null === $f) {\r
- return;\r
- }\r
-\r
- $fr = $f->unserialize('fr');\r
- $f = $f->unserialize();\r
-\r
- $res = '';\r
-\r
- $res .= $this->htmlElement($f->getTitle(), 'h3');\r
- if ($featured && !is_array($f->getText())) {\r
-\r
- $res .= $this->htmlElement($f->getText(), 'p', ['class' => 'feature-description']);\r
- }\r
-\r
- $image = CubeIT_Util_Cms::extractFile($f->getImage());\r
-\r
-\r
- if (!$image && $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(\r
- $image,\r
- $f->getTitle()\r
- , 1200, 1200,\r
- array(), 'R') . ');',\r
- 'class' => 'img full')\r
- );\r
- }\r
- $attrs = array('data-j' => ++$this->_j, 'data-i' => $i);\r
- if ($featured) {\r
- $attrs['class'] = 'featured';\r
- } else {\r
- $attrs['class'] = 'no-featured';\r
- }\r
-\r
- $res .= $this->_rollover($f, $category, $f->getFinalUrl());\r
- return $this->htmlElement($res, 'article', $attrs);\r
- }\r
-\r
- protected function _rollover($f, $category, $url) {\r
- $res = '';\r
-\r
- if ($url && $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
- foreach ($f->getCategories() as $c) {\r
- if ($c == 3) {\r
- continue;\r
- }\r
- $firstCat = $c;\r
- break;\r
- }\r
- if ($firstCat != 0 && isset($this->_categories[$firstCat])) {\r
- $cat = $this->_categories[$firstCat]->unserialize();\r
- $pages = CubeIT_Util_Cms::findPagesByContent('category', $cat->getId());\r
- shuffle($pages);\r
-\r
- if (count($pages) > 0) {\r
- $res .= $this->link($cat->getLinklabel(), 'internal:' . $pages[0], array('class' => 'others'));\r
- }\r
- }\r
-\r
- }\r
- return $this->htmlElement($res, 'div', array('class' => 'more'));\r
- }\r
+class Fluidbook_View_Helper_Exemples extends CubeIT_View_Helper_Abstract\r
+{\r
+\r
+ protected $_categories;\r
+ protected $_j = 0;\r
+\r
+ /**\r
+ * @return string\r
+ */\r
+ public function exemples($category, $title, $nb)\r
+ {\r
+ $this->headScript()\r
+ ->addMasonry()\r
+ ->addJQueryTransform()\r
+ ->addTinysort()\r
+ ->addDotDotDot()\r
+ ->addScriptAndStyle('220-exemples');\r
+\r
+ $exemples = Fluidbook_Model_Reference::factory()->order('date DESC')->find();\r
+ $this->_categories = Fluidbook_Model_Reference_Category::factory()->find();\r
+\r
+ $perline = 5.0;\r
+\r
+ $featured = array();\r
+ $normal = array();\r
+ $c = 0;\r
+\r
+ $okexemples = array();\r
+\r
+ foreach ($exemples as $id => $exemple) {\r
+ if ($category > 0 && !in_array($category, $exemple->getCategories()) && !in_array($category, $exemple->getFeaturedCategories())) {\r
+ continue;\r
+ }\r
+ $okexemples[$id] = $exemple;\r
+ $c++;\r
+ }\r
+\r
+ $c = CubeIT_Math::round($c, $perline, 'floor');\r
+ $nb = min($c, CubeIT_Math::round($nb, $perline, 'floor'));\r
+ $max_featured = floor($nb / $perline);\r
+ $normal_per_featured = $perline - 1;\r
+ $max_normal = $max_featured * $normal_per_featured;\r
+\r
+ foreach ($okexemples as $id => $exemple) {\r
+ if (in_array($category, $exemple->getFeaturedCategories())) {\r
+ $featured[] = $id;\r
+ } else {\r
+ $normal[] = $id;\r
+ }\r
+ }\r
+\r
+ $nb_featured = count($featured);\r
+ if ($nb_featured < $max_featured) {\r
+ for ($i = $nb_featured; $i < $max_featured; $i++) {\r
+ $featured[] = array_shift($normal);\r
+ }\r
+ }\r
+ $nb_featured = count($featured);\r
+\r
+ if ($nb_featured > $max_featured) {\r
+ for ($i = $max_featured; $i < $nb_featured; $i++) {\r
+ $normal[] = array_pop($featured);\r
+ }\r
+ }\r
+ $nb_featured = count($featured);\r
+\r
+ $featured = array_slice($featured, 0, $max_featured);\r
+ $normal = array_slice($normal, 0, $max_normal);\r
+\r
+ $res = $this->title($title, 'h2', array('class' => 'col-2'));\r
+\r
+ $e = 0;\r
+\r
+ $publications = '';\r
+ for ($i = 0; $i < $max_featured; $i++) {\r
+ if ($i % 2 == 0) {\r
+ $publications .= $this->_publication($exemples[$featured[$i]], $category, 1 + $i * 7, true);\r
+ }\r
+ for ($j = 0; $j < $normal_per_featured; $j++) {\r
+ $k = ($i * $normal_per_featured) + $j;\r
+ if ($j == 2 && $i % 2 == 1) {\r
+ $publications .= $this->_publication($exemples[$featured[$i]], $category, 1 + $i * 7, true);\r
+ }\r
+ $publications .= $this->_publication($exemples[$normal[$k]], $category, ($i * 7) + $j + 2, false);\r
+ }\r
+ }\r
+\r
+ $res .= $this->htmlElement($publications, 'div', array('class' => 'publications col-6'));\r
+ return $this->htmlElement($res, 'section', array('class' => "exemples content-wrapper grid wrap"));\r
+ }\r
+\r
+ /**\r
+ * @param $f Fluidbook_Model_Reference\r
+ * @param bool $featured\r
+ */\r
+ protected function _publication($f, $category, $i, $featured = false)\r
+ {\r
+ if (null === $f) {\r
+ return;\r
+ }\r
+\r
+ $fr = $f->unserialize('fr');\r
+ $f = $f->unserialize();\r
+\r
+ $res = '';\r
+\r
+ $res .= $this->htmlElement($f->getTitle(), 'h3');\r
+ if ($featured && !is_array($f->getText())) {\r
+\r
+ $res .= $this->htmlElement($f->getText(), 'p', ['class' => 'feature-description']);\r
+ }\r
+\r
+ $image = CubeIT_Util_Cms::extractFile($f->getImage());\r
+\r
+ if (!$image && $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(\r
+ $image,\r
+ $f->getTitle()\r
+ , 1200, 1200,\r
+ array(), 'R') . ');',\r
+ 'class' => 'img full')\r
+ );\r
+ }\r
+ $attrs = array('data-j' => ++$this->_j, 'data-i' => $i);\r
+ if ($featured) {\r
+ $attrs['class'] = 'featured';\r
+ } else {\r
+ $attrs['class'] = 'no-featured';\r
+ }\r
+\r
+ $res .= $this->_rollover($f, $category, $f->getFinalUrl());\r
+ return $this->htmlElement($res, 'article', $attrs);\r
+ }\r
+\r
+ protected function _rollover($f, $category, $url)\r
+ {\r
+ $res = '';\r
+\r
+ if ($url && $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
+ foreach ($f->getCategories() as $c) {\r
+ if ($c == 3) {\r
+ continue;\r
+ }\r
+ $firstCat = $c;\r
+ break;\r
+ }\r
+ if ($firstCat != 0 && isset($this->_categories[$firstCat])) {\r
+ $cat = $this->_categories[$firstCat]->unserialize();\r
+ $pages = CubeIT_Util_Cms::findPagesByContent('category', $cat->getId());\r
+ shuffle($pages);\r
+\r
+ if (count($pages) > 0) {\r
+ $res .= $this->link($cat->getLinklabel(), 'internal:' . $pages[0], array('class' => 'others'));\r
+ }\r
+ }\r
+\r
+ }\r
+ return $this->htmlElement($res, 'div', array('class' => 'more'));\r
+ }\r
}
\ No newline at end of file