From fe5c789b5d41fa7879443270661a47b59388b5c9 Mon Sep 17 00:00:00 2001 From: "stephen@cubedesigners.com" Date: Fri, 28 Jun 2019 19:50:36 +0000 Subject: [PATCH] Fixes and improvements in preparation for launch. #2033 @5 --- .../views/helpers/CasestudiesRelatedList.php | 213 ++++++++++++++++++ .../views/scripts/templates/casestudies.phtml | 1 + .../views/scripts/templates/expertise.phtml | 7 +- js/casestudies.js | 122 +++++----- js/fancy-select.js | 212 +++++++++++++++++ js/header.js | 6 +- less/agence.less | 6 +- less/fancy-select.less | 112 +++++++++ less/link-arrow.less | 57 +++-- less/list.less | 4 + 10 files changed, 653 insertions(+), 87 deletions(-) create mode 100644 framework/application/views/helpers/CasestudiesRelatedList.php create mode 100644 js/fancy-select.js create mode 100644 less/fancy-select.less diff --git a/framework/application/views/helpers/CasestudiesRelatedList.php b/framework/application/views/helpers/CasestudiesRelatedList.php new file mode 100644 index 0000000..43999f3 --- /dev/null +++ b/framework/application/views/helpers/CasestudiesRelatedList.php @@ -0,0 +1,213 @@ +addScriptAndStyle('casestudies_grid'); + $this->_datas = $datas; + $listStudies = array(); + $listStudiesPropulsed = array(); + + // ToDo: see if there's a better way to do this + $this->_page_data = Bootstrap::getInstance()->getCMSDatasOfPage(4); // ID 4 = casestudies page + + if ($currentStudie != null) { + // fb($currentStudie); + $studieCategorie = $currentStudie->categories; + $studieSecondaires = $currentStudie->tags_secondaires; + $studieTechnologies = $currentStudie->technologies; + $studieDomaines = $currentStudie->domaines; + $studieDate = $currentStudie->annee; + } + + $acl = Bootstrap::getInstance()->isAllowed("edition"); + + $db = Zend_Db_Table::getDefaultAdapter(); + $s = $db->select()->from('casestudies') + ->order('annee DESC'); + + if(is_array($categories)) { + $s->where('categories IN (?)', $categories); + } + + // Fetch specific case study IDs + if(is_array($IDs)) { + $s->where('id IN (?)', $IDs); + } + + if($limit) { + $s->limit($limit); + } + + if (!$acl) { + $s->where('online = ?', 1); + } + $q = $s->query(); + + $count = 1; + + $res = ''; + + while ($r = $q->fetch()) { + + if (null === $currentStudie || $r->id != $currentStudie->id) { + $r = CubeIT_Util_Cms::unserialize($r); + $r->point = 0; + + $addSpacer = false; + + if ($count == 3) { + $count = 1; + $addClass = ''; + } else { + $addClass = ' blocmargin'; + $count++; + } + + $addOffline = ''; + if ($acl && $r->online == 0) { + $addOffline = 'data-offline="1"'; + } + + if ($currentStudie != null) { + if ($r->propulse == 1) { + $r->point += 10000; + } + + if ($r->categories == $studieCategorie) { + $r->point += 1000; + } + + if (is_array($r->tags_secondaires) && is_array($currentStudie->tags_secondaires)) { + if (count($r->tags_secondaires) >= 1 && count($currentStudie->tags_secondaires) >= 1) { + + for ($i = 0; $i < count($studieSecondaires); $i++) { + if (in_array($currentStudie->tags_secondaires[$i], $r->tags_secondaires)) { + $r->point += 100; + } + } + } + } + + if (is_array($r->technologies) && is_array($currentStudie->technologies)) { + if (count($r->technologies) >= 1 && count($currentStudie->technologies) >= 1) { + + foreach ($currentStudie->technologies as $t) { + if (in_array([$i], $r->technologies)) { + $r->point += 15; + } + } + } + } + + if ($r->domaines != '') { + if ($r->domaines == $currentStudie->domaines) + $r->point += 10; + } + + if ($r->annee != '') { + if ($r->annee == $currentStudie->annee) + $r->point += 5; + } + } + + if (count($listStudies) < 3) { + array_push($listStudies, $r); + } else { + if ($r->point > $listStudies[0]->point) { + $listStudies[2] = $listStudies[1]; + $listStudies[1] = $listStudies[0]; + $listStudies[0] = $r; + } else if ($r->point > $listStudies[1]->point) { + $listStudies[2] = $listStudies[1]; + $listStudies[1] = $r; + } else if ($r->point > $listStudies[2]->point) { + $listStudies[2] = $r; + } else { + + } + } + + + if ($currentStudie == null) { + $res.=$this->_case($r); + } + } + } + + if ($currentStudie != null) { + + $nbStudies = 0; + $count = 1; + + $listStudies = array_reverse($listStudies); + + + foreach ($listStudies as $i => $s) { + $res.=$this->_case($s); + } + } + return $res; + } + + protected function _case($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.= '

' . $study->legende . '

'; + $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/scripts/templates/casestudies.phtml b/framework/application/views/scripts/templates/casestudies.phtml index d26b5b4..0ae7b56 100644 --- a/framework/application/views/scripts/templates/casestudies.phtml +++ b/framework/application/views/scripts/templates/casestudies.phtml @@ -1,4 +1,5 @@ headScript()->addScriptAndStyle('fancy-select'); $this->headScript()->addScriptAndStyle('casestudies'); ?> diff --git a/framework/application/views/scripts/templates/expertise.phtml b/framework/application/views/scripts/templates/expertise.phtml index acdb854..244221c 100644 --- a/framework/application/views/scripts/templates/expertise.phtml +++ b/framework/application/views/scripts/templates/expertise.phtml @@ -1,6 +1,7 @@ headScript()->addScriptAndStyle('expertises'); +$this->headScript()->addScriptAndStyle('fancy-select'); echo $this->twocols(); if(!empty($this->citation)) { @@ -15,12 +16,14 @@ $casestudy_page_data = Bootstrap::getInstance()->getCMSDatasOfPage(4); // Fetch $related_casestudies = CubeIT_Util_Cms::unserialize($this->related_casestudies); -echo '