]> _ Git - cubedesigners-v7.git/commitdiff
Implement news section and update CMS forms. Fix some small bugs with CubeIT_Form_Lis...
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 21 Aug 2015 09:53:32 +0000 (09:53 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 21 Aug 2015 09:53:32 +0000 (09:53 +0000)
14 files changed:
framework/application/Bootstrap.php
framework/application/forms/CMS/Element/News.php [new file with mode: 0644]
framework/application/forms/CMS/News.php [new file with mode: 0644]
framework/application/forms/CMS/Sub/Casestudies/Studies.php
framework/application/forms/CMS/Sub/News.php [deleted file]
framework/application/forms/CMS/Sub/News/New.php [deleted file]
framework/application/forms/CMS/Sub/News/News.php
framework/application/forms/Settings.php
framework/application/models/News.php [new file with mode: 0644]
framework/application/views/helpers/FooterActualites.php
framework/application/views/helpers/News.php [new file with mode: 0644]
framework/application/views/scripts/common/footer.phtml
framework/application/views/scripts/templates/news.phtml [new file with mode: 0644]
less/news.less [new file with mode: 0644]

index 3cc2fe4b05c28dc73cc9acb00d02fdf1aaa5bd51..04a50170ef8b4ac692750733f19acbda5657af1e 100644 (file)
@@ -123,6 +123,7 @@ class Bootstrap extends CubeIT_Bootstrap {
                $templates['Etudes de cas'] = array('casestudies' => 'Accueil des études de cas', 'casestudies_detail' => 'Détail d\'étude de cas');
                $templates['Expertises'] = array('expertises' => 'Accueil de la rubrique Expertises',
                                                 'expertise' => 'Page de détail d\'expertise');
+               $templates['news'] = 'Actualités';
                $templates['contact'] = 'Contact';
 
                return $templates;
diff --git a/framework/application/forms/CMS/Element/News.php b/framework/application/forms/CMS/Element/News.php
new file mode 100644 (file)
index 0000000..6e769c0
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+
+class Cubedesigners_Form_CMS_Element_News extends CubeIT_Form_Element_List {
+
+    public function init() {
+        parent::init();
+
+        $this->setBaseForm(new Cubedesigners_Form_CMS_Sub_News_News());
+        $this->clearDecorators();
+    }
+
+}
diff --git a/framework/application/forms/CMS/News.php b/framework/application/forms/CMS/News.php
new file mode 100644 (file)
index 0000000..5a5fc1d
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+class Cubedesigners_Form_CMS_News extends Cubedesigners_Form_CMS {
+
+    public function init() {
+        parent::init();
+
+        $titre = new CubeIT_Form_Element_Markitup('titre');
+        $titre->setLabel('Titre');
+        $this->addElement($titre);
+
+        $news = new Cubedesigners_Form_CMS_Element_News('news_items');
+        $news->setLabel(__('Gestion des actualités'));
+        $this->addElement($news);
+    }
+
+}
index 83c3c5be1212bc2aba6f82ce0db1777385cc51be..676a59a76b47041e727ad565a9a4fd2186140b27 100644 (file)
@@ -76,7 +76,11 @@ class Cubedesigners_Form_CMS_Sub_Casestudies_Studies extends CubeIT_Form_List_Mo
                $bootstrap = Bootstrap::getInstance();
                $view = $bootstrap->getView();
 
-               $this->setListTitle('Etudes de cas')->setNewTitle('Créer une étude de cas')->setEditTitle('Edition de l\'étude de cas « $titre »')->setModel('Cubedesigners_Model_Casestudy')->setTitleColumn('titre');
+               $this->setListTitle('Etudes de cas');
+        $this->setNewTitle('Créer une étude de cas');
+        $this->setEditTitle('Edition de l\'étude de cas « $titre »');
+        $this->setModel('Cubedesigners_Model_Casestudy');
+        $this->setTitleColumn('titre');
        }
 
 }
\ No newline at end of file
diff --git a/framework/application/forms/CMS/Sub/News.php b/framework/application/forms/CMS/Sub/News.php
deleted file mode 100644 (file)
index ac5280b..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-class Cubedesigners_Form_CMS_Sub_News extends CubeIT_Form_SubForm {
-
-    public function init() {
-        parent::init();
-
-        $actus = new Cubedesigners_Form_CMS_Sub_News_News('actualites');
-        $actus->setLegend('Actualités');
-        $this->addSubForm($actus, 'actualites');
-    }
-
-}
-
-?>
diff --git a/framework/application/forms/CMS/Sub/News/New.php b/framework/application/forms/CMS/Sub/News/New.php
deleted file mode 100644 (file)
index 991983a..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-class Cubedesigners_Form_CMS_Sub_News_New extends CubeIT_Form_SubForm {
-
-       public function init() {
-               parent::init();
-
-               $date = new CubeIT_Form_Element_Date('date');
-               $date->setLabel('Date');
-               $date->setPrecision(CubeIT_Date::DAY);
-               $this->addElement($date);
-
-               $texte = new CubeIT_Form_Element_Markitup_Basic('texte');
-               $texte->setLabel('Texte');
-               $this->addElement($texte);
-
-               $lien = new CubeIT_Form_Element_Link();
-               $lien->setLabel('Lien');
-               $lien->labelEnabled(false);
-               $this->addSubForm($lien, 'link');
-       }
-
-}
index 0fc9364003de0fcbc01cbea56d9575555304cc14..599f11ea7608780a92b08c33c16f8eb4350ebd6c 100644 (file)
@@ -1,14 +1,36 @@
 <?php
 
