From: stephen@cubedesigners.com Date: Thu, 14 Feb 2019 10:55:49 +0000 (+0000) Subject: WIP #2033 @7 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=407a602cb4522122527ab1105a2aa1f6f50d44b1;p=cubedesigners-v7.git WIP #2033 @7 --- diff --git a/framework/application/forms/CMS/Sub/Casestudies/Content/Bloc.php b/framework/application/forms/CMS/Sub/Casestudies/Content/Bloc.php index 9475469..96cfb12 100644 --- a/framework/application/forms/CMS/Sub/Casestudies/Content/Bloc.php +++ b/framework/application/forms/CMS/Sub/Casestudies/Content/Bloc.php @@ -19,22 +19,22 @@ class Cubedesigners_Form_CMS_Sub_Casestudies_Content_Bloc extends CubeIT_Form_Su $text_color->setLabel('Text colour (leave blank for default)'); $this->addElement($text_color); - $margin = new CubeIT_Form_Element_Int('margin'); - $margin->setLabel("Décalage vertical du bloc (en pixels)"); - $this->addElement($margin); - - $zindex = new Zend_Form_Element_Select('zindex'); - $options = array('default' => 'Par défaut'); - for ($i = 1; $i <= 10; $i++) { - $options[$i] = $i; - } - $zindex->setMultiOptions($options); - $zindex->setLabel('z-index du bloc'); - $this->addElement($zindex); - - $annee = new Zend_Form_Element_Text('annee'); - $annee->setLabel('Année'); - $this->addElement($annee); +// $margin = new CubeIT_Form_Element_Int('margin'); +// $margin->setLabel("Décalage vertical du bloc (en pixels)"); +// $this->addElement($margin); +// +// $zindex = new Zend_Form_Element_Select('zindex'); +// $options = array('default' => 'Par défaut'); +// for ($i = 1; $i <= 10; $i++) { +// $options[$i] = $i; +// } +// $zindex->setMultiOptions($options); +// $zindex->setLabel('z-index du bloc'); +// $this->addElement($zindex); +// +// $annee = new Zend_Form_Element_Text('annee'); +// $annee->setLabel('Année'); +// $this->addElement($annee); $titre = new Zend_Form_Element_Text('titre'); $titre->setLabel('Titre'); @@ -49,10 +49,10 @@ class Cubedesigners_Form_CMS_Sub_Casestudies_Content_Bloc extends CubeIT_Form_Su $visuel->setMaxItems(1); $this->addElementLocalized($visuel, $isCompactTrad); - $visuelpadding = new CubeIT_Form_Element_Int('visuelpadding'); - $visuelpadding->setLabel('Margin intérieur sous le visuel'); - $visuelpadding->setValue(50); - $this->addElement($visuelpadding); +// $visuelpadding = new CubeIT_Form_Element_Int('visuelpadding'); +// $visuelpadding->setLabel('Margin intérieur sous le visuel'); +// $visuelpadding->setValue(50); +// $this->addElement($visuelpadding); $video = new CubeIT_Form_Element_WebVideo('video'); $video->setLabel('URL de la vidéo'); diff --git a/framework/application/forms/CMS/Sub/Casestudies/Studies.php b/framework/application/forms/CMS/Sub/Casestudies/Studies.php index 6b98f3b..4d200a9 100644 --- a/framework/application/forms/CMS/Sub/Casestudies/Studies.php +++ b/framework/application/forms/CMS/Sub/Casestudies/Studies.php @@ -36,6 +36,10 @@ class Cubedesigners_Form_CMS_Sub_Casestudies_Studies extends CubeIT_Form_List_Mo $visuel->setMaxItems(1); $this->addElementLocalized($visuel, $isCompactTrad, true); + $hover_color = new CubeIT_Form_Element_Color('hover_color'); + $hover_color->setLabel('Hover overlay colour (for thumbnail)'); + $this->addElement($hover_color); + $visuel_detail = new CubeIT_Form_Element_File_Image('visuel_detail'); $visuel_detail->setLabel('Visuel de la page de détail'); $visuel_detail->setMaxItems(1); diff --git a/framework/application/models/Casestudy.php b/framework/application/models/Casestudy.php index 40ab869..685a3f0 100644 --- a/framework/application/models/Casestudy.php +++ b/framework/application/models/Casestudy.php @@ -8,6 +8,7 @@ class Cubedesigners_Model_Casestudy extends CubeIT_Model_Data_Table { protected $url; protected $visuel; protected $visuel_detail; + protected $hover_color; protected $legende; protected $header_style; protected $couleur; @@ -28,6 +29,7 @@ class Cubedesigners_Model_Casestudy extends CubeIT_Model_Data_Table { $casestudies->addColumn('url', 'text'); $casestudies->addColumn('visuel', 'string', array('length' => 128)); $casestudies->addColumn('visuel_detail', 'string', array('length' => 128)); + $casestudies->addColumn('hover_color', 'string', array('length' => 32)); $casestudies->addColumn('legende', 'text'); $casestudies->addColumn('header_style', 'text'); $casestudies->addColumn('couleur', 'text'); diff --git a/framework/application/views/helpers/CaseStudiesGrid.php b/framework/application/views/helpers/CaseStudiesGrid.php new file mode 100644 index 0000000..451728c --- /dev/null +++ b/framework/application/views/helpers/CaseStudiesGrid.php @@ -0,0 +1,92 @@ +addScriptAndStyle('casestudies_grid'); + + // ToDo: see if there's a better way to do this + $this->_page_data = Bootstrap::getInstance()->getCMSDatasOfPage(4); // ID 4 = casestudies page + + $db = Zend_Db_Table::getDefaultAdapter(); + $select = $db->select()->from('casestudies') + ->order('RAND()'); + + if ($exclude_ID) { + $select->where('id != ?', $exclude_ID); + } + + $select->limit($limit); + + $query = $select->query(); + + $res = '
'; + + + while ($study = $query->fetch()) { + $res .= $this->_study(CubeIT_Util_Cms::unserialize($study)); + } + + $res .= '
'; // .casestudies-grid + + return $res; + } + + protected function _study($study) { + + // Max display size is 512 but we over-sample the size by 20% because there is a CSS scale effect on hover + $image = $this->view->imageProcess($study->visuel, $study->titre, 615, 615, ['class' => 'responsive casestudies-grid-item-image']); + $url = Cubedesigners_Util::generateAutoUri($study, $this->_page_data['seourl_stu']); + $tag_names = []; + + foreach ($study->tags_secondaires as $categoryID) { + $tag_names[] = $this->_getTagName($categoryID); + } + + $hover_style = empty($study->hover_color) ? '' : 'background-color:'. CubeIT_Util_Cms::hexToRGBA($study->hover_color, 0.75) .';'; + + $c = $image; + $c.= '
'; + $c.= '

