Changeset 5948
- Timestamp:
- 11/10/07 13:19:52 (1 year ago)
- Files:
-
- plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/actions/actions.class.php (modified) (5 diffs)
- plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_list_ajax_layout.php (modified) (1 diff)
- plugins/sfExtjsThemePlugin/lib/sfAdminCustomGenerator.php (added)
- plugins/sfExtjsThemePlugin/lib/sfExtjsPropelAdminGenerator.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/actions/actions.class.php
r5940 r5948 29 29 } 30 30 $class = ucfirst(strtolower($this->getRequestParameter('class'))); 31 // TODO, add the application-setting, DO THIS ALSO FOR THE NORMAL JSON-DATA action32 $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)) ?>); 33 33 $page = floor($this->getRequestParameter('start', 0) / $limit)+1; 34 34 … … 37 37 // filter, define namespace to autocomplete, to not disturb normal filters of this module 38 38 $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 39 44 40 45 // pager … … 56 61 public function executeJsonList() 57 62 { 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)) ?>); 59 64 $page = floor($this->getRequestParameter('start', 0) / $limit)+1; 60 65 … … 565 570 protected function addFiltersCriteria($c, $namespace = "<?php echo $this->getSingularName() ?>") 566 571 { 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):?> 569 575 <?php $type = $column->getCreoleType() ?> 570 576 <?php if (($column->isPartial() || $column->isComponent()) && $this->getParameterValue('list.fields.'.$column->getName().'.filter_criteria_disabled')) continue ?> … … 619 625 $c->add(<?php echo $this->getPeerClassName() ?>::<?php echo strtoupper($column->getName()) ?>, strtr($this->filters['<?php echo $column->getName() ?>'].$q, '*', '%'), Criteria::LIKE); 620 626 <?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); 622 638 <?php endif; ?> 623 639 } plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_list_ajax_layout.php
r5945 r5948 228 228 //TODO: sortInfo columnName can be wrong! now the latest column is taken, you should be able to set this. 229 229 $options = array('url' => $url, 230 'baseParams' => array('filter' => 'query'), 230 231 'reader' => $jsReader, 231 232 'sortInfo' => array('field' => $class.'_'.$columnName, 'direction' => 'asc'), plugins/sfExtjsThemePlugin/lib/sfExtjsPropelAdminGenerator.php
r5929 r5948 1 1 <?php 2 2 /** 3 * Adds new functionality and extjs possibility to the existing admin generator3 * Adds new functionality regarding Extjs2 to the sfAdminCustomGenerator from DrCore 4 4 * - related fields 5 5 * To use add the following to generate.yml: … … 7 7 * 8 8 */ 9 class sfExtjsPropelAdminGenerator extends sf PropelAdminGenerator9 class sfExtjsPropelAdminGenerator extends sfAdminCustomGenerator 10 10 { 11 11 /** … … 196 196 197 197 /** 198 * Build function to retrieve column value199 *200 * @param object column $column201 * @param boolean $developed (optional) writes out function with current class202 * @param string $prefix203 */204 function getColumnGetter($column, $developed = false, $prefix = '')205 {206 // Setup get method207 $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 classes218 * A dot indicates the existence of a foreign model peer, like:219 * modelpeer.modelpeer.field220 * If fieldname is empty after dot, the __toString method is called.221 * @param string $phpName column name to process222 * @param string $method (optional) function prefix223 */224 private function processColumnName($PhpName, $method = 'get')225 {226 // Detect if there is a dot indicating foreign model peer class227 if (false !== strpos($PhpName, '::'))228 {229 list($peer, $PhpName) = explode('::', $PhpName, 2);230 $peer = ucfirst(strtolower($peer));231 232 // Reiterate for deeper link233 $PhpName = $this->processColumnName($PhpName);234 235 // _ means use __toString method of model peer class236 if ($PhpName == '')237 {238 return $peer;239 }240 // Use foreign model peer class241 else242 {243 return sprintf('%s()->%s%s', $peer, $method, $PhpName);244 }245 }246 else247 {248 return $PhpName;249 }250 }251 252 /**253 198 * Process the column name to check for foreign model peer classes 254 199 * A dot indicates the existence of a foreign model peer, like: … … 396 341 'valueField' => $valueField, 397 342 'displayField' => $relatedClassName."_".$relatedColumn, 398 'queryParam' => 'filters['.$ relatedClassName."_".$relatedColumn.']',343 'queryParam' => 'filters['.$column->getName().']', 399 344 'store' => strtolower($relatedClassPhpName).'_ds' 400 345 );