From: stephen@cubedesigners.com Date: Fri, 21 Aug 2015 09:53:32 +0000 (+0000) Subject: Implement news section and update CMS forms. Fix some small bugs with CubeIT_Form_Lis... X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b6524b4344900beaf90254fb8a145d65741dd217;p=cubedesigners-v7.git Implement news section and update CMS forms. Fix some small bugs with CubeIT_Form_List and CubeIT_View_Helper_Option. --- diff --git a/framework/application/Bootstrap.php b/framework/application/Bootstrap.php index 3cc2fe4..04a5017 100644 --- a/framework/application/Bootstrap.php +++ b/framework/application/Bootstrap.php @@ -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 index 0000000..6e769c0 --- /dev/null +++ b/framework/application/forms/CMS/Element/News.php @@ -0,0 +1,12 @@ +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 index 0000000..5a5fc1d --- /dev/null +++ b/framework/application/forms/CMS/News.php @@ -0,0 +1,17 @@ +setLabel('Titre'); + $this->addElement($titre); + + $news = new Cubedesigners_Form_CMS_Element_News('news_items'); + $news->setLabel(__('Gestion des actualités')); + $this->addElement($news); + } + +} diff --git a/framework/application/forms/CMS/Sub/Casestudies/Studies.php b/framework/application/forms/CMS/Sub/Casestudies/Studies.php index 83c3c5b..676a59a 100644 --- a/framework/application/forms/CMS/Sub/Casestudies/Studies.php +++ b/framework/application/forms/CMS/Sub/Casestudies/Studies.php @@ -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 index ac5280b..0000000 --- a/framework/application/forms/CMS/Sub/News.php +++ /dev/null @@ -1,15 +0,0 @@ -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 index 991983a..0000000 --- a/framework/application/forms/CMS/Sub/News/New.php +++ /dev/null @@ -1,23 +0,0 @@ -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'); - } - -} diff --git a/framework/application/forms/CMS/Sub/News/News.php b/framework/application/forms/CMS/Sub/News/News.php index 0fc9364..599f11e 100644 --- a/framework/application/forms/CMS/Sub/News/News.php +++ b/framework/application/forms/CMS/Sub/News/News.php @@ -1,14 +1,36 @@ 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'); + } } diff --git a/framework/application/forms/Settings.php b/framework/application/forms/Settings.php index 339bfbe..36e87a0 100644 --- a/framework/application/forms/Settings.php +++ b/framework/application/forms/Settings.php @@ -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 index 0000000..624605f --- /dev/null +++ b/framework/application/models/News.php @@ -0,0 +1,17 @@ +addColumn('date', 'datetime'); + $table->addColumn('content', 'text'); + $table->addColumn('link', 'text'); + } + +} \ No newline at end of file diff --git a/framework/application/views/helpers/FooterActualites.php b/framework/application/views/helpers/FooterActualites.php index 0b5baa7..1ccfe46 100644 --- a/framework/application/views/helpers/FooterActualites.php +++ b/framework/application/views/helpers/FooterActualites.php @@ -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 = '
'; - $res .= '

' . __('Actualités') . '

'; - foreach ($actus as $id => $actu) { - $res .= '
'; - $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 .= '
'; - } + public function footerActualites($limit = 3) { + + $db = Zend_Db_Table::getDefaultAdapter(); + $s = $db->select()->from('news') + ->order('date DESC') + ->limit($limit); + + $q = $s->query(); + + $res = '
'; + $res .= '

' . __('Actualités') . '

'; + + while ($r = $q->fetch()) { + $r = CubeIT_Util_Cms::unserialize($r); + + $res .= '
'; + $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 .= '
'; + } $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 index 0000000..4ef219d --- /dev/null +++ b/framework/application/views/helpers/News.php @@ -0,0 +1,60 @@ +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 .= '
'; + $res .= '
'. $year .'
'; + + foreach($items as $item) { + + $res .= '
'; + $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 .= '
'; + + } + + $res .= '
'; // .year-wrapper + } + + + return $res; + } + +} diff --git a/framework/application/views/scripts/common/footer.phtml b/framework/application/views/scripts/common/footer.phtml index b4e6e7d..8b18b32 100644 --- a/framework/application/views/scripts/common/footer.phtml +++ b/framework/application/views/scripts/common/footer.phtml @@ -18,7 +18,7 @@ echo $this->clear();
- footerActualites($this->option('actus')); ?> + footerActualites(); ?> diff --git a/framework/application/views/scripts/templates/news.phtml b/framework/application/views/scripts/templates/news.phtml new file mode 100644 index 0000000..0df7d13 --- /dev/null +++ b/framework/application/views/scripts/templates/news.phtml @@ -0,0 +1,11 @@ +headScript()->addScriptAndStyle('news'); +?> + +
+
markupDotclear($this->titre); ?>
+ +
+ news(); ?> +
+
\ No newline at end of file diff --git a/less/news.less b/less/news.less new file mode 100644 index 0000000..77f53b2 --- /dev/null +++ b/less/news.less @@ -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