From 623e2bde65d54f230fc009e7edfe6316023cbdf7 Mon Sep 17 00:00:00 2001 From: "stephen@cubedesigners.com" Date: Mon, 18 May 2020 15:56:03 +0000 Subject: [PATCH] WIP #3641 @5.5 --- framework/application/Bootstrap.php | 6 +++--- .../forms/CMS/Sub/Blog/ContentBlock.php | 16 +++++++++------- framework/application/models/Blog.php | 14 ++++++++++++++ .../application/views/helpers/BlogIndex.php | 6 +----- .../views/scripts/blogpost/index.phtml | 2 +- .../views/scripts/templates/blog.phtml | 3 +-- js/010-admin.js | 2 +- less/010-admin.less | 6 +++--- 8 files changed, 33 insertions(+), 22 deletions(-) diff --git a/framework/application/Bootstrap.php b/framework/application/Bootstrap.php index d826599..7215eae 100644 --- a/framework/application/Bootstrap.php +++ b/framework/application/Bootstrap.php @@ -40,7 +40,7 @@ class Bootstrap extends CubeIT_Bootstrap { // 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! + return 'blog/%title%'; } /* @param CubeIT_Navigation_Page_Locale $page */ @@ -67,8 +67,8 @@ class Bootstrap extends CubeIT_Bootstrap { $p = new CubeIT_Navigation_Page_Locale(); $p->setController('Blogpost'); - $p->setId('blog/' . $r->id); - $p->setAutoUri($r, $URL_template); + $p->setId($locale .'/blog/'. $r->id); + $p->setAutoUri($r, $URL_template, $locale); $p->setSitemap($online); $p->setTitle($pageTitle); $p->setEditable(false); diff --git a/framework/application/forms/CMS/Sub/Blog/ContentBlock.php b/framework/application/forms/CMS/Sub/Blog/ContentBlock.php index 50d5a53..d7b7ee8 100644 --- a/framework/application/forms/CMS/Sub/Blog/ContentBlock.php +++ b/framework/application/forms/CMS/Sub/Blog/ContentBlock.php @@ -9,22 +9,18 @@ class Fluidbook_Form_CMS_Sub_Blog_ContentBlock extends CubeIT_Form_SubForm { $select = new Zend_Form_Element_Select('content_type'); $select->setAttrib('data-name', 'content-type') + ->setLabel('Content Type') ->setMultiOptions([ 'text' => 'Text Block', 'image' => 'Image', ]); $this->addElement($select); - $text = new CubeIT_Form_Element_Markitup_Basic('text'); + $text = new CubeIT_Form_Element_Markitup('text'); $text->setLabel('Text Block') ->setAttrib('data-type', 'text'); // Shown when "text" content type is selected $this->addElementLocalized($text, $compact_translations); - $image = new CubeIT_Form_Element_File_Image('image'); - $image->setLabel('Image') - ->setMaxItems(1) - ->setAttrib('data-type', 'image'); // Shown when "image" content type is selected - $this->addElementLocalized($image, $compact_translations); $image_style = new Zend_Form_Element_Select('image_style'); $image_style->setLabel('Image Style') @@ -33,7 +29,13 @@ class Fluidbook_Form_CMS_Sub_Blog_ContentBlock extends CubeIT_Form_SubForm { '' => 'Normal', 'xl' => 'Extra Large', ]); - $this->addElementLocalized($image_style, $compact_translations); + $this->addElement($image_style); + + $image = new CubeIT_Form_Element_File_Image('image'); + $image->setLabel('Image') + ->setMaxItems(1) + ->setAttrib('data-type', 'image'); // Shown when "image" content type is selected + $this->addElementLocalized($image, $compact_translations); } } diff --git a/framework/application/models/Blog.php b/framework/application/models/Blog.php index 5971fb8..3c49dc9 100644 --- a/framework/application/models/Blog.php +++ b/framework/application/models/Blog.php @@ -28,4 +28,18 @@ 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 203100e..5ab92de 100644 --- a/framework/application/views/helpers/BlogIndex.php +++ b/framework/application/views/helpers/BlogIndex.php @@ -22,11 +22,7 @@ class Fluidbook_View_Helper_BlogIndex extends CubeIT_View_Helper_Abstract { $URL = CubeIT_Navigation_Page::generateAutoUri($post, Bootstrap::getBlogPostURLTemplate()); - $img = $post->getThumbnail(247, 247, 'blog-featured-image'); - - if (!$img) { - $img = ''; - } + $img = $post->getThumbnailHTML(247, 247, 'blog-featured-image'); $res = $this->link($img, $URL); $res .= $this->dateTime($post->getPublishDate(), CubeIT_Date::DAY . '/' . CubeIT_Date::MONTH . '/' . CubeIT_Date::YEAR); diff --git a/framework/application/views/scripts/blogpost/index.phtml b/framework/application/views/scripts/blogpost/index.phtml index 4b9cb78..f6c5470 100644 --- a/framework/application/views/scripts/blogpost/index.phtml +++ b/framework/application/views/scripts/blogpost/index.phtml @@ -1,4 +1,4 @@ -
+
     post); ?>
 
diff --git a/framework/application/views/scripts/templates/blog.phtml b/framework/application/views/scripts/templates/blog.phtml index 26853e9..d2110f7 100644 --- a/framework/application/views/scripts/templates/blog.phtml +++ b/framework/application/views/scripts/templates/blog.phtml @@ -2,6 +2,5 @@ $this->headScript()->addScriptAndStyle('610-blog'); -echo $this->introBlock($this->intro, ''); -echo $this->blogIndex(); +echo $this->introBlock($this->intro, $this->blogIndex()); echo $this->contactFooter(); diff --git a/js/010-admin.js b/js/010-admin.js index 2dee9c4..d6fe8f4 100644 --- a/js/010-admin.js +++ b/js/010-admin.js @@ -39,6 +39,6 @@ function getFieldWrapper(field) { if (field.parents('.localized').length > 0) { return field.parents('.localized').parent(); } else { - return field.parents('.elementwrap').parent(); + return field.parents('.elementwrap'); } } diff --git a/less/010-admin.less b/less/010-admin.less index 3099aa9..c544f44 100644 --- a/less/010-admin.less +++ b/less/010-admin.less @@ -9,9 +9,9 @@ width: 100%; padding:5px 5%; .bar { - color: #5c6268; + color: #999; a.right{ - color:#c00; + color: #f70; } } @@ -27,4 +27,4 @@ #contentWrapper .cubeit-content{ padding-top:120px; -} \ No newline at end of file +} -- 2.39.5