From 72aff57204da88e7030461d00bb5df2eecc2da2c Mon Sep 17 00:00:00 2001 From: "stephen@cubedesigners.com" Date: Wed, 27 May 2020 18:38:17 +0000 Subject: [PATCH] WIP #3641 @6 --- .../controllers/BlogpostController.php | 1 + framework/application/forms/CMS/Blog.php | 4 ++ .../forms/CMS/Element/AuthorSelectList.php | 10 ++++ .../application/forms/CMS/Element/Authors.php | 11 ++++ .../application/forms/CMS/Sub/Authors.php | 39 +++++++++++++ .../application/forms/CMS/Sub/Blog/Post.php | 4 ++ framework/application/models/Author.php | 21 +++++++ framework/application/models/Blog.php | 9 +++ .../application/views/helpers/BlogBody.php | 14 +++++ less/610-blog.less | 57 +++++++++++++++++-- 10 files changed, 166 insertions(+), 4 deletions(-) create mode 100644 framework/application/forms/CMS/Element/AuthorSelectList.php create mode 100644 framework/application/forms/CMS/Element/Authors.php create mode 100644 framework/application/forms/CMS/Sub/Authors.php create mode 100644 framework/application/models/Author.php diff --git a/framework/application/controllers/BlogpostController.php b/framework/application/controllers/BlogpostController.php index 33c34a4..7167883 100644 --- a/framework/application/controllers/BlogpostController.php +++ b/framework/application/controllers/BlogpostController.php @@ -33,6 +33,7 @@ class BlogpostController extends CubeIT_Controller_PageController { $post = $post->unserialize(); $this->view->post = $post->unserialize(); + $this->view->author = $post->getAuthorModel()->unserialize(); $this->view->headTitle($post->getTitle(), 'SET'); } diff --git a/framework/application/forms/CMS/Blog.php b/framework/application/forms/CMS/Blog.php index d1f503e..f80ec67 100644 --- a/framework/application/forms/CMS/Blog.php +++ b/framework/application/forms/CMS/Blog.php @@ -10,5 +10,9 @@ class Fluidbook_Form_CMS_Blog extends Fluidbook_Form_CMS_Base { $blog->setLabel('Blog Posts'); $this->addElement($blog); + $authors = new Fluidbook_Form_CMS_Element_Authors('authors'); + $authors->setLabel('Authors'); + $this->addElement($authors); + } } diff --git a/framework/application/forms/CMS/Element/AuthorSelectList.php b/framework/application/forms/CMS/Element/AuthorSelectList.php new file mode 100644 index 0000000..512b3b7 --- /dev/null +++ b/framework/application/forms/CMS/Element/AuthorSelectList.php @@ -0,0 +1,10 @@ +setBaseForm(new Fluidbook_Form_CMS_Sub_Authors()); + } + +} diff --git a/framework/application/forms/CMS/Element/Authors.php b/framework/application/forms/CMS/Element/Authors.php new file mode 100644 index 0000000..b83c477 --- /dev/null +++ b/framework/application/forms/CMS/Element/Authors.php @@ -0,0 +1,11 @@ +setBaseForm(new Fluidbook_Form_CMS_Sub_Authors()); + $this->clearDecorators(); + } + +} diff --git a/framework/application/forms/CMS/Sub/Authors.php b/framework/application/forms/CMS/Sub/Authors.php new file mode 100644 index 0000000..2365129 --- /dev/null +++ b/framework/application/forms/CMS/Sub/Authors.php @@ -0,0 +1,39 @@ +addElement($id); + + $photo = new CubeIT_Form_Element_File_Image('photo'); + $photo->setLabel(__('Photo')); + $photo->setMaxItems(1); + $this->addElement($photo); + + $name = new CubeIT_Form_Element_Text('name'); + $name->setLabel(__('Author Name')); + $this->addElement($name); + + $email = new CubeIT_Form_Element_Text('email'); + $email->setLabel(__('E-mail address')); + $this->addElement($email); + + $bio = new CubeIT_Form_Element_Markitup('bio'); + $bio->setLabel(__('Author Bio')); + $this->addElementLocalized($bio, $compact_translations); + + $this->setListTitle(__('Authors')); + $this->setNewTitle(__('New Author')); + $this->setEditTitle(__('Editing author « $name »')); + $this->setModel('Fluidbook_Model_Author'); + $this->setTitleColumn('name'); + $this->setAdditionnalColumns(['email']); + + } +} diff --git a/framework/application/forms/CMS/Sub/Blog/Post.php b/framework/application/forms/CMS/Sub/Blog/Post.php index b86e46d..9c33fbd 100644 --- a/framework/application/forms/CMS/Sub/Blog/Post.php +++ b/framework/application/forms/CMS/Sub/Blog/Post.php @@ -22,6 +22,10 @@ class Fluidbook_Form_CMS_Sub_Blog_Post extends CubeIT_Form_List_Model $date->setLabel(__('Publish Date')); $this->addElement($date); + $author = new Fluidbook_Form_CMS_Element_AuthorSelectList('author_id'); + $author->setLabel('Author'); + $this->addElement($author); + $title = new CubeIT_Form_Element_Text('title'); $title->setLabel(__('Post Title')); $this->addElementLocalized($title, $compact_translations); diff --git a/framework/application/models/Author.php b/framework/application/models/Author.php new file mode 100644 index 0000000..1352b18 --- /dev/null +++ b/framework/application/models/Author.php @@ -0,0 +1,21 @@ +addColumn('name', 'string', ['length' => 255]); + $table->addColumn('email', 'string', ['length' => 255]); + $table->addColumn('bio', 'text'); + $table->addColumn('photo', 'string', ['length' => 255]); + return $table; + } + +} diff --git a/framework/application/models/Blog.php b/framework/application/models/Blog.php index 746128f..2ad82a9 100644 --- a/framework/application/models/Blog.php +++ b/framework/application/models/Blog.php @@ -34,4 +34,13 @@ class Fluidbook_Model_Blog extends CubeIT_Model_Data_Table return $table; } + public function getAuthorModel() { + $authorID = $this->getAuthorId(); + if ($authorID == 0) + return null; + + $author = Fluidbook_Model_Author::factory()->where('id = ?', $authorID)->find(); + return reset($author); + } + } diff --git a/framework/application/views/helpers/BlogBody.php b/framework/application/views/helpers/BlogBody.php index b58f30c..6dcdb08 100644 --- a/framework/application/views/helpers/BlogBody.php +++ b/framework/application/views/helpers/BlogBody.php @@ -24,6 +24,20 @@ class Fluidbook_View_Helper_BlogBody extends CubeIT_View_Helper_Abstract { $res .= ''; // .block-$content->content_type } + // Author details + $photo = $this->imageProcess()->imageProcessGetUrl($this->author->getPhoto(), null, 120, 120); + $res .= '
'; + $res .= '
'; + $res .= '
'; + $res .= '

