Skip to content

Commit

Permalink
Merge pull request #231 from deanblackborough/rich-text-sub-tools
Browse files Browse the repository at this point in the history
Rich text sub tools
  • Loading branch information
deanblackborough committed Mar 3, 2017
2 parents 064e47b + 2120d67 commit 4cd1ac1
Show file tree
Hide file tree
Showing 68 changed files with 1,367 additions and 390 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@

Full changelog for Dlayer since the v1.00 release.

## v1.15: In Progress
## v1.15: 3rd Match 2017

* Enabled the rich text content item tool. [Feature]
* Added a blog post content item [Feature]
* Added styling, typography and delete sub tools to rich text and blog post content items. [Feature]
* Original text content item renamed to 'plain text'.
* Added PHP Quill HTML renderer, used by the tools which have rich content areas.
* Tool links inside an empty column dynamic.
* Refactoring.
* Minor fixes and improvements.

## v1.14: 23rd February 2017
Expand Down
2 changes: 1 addition & 1 deletion application/configs/environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
// Version number for current release
$version_no = 'v1.15';
// Release date for current release
$version_release_date = 'In Progress';
$version_release_date = '3rd March 2017';
3 changes: 2 additions & 1 deletion application/modules/dlayer/views/scripts/index/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
</div>

<div class="col-md-6 col-sm-6 col-xs-12">
<h3><span class="label label-success">v1.15</span> Blog/Rich text content items <small class="text-muted">(In progress)</small></h3>
<h3><span class="label label-success">v1.15</span> Blog/Rich text content items <small class="text-muted">(3rd March 2017)</small></h3>

<ul>
<li>Enabled the rich text content item tool. [Feature]</li>
<li>Added a blog post content item [Feature]</li>
<li>Original text content item renamed to 'plain text'.</li>
<li>Added styling, typography and delete sub tools to rich text and blog post content items. [Feature]</li>
<li>Added PHP Quill HTML renderer, used by the tools which have rich content areas.</li>
<li>Tool links inside an empty column dynamic.</li>
<li>Refactoring.</li>
Expand Down
39 changes: 0 additions & 39 deletions library/Dlayer/DesignerTool/ContentManager/BlogPost/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,45 +52,6 @@ public function formats()
);
}

/**
* Check to see how many instances there are of the content item data within the site
*
* @param integer $site_id
* @param integer $content_id
*
* @return integer Number of instances
*/
public function instancesOfData($site_id, $content_id)
{
$sql = "SELECT
COUNT(`content`.`id`) AS `instances`
FROM
`user_site_page_content_item_blog_post` `content`
WHERE
`content`.`data_id` = (
SELECT
`uspcibp`.`data_id`
FROM
`user_site_page_content_item_blog_post` `uspcibp`
WHERE
`uspcibp`.`site_id` = :site_id AND
`uspcibp`.`content_id` = :content_id
LIMIT
1)";
$stmt = $this->_db->prepare($sql);
$stmt->bindValue(':site_id', $site_id, PDO::PARAM_INT);
$stmt->bindValue(':content_id', $content_id, PDO::PARAM_INT);
$stmt->execute();

$result = $stmt->fetch();

if ($result !== false) {
return intval($result['instances']);
} else {
return 0;
}
}

