From 6c1e4df0b605abfaa4cf16b0aa639face0099d1e Mon Sep 17 00:00:00 2001 From: "stephen@cubedesigners.com" Date: Tue, 3 Mar 2020 17:10:37 +0000 Subject: [PATCH] WIP #3413 @3 --- framework/application/Bootstrap.php | 45 +++++++++ framework/application/configs/application.ini | 2 +- .../controllers/NewsController.php | 28 ++++++ framework/application/views/helpers/News.php | 14 +-- .../views/scripts/news/index.phtml | 11 +++ .../views/scripts/templates/news.phtml | 5 +- js/news.js | 94 +++++++++---------- less/news.less | 84 +++-------------- 8 files changed, 158 insertions(+), 125 deletions(-) create mode 100644 framework/application/controllers/NewsController.php create mode 100644 framework/application/views/scripts/news/index.phtml diff --git a/framework/application/Bootstrap.php b/framework/application/Bootstrap.php index 7e31832..747932f 100644 --- a/framework/application/Bootstrap.php +++ b/framework/application/Bootstrap.php @@ -94,11 +94,56 @@ class Bootstrap extends CubeIT_Bootstrap { return; } + if ($page->getTemplate() == 'news') { + $this->addNewsPages($page, $locale, $isAdmin); + } + if ($page->getTemplate() == 'research') { $this->addResearchCategoriesPages($page, $locale, $isAdmin); } } + + // URL template used for news pages + public static function getNewsArticleURLTemplate() { + return '/actualites/%title%'; // Important: must have leading slash or pages will show as not found! + } + + /** + * + * @param CubeIT_Navigation_Page_Locale $page + */ + protected function addNewsPages($page, $locale, $isAdmin) { + //$datas = $this->getCMSDatasOfNavigationPage($page); + + // How the URLs should be formed for the news articles + $URL_template = self::getNewsArticleURLTemplate(); + + $db = Zend_Db_Table::getDefaultAdapter(); + $s = $db->select()->from('news') + ->order('id ASC'); + $q = $s->query(); + + while ($r = $q->fetch()) { + + $online = true; + $pageTitle = $r->title; + + $p = new CubeIT_Navigation_Page_Locale(); + $p->setController('News'); + $p->setId($page->getId() . '/' . $r->id); + $p->setAutoUri($r, $URL_template); + $p->setSitemap($online); + $p->setTitle($pageTitle); + $p->setEditable(false); + $p->setParams(array('news_id' => $r->id)); + $p->setOnline($online); + $p->setDomain($page->getDomain()); + $p->setLabel($pageTitle); // Used in breadcrumbs + sidebar menu + $page->addPage($p); + } + } + // URL template used for research study pages public static function getResearchCategoriesURLTemplate() { return '/Recherche-clinique/%name%'; // Important: must have leading slash or pages will show as not found! diff --git a/framework/application/configs/application.ini b/framework/application/configs/application.ini index 244327d..4361fad 100644 --- a/framework/application/configs/application.ini +++ b/framework/application/configs/application.ini @@ -76,7 +76,7 @@ webhost = ccgm.test session.domain = .ccgm.test minify.js = true -minify.css = false +minify.css = true database.params.host = localhost database.params.username = root diff --git a/framework/application/controllers/NewsController.php b/framework/application/controllers/NewsController.php new file mode 100644 index 0000000..2db0df1 --- /dev/null +++ b/framework/application/controllers/NewsController.php @@ -0,0 +1,28 @@ +view->headScript()->addScriptAndStyle('news-article'); + + $parent = $this->view->currentPage->getParent(); + $parent_data = $this->getBootstrap()->getCMSDatasOfNavigationPage($parent); + $this->view->datas = $parent_data; + + $db = Zend_Db_Table::getDefaultAdapter(); + $select = $db->select()->from(['n' => 'news']) + ->where('n.id = ?', $this->getRequest()->getParam('news_id')); + $query = $select->query(); + + //echo 'QUERY: '. (string) $select; + + if (!$query->rowCount()) { + $this->_404(); + return; + } + + $this->view->news = $query->fetch(); + } + +} diff --git a/framework/application/views/helpers/News.php b/framework/application/views/helpers/News.php index 27370f5..ff98d98 100644 --- a/framework/application/views/helpers/News.php +++ b/framework/application/views/helpers/News.php @@ -16,16 +16,18 @@ class CCGM_View_Helper_News extends CubeIT_View_Helper_Abstract { } protected function _news($n) { - $img = $this->imageProcess($n->getImage(), '', 200, 200); + + $URL = CubeIT_Navigation_Page::generateAutoUri($n, Bootstrap::getNewsArticleURLTemplate()); + + $img = $this->imageProcess($n->getImage(), '', 247, 247); $res = $img; - $c = $this->dateTime($n->getDate(), CubeIT_Date::DAY . '/' . CubeIT_Date::MONTH . '/' . CubeIT_Date::YEAR); - $c .= $this->htmlElement($n->getTitle(), 'h2'); + //$c = $this->dateTime($n->getDate(), CubeIT_Date::DAY . '/' . CubeIT_Date::MONTH . '/' . CubeIT_Date::YEAR); + $c = $this->htmlElement($n->getTitle(), 'h2'); $c .= '
'; $c .= $this->markupDotclear($n->getContent()); $c .= $this->linkCMS($n->getLink()); $c .= '
'; - $c .= $this->link('Lire la suite', '#', ['class' => 'more']); - $c .= $this->link('Réduire', '#', ['class' => 'less']); + $c .= $this->link('Lire la suite', $URL, ['class' => 'read-more']); $res .= $this->htmlElement($c, 'div', ['class' => 'c']); $aargs = []; if (!$img) { @@ -33,4 +35,4 @@ class CCGM_View_Helper_News extends CubeIT_View_Helper_Abstract { } return $this->htmlElement($res, 'article', $aargs); } -} \ No newline at end of file +} diff --git a/framework/application/views/scripts/news/index.phtml b/framework/application/views/scripts/news/index.phtml new file mode 100644 index 0000000..1f95d41 --- /dev/null +++ b/framework/application/views/scripts/news/index.phtml @@ -0,0 +1,11 @@ +showsidebar = false; + +?> + +
+news);
+?>
+
diff --git a/framework/application/views/scripts/templates/news.phtml b/framework/application/views/scripts/templates/news.phtml index 14fbce1..a451ec5 100644 --- a/framework/application/views/scripts/templates/news.phtml +++ b/framework/application/views/scripts/templates/news.phtml @@ -1,13 +1,14 @@ contentWidth = 980; +$this->showsidebar = false; $this->headScript()->addScriptAndStyle('news'); ?>
markupDotclear($this->text); + echo $this->markupDotclear($this->text, [], ['class' => 'news-header']); echo $this->news(); ?>
-
\ No newline at end of file + diff --git a/js/news.js b/js/news.js index 95b5176..313c856 100644 --- a/js/news.js +++ b/js/news.js @@ -1,47 +1,47 @@ -(function ($) { - function JQnews(element) { - this.element = element; - this.init(); - } - - JQnews.prototype = { - init: function () { - var $this = this; - - - $(this.element).on('click', '.more', function () { - var c = $(this).closest('.c'); - var d = $(c).find('.acc'); - d.css({maxHeight: 999}); - $(this).hide(); - $(c).find('.less').show(); - setTimeout(function () { - d.css({maxHeight: d.outerHeight()}); - }, 600); - return false; - }); - - $(this.element).on('click', '.less', function () { - var c = $(this).closest('.c'); - var d = $(c).find('.acc'); - d.css({maxHeight: 72}); - $(this).hide(); - $(c).find('.more').show(); - return false; - }); - } - }; - - jQuery.fn.news = function () { - return this.each(function () { - var $this = $(this); - if ($(this).data('news') === undefined) { - $(this).data('news', new JQnews($this)); - } - }) - }; -})(jQuery); - -$(function () { - $("#news").news(); -}); \ No newline at end of file +// (function ($) { +// function JQnews(element) { +// this.element = element; +// this.init(); +// } +// +// JQnews.prototype = { +// init: function () { +// var $this = this; +// +// +// $(this.element).on('click', '.more', function () { +// var c = $(this).closest('.c'); +// var d = $(c).find('.acc'); +// d.css({maxHeight: 999}); +// $(this).hide(); +// $(c).find('.less').show(); +// setTimeout(function () { +// d.css({maxHeight: d.outerHeight()}); +// }, 600); +// return false; +// }); +// +// $(this.element).on('click', '.less', function () { +// var c = $(this).closest('.c'); +// var d = $(c).find('.acc'); +// d.css({maxHeight: 72}); +// $(this).hide(); +// $(c).find('.more').show(); +// return false; +// }); +// } +// }; +// +// jQuery.fn.news = function () { +// return this.each(function () { +// var $this = $(this); +// if ($(this).data('news') === undefined) { +// $(this).data('news', new JQnews($this)); +// } +// }) +// }; +// })(jQuery); +// +// $(function () { +// $("#news").news(); +// }); diff --git a/less/news.less b/less/news.less index ac81477..0d36e59 100644 --- a/less/news.less +++ b/less/news.less @@ -1,7 +1,12 @@ +.news-header { + margin: 1em 0 2em; +} + #news { font-weight: 300; article { + display: flex; border-bottom: 1px solid #dad9d9; padding-bottom: 48px; margin-bottom: 48px; @@ -10,89 +15,30 @@ margin-bottom: 0; } - &.noimg { - .c { - margin-left: 0; - width: 980px; - } - } - img { vertical-align: top; display: inline-block; - width: 200px; - height: 200px; - border-radius: 100px; + width: 247px; + height: 247px; + margin-right: 50px; + flex: 0 0 auto; + background-color: #eee; } .c { - margin-left: 80px; - vertical-align: top; - display: inline-block; - width: 686px; - time { - font-size: 13px; - } h2 { - color: #5e5e5e; - margin: 30px 0 0; - font-size: 26px; - } - - .acc { - max-height: 72px; - overflow: hidden; - transition: max-height 450ms; - margin-bottom: 30px; - > a { - display: inline-block; - text-align: center; - box-sizing: border-box; - white-space: nowrap; - background-color: #0ea6db; - font-weight: 300; - font-style: italic; - line-height: 29px; - border-radius: 3px; - color: #fff; - padding: 0 13px 1px 10px; - margin: 20px 0 20px 1px; - } + color: #f5810f; + margin: 20px 0 0; + font-size: 30px; } - .dotclear { - line-height: 24px; - min-height: 72px; - p:last-child { - margin-bottom: 0; - } - } - - .more, .less { + .read-more { color: #25a1da; font-weight: 500; font-size: 16px; display: block; - &:after { - content: ""; - display: inline-block; - margin-left: 10px; - width: 15px; - height: 15px; - position: relative; - top: 3px; - background-image: url("../images/arrow-li.svg"); - background-size: 100% 100%; - transform: rotate(90deg); - } - } - - .less { - display: none; - &:after { - transform: rotate(270deg); - } + margin-top: 1em; } } } -- 2.39.5