diff --git a/CHANGELOG.md b/CHANGELOG.md index d1cf28ec5..c0022eefa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,9 @@ Full changelog for Dlayer since the v1.00 release. * Added shortcut buttons to Column, Row and Page tools. [UX] * The column contains content query only looks at enabled content. [Bugfix] * Added a toggle ribbon button to the right side of the control bar, it expands the ribbon to open up the form. [UX] +* Control bar padding left and right set to 15px, was 0. [Bugfix] +* Added a rich text content item to the Content Manager (disabled until I add a renderer for quill). [Disabled Feature] * Refactoring. -* Control bar padding left and right set to 15px, was 0. [Bugfix] * Minor fixes and improvements. ## v1.13: 18th February 2017 diff --git a/application/configs/environment.php b/application/configs/environment.php index bbda11de2..6fb3a154f 100644 --- a/application/configs/environment.php +++ b/application/configs/environment.php @@ -16,4 +16,4 @@ // Version number for current release $version_no = 'v1.14'; // Release date for current release -$version_release_date = 'In Progress'; +$version_release_date = '23rd February 2017'; diff --git a/application/modules/dlayer/views/scripts/index/index.phtml b/application/modules/dlayer/views/scripts/index/index.phtml index 3db3a77f3..d21cac5d9 100644 --- a/application/modules/dlayer/views/scripts/index/index.phtml +++ b/application/modules/dlayer/views/scripts/index/index.phtml @@ -42,6 +42,7 @@
  • Added shortcut buttons to Column, Row and Page tools. [UX]
  • The column contains content query only looks at enabled content. [Bugfix]
  • Control bar padding left and right set to 15px, was 0. [Bugfix]
  • +
  • Added a rich text content item to the Content Manager (disabled until I add a renderer for quill). [Disabled Feature]
  • Refactoring.
  • Minor fixes and improvements.
  • diff --git a/application/modules/setup/models/Import.php b/application/modules/setup/models/Import.php index 7e310e3d0..5b95856e8 100644 --- a/application/modules/setup/models/Import.php +++ b/application/modules/setup/models/Import.php @@ -44,6 +44,7 @@ class Setup_Model_Import extends Zend_Db_Table_Abstract 'user_site_content_html', 'user_site_content_jumbotron', 'user_site_content_text', + 'user_site_content_richtext', 'user_site_form', 'user_site_form_field', 'user_site_form_field_attribute', @@ -64,6 +65,7 @@ class Setup_Model_Import extends Zend_Db_Table_Abstract 'user_site_page_content_item_html', 'user_site_page_content_item_image', 'user_site_page_content_item_jumbotron', + 'user_site_page_content_item_richtext', 'user_site_page_content_item_text', 'user_site_page_meta', 'user_site_page_structure_column', diff --git a/application/views/layouts/content-manager.phtml b/application/views/layouts/content-manager.phtml index 8f9038c34..2340db85d 100644 --- a/application/views/layouts/content-manager.phtml +++ b/application/views/layouts/content-manager.phtml @@ -26,10 +26,13 @@ layout()->js_include as $include) { ?> + + + layout()->css_include as $include) { ?> - diff --git a/library/Dlayer/DesignerTool/ContentManager/Shared/Model/Content.php b/library/Dlayer/DesignerTool/ContentManager/Shared/Model/Content.php index 719e3bcf3..52d1c8b3b 100644 --- a/library/Dlayer/DesignerTool/ContentManager/Shared/Model/Content.php +++ b/library/Dlayer/DesignerTool/ContentManager/Shared/Model/Content.php @@ -239,6 +239,10 @@ protected function contentItemTable($content_type) $table = 'user_site_page_content_item_text'; break; + case 'rich-text': + $table = 'user_site_page_content_item_richtext'; + break; + case 'html': $table = 'user_site_page_content_item_html'; break; @@ -278,6 +282,10 @@ protected function contentItemDataTable($content_type) $table = 'user_site_content_text'; break; + case 'rich-text': + $table = 'user_site_content_richtext'; + break; + case 'html': $table = 'user_site_content_html'; break; diff --git a/library/Dlayer/Form/Element/Quill.php b/library/Dlayer/Form/Element/Quill.php new file mode 100644 index 000000000..7e9489643 --- /dev/null +++ b/library/Dlayer/Form/Element/Quill.php @@ -0,0 +1,17 @@ +html($row['content_id']); break; + case 'rich-text': + $content_item = $this->richText($row['content_id']); + break; + default: $content_item = false; break; @@ -347,4 +351,18 @@ private function form($id) return $model_form->data($this->site_id, $this->page_id, $id); } + + /** + * Fetch all the data for a 'rich-text' content item + * + * @param integer $id Id of the content item + * + * @return array|false Either an array of the data for the content item or false upon error + */ + private function richText($id) + { + $model = new Dlayer_Model_View_Page_Content_RichText(); + + return $model->data($this->site_id, $this->page_id, $id); + } } diff --git a/library/Dlayer/Model/View/Page/Content/RichText.php b/library/Dlayer/Model/View/Page/Content/RichText.php new file mode 100644 index 000000000..161141ddc --- /dev/null +++ b/library/Dlayer/Model/View/Page/Content/RichText.php @@ -0,0 +1,45 @@ + + * @copyright G3D Development Limited + * @license https://github.com/Dlayer/dlayer/blob/master/LICENSE + */ +class Dlayer_Model_View_Page_Content_RichText extends Zend_Db_Table_Abstract +{ + /** + * Fetch the core data needed to create a 'html'snippet + * + * @param integer $site_id + * @param integer $page_id + * @param integer $id Id of the content item + * + * @return array|false Either the content item data array or FALSE upon error + */ + public function data($site_id, $page_id, $id) + { + $sql = "SELECT + `uspcirt`.`content_id`, + `uscrt`.`content` + FROM + `user_site_page_content_item_richtext` `uspcirt` + INNER JOIN + `user_site_content_richtext` `uscrt` ON + `uspcirt`.`data_id` = uscrt.id AND + `uscrt`.`site_id` = :site_id + WHERE + `uspcirt`.`content_id` = :content_id AND + `uspcirt`.`site_id` = :site_id AND + `uspcirt`.`page_id` = :page_id"; + $stmt = $this->_db->prepare($sql); + $stmt->bindValue(':site_id', $site_id, PDO::PARAM_INT); + $stmt->bindValue(':page_id', $page_id, PDO::PARAM_INT); + $stmt->bindValue(':content_id', $id, PDO::PARAM_INT); + $stmt->execute(); + + return $stmt->fetch(); + } +} diff --git a/library/Dlayer/Ribbon/Handler/Content.php b/library/Dlayer/Ribbon/Handler/Content.php index 7d8961f4e..fd32ea79d 100644 --- a/library/Dlayer/Ribbon/Handler/Content.php +++ b/library/Dlayer/Ribbon/Handler/Content.php @@ -57,11 +57,11 @@ class Dlayer_Ribbon_Handler_Content * @param string $tab * @param integer $multi_use * @param boolean $edit_mode - * @param integer|NULL $row_id - * @param integer|NULL $column_id - * @param integer|NULL $content_id + * @param integer|null $row_id + * @param integer|null $column_id + * @param integer|null $content_id * - * @return array|FALSE Returns an array of the data necessary to create the tool tab for the tool or FALSE if + * @return array|false Returns an array of the data necessary to create the tool tab for the tool or FALSE if * there is no data or something went wrong */ public function viewData( @@ -132,6 +132,10 @@ public function viewData( $data = $this->text($tool, $tab); break; + case 'RichText': + $data = $this->richText($tool, $tab); + break; + default: $data = false; break; @@ -567,4 +571,29 @@ private function headingDate($tool, $tab) return $data; } + + /** + * Fetch the view tab data for the Rich text tool, returns an array containing the form and the data for + * the tool + * + * @param string $tool The tool name + * @param string $tab The tool tab name + * + * @return array|false + */ + private function richText($tool, $tab) + { + switch ($tab) { + case 'rich-text': + $ribbon_rich_text = new Dlayer_DesignerTool_ContentManager_RichText_Ribbon(); + $data = $ribbon_rich_text->viewData($this->toolParams($tool)); + break; + + default: + $data = false; + break; + } + + return $data; + } } diff --git a/library/Dlayer/View/Codehinting.php b/library/Dlayer/View/Codehinting.php index ae90f6542..1dd148fee 100644 --- a/library/Dlayer/View/Codehinting.php +++ b/library/Dlayer/View/Codehinting.php @@ -471,4 +471,27 @@ public function htmlPreview(array $data) public function trimToLength($string, $length = 50) { } + + /** + * Rich text content item view helper + * + * @param array $data Content item data array + * @param boolean $selectable + * @param boolean $selected + * + * @return Dlayer_View_RichText + */ + public function richText(array $data, $selectable = false, $selected = false) + { + } + + /** + * Preview version of the rich text content item view helper + * + * @param array $data Content item data array + * @return Dlayer_View_RichTextPreview + */ + public function richTextPreview(array $data) + { + } } diff --git a/library/Dlayer/View/Content.php b/library/Dlayer/View/Content.php index 1b8b6e96c..1ff4c1753 100644 --- a/library/Dlayer/View/Content.php +++ b/library/Dlayer/View/Content.php @@ -157,6 +157,10 @@ public function render() $html .= $this->view->html($content['data'], $selectable, $selected); break; + case 'rich-text': + $html .= $this->view->richText($content['data'], $selectable, $selected); + break; + default: break; } diff --git a/library/Dlayer/View/ContentPreview.php b/library/Dlayer/View/ContentPreview.php index 62d3fce86..955291a88 100644 --- a/library/Dlayer/View/ContentPreview.php +++ b/library/Dlayer/View/ContentPreview.php @@ -107,6 +107,10 @@ public function render() $html .= $this->view->htmlPreview($content['data']); break; + case 'rich-text': + $html .= $this->view->richTextPreview($content['data']); + break; + default: break; } diff --git a/library/Dlayer/View/FormElementQuill.php b/library/Dlayer/View/FormElementQuill.php new file mode 100644 index 000000000..023404e9e --- /dev/null +++ b/library/Dlayer/View/FormElementQuill.php @@ -0,0 +1,35 @@ + + * @copyright G3D Development Limited + * @license https://github.com/Dlayer/dlayer/blob/master/LICENSE + */ +class Dlayer_View_FormElementQuill extends Zend_View_Helper_FormElement +{ + public function formElementQuill($name, $value = null, $attribs = null) + { + $info = $this->_getInfo($name, $value, $attribs); + extract($info); // name, value, attribs, options, listsep, disable + + // build the element + $disabled = ''; + if ($disable) { + // disabled + $disabled = ' disabled="disabled"'; + } + + $xhtml = '_htmlAttribs($attribs) + . $this->getClosingBracket() + . '
    '; + + return $xhtml; + } +} diff --git a/library/Dlayer/View/RichText.php b/library/Dlayer/View/RichText.php new file mode 100644 index 000000000..6300195fa --- /dev/null +++ b/library/Dlayer/View/RichText.php @@ -0,0 +1,102 @@ + + * @copyright G3D Development Limited + * @license https://github.com/Dlayer/dlayer/blob/master/LICENSE + */ +class Dlayer_View_RichText extends Zend_View_Helper_Abstract +{ + /** + * Override the hinting for the view property so that we can see the view + * helpers that have been defined + * + * @var Dlayer_View_Codehinting + */ + public $view; + + /** + * @var array Data array for the content item + */ + private $data; + + /** + * @var boolean Is the content item selectable? + */ + private $selectable; + + /** + * @var boolean Is the content item selected? + */ + private $selected; + + /** + * Constructor for view helper, data is set via the setter methods + * + * @param array $data Content item data array + * @param boolean $selectable + * @param boolean $selected + * @return Dlayer_View_RichText + */ + public function richText(array $data, $selectable = FALSE, $selected = FALSE) + { + $this->resetParams(); + + $this->data = $data; + $this->selectable = $selectable; + $this->selected = $selected; + + return $this; + } + + /** + * Reset any internal params, we do this because the view helper could be called many times within the view script + * + * @return void + */ + private function resetParams() + { + $this->data = array(); + $this->selectable = FALSE; + $this->selected = FALSE; + } + + /** + * Generate the html for the content item + * + * @return string + */ + private function render() + { + $class = 'content'; + + if($this->selectable === TRUE) + { + $class .= ' selectable'; + } + if($this->selected === TRUE) + { + $class .= ' selected'; + } + + $html = '
    view->stylingContentItem()->setContentItem($this->data['content_id']) . '>' . + $this->view->escape($this->data['content']) . '
    '; + + return $html; + } + + /** + * The view helper can be output directly, there is no need to call the render method, simply echo or print + * + * @return string + */ + public function __toString() + { + return $this->render(); + } +} diff --git a/library/Dlayer/View/RichTextPreview.php b/library/Dlayer/View/RichTextPreview.php new file mode 100644 index 000000000..053a57992 --- /dev/null +++ b/library/Dlayer/View/RichTextPreview.php @@ -0,0 +1,71 @@ + + * @copyright G3D Development Limited + * @license https://github.com/Dlayer/dlayer/blob/master/LICENSE + */ +class Dlayer_View_RichTextPreview extends Zend_View_Helper_Abstract +{ + /** + * Override the hinting for the view property so that we can see the view + * helpers that have been defined + * + * @var Dlayer_View_Codehinting + */ + public $view; + + /** + * @var array Data array for the content item + */ + private $data; + + /** + * Constructor for view helper, data is set via the setter methods + * + * @param array $data Content item data array + * @return Dlayer_View_RichTextPreview + */ + public function richTextPreview(array $data) + { + $this->resetParams(); + + $this->data = $data; + + return $this; + } + + /** + * Reset any internal params, we do this because the view helper could be called many times within the view script + * + * @return void + */ + private function resetParams() + { + $this->data = array(); + } + + /** + * Generate the html for the content item + * + * @return string + */ + private function render() + { + $html = '
    view->stylingContentItem()->setContentItem($this->data['content_id']) . '>' . $this->view->escape($this->data['content']) . '
    '; + + return $html; + } + + /** + * The view helper can be output directly, there is no need to call the render method, simply echo or print + * + * @return string + */ + public function __toString() + { + return $this->render(); + } +} diff --git a/private/database/tables/data/designer_content_type.sql b/private/database/tables/data/designer_content_type.sql index 892fb539a..b4b0f7206 100644 --- a/private/database/tables/data/designer_content_type.sql +++ b/private/database/tables/data/designer_content_type.sql @@ -6,4 +6,5 @@ insert into `designer_content_type`(`id`,`name`,`description`,`tool_id`) values (4,'jumbotron','Jumbotron',6), (5,'image','Image',8), (6,'html','Raw html',12), - (7,'heading-date','Heading & Date',28); + (7,'heading-date','Heading & Date',28), + (8,'rich-text', 'Rich text', 31); diff --git a/private/database/tables/data/dlayer_module_tool.sql b/private/database/tables/data/dlayer_module_tool.sql index e8b4e3b29..b2e735744 100644 --- a/private/database/tables/data/dlayer_module_tool.sql +++ b/private/database/tables/data/dlayer_module_tool.sql @@ -88,4 +88,7 @@ INSERT INTO `dlayer_module_tool` (`id`, `module_id`, `name`, `model`, `group_id` WHERE `name` = 'form'), 'Date of Birth', 'PresetDateOfBirth', 3, 5, 1), (NULL, (SELECT `id` FROM `dlayer_module` - WHERE `name` = 'form'), 'Alternate rows', 'StylingAlternateRow', 4, 1, 1); + WHERE `name` = 'form'), 'Alternate rows', 'StylingAlternateRow', 4, 1, 1), + (NULL, (SELECT `id` + FROM `dlayer_module` + WHERE `name` = 'content'), 'Rich text', 'RichText', 4, 6, 0); diff --git a/private/database/tables/data/dlayer_module_tool_tab.sql b/private/database/tables/data/dlayer_module_tool_tab.sql index dedd086fe..abda81b82 100644 --- a/private/database/tables/data/dlayer_module_tool_tab.sql +++ b/private/database/tables/data/dlayer_module_tool_tab.sql @@ -845,4 +845,22 @@ VALUES ON `dlayer_module_tool`.`module_id` = `dlayer_module`.`id` AND `dlayer_module`.`name` = 'form' WHERE `dlayer_module_tool`.`model` = 'StylingAlternateRow'), 'Help', 'help', NULL, + 'info-sign', NULL, 0, 0, 0, 2, 1), + (NULL, (SELECT `id` + FROM `dlayer_module` + WHERE `name` = 'content'), (SELECT `dlayer_module_tool`.`id` + FROM `dlayer_module_tool` + INNER JOIN `dlayer_module` + ON `dlayer_module_tool`.`module_id` = `dlayer_module`.`id` AND + `dlayer_module`.`name` = 'content' + WHERE `dlayer_module_tool`.`model` = 'RichText'), 'Rich text', 'rich-text', NULL, + 'pencil', NULL, 1, 0, 1, 1, 1), + (NULL, (SELECT `id` + FROM `dlayer_module` + WHERE `name` = 'content'), (SELECT `dlayer_module_tool`.`id` + FROM `dlayer_module_tool` + INNER JOIN `dlayer_module` + ON `dlayer_module_tool`.`module_id` = `dlayer_module`.`id` AND + `dlayer_module`.`name` = 'content' + WHERE `dlayer_module_tool`.`model` = 'RichText'), 'Help', 'help', NULL, 'info-sign', NULL, 0, 0, 0, 2, 1); diff --git a/private/database/tables/data/user_site_content_richtext.sql b/private/database/tables/data/user_site_content_richtext.sql new file mode 100644 index 000000000..e69de29bb diff --git a/private/database/tables/data/user_site_page_content_item_richtext.sql b/private/database/tables/data/user_site_page_content_item_richtext.sql new file mode 100644 index 000000000..e69de29bb diff --git a/private/database/tables/keys/user_site_content_richtext.sql b/private/database/tables/keys/user_site_content_richtext.sql new file mode 100644 index 000000000..3351c271b --- /dev/null +++ b/private/database/tables/keys/user_site_content_richtext.sql @@ -0,0 +1,3 @@ + +ALTER TABLE `dlayer`.`user_site_content_richtext` + ADD CONSTRAINT `user_site_content_richtext_fk1` FOREIGN KEY (`site_id`) REFERENCES `user_site` (`id`); diff --git a/private/database/tables/keys/user_site_page_content_item_richtext.sql b/private/database/tables/keys/user_site_page_content_item_richtext.sql new file mode 100644 index 000000000..5e5178b99 --- /dev/null +++ b/private/database/tables/keys/user_site_page_content_item_richtext.sql @@ -0,0 +1,6 @@ + +ALTER TABLE `dlayer`.`user_site_page_content_item_richtext` + ADD CONSTRAINT `user_site_page_content_item_richtext_fk1` FOREIGN KEY (`site_id`) REFERENCES `user_site` (`id`), + ADD CONSTRAINT `user_site_page_content_item_richtext_fk2` FOREIGN KEY (`page_id`) REFERENCES `user_site_page` (`id`), + ADD CONSTRAINT `user_site_page_content_item_richtext_fk3` FOREIGN KEY (`content_id`) REFERENCES `user_site_page_structure_content` (`id`), + ADD CONSTRAINT `user_site_page_content_item_richtext_fk4` FOREIGN KEY (`data_id`) REFERENCES `user_site_content_text` (`id`); diff --git a/private/database/tables/structure/user_site_content_richtext.sql b/private/database/tables/structure/user_site_content_richtext.sql new file mode 100644 index 000000000..55cf2ef0e --- /dev/null +++ b/private/database/tables/structure/user_site_content_richtext.sql @@ -0,0 +1,9 @@ + +CREATE TABLE `user_site_content_richtext` ( + `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `site_id` INT(11) UNSIGNED NOT NULL, + `name` VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Name so user can identity content', + `content` TEXT COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + KEY `site_id` (`site_id`) +) ENGINE=INNODB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/private/database/tables/structure/user_site_page_content_item_richtext.sql b/private/database/tables/structure/user_site_page_content_item_richtext.sql new file mode 100644 index 000000000..961f035b1 --- /dev/null +++ b/private/database/tables/structure/user_site_page_content_item_richtext.sql @@ -0,0 +1,13 @@ + +CREATE TABLE `user_site_page_content_item_richtext` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `site_id` int(11) unsigned NOT NULL, + `page_id` int(11) unsigned NOT NULL, + `content_id` int(11) unsigned NOT NULL, + `data_id` int(11) unsigned NOT NULL COMMENT 'Id of content in data table', + PRIMARY KEY (`id`), + KEY `page_id` (`page_id`), + KEY `content_id` (`content_id`), + KEY `site_id` (`site_id`), + KEY `data_id` (`data_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/public/bower.json b/public/bower.json index 7086515f8..bbaa91f6c 100644 --- a/public/bower.json +++ b/public/bower.json @@ -6,4 +6,4 @@ "jqueryui" : "latest" }, "private": true -} \ No newline at end of file +} diff --git a/public/scss/designer-shared.scss b/public/scss/designer-shared.scss index af32a23e5..67e858c23 100644 --- a/public/scss/designer-shared.scss +++ b/public/scss/designer-shared.scss @@ -71,3 +71,11 @@ cursor: pointer; } } + +.ql-editor-container { + min-height: 200px; + background-color: #FFFFFF; +} +.ql-editor { + background-color: #FFFFFF; +} diff --git a/public/web.config b/public/web.config new file mode 100644 index 000000000..9f105d08a --- /dev/null +++ b/public/web.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file