'. $this->author->getName() .'

'; + $res .= '

'. $this->author->getBio() .'

'; + $res .= $this->linkEmail($this->author->getEmail(), null, ['class' => 'blog-author-email', 'itemprop' => 'email']); + $res .= '
'; // .blog-author-details +// $res .= '
';
+//        $res .= print_r($this->author, true);
+//        $res .= '
'; + $res .= '
'; // .blog-author + $res .= ''; // .blog-post-body $res .= ''; // .content-wrapper diff --git a/less/610-blog.less b/less/610-blog.less index 43e1f2c..2d7f6f2 100644 --- a/less/610-blog.less +++ b/less/610-blog.less @@ -44,6 +44,7 @@ &:after { background-color: currentColor !important; + bottom: 0.7em !important; } a { @@ -59,6 +60,7 @@ &-excerpt { font-size: 15px; line-height: 1.7; + max-width: 550px; } .picture { @@ -71,18 +73,65 @@ .blog-post-body { - max-width: 1008px; margin: 0 auto; font-size: 24px; line-height: 1.67; + max-width: 1008px; + width: 100%; > * + * { margin-top: 1.5em; } - img { - max-width: 100%; - height: auto; + .image { + + // Super-sized images that break out of the content column when + // there is space but never go beyond 90% width. On smaller screens, + // they scale down normally within the content column... + &-xl { + position: relative; + left: 50%; + transform: translateX(-50%); + width: 1512px; // 90% of 1680px + max-width: 90vw; + } + + img { + display: block; + max-width: 100%; + height: auto; + margin: 0 auto; + } + + figcaption { + font-size: 15px; + text-align: center; + margin-top: 1.5em; + } + } + +} + +.blog-author { + display: flex; + align-items: center; + background-color: #f3f3f3; + margin-top: 50px; + padding: 1.5em; + font-size: 15px; + + &-photo { + width: 120px; + height: 120px; + background-size: cover; + background-position: center; + background-repeat: no-repeat; + border-radius: 50%; + margin-right: 1.5em; } + &-name { + font-family: @heading-font; + font-size: 30px; + } } -- 2.39.5