Development

Changeset 6819

You must first sign up to be able to contribute.

Changeset 6819

Show
Ignore:
Timestamp:
12/30/07 03:16:16 (1 year ago)
Author:
Leon.van.der.Ree
Message:

improved list actions, with template per action so you can easily override them

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_edit_ajax_actions.php

    r6586 r6819  
    2828  // save template file 
    2929  $template = '_'.$edit_name.'_ajax_actions.php'; 
    30   $generatedModuleName = 'auto'.$this->className
     30  $generatedModuleName = 'auto'.ucfirst(strToLower($this->className))
    3131  $this->getGeneratorManager()->getCache()->set($template, $generatedModuleName.DIRECTORY_SEPARATOR.'templates', $retval); 
    3232}  
  • plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_edit_form_ajax_tabpages.php

    r6718 r6819  
    3232    $content .= $innerContent; 
    3333    $content .= '</div>'; 
    34   
    3534     
    3635    // replace [?php and ?] 
     
    4443    // save template file 
    4544    $template = '_'.$edit_name.'_form_ajax.php'; 
    46     $generatedModuleName = 'auto'.$this->className
     45    $generatedModuleName = 'auto'.ucfirst(strToLower($this->className))
    4746    $this->getGeneratorManager()->getCache()->set($template, $generatedModuleName.DIRECTORY_SEPARATOR.'templates', $retval); 
    4847     
    4948?> 
    5049      include_partial('<?php echo $edit_name?>_form_ajax', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>, 'labels' => $labels));  
    51 <?php       
    52   endforeach; 
    53 ?> 
     50<?php endforeach; ?> 
    5451?] 
    5552</div> 
  • plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_list_ajax_actions.php

    r6146 r6819  
    11 
    22<?php $listActions = $this->getParameterValue('list.actions') ?> 
    3 <?php if (null !== $listActions): ?> 
    4   <?php foreach ((array) $listActions as $actionName => $params): ?> 
    5     <?php echo $this->addCredentialCondition($this->getAjaxButtonToToolbarAction($actionName, $params, false), $params) ?> 
    6   <?php endforeach; ?> 
    7 <?php else: ?> 
    8   <?php echo $this->getAjaxButtonToToolbarAction('_create', array('name' => 'Add new '.$this->getClassName()), false) ?> 
    9   <?php echo $this->getAjaxButtonToToolbarAction('_refresh', array(), false) ?> 
    10 <?php endif; ?> 
     3<?php  
     4if (null === $listActions) 
     5
     6  $listActions = array( 
     7    '_create' => array(),  
     8    '_refresh' => array() 
     9  ); 
     10
     11?> 
     12 
     13<?php foreach ((array) $listActions as $actionName => $params): ?> 
     14<?php 
     15  //get 'super' template 
     16  ob_start(); 
     17  require('__list_ajax_action.php'); 
     18  $content = ob_get_clean(); 
     19 
     20  // save template file, HACK: resolving the modulename might not always be correct but what symfony does is really dirty.... 
     21  $template = '_list_ajax_action_'.$actionName.'.php'; 
     22  $generatedModuleName = 'auto'.ucfirst(strToLower($this->className)); 
     23  $this->getGeneratorManager()->getCache()->set($template, $generatedModuleName.DIRECTORY_SEPARATOR.'templates', $content); 
     24   
     25?> 
     26  [?php include_partial('list_ajax_action_<?php echo $actionName?>'); ?]  
     27<?php endforeach; ?> 
  • plugins/sfExtjsThemePlugin/lib/sfExtjsPropelAdminGenerator.php

    r6720 r6819  
    3535      $default_icon   = sfConfig::get('sf_admin_web_dir').'/images/'.$actionName.'_icon.png'; 
    3636      $default_action = $actionName; 
    37       $default_class  = 'sf_admin_action_'.$actionName; 
     37      $default_class  = 'btn_'.$actionName; 
    3838      $default_handler_function = "Ext.Msg.alert('Error','handler_function is not defined!');"; 
    3939       
     
    4848          break; 
    4949        case 'create': 
    50           $name = isset($params['name']) ? $params['name'] : $default_name
    51           $default_handler_function = "addTab('".$name."', { url: '".$controller->genUrl($this->getModuleName().'/create')."', scripts: true, method: 'GET' }, 'create_".$this->getClassName()."')"; 
     50          $default_name = isset($params['name']) ? $params['name'] : 'Add new '.$this->getClassName()
     51          $default_handler_function = "addTab('".$default_name."', { url: '".$controller->genUrl($this->getModuleName().'/create')."', scripts: true, method: 'GET' }, 'create_".$this->getClassName()."')"; 
    5252          break; 
    5353        case 'refresh': 
     
    7373    if (!isset($options['class'])) 
    7474    { 
    75       if ($default_class) 
     75      if (isset($params['class'])) 
     76      { 
     77        $options['class'] = $params['class'];  
     78      } 
     79      elseif ($default_class) 
    7680      { 
    7781        $options['class'] = $default_class; 
     
    8286      } 
    8387    } 
     88    $actionClass = $options['class']; 
    8489 
    8590    $html = ''; 
     
    101106 
    102107    // little hack 
     108    //TODO: phpOptions is not used! 
    103109    $phpOptions = preg_replace("/'confirm' => '(.+?)(?<!\\\)'/", '\'confirm\' => __(\'$1\')', $phpOptions); 
    104110 
     
    109115                action: '".$action."', 
    110116                idRequired: false, 
    111                 cls: 'x-btn-text-icon btn_".$actionName."', 
     117                cls: 'x-btn-text-icon ".$actionClass."', 
    112118                disabled: false, 
    113119                handler : function(){ ".$handler_function." }