public function getCMSTemplates() {
$templates = parent::getCMSTemplates();
$templates['text'] = 'Page de texte';
+ $templates['news'] = 'Actualités';
return $templates;
}
--- /dev/null
+<?php
+
+class Simeox_News {
+
+ protected static $imageSize = 163; // Images are cropped square
+
+ public static function getNews($page = 1, $perPage = 3) {
+
+ //###TEMPORARY! Produce endless stream of data for testing infinite scroll
+ //$page = ($page > 1) ? 1 : $page;
+ //fb('Fetching page #'. $page);
+
+
+ $db = Bootstrap::getInstance()->getDb();
+ $news_result = $db->select()->from('news')
+ ->order('date DESC')
+ ->limit($perPage, ($page - 1) * $perPage)
+ ->query()
+ ->fetchAll();
+
+ $news_result = CubeIT_Util_Cms::unserialize($news_result);
+
+ $news = array();
+
+ foreach ($news_result as $n) {
+
+ $date = new CubeIT_Date($n->date, CubeIT_Date::MYSQL);
+
+ $news[] = array(
+ 'date' => $date->toString('dd/MM/YYYY'),
+ 'headline' => $n->headline,
+ 'content' => Bootstrap::getInstance()->getView()->markupDotclear($n->content, array(), array('class' => 'news-content')),
+ 'image' => Bootstrap::getInstance()->getView()->imageProcess($n->image, $n->headline, self::$imageSize, self::$imageSize, array(), 'C', 'C', 'M', false, 'auto', 'transparent')
+ );
+ }
+
+ return CubeIT_Util_Cms::unserialize($news);
+ }
+}
\ No newline at end of file
class AjaxController extends CubeIT_Controller_AjaxController {
-
+ public function news($page = 1, $perPage = 5) {
+ $this->_datas->addVariable('data', Simeox_News::getNews($page, $perPage));
+ }
}
--- /dev/null
+<?php
+
+class Simeox_Form_CMS_News extends CubeIT_Form_CMS {
+ public function init() {
+ parent::init();
+
+ $title = new Zend_Form_Element_Text('title');
+ $title->setLabel(__('Titre'));
+ $this->addElement($title);
+
+ $news = new Simeox_Form_Element_News('news_items');
+ $news->setLabel(__('Gestion des actualités'));
+ $this->addElement($news);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+class Simeox_Form_CMS_Sub_News extends CubeIT_Form_List_Model {
+
+ public function init() {
+ parent::init();
+
+ $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);
+
+ $headline = new Zend_Form_Element_Text('headline');
+ $headline->setLabel(__('Titre'));
+ $this->addElementLocalized($headline, $isCompactTrad);
+
+ $content = new Simeox_Form_Element_Markitup('content');
+ $content->setLabel(__('Contents'));
+ $this->addElementLocalized($content, $isCompactTrad);
+
+ $image = new CubeIT_Form_Element_File_Image('image');
+ $image->setLabel(__('Image'));
+ $this->addElement($image);
+
+ $this->setListTitle(__('Actualités'));
+ $this->setNewTitle(__('Nouvelle actualité'));
+ $this->setEditTitle(__('Edition de l\'actualité « $headline »'));
+ $this->setModel('Simeox_Model_News');
+ $this->setTitleColumn('headline');
+ $this->setAdditionnalColumns(array('date'));
+
+ }
+
+}
--- /dev/null
+<?php
+
+class Simeox_Form_Element_News extends CubeIT_Form_Element_List {
+
+ public function init() {
+ parent::init();
+
+ $this->setBaseForm(new Simeox_Form_CMS_Sub_News());
+ $this->clearDecorators();
+ }
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+class Simeox_Model_News extends CubeIT_Model_Data_Table {
+
+ protected static $_table = 'news';
+ protected $date;
+ protected $headline;
+ protected $content;
+ protected $image;
+
+ protected $_types = array('date' => 'date');
+
+ public static function getSchema($schema) {
+ $table = parent::getSchema($schema);
+ $table->addColumn('date', 'datetime');
+ $table->addColumn('headline', 'text');
+ $table->addColumn('content', 'text');
+ $table->addColumn('image', 'text');
+ }
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+/* @var $this Zend_View */
+
+$bodyClass = $this->body_class . ' ' . $this->bodyClass;
+
+$class = isset($this->navigation()->view->currentPage) ? $this->navigation()->view->currentPage->getName() : ''; // Or should it be label?
+$class.=' '.$bodyClass;
+
+echo '<body class="' . trim($class) . '">' . "\n";
+echo $this->bannerCookies();
+echo $this->render('admin/mockup.phtml');
+echo $this->render('admin/nav.phtml');
+echo $this->render('common/content.phtml');
+echo $this->render('ajax/loader.phtml');
+echo "\n" . '</body>' . "\n";
\ No newline at end of file
<?php
-$c = $this->layout()->content;
+$content = $this->htmlElement($this->layout()->content, 'div', array('class' => 'content content-wrapper'));
//$admin = $this->admin ? ' admin' : '';
echo '<div id="top"></div>';
echo $this->render('common/header.phtml');
-echo $this->htmlElement($c, 'main', array('class' => ''));
+echo $this->htmlElement($content, 'main', array('class' => ''));
echo $this->render('common/footer.phtml');
\ No newline at end of file
<footer class="group">
<div class="content">
- <?php
- echo $this->localeNavigation(true, CubeIT_View_Helper_LocaleNavigation::BIGRAMME);
- ?>
-
<?php echo $this->markupDotclear($this->option('footer')); ?>
</div>
</footer>
\ No newline at end of file
$this->headScript()->addScriptAndStyle('navigation');
// Major nav sections
-$sections = array('simeox', 'clinic', 'about', 'contact');
+$sections = array('simeox', 'clinic', 'about', 'news', 'contact');
$data = CubeIT_Util_Cms::getCMSDatasOfPage('home');
<ul>
<?php
foreach ($sections as $i => $s) {
- echo '<li data-i="' . $i . '"><a href="/#' . $s . '">' . $data[$s]['menu_title'] . '</a></li>';
+
+ if ($s == 'news') {
+ $title = __('Actualités');
+ $URL = CubeIT_View_Helper_Link::internal('news');
+ } else {
+ $title = $data[$s]['menu_title'];
+ $URL = "/#$s";
+ }
+
+ echo '<li data-i="'. $i .'"><a href="'. $URL .'">'. $title .'</a></li>';
}
?>
</ul>
</nav>
+
+ <?php echo $this->localeNavigation(true, CubeIT_View_Helper_LocaleNavigation::BIGRAMME); ?>
+
</div>
</header>
\ No newline at end of file
<?php
+$this->headScript()->addScriptAndStyle('home');
+
echo $this->render('home/hero.phtml');
echo $this->render('home/simeox.phtml');
echo $this->render('home/rdclinic.phtml');
--- /dev/null
+<?php\r
+\r
+$this->headScript()->addScriptAndStyle('news');\r
+\r
+?>\r
+\r
+<h1 class="page-heading"><?php echo $this->title ?></h1>\r
+\r
+<div id="newsFeed"\r
+ data-read-more-closed="<?php echo __('Lire la suite') ?>"\r
+ data-read-more-open="<?php echo __('Réduire') ?>">\r
+</div>\r
+\r
+<div class="loader-container">\r
+ <div class="loader">Loading...</div>\r
+</div>
\ No newline at end of file
<?php\r
$this->headScript()->addScriptAndStyle('text');\r
-echo '<div class="content">';\r
echo $this->markupDotclear($this->text);\r
-echo '</div>';\r
--- /dev/null
+registerLoader(load_newsfeed);
+
+var currentPage = 1,
+ scrollBufferTrigger = $(window).height() / 5, // How many pixels from bottom before next AJAX event is fired
+ isLoading = false,
+ allDataLoaded = false;
+
+//--- INIT ---//
+function load_newsfeed() {
+
+ $('.loader').hide();
+
+ // Initial load of data via AJAX
+ loadMoreContent(fillPage);
+
+
+ //-- Infinite Scroll: track scroll position and load more data when needed --//
+ $(window).scroll(function () {
+
+ var dh = $(document).height(),
+ wh = $(window).height(),
+ top = $(window).scrollTop();
+
+ // Trigger will be true {scrollBufferTrigger}px above bottom of page
+ var triggerPoint = (dh < wh) || (top >= dh - wh - scrollBufferTrigger);
+
+ if (!allDataLoaded && !isLoading && triggerPoint) {
+ loadMoreContent();
+ }
+ });
+
+
+ //-- Handle show/hide link clicks
+ $(document).on('click', 'a.read-more', function() {
+
+ var content = $(this).siblings('.news-content');
+
+ if (content.hasClass('open')) {
+ content.removeClass('open');
+ $(this).text($(this).data('closed'));
+ } else {
+ content.addClass('open');
+ $(this).text($(this).data('open'));
+ }
+
+ return false;
+ });
+}
+
+// Ensure we have loaded enough to be able to scroll
+function fillPage() {
+ // If we don't have a full window of content, the scroll
+ // trigger won't fire, so load more content until it can
+ if ($(document).height() <= $(window).height()) {
+ console.info('fillpage ' + currentPage);
+ loadMoreContent(fillPage);
+ }
+}
+
+//-----------------------//
+
+function loadMoreContent(callback) {
+
+ var $container = $('#newsFeed'),
+ readMoreClosed = $container.data('read-more-closed'),
+ readMoreOpen = $container.data('read-more-open');
+
+ var dataURL = '/ajax/news/' + currentPage;
+
+ isLoading = true;
+ $('.loader').show();
+
+ $.getJSON(dataURL, function (result) {
+
+ if (result.vars.data.length == 0) { // No more data
+ fb('End of data.');
+ allDataLoaded = true;
+
+ } else {
+
+ var elems = [];
+
+ $.each(result.vars.data, function (key, data) {
+
+ fb('loaded page #' + currentPage);
+
+ var res, image;
+
+ res = '<div class="news-image">' + data.image + '</div>';
+ res += '<div class="news-body">';
+ res += '<time class="news-date">' + data.date + '</time>';
+ res += '<h3 class="news-headline">' + data.headline + '</h3>';
+ res += data.content; // MarkupDotClear view helper already wraps content in a div
+
+ // Add the open/close link
+ res += '<a href="#" class="read-more" data-closed="'+ readMoreClosed +'" data-open="'+ readMoreOpen +'">'+ readMoreClosed +'</a>';
+
+ res += '</div>'; // .news-body
+
+ // Add items
+ var elem = document.createElement('article');
+ elem.innerHTML = res;
+ elem.className = 'news-item';
+ elems.push(elem);
+ });
+
+ // Add new items to container and update Masonry
+ $container.append(elems);
+
+ currentPage++;
+
+ if (typeof callback === "function") {
+ callback();
+ }
+ }
+
+ //fb('finished loading');
+ isLoading = false;
+ $('.loader').hide();
+
+ });
+}
\ No newline at end of file
line-height: 1.5;
}
+.content-wrapper {
+ padding-bottom: 20px;
+}
+
.content {
width: 960px;
margin: 0 auto;
--- /dev/null
+body.home {
+
+ .content-wrapper {
+ width: 100%;
+ margin: 0;
+ padding: 0;
+ }
+
+}
\ No newline at end of file
}
li {
- margin-left: 68px;
- &[data-i='0'] {
+ margin-left: 30px;
+ &:first-of-type {
margin-left: 0;
}
}
nav.locale {
font-size: 11px;
font-weight: 300;
- float: right;
+ position: absolute;
+ right: 0;
+ top: 15px;
+ opacity: 1;
+ transition: opacity 0.1s ease-in;
+ backface-visibility: hidden;
+
+ .small & {
+ //display: none;
+ opacity: 0;
+ top: -100%;
+ }
a {
display: inline-block;
- margin: 8px 0 0 5px;
+ margin-left: 5px;
width: 28px;
height: 28px;
line-height: 28px;
text-align: center;
border-radius: 50%;
- background-color: #444;
- color: #999;
+ background-color: #ececec;
+ color: #818181;
text-transform: uppercase;
&:hover, &.active {
--- /dev/null
+.page-heading {
+ margin-bottom: 110px;
+}
+
+.news-item {
+ overflow: hidden;
+ padding-bottom: 55px;
+ border-bottom: 1px solid #dadada;
+ margin-bottom: 55px;
+}
+
+.news-image {
+ float: left;
+ margin-right: 45px;
+ img {
+ border-radius: 100%;
+ }
+}
+
+.news-body {
+ overflow: hidden;
+}
+
+.news-date {
+ font-size: 12px;
+ font-weight: 300;
+}
+
+.news-headline {
+ font-size: 32px;
+ font-weight: 300;
+ margin: 15px 0 25px;
+}
+
+.news-content {
+ overflow: hidden;
+ max-height: 3em; // Line height is 1.5 so 3em = 2 lines visible
+
+ &.open {
+ max-height: none;
+ }
+
+ p {
+ &:first-of-type {
+ padding-top: 0;
+ }
+ }
+}
+
+.read-more {
+ font-size: 16px;
+ font-weight: 600;
+ color: #000;
+ display: block;
+ margin-top: 1em;
+}
+
+
+//--------- Loading Animation ---------//
+// Credit: http://projects.lukehaas.me/css-loaders/
+
+.loader-container {
+ opacity: 0.2;
+ overflow: hidden;
+}
+
+.loader:before,
+.loader:after,
+.loader {
+ border-radius: 50%;
+ width: 2.5em;
+ height: 2.5em;
+ -webkit-animation-fill-mode: both;
+ animation-fill-mode: both;
+ -webkit-animation: load7 1.8s infinite ease-in-out;
+ animation: load7 1.8s infinite ease-in-out;
+}
+.loader {
+ margin: 1em auto 6em auto;
+ font-size: 10px;
+ position: relative;
+ text-indent: -9999em;
+ -webkit-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-animation-delay: -0.16s;
+ animation-delay: -0.16s;
+}
+.loader:before {
+ left: -3.5em;
+ -webkit-animation-delay: -0.32s;
+ animation-delay: -0.32s;
+}
+.loader:after {
+ left: 3.5em;
+}
+.loader:before,
+.loader:after {
+ content: '';
+ position: absolute;
+ top: 0;
+}
+@-webkit-keyframes load7 {
+ 0%,
+ 80%,
+ 100% {
+ box-shadow: 0 2.5em 0 -1.3em #000;
+ }
+ 40% {
+ box-shadow: 0 2.5em 0 0 #000;
+ }
+}
+@keyframes load7 {
+ 0%,
+ 80%,
+ 100% {
+ box-shadow: 0 2.5em 0 -1.3em #000;
+ }
+ 40% {
+ box-shadow: 0 2.5em 0 0 #000;
+ }
+}
\ No newline at end of file