Development

Changeset 5948

You must first sign up to be able to contribute.

Changeset 5948

Show
Ignore:
Timestamp:
11/10/07 13:19:52 (1 year ago)
Author:
Leon.van.der.Ree
Message:

Split some work of DrCore? out of this plugin, to a seperate generator (which is not depended on Extjs)
Hacked autocomplete, need some polishing ;)

Files:

Legend:

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

    r5940 r5948  
    2929    } 
    3030    $class = ucfirst(strtolower($this->getRequestParameter('class'))); 
    31     // TODO, add the application-setting, DO THIS ALSO FOR THE NORMAL JSON-DATA action 
    32     $limit = $this->getRequestParameter('limit', <?php echo $this->getParameterValue('list.max_per_page', 20) ?>); 
     31     
     32    $limit = $this->getRequestParameter('limit', <?php echo $this->getParameterValue('list.max_per_page', sfConfig::get('app_sf_extjs_theme_plugin_list_max_per_page', 20)) ?>); 
    3333    $page = floor($this->getRequestParameter('start', 0) / $limit)+1; 
    3434 
     
    3737    // filter, define namespace to autocomplete, to not disturb normal filters of this module 
    3838    $this->processFilters("autocomplete"); 
     39 
     40<?php if ($this->getParameterValue('list.filters')): ?> 
     41    $this->filters = $this->getUser()->getAttributeHolder()->getAll('sf_admin/autocomplete/filters'); 
     42<?php endif; ?> 
     43 
    3944 
    4045    // pager 
     
    5661  public function executeJsonList() 
    5762  { 
    58     $limit = $this->getRequestParameter('limit', <?php echo $this->getParameterValue('list.max_per_page', 20) ?>); 
     63    $limit = $this->getRequestParameter('limit', <?php echo $this->getParameterValue('list.max_per_page', sfConfig::get('app_sf_extjs_theme_plugin_list_max_per_page', 20)) ?>); 
    5964    $page = floor($this->getRequestParameter('start', 0) / $limit)+1; 
    6065 
     
    565570  protected function addFiltersCriteria($c, $namespace = "<?php echo $this->getSingularName() ?>") 
    566571  { 
    567 <?php if ($this->getParameterValue('list.filters')): ?> 
    568 <?php foreach ($this->getColumns('list.filters') as $column):?> 
     572<?php if ($this->getParameterValue('list.filters') || $this->getParameterValue('list.display')): ?> 
     573<?php $columns = array_merge($this->getColumns('list.filters'), $this->getColumns('list.display')) ?> 
     574<?php foreach ($columns as $column):?> 
    569575<?php $type = $column->getCreoleType() ?> 
    570576<?php if (($column->isPartial() || $column->isComponent()) && $this->getParameterValue('list.fields.'.$column->getName().'.filter_criteria_disabled')) continue ?> 
     
    619625      $c->add(<?php echo $this->getPeerClassName() ?>::<?php echo strtoupper($column->getName()) ?>, strtr($this->filters['<?php echo $column->getName() ?>'].$q, '*', '%'), Criteria::LIKE); 
    620626<?php else: ?> 
    621       $c->add(<?php echo $this->getPeerClassName() ?>::<?php echo strtoupper($column->getName()) ?>, $this->filters['<?php echo $column->getName() ?>']); 
     627<?php  
     628  $columnName = $column->getName(); 
     629  $peer = $this->getPeerClassName(); 
     630  if (false !== strpos($columnName, '/')) 
     631  { 
     632    list($peer, $columnName) = explode('/', $columnName, 2); 
     633  } 
     634?> 
     635      $q = ''; 
     636      if ($this->getRequest()->getParameter('filter') == 'query') $q = '%'; 
     637      $c->add('<?php echo $peer ?>.<?php echo strtoupper($columnName) ?>', strtr($this->filters['<?php echo $column->getName() ?>'].$q, '*', '%'), Criteria::LIKE); 
    622638<?php endif; ?> 
    623639    } 
  • plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_list_ajax_layout.php

    r5945 r5948  
    228228//TODO: sortInfo columnName can be wrong! now the latest column is taken, you should be able to set this. 
    229229    $options = array('url' => $url, 
     230                     'baseParams' => array('filter' => 'query'), 
    230231                     'reader' => $jsReader, 
    231232                     'sortInfo' => array('field' => $class.'_'.$columnName, 'direction' => 'asc'), 
  • plugins/sfExtjsThemePlugin/lib/sfExtjsPropelAdminGenerator.php

    r5929 r5948  
    11<?php 
    22/** 
    3  * Adds new functionality and extjs possibility to the existing admin generator 
     3 * Adds new functionality regarding Extjs2 to the sfAdminCustomGenerator from DrCore 
    44 * - related fields 
    55 * To use add the following to generate.yml: 
     
    77 * 
    88 */ 
    9 class sfExtjsPropelAdminGenerator extends sfPropelAdminGenerator 
     9class sfExtjsPropelAdminGenerator extends sfAdminCustomGenerator 
    1010{ 
    1111  /** 
     
    196196   
    197197  /** 
    198    * Build function to retrieve column value 
    199    * 
    200    * @param object column $column 
    201    * @param boolean $developed (optional) writes out function with current class 
    202    * @param string $prefix 
    203    */ 
    204   function getColumnGetter($column, $developed = false, $prefix = '') 
    205   { 
    206     // Setup get method 
    207     $getter = 'get'.$this->processColumnName($column->getPhpName()); 
    208  
    209     if ($developed) 
    210     { 
    211       $getter = sprintf('$%s%s->%s()', $prefix, $this->getSingularName(), $getter); 
    212     } 
    213     return $getter; 
    214   } 
    215  
    216   /** 
    217    * Process the column name to check for foreign model peer classes 
    218    * A dot indicates the existence of a foreign model peer, like: 
    219    *   modelpeer.modelpeer.field 
    220    * If fieldname is empty after dot, the __toString method is called. 
    221    * @param string $phpName column name to process 
    222    * @param string $method (optional) function prefix 
    223    */ 
    224   private function processColumnName($PhpName, $method = 'get') 
    225   { 
    226     // Detect if there is a dot indicating foreign model peer class 
    227     if (false !== strpos($PhpName, '::')) 
    228     { 
    229       list($peer, $PhpName) = explode('::', $PhpName, 2); 
    230       $peer = ucfirst(strtolower($peer)); 
    231  
    232       // Reiterate for deeper link 
    233       $PhpName = $this->processColumnName($PhpName); 
    234  
    235       // _ means use __toString method of model peer class 
    236       if ($PhpName == '') 
    237       { 
    238         return $peer; 
    239       } 
    240       // Use foreign model peer class 
    241       else 
    242       { 
    243         return sprintf('%s()->%s%s', $peer, $method, $PhpName); 
    244       } 
    245     } 
    246     else 
    247     { 
    248       return $PhpName; 
    249     } 
    250   } 
    251  
    252   /** 
    253198   * Process the column name to check for foreign model peer classes 
    254199   * A dot indicates the existence of a foreign model peer, like: 
     
    396341                         'valueField' => $valueField, 
    397342                         'displayField' => $relatedClassName."_".$relatedColumn, 
    398                          'queryParam' => 'filters['.$relatedClassName."_".$relatedColumn.']', 
     343                         'queryParam' => 'filters['.$column->getName().']', 
    399344                         'store' => strtolower($relatedClassPhpName).'_ds' 
    400345                        );