Skip to content

Commit

Permalink
Merge branch '2.0-misc'
Browse files Browse the repository at this point in the history
* 2.0-misc:
  Removing hardcoded img-polaroid classes
  Add configurable default image class
  Remove 'class' => false setting for checkboxes and radio buttons
  Use icon configurations from theme in the JS layer
  Remove hardcoded icon codes and use $_icons instead
  Remove trailing space in icon template
  More configurable icon codes and make it available as $_icons in views
  Use custom element for all setFlash() calls
  Don't use default input class for radio and checkboxes
  Move helper settings to theme while still being overridable
  • Loading branch information
rchavik committed Sep 1, 2014
2 parents cdedb90 + b13db90 commit 1dab59a
Show file tree
Hide file tree
Showing 106 changed files with 603 additions and 474 deletions.
22 changes: 11 additions & 11 deletions Acl/Controller/AclActionsController.php
Expand Up @@ -75,10 +75,10 @@ public function admin_add() {
}

if ($this->Acl->Aco->save($this->request->data['Aco'])) {
$this->Session->setFlash(sprintf(__d('croogo', 'The %s has been saved'), $acoType), 'default', array('class' => 'success'));
$this->Session->setFlash(sprintf(__d('croogo', 'The %s has been saved'), $acoType), 'flash', array('class' => 'success'));
return $this->Croogo->redirect(array('action' => 'edit', $this->Acl->Aco->id));
} else {
$this->Session->setFlash(sprintf(__d('croogo', 'The %s could not be saved. Please, try again.'), $acoType), 'default', array('class' => 'error'));
$this->Session->setFlash(sprintf(__d('croogo', 'The %s could not be saved. Please, try again.'), $acoType), 'flash', array('class' => 'error'));
}
}

