From 03a76032840446734c271f2187d1e95470b6147f Mon Sep 17 00:00:00 2001 From: "stephen@cubedesigners.com" Date: Wed, 20 May 2020 17:16:21 +0000 Subject: [PATCH] WIP #3641 @7 --- .../controllers/AdminajaxController.php | 9 ++++++ framework/application/forms/CMS/Blog.php | 2 ++ .../forms/CMS/Sub/Blog/ContentBlock.php | 5 ++++ .../application/forms/CMS/Sub/Blog/Post.php | 28 +++++++++++++++---- framework/application/models/Blog.php | 24 ++++++---------- .../application/views/helpers/BlogIndex.php | 5 ++-- .../views/scripts/templates/blog.phtml | 2 +- 7 files changed, 51 insertions(+), 24 deletions(-) diff --git a/framework/application/controllers/AdminajaxController.php b/framework/application/controllers/AdminajaxController.php index 6998418..baac212 100644 --- a/framework/application/controllers/AdminajaxController.php +++ b/framework/application/controllers/AdminajaxController.php @@ -2,6 +2,15 @@ class AdminajaxController extends CubeIT_Controller_Admin_AdminajaxController { + // Make sure navigation URLs are updated when saving blog articles + public function saveselectlist($class, $element, $dataFilters, $reloadOnSave = false) { + + $this->clearCacheTag('navigation'); + $this->clearCacheTag('contents'); + + return parent::saveselectlist($class, $element, $dataFilters, $reloadOnSave); + } + } ?> diff --git a/framework/application/forms/CMS/Blog.php b/framework/application/forms/CMS/Blog.php index 8e1ddeb..d1f503e 100644 --- a/framework/application/forms/CMS/Blog.php +++ b/framework/application/forms/CMS/Blog.php @@ -4,6 +4,8 @@ class Fluidbook_Form_CMS_Blog extends Fluidbook_Form_CMS_Base { public function init() { parent::init(); + $this->removeSubForm('intro'); + $blog = new Fluidbook_Form_CMS_Element_BlogPosts('blog_posts'); $blog->setLabel('Blog Posts'); $this->addElement($blog); diff --git a/framework/application/forms/CMS/Sub/Blog/ContentBlock.php b/framework/application/forms/CMS/Sub/Blog/ContentBlock.php index d7b7ee8..c65b556 100644 --- a/framework/application/forms/CMS/Sub/Blog/ContentBlock.php +++ b/framework/application/forms/CMS/Sub/Blog/ContentBlock.php @@ -37,5 +37,10 @@ class Fluidbook_Form_CMS_Sub_Blog_ContentBlock extends CubeIT_Form_SubForm { ->setAttrib('data-type', 'image'); // Shown when "image" content type is selected $this->addElementLocalized($image, $compact_translations); + $image_caption = new Zend_Form_Element_Text('image_caption'); + $image_caption->setLabel('Image caption') + ->setAttrib('data-type', 'image'); + $this->addElementLocalized($image_caption, $compact_translations); + } } diff --git a/framework/application/forms/CMS/Sub/Blog/Post.php b/framework/application/forms/CMS/Sub/Blog/Post.php index 34ccdc5..db33459 100644 --- a/framework/application/forms/CMS/Sub/Blog/Post.php +++ b/framework/application/forms/CMS/Sub/Blog/Post.php @@ -27,13 +27,31 @@ class Fluidbook_Form_CMS_Sub_Blog_Post extends CubeIT_Form_List_Model $this->addElementLocalized($title, $compact_translations); $excerpt = new CubeIT_Form_Element_Markitup('excerpt'); - $excerpt->setLabel(__('Excerpt')); + $excerpt->setLabel(__('Intro Excerpt')); $this->addElementLocalized($excerpt, $compact_translations); - $thumbnail = new CubeIT_Form_Element_File_Image('thumbnail'); - $thumbnail->setLabel(__('Post Thumbnail')); - $thumbnail->setMaxItems(1); - $this->addElement($thumbnail); + $intro_image = new CubeIT_Form_Element_File_Image('intro_image'); + $intro_image->setLabel(__('Intro Image')); + $intro_image->setMaxItems(1); + $this->addElement($intro_image); + + $intro_text_color = new Zend_Form_Element_Select('intro_text_color'); + $intro_text_color->setLabel('Intro Text Colour') + ->setMultiOptions([ + 'light' => 'Light', + 'dark' => 'Dark', + ]); + $this->addElement($intro_text_color); + + $intro_gradient_start = new CubeIT_Form_Element_Color('intro_gradient_start'); + $intro_gradient_start->setLabel('Intro Gradient Start') + ->setValue('#0e1f31'); + $this->addElement($intro_gradient_start); + + $intro_gradient_end = new CubeIT_Form_Element_Color('intro_gradient_end'); + $intro_gradient_end->setLabel('Intro Gradient End') + ->setValue('#2f5377'); + $this->addElement($intro_gradient_end); $content = new Fluidbook_Form_CMS_Sub_Blog_ContentBlocks(); $content->setLegend('Content Blocks'); diff --git a/framework/application/models/Blog.php b/framework/application/models/Blog.php index 3c49dc9..72771b6 100644 --- a/framework/application/models/Blog.php +++ b/framework/application/models/Blog.php @@ -6,7 +6,10 @@ class Fluidbook_Model_Blog extends CubeIT_Model_Data_Table protected $title; protected $excerpt; - protected $thumbnail; + protected $intro_image; + protected $intro_gradient_start; + protected $intro_gradient_end; + protected $intro_text_color; protected $content; protected $publish_date; protected $author_id; @@ -20,7 +23,10 @@ class Fluidbook_Model_Blog extends CubeIT_Model_Data_Table $table = parent::getSchema($schema); $table->addColumn('title', 'string', ['length' => 255]); $table->addColumn('excerpt', 'text'); - $table->addColumn('thumbnail', 'text'); + $table->addColumn('intro_image', 'text'); + $table->addColumn('intro_gradient_start', 'string', ['length' => 7]); // Hex code + $table->addColumn('intro_gradient_end', 'string', ['length' => 7]); // Hex code + $table->addColumn('intro_text_color', 'string', ['length' => 7]); // light|dark $table->addColumn('content', 'text'); $table->addColumn('publish_date', 'datetime'); $table->addColumn('author_id', 'integer', ['unsigned' => true]); @@ -28,18 +34,4 @@ class Fluidbook_Model_Blog extends CubeIT_Model_Data_Table return $table; } - public function getThumbnailHTML($width, $height, $class) { - - $this->view = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer')->view; - - $img = $this->view->imageProcess($this->getThumbnail(), '', $width, $height, ['class' => $class]); - - // Fallback to other uploaded images if no thumbnail is set - if (!$img) { - $img = ''; - } - - return $img; - } - } diff --git a/framework/application/views/helpers/BlogIndex.php b/framework/application/views/helpers/BlogIndex.php index 5ab92de..4366e46 100644 --- a/framework/application/views/helpers/BlogIndex.php +++ b/framework/application/views/helpers/BlogIndex.php @@ -22,10 +22,11 @@ class Fluidbook_View_Helper_BlogIndex extends CubeIT_View_Helper_Abstract { $URL = CubeIT_Navigation_Page::generateAutoUri($post, Bootstrap::getBlogPostURLTemplate()); - $img = $post->getThumbnailHTML(247, 247, 'blog-featured-image'); + $img = $this->view->imageCms($post->getIntroImage(), $post->getTitle(), null, null, ['class' => 'blog-hero-image']); $res = $this->link($img, $URL); - $res .= $this->dateTime($post->getPublishDate(), CubeIT_Date::DAY . '/' . CubeIT_Date::MONTH . '/' . CubeIT_Date::YEAR); + $res .= '
'; + $res .= $this->dateTime($post->getPublishDate(), CubeIT_Date::DAY .' '. CubeIT_Date::MONTH_NAME .' '. CubeIT_Date::YEAR); $res .= $this->link($this->htmlElement($post->getTitle(), 'h2'), $URL, ['class' => 'news-heading-link']); $res .= '
'; $res .= $this->markupDotclear($post->getExcerpt()); diff --git a/framework/application/views/scripts/templates/blog.phtml b/framework/application/views/scripts/templates/blog.phtml index d2110f7..93cf234 100644 --- a/framework/application/views/scripts/templates/blog.phtml +++ b/framework/application/views/scripts/templates/blog.phtml @@ -2,5 +2,5 @@ $this->headScript()->addScriptAndStyle('610-blog'); -echo $this->introBlock($this->intro, $this->blogIndex()); +echo $this->blogIndex(); echo $this->contactFooter(); -- 2.39.5