Development

#2953: list_params_carry_over.patch

You must first sign up to be able to contribute.

Ticket #2953: list_params_carry_over.patch

File list_params_carry_over.patch, 10.5 kB (added by manickam, 11 months ago)

Carry over parameters in the sort/page/filter links

  • lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/templates/_filters.php

    old new  
    2525<?php endif; ?> 
    2626 
    2727    <?php endforeach; ?> 
     28    [?php echo $param_tags; ?] 
    2829  </fieldset> 
    2930 
    3031  <ul class="sf_admin_actions"> 
    31     <li>[?php echo button_to(__('reset'), '<?php echo $this->getModuleName() ?>/list?filter=filter', 'class=sf_admin_action_reset_filter') ?]</li> 
     32    <li>[?php echo button_to(__('reset'), '<?php echo $this->getModuleName() ?>/list?filter=filter'.$param_args, 'class=sf_admin_action_reset_filter') ?]</li> 
    3233    <li>[?php echo submit_tag(__('filter'), 'name=filter class=sf_admin_action_filter') ?]</li> 
    3334  </ul> 
    3435 
  • lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/templates/_list.php

    old new  
     1[?php //Set the filter Argument  
     2 
     3    $filters = $sf_request->getParameterHolder()->get('filters'); 
     4    $filter_args = ''; 
     5    foreach( $filters as $key => $value ) 
     6    { 
     7        if( $value ) 
     8        { 
     9            if( is_array( $value ) ) 
     10            { 
     11                foreach( $value as $key2 => $val) 
     12                { 
     13                    if( $val ) 
     14                    { 
     15                        $filter_args .= "&filters[$key][$key2]=$val"; 
     16                    } 
     17                } 
     18            } 
     19            else 
     20            { 
     21                $filter_args .= "&filters[$key]=$value"; 
     22            } 
     23        } 
     24    } 
     25    $filter_args .= '&filter=filter'; 
     26 
     27?] 
     28 
     29[?php   $sort = $sf_params->get('sort'); 
     30    if( $sort ) 
     31    { 
     32        $sort_args = "&sort=$sort&type=".$sf_params->get( 'type' ); 
     33    } 
     34?] 
     35 
    136<?php if ($this->getParameterValue('list.batch_actions')): ?> 
    237[?php echo form_tag('<?php echo $this->getModuleNAme() ?>/batchAction') ?] 
    338<?php endif; ?> 
     
    742<?php if ($this->getParameterValue('list.batch_actions')): ?> 
    843  <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> 
    944<?php endif; ?> 
    10 [?php include_partial('list_th_<?php echo $this->getParameterValue('list.layout', 'tabular') ?>') ?] 
     45[?php include_partial('list_th_<?php echo $this->getParameterValue('list.layout', 'tabular') ?>', array( 'filter_args' => $filter_args, 'param_args' => $param_args) ) ?] 
    1146<?php if ($this->getParameterValue('list.object_actions')): ?> 
    1247  <th id="sf_admin_list_th_sf_actions">[?php echo __('Actions') ?]</th> 
    1348<?php endif; ?> 
     
    1752<tr><th colspan="<?php echo count($this->getColumns('list.display')) + ($this->getParameterValue('list.object_actions') ? 1 : 0) + ($this->getParameterValue('list.batch_actions') ? 1 : 0) ?>"> 
    1853<div class="float-right"> 
    1954[?php if ($pager->haveToPaginate()): ?] 
    20   [?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') ?] 
    21   [?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  [?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'.$filter_args.$param_args.$sort_args) ?] 
     56  [?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().$filter_args.$param_args.$sort_args) ?] 
    2257 
    2358  [?php foreach ($pager->getLinks() as $page): ?] 
    24     [?php echo link_to_unless($page == $pager->getPage(), $page, '<?php echo $this->getModuleName() ?>/list?page='.$page) ?] 
     59    [?php echo link_to_unless($page == $pager->getPage(), $page, '<?php echo $this->getModuleName() ?>/list?page='.$page.$filter_args.$param_args.$sort_args) ?] 
    2560  [?php endforeach; ?] 
    2661 
    27   [?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()) ?] 
    28   [?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()) ?] 
     62  [?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().$filter_args.$param_args.$sort_args) ?] 
     63  [?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().$filter_args.$param_args.$sort_args) ?] 
    2964[?php endif; ?] 
    3065</div> 
    31 [?php echo format_number_choice('[0] no result|[1] 1 result|(1,+Inf] %1% results', array('%1%' => $pager->getNbResults()), $pager->getNbResults()) ?] 
     66[?php echo $pager->getFirstIndice()." to ".$pager->getLastIndice()." of ".format_number_choice('[0] no result|[1] 1 result|(1,+Inf] %1% results', array('%1%' => $pager->getNbResults()), $pager->getNbResults()) ?] 
    3267</th></tr> 
    3368</tfoot> 
    3469<tbody> 
  • lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/templates/_list_th_tabular.php

    old new  
    88  <th id="sf_admin_list_th_<?php echo $column->getName() ?>"> 
    99    <?php if ($column->isReal()): ?> 
    1010      [?php if ($sf_user->getAttribute('sort', null, 'sf_admin/<?php echo $this->getSingularName() ?>/sort') == '<?php echo $column->getName() ?>'): ?] 
    11       [?php echo link_to(__('<?php echo str_replace("'", "\\'", $this->getParameterValue('list.fields.'.$column->getName().'.name')) ?>'), '<?php echo $this->getModuleName() ?>/list?sort=<?php echo $column->getName() ?>&type='.($sf_user->getAttribute('type', 'asc', 'sf_admin/<?php echo $this->getSingularName() ?>/sort') == 'asc' ? 'desc' : 'asc')) ?] 
     11      [?php echo link_to(__('<?php echo str_replace("'", "\\'", $this->getParameterValue('list.fields.'.$column->getName().'.name')) ?>'), '<?php echo $this->getModuleName() ?>/list?sort=<?php echo $column->getName() ?>&type='.($sf_user->getAttribute('type', 'asc', 'sf_admin/<?php echo $this->getSingularName() ?>/sort') == 'asc' ? 'desc' : 'asc').$filter_args.$param_args) ?] 
    1212      ([?php echo __($sf_user->getAttribute('type', 'asc', 'sf_admin/<?php echo $this->getSingularName() ?>/sort')) ?]) 
    1313      [?php else: ?] 
    14       [?php echo link_to(__('<?php echo str_replace("'", "\\'", $this->getParameterValue('list.fields.'.$column->getName().'.name')) ?>'), '<?php echo $this->getModuleName() ?>/list?sort=<?php echo $column->getName() ?>&type=asc') ?] 
     14      [?php echo link_to(__('<?php echo str_replace("'", "\\'", $this->getParameterValue('list.fields.'.$column->getName().'.name')) ?>'), '<?php echo $this->getModuleName() ?>/list?sort=<?php echo $column->getName() ?>&type=asc'.$filter_args.$param_args) ?] 
    1515      [?php endif; ?] 
    1616    <?php else: ?> 
    1717    [?php echo __('<?php echo str_replace("'", "\\'", $this->getParameterValue('list.fields.'.$column->getName().'.name')) ?>') ?] 
  • lib/plugins/sfPropelPlugin/data/generator/sfPropelAdmin/default/template/templates/listSuccess.php

    old new  
    22 
    33[?php use_stylesheet('<?php echo $this->getParameterValue('css', sfConfig::get('sf_admin_web_dir').'/css/main') ?>') ?] 
    44 
     5[?php 
     6    $params = $sf_request->getParameterHolder()->getAll(); 
     7    $param_args = ''; 
     8    $sorted = $sf_params->get( 'sort' );//Used to make sure 'type' parameter is passed to links unless it is for sorting purposes 
     9    foreach( $params as $key => $value ) 
     10    { 
     11        if( $value && !is_array( $value ) && strcmp( $key, 'filter') != 0  && strcmp( $key, 'page' ) != 0  
     12            && strcmp( $key, 'module') != 0 && strcmp( $key, 'action' ) != 0 
     13            && ( !$sorted || ( strcmp( $key, 'sort' ) != 0 && strcmp( $key, 'type' ) ) ) ) 
     14        { 
     15            $param_args .= "&$key=$value"; 
     16            $param_tags .= input_hidden_tag( "$key", "$value" ); 
     17        } 
     18    } 
     19    //echo "<br/>Param Args = $param_args<br/>"; 
     20?] 
    521<div id="sf_admin_container"> 
    622 
    723<h1><?php echo $this->getI18NString('list.title', $this->getModuleName().' list') ?></h1> 
     
    1329 
    1430<div id="sf_admin_bar"> 
    1531<?php if ($this->getParameterValue('list.filters')): ?> 
    16 [?php include_partial('filters', array('filters' => $filters)) ?] 
     32[?php include_partial('filters', array('filters' => $filters, 'param_args' => $param_args, 'param_tags' => $param_tags)) ?] 
    1733<?php endif; ?> 
    1834</div> 
    1935 
     
    2137[?php if (!$pager->getNbResults()): ?] 
    2238[?php echo __('no result') ?] 
    2339[?php else: ?] 
    24 [?php include_partial('<?php echo $this->getModuleName() ?>/list', array('pager' => $pager)) ?] 
     40[?php include_partial('<?php echo $this->getModuleName() ?>/list', array('pager' => $pager, 'param_args' => $param_args)) ?] 
    2541[?php endif; ?] 
    2642[?php include_partial('list_batch_actions') ?] 
    2743[?php include_partial('list_actions') ?]