]> _ Git - ccgm.git/commitdiff
WIP #3413 @3
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 3 Mar 2020 17:10:37 +0000 (17:10 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 3 Mar 2020 17:10:37 +0000 (17:10 +0000)
framework/application/Bootstrap.php
framework/application/configs/application.ini
framework/application/controllers/NewsController.php [new file with mode: 0644]
framework/application/views/helpers/News.php
framework/application/views/scripts/news/index.phtml [new file with mode: 0644]
framework/application/views/scripts/templates/news.phtml
js/news.js
less/news.less

index 7e31832b70be098ee430fa5b00690bd50e07d501..747932fd027e085796f0500aa13c40493056bb1c 100644 (file)
@@ -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!
index 244327dc69a763e1e13582be5790dbf34ef417da..4361fadb00be7c1dd332f081d262ea622958fbd3 100644 (file)
@@ -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 (file)
index 0000000..2db0df1
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+class NewsController extends CubeIT_Controller_PageController {
+
+    public function indexAction() {
+
+        $this->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();
+    }
+
+}
index 27370f57c58271cccd92a956ce97b8185a5e25b6..ff98d98bebddb2f70c301c7bab76a843d77742e7 100644 (file)
@@ -16,16 +16,18 @@ class CCGM_View_Helper_News extends CubeIT_View_Helper_Abstract {
        }\r
 \r
        protected function _news($n) {\r
-               $img = $this->imageProcess($n->getImage(), '', 200, 200);\r
+\r
+           $URL = CubeIT_Navigation_Page::generateAutoUri($n, Bootstrap::getNewsArticleURLTemplate());\r
+\r
+               $img = $this->imageProcess($n->getImage(), '', 247, 247);\r
                $res = $img;\r
-               $c = $this->dateTime($n->getDate(), CubeIT_Date::DAY . '/' . CubeIT_Date::MONTH . '/' . CubeIT_Date::YEAR);\r
-               $c .= $this->htmlElement($n->getTitle(), 'h2');\r
+               //$c = $this->dateTime($n->getDate(), CubeIT_Date::DAY . '/' . CubeIT_Date::MONTH . '/' . CubeIT_Date::YEAR);\r
+               $c  = $this->htmlElement($n->getTitle(), 'h2');\r
                $c .= '<div class="acc">';\r
                $c .= $this->markupDotclear($n->getContent());\r
                $c .= $this->linkCMS($n->getLink());\r
                $c .= '</div>';\r
-               $c .= $this->link('Lire la suite', '#', ['class' => 'more']);\r
-               $c .= $this->link('RĂ©duire', '#', ['class' => 'less']);\r
+               $c .= $this->link('Lire la suite', $URL, ['class' => 'read-more']);\r
                $res .= $this->htmlElement($c, 'div', ['class' => 'c']);\r
                $aargs = [];\r
                if (!$img) {\r
@@ -33,4 +35,4 @@ class CCGM_View_Helper_News extends CubeIT_View_Helper_Abstract {
                }\r
                return $this->htmlElement($res, 'article', $aargs);\r
        }\r
-}
\ No newline at end of file
+}\r
diff --git a/framework/application/views/scripts/news/index.phtml b/framework/application/views/scripts/news/index.phtml
new file mode 100644 (file)
index 0000000..1f95d41
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+$this->showsidebar = false;
+
+?>
+
+<pre>
+<?php
+    print_r($this->news);
+?>
+</pre>
index 14fbce1f5aae507ac18c5cf4c0a13a9db54a5bee..a451ec5e19c14317ed969fac6753a002f49fe47a 100644 (file)
@@ -1,13 +1,14 @@
 <?php\r
 $this->contentWidth = 980;\r
+$this->showsidebar = false;\r
 $this->headScript()->addScriptAndStyle('news');\r
 ?>\r
 \r
 <section id="content">\r
        <div id="c">\r
                <?php\r
-               echo $this->markupDotclear($this->text);\r
+               echo $this->markupDotclear($this->text, [], ['class' => 'news-header']);\r
                echo $this->news();\r
                ?>\r
        </div>\r
