Skip to content

Commit

Permalink
Merge pull request #142 from deanblackborough/image-tool
Browse files Browse the repository at this point in the history
Image tool
  • Loading branch information
deanblackborough committed Sep 4, 2016
2 parents a709839 + 8f8a524 commit dc184f2
Show file tree
Hide file tree
Showing 27 changed files with 1,182 additions and 1,405 deletions.
4 changes: 2 additions & 2 deletions application/configs/environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
/**
* Version number and version release date
*/
$version_no = 'v0.99-alpha-2';
$version_release_date = '17th July 2016';
$version_no = 'v0.99-alpha-3';
$version_release_date = '5th September 2016';
78 changes: 45 additions & 33 deletions application/modules/content/controllers/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,41 @@ class Content_AjaxController extends Zend_Controller_Action
*/
protected $_helper;

private $session_dlayer;
private $session_content;
private $site_id;
private $page_id;

/**
* @var Dlayer_Session_Designer
*/
private $session_designer;


/**
* @var Dlayer_Model_ImagePicker
*/
private $model_image_picker;

/**
* Initialise the controller, run any required set up code and set
* properties required by controller actions
* Initialise the controller, run any required set up code and set properties required by controller actions
*
* @return void
*/
public function init()
{
$this->_helper->authenticate();

$this->_helper->disableLayout(FALSE);

$this->_helper->setModule();

$this->_helper->validateSiteId();

$this->_helper->validateTemplateId(TRUE);

$this->_helper->disableLayout(FALSE);
$session_dlayer = new Dlayer_Session();
$this->site_id = $session_dlayer->siteId();

$this->session_dlayer = new Dlayer_Session();
$this->session_content = new Dlayer_Session_Content();
$this->page_id = $this->session_content->pageId();

$this->session_designer = new Dlayer_Session_Designer();

}

/**
Expand Down Expand Up @@ -139,8 +146,7 @@ public function imagePickerSelectImageAction()

$this->model_image_picker = new Dlayer_Model_ImagePicker();

$image = $this->model_image_picker->validateImage(
$this->session_dlayer->siteId(), $image_id, $version_id);
$image = $this->model_image_picker->validateImage($this->site_id, $image_id, $version_id);

$json = array('data'=>FALSE);

Expand Down Expand Up @@ -199,36 +205,42 @@ function imagePickerAction()
$category_id = $this->getRequest()->getParam('category_id');
$sub_category_id = $this->getRequest()->getParam('sub_category_id');
$image_id = $this->getRequest()->getParam('image_id');

if($category_id != NULL) {
if($category_id != 'clear') {

/**
*
*
* Move these, session class can do the checks
*
*
*
*/
if($category_id !== NULL) {
if($category_id !== 'clear') {
$this->session_designer->setImagePickerCategoryId(
intval($category_id));
} else {
$this->session_designer->clearImagePickerCategoryId();
}
}

