From: vincent@cubedesigners.com Date: Mon, 5 Sep 2016 13:28:41 +0000 (+0000) Subject: done #661 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=e5d7d3a51d89ddb18cb3d4fcd39cbd01bfe69538;p=fluidbook-v3.git done #661 @0.5 --- diff --git a/framework/application/controllers/MaintenanceController.php b/framework/application/controllers/MaintenanceController.php index d171279..09e206f 100644 --- a/framework/application/controllers/MaintenanceController.php +++ b/framework/application/controllers/MaintenanceController.php @@ -8,11 +8,16 @@ class MaintenanceController extends CubeIT_Controller_MaintenanceController { 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 featuredCategories() { +// $references = Fluidbook_Model_Reference::factory()->find(); +// foreach ($references as $reference) { +// if ($reference->getFeatured()) { +// $reference->setFeaturedCategories($reference->getCategories()); +// } +// fb($reference->toArray()); +// $reference->save(); +// } +// } public function importReferences() { set_time_limit(0); diff --git a/framework/application/forms/CMS/Sub/Exemples/Fluidbook.php b/framework/application/forms/CMS/Sub/Exemples/Fluidbook.php index c663a07..caa3af1 100644 --- a/framework/application/forms/CMS/Sub/Exemples/Fluidbook.php +++ b/framework/application/forms/CMS/Sub/Exemples/Fluidbook.php @@ -41,9 +41,9 @@ class Fluidbook_Form_CMS_Sub_Exemples_Fluidbook extends CubeIT_Form_List_Model { $categories->setLabel('Catégories'); $this->addElement($categories); - $featured = new Zend_Form_Element_Checkbox('featured'); - $featured->setLabel('Mis en avant'); - $this->addElement($featured); + $categories = new Fluidbook_Form_CMS_Element_Exemple_Categories('featured_categories'); + $categories->setLabel('Mise en avant'); + $this->addElement($categories); $homeimage = new CubeIT_Form_Element_File_Image('homeimage'); $homeimage->setLabel('Image pour la page d\'accueil'); diff --git a/framework/application/models/Reference.php b/framework/application/models/Reference.php index 38e852b..7db26c3 100644 --- a/framework/application/models/Reference.php +++ b/framework/application/models/Reference.php @@ -11,8 +11,8 @@ class Fluidbook_Model_Reference extends CubeIT_Model_Data_Table { protected $fluidbook_id; protected $fluidbook_page; protected $image; - protected $featured; protected $categories; + protected $featured_categories; protected $homeimage; protected $_types = array('categories' => 'list', 'title' => 'json', 'text' => 'json', 'image' => 'json', 'homeimage' => 'json', 'fluidbook_id' => 'json', 'fluidbook_page' => 'json'); @@ -29,21 +29,26 @@ class Fluidbook_Model_Reference extends CubeIT_Model_Data_Table { $table->addColumn('image', 'string', array('length' => 64)); $table->addColumn('homeimage', 'string', array('length' => 64)); $table->addColumn('categories', 'string', array('length' => 64)); + $table->addColumn('featured_categories', 'string', array('length' => 64)); return $table; } - public function getFinalFluidbookId() { + public function getFluidbookId() { $res = parent::getFluidbookId(); return $this->_setFrDefault($res); } protected function _setFrDefault($res) { + if (CubeIT_Util_Json::isJson($res)) { $res = CubeIT_Util_Json::decode($res); } + if (!is_array($res) && !is_object($res)) { return $res; } + $res = CubeIT_Util_Object::asObject($res); + if (!$res->en) { $res->en = $res->fr; } @@ -56,9 +61,9 @@ class Fluidbook_Model_Reference extends CubeIT_Model_Data_Table { return $url; } if (null === $locale) { - return $this->_getLocalReference($this->getFinalFluidbookId()); + return $this->_getLocalReference($this->getFluidbookId()); } else { - return $this->_getLocalReference($this->getFinalFluidbookId()->$locale); + return $this->_getLocalReference($this->getFluidbookId()->$locale); } } @@ -82,7 +87,7 @@ class Fluidbook_Model_Reference extends CubeIT_Model_Data_Table { return '/references/' . $d . '/'; } - public function getFinalFluidbookPage() { + public function getFluidbookPage() { $res = parent::getFluidbookPage(); return $this->_setFrDefault($res); } @@ -96,7 +101,7 @@ class Fluidbook_Model_Reference extends CubeIT_Model_Data_Table { } $res->fr = $this->_getFinalURL($res->fr, 'fr'); - $res->fr = $this->_getFinalURL($res->en, 'en'); + $res->en = $this->_getFinalURL($res->en, 'en'); return $res; } diff --git a/framework/application/views/helpers/Exemples.php b/framework/application/views/helpers/Exemples.php index 93345d1..022e4e4 100644 --- a/framework/application/views/helpers/Exemples.php +++ b/framework/application/views/helpers/Exemples.php @@ -28,7 +28,7 @@ class Fluidbook_View_Helper_Exemples extends CubeIT_View_Helper_Abstract { $okexemples = array(); foreach ($exemples as $id => $exemple) { - if ($category > 0 && !in_array($category, $exemple->getCategories())) { + if ($category > 0 && !in_array($category, $exemple->getCategories()) && !in_array($category, $exemple->getFeaturedCategories())) { continue; } $okexemples[$id] = $exemple; @@ -42,7 +42,7 @@ class Fluidbook_View_Helper_Exemples extends CubeIT_View_Helper_Abstract { $max_normal = $max_featured * $normal_per_featured; foreach ($okexemples as $id => $exemple) { - if ($exemple->getFeatured()) { + if (in_array($category, $exemple->getFeaturedCategories())) { $featured[] = $id; } else { $normal[] = $id; @@ -111,8 +111,9 @@ class Fluidbook_View_Helper_Exemples extends CubeIT_View_Helper_Abstract { $image = CubeIT_Util_Cms::extractFile($f->getImage()); - if (!$image && $f->getFinalFluidbookId()) { - $res .= $this->exemplePublication($f->getFinalFluidbookId(), $f->getFinalFluidbookPage()); + + if (!$image && $f->getFluidbookId()) { + $res .= $this->exemplePublication($f->getFluidbookId(), $f->getFluidbookPage()); } else { $res .= $this->htmlElement('', 'div', array('style' => 'background-image:url(' . $this->imageProcess()->imageProcessGetURL($image, $f->getTitle() . ' - ' . $f->getText(), 660, 440, array(), 'R') . ');',