Expand All @@ -95,15 +95,15 @@ public function admin_edit($id = null) {
$this->set('title_for_layout', __d('croogo', 'Edit Action'));

if (!$id && empty($this->request->data)) {
$this->Session->setFlash(__d('croogo', 'Invalid Action'), 'default', array('class' => 'error'));
$this->Session->setFlash(__d('croogo', 'Invalid Action'), 'flash', array('class' => 'error'));
return $this->redirect(array('action' => 'index'));
}
if (!empty($this->request->data)) {
if ($this->Acl->Aco->save($this->request->data['Aco'])) {
$this->Session->setFlash(__d('croogo', 'The Action has been saved'), 'default', array('class' => 'success'));
$this->Session->setFlash(__d('croogo', 'The Action has been saved'), 'flash', array('class' => 'success'));
return $this->Croogo->redirect(array('action' => 'edit', $this->Acl->Aco->id));
} else {
$this->Session->setFlash(__d('croogo', 'The Action could not be saved. Please, try again.'), 'default', array('class' => 'error'));
$this->Session->setFlash(__d('croogo', 'The Action could not be saved. Please, try again.'), 'flash', array('class' => 'error'));
}
}
if (empty($this->request->data)) {
Expand All @@ -121,11 +121,11 @@ public function admin_edit($id = null) {
*/
public function admin_delete($id = null) {
if (!$id) {
$this->Session->setFlash(__d('croogo', 'Invalid id for Action'), 'default', array('class' => 'error'));
$this->Session->setFlash(__d('croogo', 'Invalid id for Action'), 'flash', array('class' => 'error'));
return $this->redirect(array('action' => 'index'));
}
if ($this->Acl->Aco->delete($id)) {
$this->Session->setFlash(__d('croogo', 'Action deleted'), 'default', array('class' => 'success'));
$this->Session->setFlash(__d('croogo', 'Action deleted'), 'flash', array('class' => 'success'));
return $this->redirect(array('action' => 'index'));
}
}
Expand All @@ -139,17 +139,17 @@ public function admin_delete($id = null) {
*/
public function admin_move($id, $direction = 'up', $step = '1') {
if (!$id) {
$this->Session->setFlash(__d('croogo', 'Invalid id for Action'), 'default', array('class' => 'error'));
$this->Session->setFlash(__d('croogo', 'Invalid id for Action'), 'flash', array('class' => 'error'));
return $this->redirect(array('action' => 'index'));
}
if ($direction == 'up') {
if ($this->Acl->Aco->moveUp($id)) {
$this->Session->setFlash(__d('croogo', 'Action moved up'), 'default', array('class' => 'success'));
$this->Session->setFlash(__d('croogo', 'Action moved up'), 'flash', array('class' => 'success'));
return $this->redirect(array('action' => 'index'));
}
} else {
if ($this->Acl->Aco->moveDown($id)) {
$this->Session->setFlash(__d('croogo', 'Action moved down'), 'default', array('class' => 'success'));
$this->Session->setFlash(__d('croogo', 'Action moved down'), 'flash', array('class' => 'success'));
return $this->redirect(array('action' => 'index'));
}
}
Expand All @@ -176,7 +176,7 @@ public function admin_generate() {
$class = 'error';
}

$this->Session->setFlash(join('<br>', $output), 'default', array('class' => $class));
$this->Session->setFlash(join('<br>', $output), 'flash', array('class' => $class));

if (isset($this->request->params['named']['permissions'])) {
return $this->redirect(array('plugin' => 'acl', 'controller' => 'acl_permissions', 'action' => 'index'));
Expand Down
4 changes: 2 additions & 2 deletions Acl/Controller/AclPermissionsController.php
Expand Up @@ -165,9 +165,9 @@ public function admin_upgrade() {
$result = $AclUpgrade->upgrade();
if ($result === true) {
$this->Session->delete(AuthComponent::$sessionKey . '.aclUpgrade');
$this->Session->setFlash(__d('croogo', 'ACL database has been upgraded successfully'), 'default', array('class' => 'success'));
$this->Session->setFlash(__d('croogo', 'ACL database has been upgraded successfully'), 'flash', array('class' => 'success'));
} else {
$this->Session->setFlash(join('<br>', $result), 'default', array('class' => 'error'));
$this->Session->setFlash(join('<br>', $result), 'flash', array('class' => 'error'));
}
return $this->redirect($this->referer());
}
Expand Down
2 changes: 1 addition & 1 deletion Acl/Controller/Component/AclFilterComponent.php
Expand Up @@ -82,7 +82,7 @@ protected function _configure() {
$notice = __d('croogo', '"AutoLogin" (Remember Me) disabled since mcrypt_encrypt is not available');
$this->log($notice, LOG_CRIT);
if (isset($this->_controller->request->params['admin'])) {
$this->_controller->Session->setFlash($notice, 'default', null, array('class', 'error'));
$this->_controller->Session->setFlash($notice, 'flash', null, array('class', 'error'));
}
if (isset($this->_controller->Setting)) {
$Setting = $this->_controller->Setting;
Expand Down
4 changes: 2 additions & 2 deletions Acl/Lib/AclExtras.php
Expand Up @@ -112,7 +112,7 @@ public function startup($controller = null) {
public function out($msg) {
$this->output[] = $msg;
if (!empty($this->controller->Session)) {
$this->controller->Session->setFlash($msg);
$this->controller->Session->setFlash($msg, 'flash');
} elseif (isset($this->Shell)) {
return $this->Shell->out($msg);
}
Expand All @@ -121,7 +121,7 @@ public function out($msg) {
public function err($msg) {
$this->errors[] = $msg;
if (!empty($this->controller->Session)) {
$this->controller->Session->setFlash($msg);
$this->controller->Session->setFlash($msg, 'flash');
} elseif (isset($this->Shell)) {
return $this->Shell->err($msg);
}
Expand Down
5 changes: 2 additions & 3 deletions Acl/Test/Case/Controller/AclActionsControllerTest.php
Expand Up @@ -52,9 +52,8 @@ public function testGenerateActions() {
->method('setFlash')
->with(
$this->matchesRegularExpression('/(Created Aco node:)|.*Aco Update Complete.*|(Skipped Aco node:)/'),
$this->equalTo('default'),
$this->anything(),
$this->equalTo('flash')
$this->equalTo('flash'),
$this->anything()
);
$AclActions
->expects($this->once())
Expand Down
2 changes: 1 addition & 1 deletion Acl/View/AclActions/admin_form.ctp
Expand Up @@ -2,7 +2,7 @@
$this->extend('/Common/admin_edit');
$this->set('className', 'acl_actions');
$this->Html
->addCrumb('', '/admin', array('icon' => 'home'))
->addCrumb('', '/admin', array('icon' => $_icons['home']))
->addCrumb(__d('croogo', 'Users'), array('plugin' => 'users', 'controller' => 'users', 'action' => 'index'))
->addCrumb(__d('croogo', 'Permissions'), array('plugin' => 'acl', 'controller' => 'acl_permissions'))
->addCrumb(__d('croogo', 'Actions'), array('plugin' => 'acl', 'controller' => 'acl_actions', 'action' => 'index'));
Expand Down
11 changes: 6 additions & 5 deletions Acl/View/AclActions/admin_index.ctp
@@ -1,12 +1,13 @@
<?php

$this->extend('/Common/admin_index');

$this->name = 'acos';
$this->Html->script('/acl/js/acl_permissions.js', false);
$this->Html->scriptBlock("$(document).ready(function(){ AclPermissions.documentReady(); });", array('inline' => false));

$this->Html
->addCrumb('', '/admin', array('icon' => 'home'))
->addCrumb('', '/admin', array('icon' => $_icons['home']))
->addCrumb(__d('croogo', 'Users'), array('plugin' => 'users', 'controller' => 'users', 'action' => 'index'))
->addCrumb(__d('croogo', 'Permissions'), array(
'plugin' => 'acl', 'controller' => 'acl_permissions',
Expand Down Expand Up @@ -101,21 +102,21 @@ $this->append('table-body');
$actions = array();
$actions[] = $this->Html->link('',
array('action' => 'move', $id, 'up'),
array('icon' => 'chevron-up', 'tooltip' => __d('croogo', 'Move up'))
array('icon' => $_icons['move-up'], 'tooltip' => __d('croogo', 'Move up'))
);
$actions[] = $this->Html->link('',
array('action' => 'move', $id, 'down'),
array('icon' => 'chevron-down', 'tooltip' => __d('croogo', 'Move down'))
array('icon' => $_icons['move-down'], 'tooltip' => __d('croogo', 'Move down'))
);

$actions[] = $this->Html->link('',
array('action' => 'edit', $id),
array('icon' => 'pencil', 'tooltip' => __d('croogo', 'Edit this item'))
array('icon' => $_icons['update'], 'tooltip' => __d('croogo', 'Edit this item'))
);
$actions[] = $this->Form->postLink('',
array('action' => 'delete', $id),
array(
'icon' => 'trash',
'icon' => $_icons['delete'],
'tooltip' => __d('croogo', 'Remove this item'),
'escapeTitle' => false,
'escape' => true,
Expand Down
2 changes: 1 addition & 1 deletion Acl/View/AclPermissions/admin_index.ctp
Expand Up @@ -5,7 +5,7 @@ $this->name = 'acl_permissions';
$this->Croogo->adminScript('Acl.acl_permissions');

$this->Html
->addCrumb('', '/admin', array('icon' => 'home'))
->addCrumb('', '/admin', array('icon' => $_icons['home']))
->addCrumb(__d('croogo', 'Users'), array('plugin' => 'users', 'controller' => 'users', 'action' => 'index'))
->addCrumb(__d('croogo', 'Permissions'), array(
'plugin' => 'acl', 'controller' => 'acl_permissions',
Expand Down
9 changes: 5 additions & 4 deletions Acl/View/AclPermissions/admin_toggle.ctp
Expand Up @@ -2,17 +2,18 @@

if ($success == 1) {
if ($permitted == 1) {
echo $this->Html->tag('i', null, array(
'class' => 'permission-toggle icon-ok green',
echo $this->Html->icon($_icons['check-mark'], array(
'class' => 'permission-toggle green',
'data-aco_id' => $acoId,
'data-aro_id' => $aroId
));
} else {
echo $this->Html->tag('i', null, array(
'class' => 'permission-toggle icon-remove red',
echo $this->Html->icon($_icons['x-mark'], array(
'class' => 'permission-toggle red',
'data-aco_id' => $acoId,
'data-aro_id' => $aroId
));

}
} else {
echo __d('croogo', 'error');
Expand Down
8 changes: 4 additions & 4 deletions Acl/View/AclPermissions/json/admin_index.ctp
Expand Up @@ -4,19 +4,19 @@ if (isset($this->request->query['urls'])) {
$aco[key($aco)]['url'] = array(
'up' => $this->Html->link('',
array('controller' => 'acl_actions', 'action' => 'moveup', $acoId, 'up'),
array('icon' => 'chevron-up', 'tooltip' => __d('croogo', 'Move up'))
array('icon' => $_icons['move-up'], 'tooltip' => __d('croogo', 'Move up'))
),
'down' => $this->Html->link('',
array('controller' => 'acl_actions', 'action' => 'movedown', $acoId, 'down'),
array('icon' => 'chevron-down', 'tooltip' => __d('croogo', 'Move down'))
array('icon' => $_icons['move-down'], 'tooltip' => __d('croogo', 'Move down'))
),
'edit' => $this->Html->link('',
array('controller' => 'acl_actions', 'action' => 'edit', $acoId),
array('icon' => 'pencil', 'tooltip' => __d('croogo', 'Edit this item'))
array('icon' => $_icons['update'], 'tooltip' => __d('croogo', 'Edit this item'))
),
'del' => $this->Form->postLink('',
array('controller' => 'acl_actions', 'action' => 'delete', $acoId),
array('icon' => 'trash', 'tooltip' => __d('croogo', 'Remove this item')),
array('icon' => $_icons['delete'], 'tooltip' => __d('croogo', 'Remove this item')),
__d('croogo', 'Are you sure?')
),
);
Expand Down
28 changes: 16 additions & 12 deletions Acl/webroot/js/acl_permissions.js
Expand Up @@ -46,17 +46,18 @@ AclPermissions.tabLoad = function(e) {
var matches = (e.target.toString().match(/#.+/gi));
var pane = matches[0];
var alias = $target.data('alias');
var $span = $('.icon-spin', $target);
var $span = $('.' + Admin.iconClass('spinner', false), $target);
var spinnerClass = Admin.iconClass('spinner') + ' ' +Admin.iconClass('spin', false);
if ($span.length > 0) {
$span.addClass('icon-spinner');
$span.addClass(spinnerClass);
} else {
$target.append(' <span class="icon-spin icon-spinner"></span>');
$target.append(' <span class="' + spinnerClass + '"></span>');
};
$(pane).load(
Croogo.basePath + 'admin/acl/acl_permissions/',
$.param({ root: alias }),
function(responseText, textStatus, xhr) {
$('span', $target).removeClass('icon-spinner');
$('span', $target).removeClass(spinnerClass);
AclPermissions.documentReady();
}
);
Expand Down Expand Up @@ -85,11 +86,12 @@ AclPermissions.permissionToggle = function() {
var $this = $(this);
var acoId = $this.data('aco_id');
var aroId = $this.data('aro_id');
var spinnerClass = Admin.iconClass('spinner') + ' ' + Admin.iconClass('spin', false);

// show loader
$this
.removeClass('icon-ok icon-remove')
.addClass('icon-spin icon-spinner');
.removeClass(Admin.iconClass('check-mark') + ' ' + Admin.iconClass('x-mark'))
.addClass(spinnerClass);

// prepare loadUrl
var loadUrl = Croogo.basePath+'admin/acl/acl_permissions/toggle/';
Expand Down Expand Up @@ -118,6 +120,7 @@ AclPermissions.tableToggle = function() {
var $el = $(this);
var rows = '';
var id = $el.data('id');
var spinnerClass = Admin.iconClass('spinner') + ' ' + Admin.iconClass('spin');
for (var acoId in data.permissions) {
text = '<td>' + acoId + '</td>';
var aliases = data.permissions[acoId];
Expand Down Expand Up @@ -150,7 +153,7 @@ AclPermissions.tableToggle = function() {
}
var $row = $el.parents('tr');
$(rows).insertAfter($row);
$el.find('i').removeClass('icon-spinner icon-spin');
$el.find('i').removeClass(spinnerClass);
};

// create table cells for role permissions
Expand All @@ -169,12 +172,12 @@ AclPermissions.tableToggle = function() {

var allowed = roles['roles'][aroIndex];
if (aroIndex == 1) {
cell.classes += "icon-ok lightgray permission-disabled";
cell.classes += "lightgray permission-disabled " + Admin.iconClass("check-mark");
} else {
if (allowed) {
cell.classes += "icon-ok green";
cell.classes += "green " + Admin.iconClass("check-mark");
} else {
cell.classes += "icon-remove red";
cell.classes += "red " + Admin.iconClass("x-mark");
}
}
text += AclPermissions.templates.toggleButton(cell);
Expand All @@ -186,8 +189,9 @@ AclPermissions.tableToggle = function() {
var $el = $(this);
var id = $el.data('id');
var level = $el.data('level');
var spinnerClass = Admin.iconClass('spinner') + ' ' + Admin.iconClass('spin', false);

$el.find('i').addClass('icon-spin icon-spinner');
$el.find('i').addClass(spinnerClass);
if ($el.hasClass('perm-expand')) {
$el.removeClass('perm-expand').addClass('perm-collapse');
} else {
Expand All @@ -197,7 +201,7 @@ AclPermissions.tableToggle = function() {
$('tr[data-parent_id=' + childId + ']').remove();
}).remove();
$el.removeClass('perm-collapse').addClass('perm-expand')
.find('i').removeClass('icon-spin icon-spinner');
.find('i').removeClass(spinnerClass);
return;
}

Expand Down
22 changes: 11 additions & 11 deletions Blocks/Controller/BlocksController.php
Expand Up @@ -126,10 +126,10 @@ public function admin_add() {
$this->request->data['Block']['visibility_roles'] = $this->Block->encodeData($this->request->data['Role']['Role']);
$this->request->data['Block']['visibility_paths'] = $this->Block->encodeData(explode("\n", $this->request->data['Block']['visibility_paths']));
if ($this->Block->saveAll($this->request->data)) {
$this->Session->setFlash(__d('croogo', 'The Block has been saved'), 'default', array('class' => 'success'));
$this->Session->setFlash(__d('croogo', 'The Block has been saved'), 'flash', array('class' => 'success'));
$this->Croogo->redirect(array('action' => 'edit', $this->Block->id));
} else {
$this->Session->setFlash(__d('croogo', 'The Block could not be saved. Please, try again.'), 'default', array('class' => 'error'));
$this->Session->setFlash(__d('croogo', 'The Block could not be saved. Please, try again.'), 'flash', array('class' => 'error'));
}
}
$regions = $this->Block->Region->find('list');
Expand All @@ -148,17 +148,17 @@ public function admin_edit($id = null) {
$this->set('title_for_layout', __d('croogo', 'Edit Block'));

if (!$id && empty($this->request->data)) {
$this->Session->setFlash(__d('croogo', 'Invalid Block'), 'default', array('class' => 'error'));
$this->Session->setFlash(__d('croogo', 'Invalid Block'), 'flash', array('class' => 'error'));
return $this->redirect(array('action' => 'index'));
}
if (!empty($this->request->data)) {
$this->request->data['Block']['visibility_roles'] = $this->Block->encodeData($this->request->data['Role']['Role']);
$this->request->data['Block']['visibility_paths'] = $this->Block->encodeData(explode("\n", $this->request->data['Block']['visibility_paths']));
if ($this->Block->saveAll($this->request->data)) {
$this->Session->setFlash(__d('croogo', 'The Block has been saved'), 'default', array('class' => 'success'));
$this->Session->setFlash(__d('croogo', 'The Block has been saved'), 'flash', array('class' => 'success'));
$this->Croogo->redirect(array('action' => 'edit', $id));
} else {
$this->Session->setFlash(__d('croogo', 'The Block could not be saved. Please, try again.'), 'default', array('class' => 'error'));
$this->Session->setFlash(__d('croogo', 'The Block could not be saved. Please, try again.'), 'flash', array('class' => 'error'));
}
}
if (empty($this->request->data)) {
Expand All @@ -183,11 +183,11 @@ public function admin_edit($id = null) {
*/
public function admin_delete($id = null) {
if (!$id) {
$this->Session->setFlash(__d('croogo', 'Invalid id for Block'), 'default', array('class' => 'error'));
$this->Session->setFlash(__d('croogo', 'Invalid id for Block'), 'flash', array('class' => 'error'));
return $this->redirect(array('action' => 'index'));
}
if ($this->Block->delete($id)) {
$this->Session->setFlash(__d('croogo', 'Block deleted'), 'default', array('class' => 'success'));
$this->Session->setFlash(__d('croogo', 'Block deleted'), 'flash', array('class' => 'success'));
return $this->redirect(array('action' => 'index'));
}
}
Expand All @@ -202,9 +202,9 @@ public function admin_delete($id = null) {
*/
public function admin_moveup($id, $step = 1) {
if ($this->Block->moveUp($id, $step)) {
$this->Session->setFlash(__d('croogo', 'Moved up successfully'), 'default', array('class' => 'success'));
$this->Session->setFlash(__d('croogo', 'Moved up successfully'), 'flash', array('class' => 'success'));
} else {
$this->Session->setFlash(__d('croogo', 'Could not move up'), 'default', array('class' => 'error'));
$this->Session->setFlash(__d('croogo', 'Could not move up'), 'flash', array('class' => 'error'));
}

return $this->redirect(array('action' => 'index'));
Expand All @@ -220,9 +220,9 @@ public function admin_moveup($id, $step = 1) {
*/
public function admin_movedown($id, $step = 1) {
if ($this->Block->moveDown($id, $step)) {
$this->Session->setFlash(__d('croogo', 'Moved down successfully'), 'default', array('class' => 'success'));
$this->Session->setFlash(__d('croogo', 'Moved down successfully'), 'flash', array('class' => 'success'));
} else {
$this->Session->setFlash(__d('croogo', 'Could not move down'), 'default', array('class' => 'error'));
$this->Session->setFlash(__d('croogo', 'Could not move down'), 'flash', array('class' => 'error'));
}

return $this->redirect(array('action' => 'index'));
Expand Down

0 comments on commit 1dab59a

Please sign in to comment.