Skip to content

Commit

Permalink
adding a helper for generating buttons for mass actions [#67]
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Jan 4, 2010
1 parent 2f63e43 commit f09e3c3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
18 changes: 18 additions & 0 deletions app_helper.php
Expand Up @@ -326,5 +326,23 @@ function niceBoxEnd()
{
return '<div class="bottom"><div class="bottom"><div class="bottom"></div></div></div></div>';
}

function massActionButtons( $buttons = null )
{
if ( !$buttons )
{
$this->errors[] = 'No buttons set';
return false;
}

$out = '';

foreach( $buttons as $button )
{
$out .= $this->Form->button( __( Inflector::humanize( $button ), true ), array( 'value' => strtolower( str_replace( array( '-', ' ' ), '_', $button ) ), 'name' => 'action' ) );
}

return $out;
}
}
?>
2 changes: 1 addition & 1 deletion plugins/blog/views/helpers/blog.php
Expand Up @@ -20,7 +20,7 @@ class BlogHelper extends AppHelper
{
var $helpers = array(
//cake helpers
'Html', 'Text', 'Time',
'Html', 'Form', 'Text', 'Time',

// core helpers
'Core.Wysiwyg'
Expand Down
13 changes: 8 additions & 5 deletions plugins/blog/views/posts/admin_index.ctp
Expand Up @@ -16,12 +16,11 @@
* @subpackage blog.views.posts.admin_index
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/

echo $this->Form->create( 'Post', array( 'url' => array( 'controller' => 'posts', 'action' => 'mass', 'admin' => 'true' ) ) );
echo $this->Blog->adminIndexHead( $this, $paginator, $filterOptions );
?>
<div class="table">
<?php echo $this->Blog->adminTableHeadImages(); ?>
<?php echo $this->Form->create( 'Post', array( 'url' => array( 'controller' => 'posts', 'action' => 'mass', 'admin' => 'true' ) ) ); ?>
<table class="listing" cellpadding="0" cellspacing="0">
<?php
echo $this->Blog->adminTableHeader(
Expand Down Expand Up @@ -82,9 +81,13 @@
?>
</table>
<?php
echo $this->Form->button( __( 'Toggle', true ), array( 'value' => 'toggle', 'name' => 'action' ) );
echo $this->Form->button( __( 'Copy', true ), array( 'value' => 'copy', 'name' => 'action' ) );
echo $this->Form->button( __( 'Delete', true ), array( 'value' => 'delete', 'name' => 'action' ) );
echo $this->Blog->massActionButtons(
array(
'toggle',
'copy',
'delete'
)
);
echo $this->Form->end();

?>
Expand Down

0 comments on commit f09e3c3

Please sign in to comment.