/**
* Add a new blog post content item
*
Expand Down
12 changes: 1 addition & 11 deletions library/Dlayer/DesignerTool/ContentManager/BlogPost/Ribbon.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,7 @@ protected function contentData()
*/
protected function instancesOfData()
{
if ($this->instances_of_fetched === false) {

$this->instances_of = 0;

if ($this->tool['content_id'] !== null) {
$model = new Dlayer_DesignerTool_ContentManager_BlogPost_Model();
$this->instances_of = $model->instancesOfData($this->tool['site_id'], $this->tool['content_id']);
}

$this->instances_of_fetched = true;
}
$this->instancesOfDataForBaseTool('BlogPost');
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* @author Dean Blackborough
* @copyright G3D Development Limited
* @license https://github.com/Dlayer/dlayer/blob/master/LICENSE
*/
class Dlayer_DesignerTool_ContentManager_BlogPost_SubTool_Delete_Form extends
Dlayer_DesignerTool_ContentManager_Shared_Form_Delete
{
/**
* Set the properties for the form
*
* @param array $tool Tool and environment data array
* @param array $data Current data for content item
* @param integer $instances Instances of content data on web site
* @param array $element_data
* @param array|NULL $options Zend form options
*/
public function __construct(array $tool, array $data, $instances, array $element_data, $options = null)
{
$this->content_type = 'BlogPost';
$this->sub_tool_model = 'Delete';

parent::__construct($tool, $data, $instances, $element_data, $options);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

/**
* @author Dean Blackborough <dean@g3d-development.com>
* @copyright G3D Development Limited
* @license https://github.com/Dlayer/dlayer/blob/master/LICENSE
*/
class Dlayer_DesignerTool_ContentManager_BlogPost_SubTool_Delete_Model extends
Dlayer_DesignerTool_ContentManager_Shared_Model_Delete
{
// No custom logic required
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/**
@author Dean Blackborough <dean@g3d-development.com>
* @copyright G3D Development Limited
* @license https://github.com/Dlayer/dlayer/blob/master/LICENSE
*/
class Dlayer_DesignerTool_ContentManager_BlogPost_SubTool_Delete_Ribbon extends Dlayer_Ribbon_Content
{
/**
* Fetch the view data for the current tool tab, typically the returned array will have at least two indexes,
* one for the form and another with the data required by the preview functions
*
* @param array $tool Tool and environment data
*
* @return array
*/
public function viewData(array $tool)
{
$this->tool = $tool;

return array(
'form' => new Dlayer_DesignerTool_ContentManager_BlogPost_SubTool_Delete_Form(
$tool,
array(),
0,
array()
)
);
}

/**
* Fetch the data array for the content item, if in edit mode mode populate the values otherwise every value is
* set to FALSE, the tool form can simply check to see if the value is FALSe or not and then set the existing value
*
* @return array
*/
protected function contentData()
{
// TODO: Implement contentData() method.
}

/**
* Fetch the number of instances for the content items data
*
* @return integer
*/
protected function instancesOfData()
{
// TODO: Implement instancesOfData() method.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

/**
* @author Dean Blackborough <dean@g3d-development.com>
* @copyright G3D Development Limited
* @license https://github.com/Dlayer/dlayer/blob/master/LICENSE
*/
class Dlayer_DesignerTool_ContentManager_BlogPost_SubTool_Delete_Tool extends
Dlayer_DesignerTool_ContentManager_Shared_Tool_Delete
{
// No custom logic required
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php /** @var $this Dlayer_View_Codehinting */ ?>

<div class="col-md-12 col-sm-12 small">
<?php
if ($this->data != false) {
echo $this->data['form'];
}
?>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* @author Dean Blackborough
* @copyright G3D Development Limited
* @license https://github.com/Dlayer/dlayer/blob/master/LICENSE
*/
class Dlayer_DesignerTool_ContentManager_BlogPost_SubTool_Styling_Form extends
Dlayer_DesignerTool_ContentManager_Shared_Form_Styling
{
/**
* Set the properties for the form
*
* @param array $tool Tool and environment data array
* @param array $data Current data for content item
* @param integer $instances Instances of content data on web site
* @param array $element_data
* @param array|NULL $options Zend form options
*/
public function __construct(array $tool, array $data, $instances, array $element_data, $options = null)
{
$this->content_type = 'BlogPost';
$this->sub_tool_model = 'Styling';

parent::__construct($tool, $data, $instances, $element_data, $options);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

/**
* @author Dean Blackborough <dean@g3d-development.com>
* @copyright G3D Development Limited
* @license https://github.com/Dlayer/dlayer/blob/master/LICENSE
*/
class Dlayer_DesignerTool_ContentManager_BlogPost_SubTool_Styling_Model extends
Dlayer_DesignerTool_ContentManager_Shared_Model_Styling
{
// No custom logic, here if required
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

/**
* @author Dean Blackborough <dean@g3d-development.com>
* @copyright G3D Development Limited
* @license https://github.com/Dlayer/dlayer/blob/master/LICENSE
*/
class Dlayer_DesignerTool_ContentManager_BlogPost_SubTool_Styling_Ribbon extends Dlayer_Ribbon_Content
{
/**
* Fetch the view data for the current tool tab, typically the returned array will have at least two indexes,
* one for the form and another with the data required by the preview functions
*
* @param array $tool Tool and environment data
*
* @return array
*/
public function viewData(array $tool)
{
$this->tool = $tool;

$this->contentData();
$this->previewData();

return array(
'form' => new Dlayer_DesignerTool_ContentManager_BlogPost_SubTool_Styling_Form(
$tool,
$this->content_data,
$this->instancesOfData(),
array()
),
'preview' => $this->preview_data
);
}

/**
* Fetch the data array for the content item, if in edit mode mode populate the values otherwise every value is
* set to FALSE, the tool form can simply check to see if the value is FALSe or not and then set the existing value
*
* @return void Writes to $this->content_data
*/
protected function contentData()
{
if($this->content_fetched === false) {
$this->content_data = array(
'content_background_color' => false,
);

if ($this->tool['content_id'] !== null) {
$model_styling = new Dlayer_DesignerTool_ContentManager_BlogPost_SubTool_Styling_Model();
$content_background_color = $model_styling->backgroundColor(
$this->tool['site_id'],
$this->tool['page_id'],
$this->tool['content_id']
);

if ($content_background_color !== false) {
$this->content_data['content_background_color'] = $content_background_color;
}
}

$this->content_fetched = true;
}
}

/**
* Fetch the data required by the preview functions
*
* @return void
*/
protected function previewData()
{
if ($this->preview_data_fetched === false) {

$this->contentData();

$this->preview_data = array(
'id' => $this->tool['content_id'],
'background_color' => $this->content_data['content_background_color']
);

$this->preview_data_fetched = true;
}
}

/**
* Fetch the number of instances for the content items data
*
* @return integer
*/
protected function instancesOfData()
{
return 0;
}
}
Loading

0 comments on commit 4cd1ac1

Please sign in to comment.