$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;
--- /dev/null
+<?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();
+ }
+
+}
--- /dev/null
+<?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);
+ }
+
+}
$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
+++ /dev/null
-<?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');
- }
-
-}
-
-?>
+++ /dev/null
-<?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');
- }
-
-}
<?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');
+
}
}
$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');
--- /dev/null
+<?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
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'));
--- /dev/null
+<?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;
+ }
+
+}
</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>
--- /dev/null
+<?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
--- /dev/null
+.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