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
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) {
+ }
+
+ }
}
}
->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
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
--- /dev/null
+<?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
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
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
$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
\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
$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
);\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
*/\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