Changeset 2786
- Timestamp:
- 11/22/06 19:06:27 (2 years ago)
- Files:
-
- trunk/data/generator/sfPropelAdmin/default/template/actions/actions.class.php (modified) (3 diffs)
- trunk/data/generator/sfPropelAdmin/default/template/templates/_edit_form.php (added)
- trunk/data/generator/sfPropelAdmin/default/template/templates/_edit_messages.php (added)
- trunk/data/generator/sfPropelAdmin/default/template/templates/_list.php (added)
- trunk/data/generator/sfPropelAdmin/default/template/templates/_list_messages.php (added)
- trunk/data/generator/sfPropelAdmin/default/template/templates/editSuccess.php (modified) (1 diff)
- trunk/data/generator/sfPropelAdmin/default/template/templates/listSuccess.php (modified) (1 diff)
- trunk/test/functional/backend/customizationTest.php (modified) (1 diff)
- trunk/test/functional/backend/editfieldnameTest.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/data/generator/sfPropelAdmin/default/template/actions/actions.class.php
r2645 r2786 76 76 { 77 77 return $this->redirect('<?php echo $this->getModuleName() ?>/edit?<?php echo $this->getPrimaryKeyUrlParams('this->') ?>); 78 <?php //' ?>79 78 } 80 79 } 81 80 else 82 81 { 83 // add javascripts 84 $this->getResponse()->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/prototype'); 85 $this->getResponse()->addJavascript(sfConfig::get('sf_admin_web_dir').'/js/collapse'); 86 $this->getResponse()->addJavascript(sfConfig::get('sf_admin_web_dir').'/js/double_list'); 82 $this->addJavascriptsForEdit(); 83 84 $this->labels = $this->getLabels(); 87 85 } 88 86 } … … 126 124 $this-><?php echo $this->getSingularName() ?> = $this->get<?php echo $this->getClassName() ?>OrCreate(); 127 125 $this->update<?php echo $this->getClassName() ?>FromRequest(); 126 127 $this->addJavascriptsForEdit(); 128 129 $this->labels = $this->getLabels(); 128 130 129 131 return sfView::SUCCESS; … … 408 410 } 409 411 } 412 413 protected function addJavascriptsForEdit() 414 { 415 $this->getResponse()->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/prototype'); 416 $this->getResponse()->addJavascript(sfConfig::get('sf_admin_web_dir').'/js/collapse'); 417 $this->getResponse()->addJavascript(sfConfig::get('sf_admin_web_dir').'/js/double_list'); 418 } 419 420 protected function getLabels() 421 { 422 return array( 423 <?php foreach ($this->getColumnCategories('edit.display') as $category): ?> 424 <?php foreach ($this->getColumns('edit.display', $category) as $name => $column): ?> 425 '<?php echo $this->getSingularName() ?>{<?php echo $column->getName() ?>}' => '<?php $label_name = str_replace("'", "\\'", $this->getParameterValue('edit.fields.'.$column->getName().'.name')); echo $label_name ?><?php if ($label_name): ?>:<?php endif ?>', 426 <?php endforeach; ?> 427 <?php endforeach; ?> 428 ); 429 } 410 430 } trunk/data/generator/sfPropelAdmin/default/template/templates/editSuccess.php
r2553 r2786 10 10 11 11 <div id="sf_admin_content"> 12 13 [?php $labels = array( 14 <?php foreach ($this->getColumnCategories('edit.display') as $category): ?> 15 <?php foreach ($this->getColumns('edit.display', $category) as $name => $column): ?> 16 '<?php echo $this->getSingularName() ?>{<?php echo $column->getName() ?>}' => '<?php $label_name = str_replace("'", "\\'", $this->getParameterValue('edit.fields.'.$column->getName().'.name')); echo $label_name ?><?php if ($label_name): ?>:<?php endif ?>', 17 <?php endforeach; ?> 18 <?php endforeach; ?> 19 ); ?] 20 21 [?php if ($sf_request->hasErrors()): ?] 22 <div class="form-errors"> 23 <h2>[?php echo __('There are some errors that prevent the form to validate') ?]</h2> 24 <dl> 25 [?php foreach ($sf_request->getErrorNames() as $name): ?] 26 <dt>[?php echo __($labels[$name]) ?]</dt> 27 <dd>[?php echo $sf_request->getError($name) ?]</dd> 28 [?php endforeach; ?] 29 </dl> 30 </div> 31 [?php elseif ($sf_flash->has('notice')): ?] 32 <div class="save-ok"> 33 <h2>[?php echo __($sf_flash->get('notice')) ?]</h2> 34 </div> 35 [?php endif; ?] 36 37 [?php echo form_tag('<?php echo $this->getModuleName() ?>/edit', 'id=sf_admin_edit_form name=sf_admin_edit_form multipart=true onsubmit=double_list_submit(); return true;') ?] 38 39 <?php foreach ($this->getPrimaryKey() as $pk): ?> 40 [?php echo object_input_hidden_tag($<?php echo $this->getSingularName() ?>, 'get<?php echo $pk->getPhpName() ?>') ?] 41 <?php endforeach; ?> 42 43 <?php foreach ($this->getColumnCategories('edit.display') as $category): ?> 44 <?php 45 if ($category[0] == '-') 46 { 47 $category_name = substr($category, 1); 48 $collapse = true; 49 } 50 else 51 { 52 $category_name = $category; 53 $collapse = false; 54 } 55 ?> 56 <fieldset id="sf_fieldset_<?php echo preg_replace('/[^a-z0-9_]/', '_', strtolower($category_name)) ?>" class="<?php if ($collapse): ?> collapse<?php endif; ?>"> 57 <?php if ($category != 'NONE'): ?><h2>[?php echo __('<?php echo $category_name ?>') ?]</h2> 58 59 <?php endif; ?> 60 <?php foreach ($this->getColumns('edit.display', $category) as $name => $column): ?> 61 <?php if ($column->isPrimaryKey()) continue ?> 62 <?php $credentials = $this->getParameterValue('edit.fields.'.$column->getName().'.credentials') ?> 63 <?php if ($credentials): $credentials = str_replace("\n", ' ', var_export($credentials, true)) ?> 64 [?php if ($sf_user->hasCredential(<?php echo $credentials ?>)): ?] 65 <?php endif; ?> 66 <div class="form-row"> 67 [?php echo label_for('<?php echo $this->getParameterValue("edit.fields.".$column->getName().".label_for", $this->getSingularName()."[".$column->getName()."]") ?>', __($labels['<?php echo $this->getSingularName() ?>{<?php echo $column->getName() ?>}']), '<?php if ($column->isNotNull()): ?>class="required" <?php endif; ?>') ?] 68 <div class="content[?php if ($sf_request->hasError('<?php echo $this->getSingularName() ?>{<?php echo $column->getName() ?>}')): ?] form-error[?php endif; ?]"> 69 [?php if ($sf_request->hasError('<?php echo $this->getSingularName() ?>{<?php echo $column->getName() ?>}')): ?] 70 [?php echo form_error('<?php echo $this->getSingularName() ?>{<?php echo $column->getName() ?>}', array('class' => 'form-error-msg')) ?] 71 [?php endif; ?] 72 73 [?php $value = <?php echo $this->getColumnEditTag($column); ?>; echo $value ? $value : ' ' ?] 74 <?php echo $this->getHelp($column, 'edit') ?> 75 </div> 76 </div> 77 <?php if ($credentials): ?> 78 [?php endif; ?] 79 <?php endif; ?> 80 81 <?php endforeach; ?> 82 </fieldset> 83 <?php endforeach; ?> 84 85 [?php include_partial('edit_actions', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>)) ?] 86 87 </form> 88 89 <ul class="sf_admin_actions"> 90 <?php 91 /* 92 * WARNING: delete is a form, it must be outside the main form 93 */ 94 $editActions = $this->getParameterValue('edit.actions'); 95 ?> 96 <?php if (null === $editActions || (null !== $editActions && array_key_exists('_delete', $editActions))): ?> 97 <?php echo $this->addCredentialCondition($this->getButtonToAction('_delete', $editActions['_delete'], true), $editActions['_delete']) ?> 98 <?php endif; ?> 99 </ul> 100 12 [?php include_partial('<?php echo $this->getModuleName() ?>/edit_messages', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>, 'labels' => $labels)) ?] 13 [?php include_partial('<?php echo $this->getModuleName() ?>/edit_form', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>, 'labels' => $labels)) ?] 101 14 </div> 102 15 trunk/data/generator/sfPropelAdmin/default/template/templates/listSuccess.php
r2642 r2786 7 7 <div id="sf_admin_header"> 8 8 [?php include_partial('<?php echo $this->getModuleName() ?>/list_header', array('pager' => $pager)) ?] 9 [?php if ($sf_request->getError('delete')): ?] 10 <div class="form-errors"> 11 <h2>Could not delete the selected <?php echo sfInflector::humanize($this->getSingularName()) ?></h2> 12 <ul> 13 <li>[?php echo $sf_request->getError('delete') ?]</li> 14 </ul> 15 </div> 16 [?php endif; ?] 9 [?php include_partial('<?php echo $this->getModuleName() ?>/list_messages', array('pager' => $pager)) ?] 17 10 </div> 18 11 19 12 <div id="sf_admin_bar"> 20 21 13 <?php if ($this->getParameterValue('list.filters')): ?> 22 14 [?php include_partial('filters', array('filters' => $filters)) ?] 23 15 <?php endif; ?> 24 25 16 </div> 26 17 27 18 <div id="sf_admin_content"> 28 29 19 [?php if(!$pager->getNbResults()): ?] 30 20 [?php echo __('no result') ?] 31 21 [?php else: ?] 32 <table cellspacing="0" class="sf_admin_list"> 33 <thead> 34 <tr> 35 [?php include_partial('list_th_<?php echo $this->getParameterValue('list.layout', 'tabular') ?>') ?] 36 <?php if ($this->getParameterValue('list.object_actions')): ?> 37 <th id="sf_admin_list_th_sf_actions">[?php echo __('Actions') ?]</th> 38 <?php endif; ?> 39 </tr> 40 </thead> 41 <tbody> 42 [?php $i = 1; foreach ($pager->getResults() as $<?php echo $this->getSingularName() ?>): $odd = fmod(++$i, 2) ?] 43 <tr class="sf_admin_row_[?php echo $odd ?]"> 44 [?php include_partial('list_td_<?php echo $this->getParameterValue('list.layout', 'tabular') ?>', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>)) ?] 45 [?php include_partial('list_td_actions', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>)) ?] 46 </tr> 47 [?php endforeach; ?] 48 </tbody> 49 <tfoot> 50 <tr><th colspan="<?php echo $this->getParameterValue('list.object_actions') ? count($this->getColumns('list.display')) + 1 : count($this->getColumns('list.display')) ?>"> 51 <div class="float-right"> 52 [?php if ($pager->haveToPaginate()): ?] 53 [?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/first.png', array('align' => 'absmiddle', 'alt' => __('First'), 'title' => __('First'))), '<?php echo $this->getModuleName() ?>/list?page=1') ?] 54 [?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/previous.png', array('align' => 'absmiddle', 'alt' => __('Previous'), 'title' => __('Previous'))), '<?php echo $this->getModuleName() ?>/list?page='.$pager->getPreviousPage()) ?] 55 56 [?php foreach ($pager->getLinks() as $page): ?] 57 [?php echo link_to_unless($page == $pager->getPage(), $page, '<?php echo $this->getModuleName() ?>/list?page='.$page) ?] 58 [?php endforeach; ?] 59 60 [?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/next.png', array('align' => 'absmiddle', 'alt' => __('Next'), 'title' => __('Next'))), '<?php echo $this->getModuleName() ?>/list?page='.$pager->getNextPage()) ?] 61 [?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/last.png', array('align' => 'absmiddle', 'alt' => __('Last'), 'title' => __('Last'))), '<?php echo $this->getModuleName() ?>/list?page='.$pager->getLastPage()) ?] 22 [?php include_partial('<?php echo $this->getModuleName() ?>/list', array('pager' => $pager)) ?] 62 23 [?php endif; ?] 63 </div>64 [?php echo format_number_choice('[0] no result|[1] 1 result|(1,+Inf] %1% results', array('%1%' => $pager->getNbResults()), $pager->getNbResults()) ?]65 </th></tr>66 </tfoot>67 </table>68 [?php endif; ?]69 70 24 [?php include_partial('list_actions') ?] 71 72 25 </div> 73 26 trunk/test/functional/backend/customizationTest.php
r2602 r2786 74 74 checkResponseElement('body h1', 'edit "foo title"')-> 75 75 76 // edit fields77 checkEditCustomization('edit field name customization', array('fields' => array('body' => array('name' => 'My Body'))))->78 checkResponseElement('label[for="article_body"]', 'My Body:')->79 80 76 // edit fields display 81 77 checkEditCustomization('edit fields display customization', array('display' => array('body', 'title')))->