-</section>
\ No newline at end of file
+</section>\r
index 95b51767e10af535fe72b18227112e00da65246f..313c8569b2727de3d40b8b6b4e36c1362705ff75 100644 (file)
@@ -1,47 +1,47 @@
-(function ($) {\r
-    function JQnews(element) {\r
-        this.element = element;\r
-        this.init();\r
-    }\r
-\r
-    JQnews.prototype = {\r
-        init: function () {\r
-            var $this = this;\r
-\r
-\r
-            $(this.element).on('click', '.more', function () {\r
-                var c = $(this).closest('.c');\r
-                var d = $(c).find('.acc');\r
-                d.css({maxHeight: 999});\r
-                $(this).hide();\r
-                $(c).find('.less').show();\r
-                setTimeout(function () {\r
-                    d.css({maxHeight: d.outerHeight()});\r
-                }, 600);\r
-                return false;\r
-            });\r
-\r
-            $(this.element).on('click', '.less', function () {\r
-                var c = $(this).closest('.c');\r
-                var d = $(c).find('.acc');\r
-                d.css({maxHeight: 72});\r
-                $(this).hide();\r
-                $(c).find('.more').show();\r
-                return false;\r
-            });\r
-        }\r
-    };\r
-\r
-    jQuery.fn.news = function () {\r
-        return this.each(function () {\r
-            var $this = $(this);\r
-            if ($(this).data('news') === undefined) {\r
-                $(this).data('news', new JQnews($this));\r
-            }\r
-        })\r
-    };\r
-})(jQuery);\r
-\r
-$(function () {\r
-    $("#news").news();\r
-});
\ No newline at end of file
+// (function ($) {\r
+//     function JQnews(element) {\r
+//         this.element = element;\r
+//         this.init();\r
+//     }\r
+//\r
+//     JQnews.prototype = {\r
+//         init: function () {\r
+//             var $this = this;\r
+//\r
+//\r
+//             $(this.element).on('click', '.more', function () {\r
+//                 var c = $(this).closest('.c');\r
+//                 var d = $(c).find('.acc');\r
+//                 d.css({maxHeight: 999});\r
+//                 $(this).hide();\r
+//                 $(c).find('.less').show();\r
+//                 setTimeout(function () {\r
+//                     d.css({maxHeight: d.outerHeight()});\r
+//                 }, 600);\r
+//                 return false;\r
+//             });\r
+//\r
+//             $(this.element).on('click', '.less', function () {\r
+//                 var c = $(this).closest('.c');\r
+//                 var d = $(c).find('.acc');\r
+//                 d.css({maxHeight: 72});\r
+//                 $(this).hide();\r
+//                 $(c).find('.more').show();\r
+//                 return false;\r
+//             });\r
+//         }\r
+//     };\r
+//\r
+//     jQuery.fn.news = function () {\r
+//         return this.each(function () {\r
+//             var $this = $(this);\r
+//             if ($(this).data('news') === undefined) {\r
+//                 $(this).data('news', new JQnews($this));\r
+//             }\r
+//         })\r
+//     };\r
+// })(jQuery);\r
+//\r
+// $(function () {\r
+//     $("#news").news();\r
+// });\r
index ac81477977c771e9f1f209c6d8f3299cde8b470d..0d36e59aad1b8251df3e1327c91bd9e5cf17b1a4 100644 (file)
@@ -1,7 +1,12 @@
+.news-header {\r
+       margin: 1em 0 2em;\r
+}\r
+\r
 #news {\r
        font-weight: 300;\r
 \r
        article {\r
+               display: flex;\r
                border-bottom: 1px solid #dad9d9;\r
                padding-bottom: 48px;\r
                margin-bottom: 48px;\r
                        margin-bottom: 0;\r
                }\r
 \r
-               &.noimg {\r
-                       .c {\r
-                               margin-left: 0;\r
-                               width: 980px;\r
-                       }\r
-               }\r
-\r
                img {\r
                        vertical-align: top;\r
                        display: inline-block;\r
-                       width: 200px;\r
-                       height: 200px;\r
-                       border-radius: 100px;\r
+                       width: 247px;\r
+                       height: 247px;\r
+                       margin-right: 50px;\r
+                       flex: 0 0 auto;\r
+                       background-color: #eee;\r
                }\r
 \r
                .c {\r
-                       margin-left: 80px;\r
-                       vertical-align: top;\r
-                       display: inline-block;\r
-                       width: 686px;\r
-                       time {\r
-                               font-size: 13px;\r
-                       }\r
 \r
                        h2 {\r
-                               color: #5e5e5e;\r
-                               margin: 30px 0 0;\r
-                               font-size: 26px;\r
-                       }\r
-\r
-                       .acc {\r
-                               max-height: 72px;\r
-                               overflow: hidden;\r
-                               transition: max-height 450ms;\r
-                               margin-bottom: 30px;\r
-                               > a {\r
-                                       display: inline-block;\r
-                                       text-align: center;\r
-                                       box-sizing: border-box;\r
-                                       white-space: nowrap;\r
-                                       background-color: #0ea6db;\r
-                                       font-weight: 300;\r
-                                       font-style: italic;\r
-                                       line-height: 29px;\r
-                                       border-radius: 3px;\r
-                                       color: #fff;\r
-                                       padding: 0 13px 1px 10px;\r
-                                       margin: 20px 0 20px 1px;\r
-                               }\r
+                               color: #f5810f;\r
+                               margin: 20px 0 0;\r
+                               font-size: 30px;\r
                        }\r
 \r
-                       .dotclear {\r
-                               line-height: 24px;\r
-                               min-height: 72px;\r
-                               p:last-child {\r
-                                       margin-bottom: 0;\r
-                               }\r
-                       }\r
-\r
-                       .more, .less {\r
+                       .read-more {\r
                                color: #25a1da;\r
                                font-weight: 500;\r
                                font-size: 16px;\r
                                display: block;\r
-                               &:after {\r
-                                       content: "";\r
-                                       display: inline-block;\r
-                                       margin-left: 10px;\r
-                                       width: 15px;\r
-                                       height: 15px;\r
-                                       position: relative;\r
-                                       top: 3px;\r
-                                       background-image: url("../images/arrow-li.svg");\r
-                                       background-size: 100% 100%;\r
-                                       transform: rotate(90deg);\r
-                               }\r
-                       }\r
-\r
-                       .less {\r
-                               display: none;\r
-                               &:after {\r
-                                       transform: rotate(270deg);\r
-                               }\r
+                               margin-top: 1em;\r
                        }\r
                }\r
        }\r