Changeset 5102
- Timestamp:
- 09/15/07 09:47:25 (1 year ago)
- Files:
-
- trunk/lib/generator/sfAdminGenerator.class.php (modified) (1 diff)
- trunk/lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/actions/actions.class.php (modified) (1 diff)
- trunk/lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/templates/_list.php (modified) (3 diffs)
- trunk/lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/templates/_list_batch_actions.php (added)
- trunk/lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/templates/_list_td_batch_actions.php (added)
- trunk/lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/templates/listSuccess.php (modified) (1 diff)
- trunk/test/functional/backend/batchActionsTest.php (added)
- trunk/test/functional/backend/customizationTest.php (modified) (1 diff)
- trunk/test/functional/fixtures/project/apps/backend/modules/article/actions/actions.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/generator/sfAdminGenerator.class.php
r5098 r5102 226 226 227 227 /** 228 * Returns HTML code for an action option in a select tag. 229 * 230 * @param string The action name 231 * @param array The parameters 232 * 233 * @return string HTML code 234 */ 235 public function getOptionToAction($actionName, $params) 236 { 237 $options = isset($params['params']) ? sfToolkit::stringToArray($params['params']) : array(); 238 239 // default values 240 if ($actionName[0] == '_') 241 { 242 $actionName = substr($actionName, 1); 243 if ($actionName == 'deleteSelected') 244 { 245 $params['name'] = 'Delete Selected'; 246 } 247 } 248 $name = isset($params['name']) ? $params['name'] : $actionName; 249 250 $options['value'] = $actionName; 251 252 $phpOptions = var_export($options, true); 253 254 return '[?php echo content_tag(\'option\', __(\''.$name.'\')'.($options ? ', '.$phpOptions : '').') ?]'; 255 } 256 257 /** 228 258 * Returns HTML code for a column in edit mode. 229 259 * trunk/lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/actions/actions.class.php
r4934 r5102 51 51 { 52 52 return $this->forward('<?php echo $this->getModuleName() ?>', 'edit'); 53 } 54 55 <?php $listActions = $this->getParameterValue('list.batch_actions') ?> 56 <?php if (null !== $listActions): ?> 57 public function executeBatchAction() 58 { 59 $action = $this->getRequestParameter('sf_admin_batch_action'); 60 switch($action) 61 { 62 <?php foreach ((array) $listActions as $actionName => $params): ?> 63 <?php 64 // default values 65 if ($actionName[0] == '_') 66 { 67 $actionName = substr($actionName, 1); 68 $name = $actionName; 69 $action = $actionName; 70 } 71 else 72 { 73 $name = $actionName; 74 $action = isset($params['action']) ? $params['action'] : sfInflector::camelize($actionName); 75 } 76 ?> 77 case "<?php echo $name ?>": 78 $this->forward('<?php echo $this->getModuleName() ?>', '<?php echo $action ?>'); 79 break; 80 <?php endforeach; ?> 81 } 82 83 return $this->redirect('<?php echo $this->getModuleName() ?>/list'); 84 } 85 <?php endif; ?> 86 87 public function executeDeleteSelected() 88 { 89 $this->selectedItems = $this->getRequestParameter('sf_admin_batch_selection', array()); 90 91 try 92 { 93 <?php echo $this->getClassName() ?>Peer::doDelete($this->selectedItems); 94 } 95 catch (PropelException $e) 96 { 97 $this->getRequest()->setError('delete', 'Could not delete the selected <?php echo sfInflector::humanize($this->getPluralName()) ?>. Make sure they do not have any associated items.'); 98 return $this->forward('<?php echo $this->getModuleName() ?>', 'list'); 99 } 100 101 return $this->redirect('<?php echo $this->getModuleName() ?>/list'); 53 102 } 54 103 trunk/lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/templates/_list.php
r2786 r5102 1 <?php if ($this->getParameterValue('list.batch_actions')): ?> 2 [?php echo form_tag('<?php echo $this->getModuleNAme() ?>/batchAction') ?] 3 <?php endif; ?> 1 4 <table cellspacing="0" class="sf_admin_list"> 2 5 <thead> 3 6 <tr> 7 <?php if ($this->getParameterValue('list.batch_actions')): ?> 8 <th id="sf_admin_list_th_sf_batch_actions">[?php echo checkbox_tag('foo', 1, 0, array('onclick' => "boxes = document.getElementsByTagName('input'); for(index in boxes) { box = boxes[index]; if (box.type == 'checkbox' && box.className == 'sf_admin_batch_checkbox') box.checked = this.checked } return true;")) ?]</th> 9 <?php endif; ?> 4 10 [?php include_partial('list_th_<?php echo $this->getParameterValue('list.layout', 'tabular') ?>') ?] 5 11 <?php if ($this->getParameterValue('list.object_actions')): ?> … … 11 17 [?php $i = 1; foreach ($pager->getResults() as $<?php echo $this->getSingularName() ?>): $odd = fmod(++$i, 2) ?] 12 18 <tr class="sf_admin_row_[?php echo $odd ?]"> 19 [?php include_partial('list_td_batch_actions', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>)) ?] 13 20 [?php include_partial('list_td_<?php echo $this->getParameterValue('list.layout', 'tabular') ?>', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>)) ?] 14 21 [?php include_partial('list_td_actions', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>)) ?] … … 17 24 </tbody> 18 25 <tfoot> 19 <tr><th colspan="<?php echo $this->getParameterValue('list.object_actions') ? count($this->getColumns('list.display')) + 1 : count($this->getColumns('list.display')) ?>">26 <tr><th colspan="<?php echo count($this->getColumns('list.display')) + ($this->getParameterValue('list.object_actions') ? 1 : 0) + ($this->getParameterValue('list.batch_actions') ? 1 : 0) ?>"> 20 27 <div class="float-right"> 21 28 [?php if ($pager->haveToPaginate()): ?] trunk/lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/templates/listSuccess.php
r3310 r5102 24 24 [?php include_partial('<?php echo $this->getModuleName() ?>/list', array('pager' => $pager)) ?] 25 25 [?php endif; ?] 26 [?php include_partial('list_batch_actions') ?] 26 27 [?php include_partial('list_actions') ?] 27 28 </div> trunk/test/functional/backend/customizationTest.php
r4251 r5102 65 65 checkResponseElement('body input[class="sf_admin_action_create"][onclick*="/article/create"]', false)-> 66 66 checkResponseElement('body input[class="myButtonClass"][onclick*="/article/myAction"][value="my button"]', true)-> 67 68 checkListCustomization('add object action button', array('object_actions' => array('_edit' => null, '_delete' => null, 'custom' => array('name' => 'my button', 'action' => 'myAction'))))-> 69 checkResponseElement('table.sf_admin_list tr.sf_admin_row_0 td ul[class="sf_admin_td_actions"]', true)-> 70 checkResponseElement('table.sf_admin_list tr.sf_admin_row_0 td ul[class="sf_admin_td_actions"] li a', 3)-> 71 checkResponseElement('table.sf_admin_list tr.sf_admin_row_0 td ul[class="sf_admin_td_actions"] li a img[title="edit"]', true)-> 72 checkResponseElement('table.sf_admin_list tr.sf_admin_row_0 td ul[class="sf_admin_td_actions"] li a img[title="delete"]', true)-> 73 checkResponseElement('table.sf_admin_list tr.sf_admin_row_0 td ul[class="sf_admin_td_actions"] li a[href*="/article/myAction"] img[title="my button"]', true)-> 67 74 68 75 // edit trunk/test/functional/fixtures/project/apps/backend/modules/article/actions/actions.class.php
r2288 r5102 11 11 class articleActions extends autoarticleActions 12 12 { 13 public function executeMyAction() 14 { 15 return $this->renderText('Selected '.implode(', ', $this->getRequestParameter('sf_admin_batch_selection', array()))); 16 } 13 17 }