' . $study->titre . '

'; + $c.= '

' . implode(' / ', $tag_names) . '

'; + $c.= '
'; // .casestudies-grid-item-label + + + + // Create a staggered delay for each row (3 items per row) + $delay = 300 + (($this->_counter % 3) * 200); + + $this->_counter++; + + return $this->link($c, $url, array( + 'data-cat' => $study->categories, + 'class' => 'casestudies-grid-item wow fadeInUp', + 'data-wow-delay' => $delay . 'ms', + )) . ' '; // Space needed between elements for justified alignment + } + + + // Get secondary category names + protected function _getTagName($catID) { + + // Cache the query data if it's not already done + if (!$this->_tags) { + + $db = Zend_Db_Table::getDefaultAdapter(); + $query = $db->select()->from('tags')->query(); + + while ($category = $query->fetch()) { + $category = CubeIT_Util_Cms::unserializeRow($category); + $this->_tags[$category->id] = CubeIT_Util_Object::toArray($category); + } + } + + return $this->_tags[$catID]['name']; + } + +} diff --git a/framework/application/views/helpers/CasestudiesDetail.php b/framework/application/views/helpers/CasestudiesDetail.php index 8e92b87..8e1a790 100644 --- a/framework/application/views/helpers/CasestudiesDetail.php +++ b/framework/application/views/helpers/CasestudiesDetail.php @@ -36,9 +36,29 @@ class Cubedesigners_View_Helper_CasestudiesDetail extends CubeIT_View_Helper_Abs $res .= '
'; + // To simplify spacing, blocks are separated by margins (top & bottom) + // which collapse into each other so we don't end up with unwanted double spacing. + // Blocks are grouped into sections that have the same background colour. + // This gives the needed spacing between colour changes because margins are contained within each section + $blocs = $studie->blocs; + $current_bg = ''; + + foreach ($blocs as $bloc_index => $bloc) { + + $section_style = empty($bloc->bg_color) ? '' : ' style="background-color:'. $bloc->bg_color .'"'; + + // Are we on the first block? If so, start the first section and record the current bg colour + if ($bloc_index == 0) { + $current_bg = $bloc->bg_color; + $res .= ''; + } elseif ($bloc->bg_color !== $current_bg) { + $current_bg = $bloc->bg_color; + // Background change, so start a new section + $res .= ''; + $res .= ''; + } - foreach ($blocs as $bloc) { // fb($bloc); $margin = ''; @@ -56,17 +76,14 @@ class Cubedesigners_View_Helper_CasestudiesDetail extends CubeIT_View_Helper_Abs $colours = ''; - if ($bloc->bg_color != '') { - $colours .= 'background-color:'. $bloc->bg_color .';'; - } +// if ($bloc->bg_color != '') { +// $colours .= 'background-color:'. $bloc->bg_color .';'; +// } if ($bloc->text_color != '') { $colours .= 'color:'. $bloc->text_color .';'; } - - // TODO: Manage padding better so it can be disabled for blocks that have the same colour where we don't want a double gap between them. - - $res .= '
'; + $res .= '
'; //-------------- @@ -83,10 +100,11 @@ class Cubedesigners_View_Helper_CasestudiesDetail extends CubeIT_View_Helper_Abs $width = -1; $height = -1; CubeIT_Image::getDimensions($visuel, $width, $height); - $padding = isset($bloc->visuelpadding) ? $bloc->visuelpadding : 50; + //$padding = isset($bloc->visuelpadding) ? $bloc->visuelpadding : 50; // Convert padding into a relative measure (%) for responsive images - $padding = $padding / 1200 * 100; + //$padding = $padding / 1200 * 100; + $padding = 0; //$res .= '
'; $res .= '
'; @@ -123,8 +141,9 @@ class Cubedesigners_View_Helper_CasestudiesDetail extends CubeIT_View_Helper_Abs $res .= '
'; // .detail-block } - $res .= '
'; - $res .= '
'; + $res .= ''; // Always close the last section that was opened... + $res .= '
'; // .casestudies-detail-content + $res .= ''; // .case return $res; } diff --git a/framework/application/views/helpers/CasestudiesList.php b/framework/application/views/helpers/CasestudiesList.php index 8e2b051..233f43f 100644 --- a/framework/application/views/helpers/CasestudiesList.php +++ b/framework/application/views/helpers/CasestudiesList.php @@ -162,7 +162,10 @@ class Cubedesigners_View_Helper_CasestudiesList extends CubeIT_View_Helper_Abstr $image = $this->view->imageProcess($s->visuel, $s->titre, 512, 'auto'); $url = Cubedesigners_Util::generateAutoUri($s, $this->_datas['seourl_stu']); - $c = '
'; + $s->hover_color = empty($s->hover_color) ? '#000' : $s->hover_color; + $hover_style = 'color:'. CubeIT_Util_Cms::hexToRGBA($s->hover_color, 0.5) .';'; // Using color so CSS can pass currentColor to :before pseudo element + + $c = '
'; $c.= $image; $c.= '
'; $c.= '

' . $s->titre . '

'; diff --git a/framework/application/views/scripts/studies/index.phtml b/framework/application/views/scripts/studies/index.phtml index decd9d0..3c2a76d 100644 --- a/framework/application/views/scripts/studies/index.phtml +++ b/framework/application/views/scripts/studies/index.phtml @@ -6,10 +6,11 @@ $this->headScript()->addScriptAndStyle('casestudies_detail'); echo $this->CasestudiesDetail($this->studie); ?> -