if($sub_category_id != NULL) {
if($sub_category_id != 'clear') {
if($sub_category_id !== NULL) {
if($sub_category_id !== 'clear') {
$this->session_designer->setImagePickerSubCategoryId(
intval($sub_category_id));
} else {
$this->session_designer->clearImagePickerSubCategoryId();
}
}

if($image_id != NULL) {
if($image_id != 'clear') {
if($image_id !== NULL) {
if($image_id !== 'clear') {
$this->session_designer->setImagePickerImageId(
intval($image_id));
} else {
$this->session_designer->clearImagePickerImageId();
}
}

$site_id = $this->session_dlayer->siteId();

$this->model_image_picker = new Dlayer_Model_ImagePicker();

$category_id = $this->session_designer->imagePickerCategoryId();
Expand All @@ -244,12 +256,9 @@ function imagePickerAction()
$this->view->visible = TRUE;
}

$this->view->category = $this->imagePickerCategory($site_id,
$category_id);
$this->view->sub_category = $this->imagePickerSubCategory($site_id,
$category_id, $sub_category_id);
$this->view->images = $this->imagePickerImages($site_id, $category_id,
$sub_category_id, $image_id);
$this->view->category = $this->imagePickerCategory($this->site_id, $category_id);
$this->view->sub_category = $this->imagePickerSubCategory($this->site_id, $category_id, $sub_category_id);
$this->view->images = $this->imagePickerImages($this->site_id, $category_id, $sub_category_id, $image_id);

echo $this->view->render('ajax/image-picker.phtml');
}
Expand Down Expand Up @@ -284,12 +293,15 @@ function imagePickerCategory($site_id, $category_id)
*/
function imagePickerSubCategory($site_id, $category_id, $sub_category_id)
{
if($category_id === NULL) {
if($category_id === NULL)
{
return NULL;
} else {
if($sub_category_id === NULL) {
$this->view->sub_categories =
$this->model_image_picker->subCategories($site_id,
}
else
{
if($sub_category_id === NULL)
{
$this->view->sub_categories = $this->model_image_picker->subCategories($site_id,
$category_id);

return $this->view->render(
Expand Down Expand Up @@ -348,4 +360,4 @@ function imagePickerImages($site_id, $category_id, $sub_category_id,
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<script>
dlayer.fn.imagePicker.setCategory();
dlayerDesigner.imagePicker.setSelectedCategory();
</script>

<div class="form-group ip-category">
<label for="ip-category" class="required">Category</label>
<select name="ip-category" id="ip-category" class="form-control input-sm">
<div class="form-group">
<label for="category-selector" class="required">Category</label>
<select name="category-selector" class="form-control input-sm category-selector">
<?php foreach($this->categories as $id=>$label) { ?>
<option value="<?php echo $this->escape($id); ?>"><?php echo $this->escape($label); ?></option>
<?php } ?>
</select>
<p class="help-block">Select a category from your Image
library to show sub categories.</p>
</div>
<p class="help-block">Select a category from your Image library to show sub categories.</p>
</div>
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<script>
dlayer.fn.imagePicker.clearCategory();
dlayerDesigner.imagePicker.clearSelectedCategory();
</script>

<h4>Category: <small title="<?php echo $this->escape($this->category['number_of_images']); ?> images in category"><?php echo $this->escape($this->category['name']); ?> <span class="badge"><?php echo $this->escape($this->category['number_of_images']); ?></span></small>
<span class="glyphicon glyphicon-remove pull-right clear-image-picker-value clear-image-picker-category"
title="Clear category" aria-hidden="true"></span></h4>
<span class="glyphicon glyphicon-remove pull-right close-icon clear-selected-category" title="Clear category" aria-hidden="true"></span></h4>

<hr />
<hr />
Original file line number Diff line number Diff line change
@@ -1,71 +1,63 @@
<script>
dlayer.fn.imagePicker.setImage();
dlayer.fn.imagePicker.selectImage();
dlayerDesigner.imagePicker.setSelectedImage();
dlayerDesigner.imagePicker.selectImage();
</script>

<div class="image-list">
<h4>Images <small>Images for the selected category and
sub category</small></h4>

<p>You can either select the latest version of an imaage or click the
'view versions' button to choose a specific version.</p>

<!--<div class="row" style="padding-bottom: 10px;">
<div class="col-xs-12">
<div class="btn-toolbar">
<div class="btn-group btn-group-xs" role="group" aria-label="...">
<a title="Sorted by name" href="#" class="btn btn-primary">Name</a>
<a title="Sort by size" href="#" class="btn btn-default">Size</a>
<a title="Sort by date uploaded to library" href="#" class="btn btn-default">Uploaded</a>
</div>
<div class="btn-group btn-group-xs" role="group" aria-label="...">
<a title="Display in ascending order" href="#" class="btn btn-default">Asc.</a>
<a title="Displayed in descending order" href="#" class="btn btn-primary">Desc.</a>
</div>
</div>
</div>
</div>-->

<?php foreach($this->images as $image) { ?>

<?php $src = $this->escape($image['image_id'] .
'/' . $image['version_id'] . $image['extension']); ?>
<?php $dimensions = $this->escape($image['width'] . ' x ' .
$image['height'] . ' pixels'); ?>
<?php $select_id = $this->escape('ip-image-' . $image['image_id'] . ':' .
$image['version_id']); ?>
<?php $set_id = $this->escape('ip-set-image-' . $image['image_id']); ?>
<h4>Images <small>Images for the selected category and
sub category</small></h4>

<div class="row" style="padding-bottom: 10px;">
<div class="col-xs-4">
<img src="/images/library/<?php echo $src; ?>"
title="<?php echo $this->escape($image['name']); ?>"
alt="Image library image" width="160" height="120"
class="img-thumbnail">
</div>
<div class="col-xs-8">
<p>
<strong>Name:</strong> <?php echo $this->escape($image['name']); ?><br />
<strong>Dimenisons:</strong> <?php echo $dimensions; ?><br />
<strong>Size:</strong> <?php echo $this->escape($image['size']); ?>
</p>
</div>
<div class="col-xs-12 text-right">
<!--<div class="row" style="padding-bottom: 10px;">
<div class="col-xs-12">
<div class="btn-toolbar">
<div class="btn-group btn-group-xs" role="group" aria-label="...">
<button type="button"
class="btn btn-primary ip-select-image"
id="<?php echo $select_id; ?>">Select</button>
<?php if($image['versions'] == 1) { ?>
<button type="button" id="<?php echo $id; ?>"
class="btn btn-default"
disabled="disabled">View versions</button>
<?php } else { ?>
<button type="button" class="btn btn-default ip-image"
id="<?php echo $set_id; ?>">View versions</button>
<?php } ?>
<a title="Sorted by name" href="#" class="btn btn-primary">Name</a>
<a title="Sort by size" href="#" class="btn btn-default">Size</a>
<a title="Sort by date uploaded to library" href="#" class="btn btn-default">Uploaded</a>
</div>
<div class="btn-group btn-group-xs" role="group" aria-label="...">
<a title="Display in ascending order" href="#" class="btn btn-default">Asc.</a>
<a title="Displayed in descending order" href="#" class="btn btn-primary">Desc.</a>
</div>
</div>
</div>
</div>-->

<?php foreach($this->images as $image) { ?>

<?php $src = $this->escape($image['image_id'] .
'/' . $image['version_id'] . $image['extension']); ?>
<?php $dimensions = $this->escape($image['width'] . ' x ' .
$image['height'] . ' pixels'); ?>
<?php $select_id = $this->escape('ip-image-' . $image['image_id'] . ':' .
$image['version_id']); ?>
<?php $set_id = $this->escape('ip-set-image-' . $image['image_id']); ?>

<div class="row" style="padding-bottom: 10px;">
<div class="col-xs-6">
<img src="/images/library/<?php echo $src; ?>" title="<?php echo $this->escape($image['name']); ?>"
alt="Image library image" width="160" height="120" class="img-thumbnail" />
</div>
<div class="col-xs-6 small">
<p>
<strong><?php echo $this->escape($image['name']); ?></strong><br />
- <?php echo $dimensions; ?><br />
- <?php echo $this->escape($image['size']); ?>
</p>
</div>
<div class="col-xs-12 text-right">
<div class="btn-group btn-group-xs" role="group" aria-label="...">
<button type="button"
class="btn btn-primary version-selector"
data-version-id="<?php echo $this->escape($image['version_id']); ?>" data-image-id="<?php echo $this->escape($image['image_id']); ?>">Select</button>
<?php if($image['versions'] == 1) { ?>
<button type="button" id="<?php echo $id; ?>"
class="btn btn-default"
disabled="disabled">View versions</button>
<?php } else { ?>
<button type="button" class="btn btn-default image-selector" data-image-id="<?php echo $this->escape($image['image_id']); ?>">View versions</button>
<?php } ?>
</div>
</div>
<?php } ?>
</div>
</div>

<?php } ?>
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<script>
dlayer.fn.imagePicker.setSubCategory();
dlayerDesigner.imagePicker.setSelectedSubCategory();
</script>

<div class="form-group ip-sub-category">
<label for="ip-sub-category" class="required">Sub category</label>
<select name="ip-sub-category" id="ip-sub-category" class="form-control input-sm">
<div class="form-group">
<label for="sub-category-selector" class="required">Sub category</label>
<select name="sub-category-selector" class="form-control input-sm sub-category-selector">
<?php foreach($this->sub_categories as $id=>$label) { ?>
<option value="<?php echo $this->escape($id); ?>"><?php echo $this->escape($label); ?></option>
<?php } ?>
</select>
<p class="help-block">Select a sub category to list the images
defined in the selected category and sub category.</p>
</div>
<p class="help-block">Select a sub category to list the images defined in the selected category and sub category.</p>
</div>
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<script>
dlayer.fn.imagePicker.clearSubCategory();
dlayerDesigner.imagePicker.clearSelectedSubCategory();
</script>

<h4>Sub category: <small title="<?php echo $this->escape($this->sub_category['number_of_images']); ?> images in sub category/categories"><?php echo $this->escape($this->sub_category['name']); ?> <span class="badge"><?php echo $this->escape($this->sub_category['number_of_images']); ?></span></small>
<span class="glyphicon glyphicon-remove clear-image-picker-value clear-image-picker-sub-category pull-right"
title="Clear sub category" aria-hidden="true"></span></h4>
<span class="glyphicon glyphicon-remove clear-selected-sub-category close-icon pull-right" title="Clear sub category" aria-hidden="true"></span></h4>

<hr />
<hr />
Loading

0 comments on commit dc184f2

Please sign in to comment.