-class Cubedesigners_Form_CMS_Sub_News_News extends CubeIT_Form_Multi_SubForm {
+class Cubedesigners_Form_CMS_Sub_News_News extends CubeIT_Form_List_Model {
 
        public function init() {
                parent::init();
 
-               $actu = new Cubedesigners_Form_CMS_Sub_News_New();
-               $this->setBaseSubForm($actu);
-               $this->setBaseLegend('Edition de l\'actualité du « $date »');
-               $this->setNewLegend('Nouvelle actualité');
+        $isCompactTrad = false;
+
+        $id = new CubeIT_Form_Element_Id();
+        $this->addElement($id);
+
+        $date = new CubeIT_Form_Element_Date('date');
+        $date->setPrecision(Zend_Date::DAY);
+        $date->setLabel(__('Date'));
+        $this->addElement($date);
+
+        $content = new CubeIT_Form_Element_Markitup_Basic('content');
+        $content->setLabel(__('Contents'));
+        $this->addElementLocalized($content, $isCompactTrad);
+
+        $link = new CubeIT_Form_Element_Link();
+        $link->setLabel(__('Lien'));
+        $link->labelEnabled(false);
+        $this->addSubForm($link, 'link');
+        $this->addSubFormLocalized($link, 'link', $isCompactTrad);
+
+        $this->setListTitle(__('Actualités'));
+        $this->setNewTitle(__('Nouvelle actualité'));
+        $this->setEditTitle(__('Edition de l\'actualité du « $date »'));
+        $this->setModel('Cubedesigners_Model_News');
+        $this->setTitleColumn('content');
+
        }
 
 }
index 339bfbe1d2f4f87b32e2b1acc7656c397aa6e542..36e87a0fea4539e023075ee8fe59bf9dfe912372 100644 (file)
@@ -39,12 +39,6 @@ class Cubedesigners_Form_Settings extends CubeIT_Form_Settings {
                $contact->setLabel('Informations de contact');
                $this->addSubFormLocalized($contact, 'contact');
 
-
-               /* BLOC ACTUALITES */
-               $actus = new Cubedesigners_Form_CMS_Sub_News();
-               $actus->setLabel('Bloc Actualités');
-               $this->addSubFormLocalized($actus, 'actus');
-
                /* BLOC SUIVEZ-NOUS */
                $followus = new Cubedesigners_Form_CMS_Sub_Followus();
                $followus->setLabel('Bloc Suivez-nous');
diff --git a/framework/application/models/News.php b/framework/application/models/News.php
new file mode 100644 (file)
index 0000000..624605f
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+class Cubedesigners_Model_News extends CubeIT_Model_Data_Table {
+
+    protected static $_table = 'news';
+    protected $date;
+    protected $content;
+    protected $link;
+
+    public static function getSchema($schema) {
+        $table = parent::getSchema($schema);
+        $table->addColumn('date', 'datetime');
+        $table->addColumn('content', 'text');
+        $table->addColumn('link', 'text');
+    }
+
+}
\ No newline at end of file
index 0b5baa7ba3f5941715ae753093c3542005e0a245..1ccfe469f9b0e7de37b9a24df0a8b9e0a7c44f62 100644 (file)
@@ -2,22 +2,28 @@
 
 class Cubedesigners_View_Helper_FooterActualites extends CubeIT_View_Helper_Abstract {
 
-       public function footerActualites($actus) {
-
-               $actus = $actus["actualites"];
-
-               $nbActus = count($actus);
-
-               $res = '<section class="actus">';
-               $res .= '<h2>' . __('Actualités') . '</h2>';
-               foreach ($actus as $id => $actu) {
-                       $res .= '<article class="actu">';
-                       $c = $this->view->dateTime($actu['date'], "dd-MM-y", array('class' => 'date'));
-                       $c .= $this->view->markupDotclear($actu['texte']);
-                       $actu['link']['label'] = $c;
-                       $res .= $this->view->linkCMS($actu['link']);
-                       $res .= '</article>';
-               }
+       public function footerActualites($limit = 3) {
+
+        $db = Zend_Db_Table::getDefaultAdapter();
+        $s = $db->select()->from('news')
+            ->order('date DESC')
+            ->limit($limit);
+
+        $q = $s->query();
+
+        $res = '<section class="actus">';
+        $res .= '<h2>' . __('Actualités') . '</h2>';
+
+        while ($r = $q->fetch()) {
+            $r = CubeIT_Util_Cms::unserialize($r);
+
+            $res .= '<article class="actu">';
+            $c  = $this->view->dateTime($r->date, "dd-MM-y", array('class' => 'date'));
+            $c .= $this->view->markupDotclear($r->content);
+            $r->link->label = $c; // Set content as label so it can be used with linkCMS()
+            $res .= $this->linkCMS($r->link);
+            $res .= '</article>';
+        }
 
                $res .= $this->linkInternal(__('Plus d\'actualités'), 'news', array('class' => 'but'));
 
diff --git a/framework/application/views/helpers/News.php b/framework/application/views/helpers/News.php
new file mode 100644 (file)
index 0000000..4ef219d
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+
+class Cubedesigners_View_Helper_News extends CubeIT_View_Helper_Abstract {
+
+    public function news($options = array()) {
+
+        $this->addScriptAndStyle('news');
+
+        $db = Zend_Db_Table::getDefaultAdapter();
+        $s = $db->select()->from('news')
+            ->order('date DESC');
+
+        // Handle limit on query
+        if(isset($options['limit'])) {
+            $s->limit($options['limit']);
+        }
+
+        $q = $s->query();
+
+        $news = array();
+
+        // Group news items by year
+        while ($r = $q->fetch()) {
+            $r = CubeIT_Util_Cms::unserialize($r);
+
+            $y = date('Y', strtotime($r->date));
+
+            $news[$y][] = array(
+                'date' => $this->view->dateTime($r->date, "dd-MM-y", array('class' => 'date')),
+                'content' => $this->view->markupDotclear($r->content),
+                'link' => $r->link
+            );
+        }
+
+        $res = '';
+
+        foreach($news as $year => $items) {
+
+            $res .= '<div class="year-wrapper">';
+            $res .= '<div class="year">'. $year .'</div>';
+
+            foreach($items as $item) {
+
+                $res .= '<article class="news-item">';
+                $c  = $item['date'];
+                $c .= $item['content'];
+                $item['link']->label = $c; // Set content as label so it can be used with linkCMS()
+                $res .= $this->linkCMS($item['link']);
+                $res .= '</article>';
+
+            }
+
+            $res .= '</div>'; // .year-wrapper
+        }
+
+
+        return $res;
+    }
+
+}
index b4e6e7dcf3e3473676a0389941962342c32f3025..8b18b320abaef8adeb9133d3fe0ea92de474d8f1 100644 (file)
@@ -18,7 +18,7 @@ echo $this->clear();
                                </div>
 
                                <div class="bloc">
-                                       <?php echo $this->footerActualites($this->option('actus')); ?>
+                                       <?php echo $this->footerActualites(); ?>
                                        <div class="social">
                                                <?php echo $this->footerSocials($this->option('followus')); ?>
                                        </div>
diff --git a/framework/application/views/scripts/templates/news.phtml b/framework/application/views/scripts/templates/news.phtml
new file mode 100644 (file)
index 0000000..0df7d13
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+$this->headScript()->addScriptAndStyle('news');
+?>
+
+<div class="news content">
+    <div class="title"><?php echo $this->markupDotclear($this->titre); ?></div>
+
+    <div class="news-list">
+        <?php echo $this->news(); ?>
+    </div>
+</div>
\ No newline at end of file
diff --git a/less/news.less b/less/news.less
new file mode 100644 (file)
index 0000000..77f53b2
--- /dev/null
@@ -0,0 +1,51 @@
+.news .title {
+  padding-top: 60px;
+}
+
+.news-list {
+    margin: 34px 0 100px 0;
+
+    a {
+      color: #222428;
+    }
+}
+
+.year-wrapper {
+  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAAGCAIAAABmRdhlAAAAH0lEQVR4AWP8++EuAwMD4/ct6iDq5+laEPX//38MCgBUCA/blssRfQAAAABJRU5ErkJggg==');
+  background-repeat: repeat-y;
+  background-position: 44px 0; // Half of circle width (90px/2) minus half of bg width (2px/2) to align perfectly
+  position: relative;
+  min-height: 90px;
+  padding: 20px 0 0 120px;
+  margin-bottom: 7px;
+}
+
+.year {
+  position: absolute;
+  width: 90px;
+  height: 90px;
+  line-height: 90px;
+  border-radius: 50%;
+  background-color: #f6ae01;
+  color: #fff;
+  top: 0;
+  left: 0;
+  display: block;
+  text-align: center;
+  font-size: 24px;
+
+  &:after { // Makes a gap under the circle to cover the dotted bg
+    content: '';
+    background-color: #fff;
+    display: block;
+    height: 7px;
+  }
+}
+
+.news-item {
+  padding-bottom: 27px;
+
+  &:last-child {
+    padding-bottom: 0;
+  }
+}
\ No newline at end of file