$templates['landingcampaign'] = 'Landing Campagne (Intro + formulaire)';
$templates['agences'] = 'Agences';
$templates['faq'] = 'FAQ';
+ $templates['blog'] = 'Blog';
$templates = array_merge($templates, parent::getCMSTemplates());
return $templates;
}
- public function _initRouter($initCms = true, $standard = true) {
+ protected function _makeNavigationOnePage(&$navigation, $r, $t, $isAdmin, $locale = false) {
+ $page = parent::_makeNavigationOnePage($navigation, $r, $t, $isAdmin, $locale);
+
+ if (!$page) return;
+
+ if ($page->getTemplate() === 'blog') {
+ $this->addBlogPages($page, $locale, $isAdmin);
+ }
+ }
+
+ // URL template used for blog pages
+ public static function getBlogPostURLTemplate() {
+ return '/blog/%title%'; // Important: must have leading slash or pages will show as not found!
+ }
+
+ /* @param CubeIT_Navigation_Page_Locale $page */
+ protected function addBlogPages($page, $locale, $isAdmin) {
+ //$datas = $this->getCMSDatasOfNavigationPage($page);
+
+ // How the URLs should be formed for the news articles
+ $URL_template = self::getBlogPostURLTemplate();
+
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $s = $db->select()->from('blog')
+ ->order('id ASC');
+ $q = $s->query();
+
+ while ($r = $q->fetch()) {
+
+ $online = true;
+ $pageTitle = $r->title;
+
+ $p = new CubeIT_Navigation_Page_Locale();
+ $p->setController('Blogpost');
+ $p->setId('blog/' . $r->id);
+ $p->setAutoUri($r, $URL_template);
+ $p->setSitemap($online);
+ $p->setTitle($pageTitle);
+ $p->setEditable(false);
+ $p->setParams(['post_id' => $r->id]);
+ $p->setOnline($online);
+ $p->setDomain($page->getDomain());
+ $p->setLabel($pageTitle);
+ $page->addPage($p);
+ }
+ }
+
+
+ public function _initRouter($initCms = true, $standard = true) {
profile(__FILE__, __LINE__, 'Init Router');
$router = parent::_initRouter($initCms, $standard);
$router->addStaticRoute('15000', 'landing', 'quinzemille');
--- /dev/null
+<?php
+
+class BlogpostController extends CubeIT_Controller_PageController {
+
+ public function indexAction() {
+
+ $this->view->headScript()->addScriptAndStyle('blog-post');
+
+ //$parent = $this->view->currentPage->getParent();
+ //$parent_data = $this->getBootstrap()->getCMSDatasOfNavigationPage($parent);
+ //$this->view->datas = $parent_data;
+
+
+ $model = Fluidbook_Model_Blog::factory()
+ ->order('publish_date DESC')
+ ->where('id = ?', $this->getRequest()
+ ->getParam('post_id'));
+ $post = $model->find();
+
+ if (count($post) < 1) {
+ $this->_404();
+ return;
+ }
+
+ // Get the first and only array item
+ $post = reset($post);
+
+ $this->view->post = $post;
+ $this->view->headTitle($post->getTitle(), 'SET');
+ }
+
+}
--- /dev/null
+<?php\r
+\r
+class Fluidbook_Form_CMS_Blog extends Fluidbook_Form_CMS_Base {\r
+ public function init() {\r
+ parent::init();\r
+\r
+ $blog = new Fluidbook_Form_CMS_Element_BlogPosts('blog_posts');\r
+ $blog->setLabel('Blog Posts');\r
+ $this->addElement($blog);\r
+\r
+ }\r
+}\r
--- /dev/null
+<?php
+
+class Fluidbook_Form_CMS_Element_BlogPosts extends CubeIT_Form_Element_List {
+ public function init() {
+ parent::init();
+
+ $this->setBaseForm(new Fluidbook_Form_CMS_Sub_Blog_Post());
+ $this->clearDecorators();
+ }
+
+}
--- /dev/null
+<?php
+
+class Fluidbook_Form_CMS_Sub_Blog_Post extends CubeIT_Form_List_Model
+{
+
+ public function init() {
+ parent::init();
+
+ $id = new CubeIT_Form_Element_Id();
+ $this->addElement($id);
+
+ $online = new Zend_Form_Element_Checkbox('online');
+ $online->setLabel(__('Published?'));
+ $this->addElement($online);
+
+ $date = new CubeIT_Form_Element_Date('publish_date');
+ $date->setPrecision(Zend_Date::MINUTE);
+ $date->setMinYear('-5');
+ $date->setMaxYear('+1');
+ $date->setLabel(__('Publish Date'));
+ $this->addElement($date);
+
+ $title = new CubeIT_Form_Element_Text('title');
+ $title->setLabel(__('Post Title'));
+ $this->addElement($title);
+
+ $excerpt = new CubeIT_Form_Element_Markitup('excerpt');
+ $excerpt->setLabel(__('Excerpt'));
+ $this->addElement($excerpt);
+
+ $thumbnail = new CubeIT_Form_Element_File_Image('thumbnail');
+ $thumbnail->setLabel(__('Post Thumbnail'));
+ $this->addElement($thumbnail);
+
+ // TODO add content blocks (text + images) based on Cubedesigners case studies content. Also add author reference.
+
+ $this->setListTitle(__('Blog Posts'));
+ $this->setNewTitle(__('New Post'));
+ $this->setEditTitle(__('Edition du post « $title »'));
+ $this->setModel('Fluidbook_Model_Blog');
+ $this->setTitleColumn('title');
+ $this->setAdditionnalColumns(['publish_date', 'online']);
+
+
+ }
+}
if ($this->acl()->isAllowed('edition')) {
$this->headScript()->addCommonsAdmin();
+ $this->headScript()->addScriptAndStyle('010-admin');
}
$this->headMeta()->setViewport('device-width');
--- /dev/null
+<?php\r
+\r
+class Fluidbook_Model_Blog extends CubeIT_Model_Data_Table\r
+{\r
+ protected static $_table = 'blog';\r
+\r
+ protected $title;\r
+ protected $excerpt;\r
+ protected $thumbnail;\r
+ protected $content;\r
+ protected $publish_date;\r
+ protected $author_id;\r
+ protected $online;\r
+\r
+ protected $_types = [\r
+ 'publish_date' => 'date',\r
+ ];\r
+\r
+ public static function getSchema($schema) {\r
+ $table = parent::getSchema($schema);\r
+ $table->addColumn('title', 'string', ['length' => 255]);\r
+ $table->addColumn('excerpt', 'text');\r
+ $table->addColumn('thumbnail', 'text');\r
+ $table->addColumn('content', 'text');\r
+ $table->addColumn('publish_date', 'datetime');\r
+ $table->addColumn('author_id', 'integer', ['unsigned' => true]);\r
+ $table->addColumn('online', 'boolean', ['default' => 1]);\r
+ return $table;\r
+ }\r
+\r
+}\r
--- /dev/null
+<?php\r
+\r
+class Fluidbook_View_Helper_BlogIndex extends CubeIT_View_Helper_Abstract {\r
+ /**\r
+ * @return string\r
+ */\r
+ public function blogIndex() {\r
+\r
+ $posts = Fluidbook_Model_Blog::factory()->order('publish_date DESC')->find();\r
+\r
+ $res = '';\r
+\r
+ foreach ($posts as $post) {\r
+ $res .= $this->post($post);\r
+ }\r
+\r
+ return $this->htmlElement($res, 'div', ['class' => 'blog-index']);\r
+ }\r
+\r
+ protected function post($post) {\r
+\r
+ $URL = CubeIT_Navigation_Page::generateAutoUri($post, Bootstrap::getBlogPostURLTemplate());\r
+\r
+ $img = $post->getThumbnail(247, 247, 'blog-featured-image');\r
+\r
+ if (!$img) {\r
+ $img = '<div class="blog-featured-image blog-featured-image-empty"></div>';\r
+ }\r
+\r
+ $res = $this->link($img, $URL);\r
+ $res .= $this->dateTime($post->getPublishDate(), CubeIT_Date::DAY . '/' . CubeIT_Date::MONTH . '/' . CubeIT_Date::YEAR);\r
+ $res .= $this->link($this->htmlElement($post->getTitle(), 'h2'), $URL, ['class' => 'news-heading-link']);\r
+ $res .= '<div class="acc">';\r
+ $res .= $this->markupDotclear($post->getExcerpt());\r
+ $res .= '</div>';\r
+ $res .= $this->link(__('Lire la suite'), $URL, ['class' => 'read-more']);\r
+ return $this->htmlElement($res, 'article');\r
+ }\r
+}\r
$this->headLink()->appendStylesheet('/less/010-admin.less', 'all');\r
echo '<div id="message"></div>';\r
echo $this->form;\r
-echo '</div>';
\ No newline at end of file
+echo '</div>';\r
--- /dev/null
+<?php // TODO: blog post detail view ?>
+<pre>
+ <?php print_r($this->post); ?>
+</pre>
--- /dev/null
+<?php
+
+$this->headScript()->addScriptAndStyle('610-blog');
+
+echo $this->introBlock($this->intro, '');
+echo $this->blogIndex();
+echo $this->contactFooter();
+// Todo: adapt code from cubedesigners-v6/js/admin.js to have the custom multi-subform with different fields shown / hidden depending on the option selected