<?php\r
\r
-class CCGM_View_Helper_Actualites extends Zend_View_Helper_Abstract {\r
+class CCGM_View_Helper_Actualites extends CubeIT_View_Helper_Abstract {\r
\r
public function actualites($actus) {\r
- $actus = $this->_filter($actus);\r
- if (!count($actus)) {\r
- return;\r
- }\r
+ $actus = CCGM_Model_News::factory()->order('date DESC')->find();\r
\r
$this->view->headScript()->addScriptAndStyle('actualites')\r
->addGSAP();\r
}\r
\r
protected function _actu($a) {\r
- $nline = min(substr_count($a['news'], "\n") + 1, 2);\r
+ $nline = 1;\r
\r
$attrs = array('data-lines' => $nline);\r
\r
$res = '<div class="slide">';\r
$p = '';\r
- if (!$a['noshowdate']) {\r
- $p .= $this->view->dateTime($a['date'], Zend_Date::DAY . '/' . Zend_Date::MONTH . '/' . Zend_Date::YEAR, array('class' => 'date')) . ' ';\r
- } else {\r
- $attrs['class'] = 'nodate';\r
- }\r
- $p .= nl2br($a['news']);\r
+ $p .= $this->view->dateTime($a->getDate(), Zend_Date::DAY . '/' . Zend_Date::MONTH . '/' . Zend_Date::YEAR, array('class' => 'date')) . ' ';\r
+ $p .= $a->getTitle();\r
$res .= $this->view->htmlElement($p, 'p', $attrs);\r
$res .= '</div>';\r
return $res;\r
}\r
\r
- protected function _filter($actus) {\r
- $res = array();\r
- foreach ($actus as $a) {\r
- if (trim($a['news']) == '') {\r
- continue;\r
- }\r
- $res[] = $a;\r
- }\r
-\r
- usort($res, array($this, '_sort'));\r
- return $res;\r
- }\r
-\r
- protected function _sort($a, $b) {\r
- $da = new Zend_Date($a['date'], CubeIT_Date::MYSQL);\r
- $db = new Zend_Date($b['date'], CubeIT_Date::MYSQL);\r
-\r
- return -1 * $da->compare($db);\r
- }\r
\r
}\r
init: function () {\r
var $this = this;\r
\r
- if (this.number < 2) {\r
- this.element.find('.btn-area').hide();\r
- }\r
-\r
this.element.find('.btn-area a').click(function () {\r
if ($(this).hasClass('btn-next')) {\r
$this.goNext();\r
if (this.animating) {\r
return;\r
}\r
+\r
+ if(this.number==1){\r
+ this.getActu(index).show();\r
+ this.arrowsVisibility(index, 0.5);\r
+ this.endTransition(0);\r
+ return;\r
+ }\r
+\r
var $this = this;\r
this.animating = true;\r
var w = 870;\r
}\r
var currentActu = this.getActu(this.currentIndex);\r
\r
-\r
$(nextActu).css('left', w * -dir).show();\r
TweenMax.to(nextActu, d, {left: 0});\r
TweenMax.to(currentActu, d, {\r
}\r
});\r
this.arrowsVisibility(index, d);\r
-\r
-\r
},\r
arrowsVisibility: function (index, d) {\r
var prev = this.element.find('.btn-prev');\r
},\r
endTransition: function (index) {\r
this.animating = false;\r
- this.getActu(this.currentIndex).hide();\r
+ if(this.number>1) {\r
+ this.getActu(this.currentIndex).hide();\r
+ }\r
this.currentIndex = index;\r
},\r
};\r