Corrected some code logic, sort items were still being displayed when they had been disabled using ListFactory::setField() HEAD
authorSami Barakat <sami@sbarakat.co.uk>
Thu Nov 05 21:33:05 2009 +0000 (2009-11-05)
branchHEAD
changeset 7441142904168971
parent 7440 d2f5a93daea6
child 7442 5f5387780b30
Corrected some code logic, sort items were still being displayed when they had been disabled using ListFactory::setField()
system/classes/listfactory.class.php
     1.1 --- a/system/classes/listfactory.class.php	Thu Nov 05 19:05:28 2009 +0000
     1.2 +++ b/system/classes/listfactory.class.php	Thu Nov 05 21:33:05 2009 +0000
     1.3 @@ -665,42 +665,52 @@
     1.4                  $text = $sort_text . $field['title'];
     1.5                  $href = '';
     1.6                  $selected = '';
     1.7 -                if ($show_sort && $field['sort'] != false)
     1.8 +                
     1.9 +                if ($this->_style == 'inline' && $show_sort && $field['sort'] != false)
    1.10                  {
    1.11                      $direction = $this->_def_sort_arr['direction'];
    1.12  
    1.13                      // Show the sort arrow
    1.14                      if ($this->_sort_arr['field'] === $field['name'])
    1.15                      {
    1.16 +                        // Add drop down item for current sort order
    1.17 +                        $list_templates->set_var('sort_text', $text.' ('.$this->_sort_arr['direction'].')');
    1.18 +                        $list_templates->set_var('sort_href', '');
    1.19 +                        $list_templates->set_var('sort_selected', ' selected="selected"');
    1.20 +                        $list_templates->parse('page_sort', 'sort', true);
    1.21 +
    1.22 +                        // Set up the sort order for the opposite direction
    1.23                          $direction = $this->_sort_arr['direction'] == 'asc' ? 'desc' : 'asc';
    1.24 +                        $text .= " ($direction)";
    1.25 +                    }
    1.26 +                    $href = $this->_page_url . "results={$this->_per_page}&amp;" .
    1.27 +                                "order={$field['name']}&amp;direction=$direction";
    1.28  
    1.29 -                        if ($this->_style == 'inline') {
    1.30 -                            // Add drop down item for current sort order
    1.31 -                            $list_templates->set_var('sort_text', $text.' ('.$this->_sort_arr['direction'].')');
    1.32 -                            $list_templates->set_var('sort_href', '');
    1.33 -                            $list_templates->set_var('sort_selected', ' selected="selected"');
    1.34 -                            $list_templates->parse('page_sort', 'sort', true);
    1.35 +                    // Write field
    1.36 +                    $list_templates->set_var('sort_text', $text);
    1.37 +                    $list_templates->set_var('sort_href', $href);
    1.38 +                    $list_templates->set_var('sort_selected', '');
    1.39 +                    $list_templates->parse('page_sort', 'sort', true);
    1.40 +                }
    1.41 +                else if ($this->_style == 'table')
    1.42 +                {
    1.43 +                    if ($show_sort && $field['sort'] != false)
    1.44 +                    {
    1.45 +                        $text = "<a href=\"$href\">$text</a>";
    1.46  
    1.47 -                            // Set up the sort order for the opposite direction
    1.48 -                            $text .= " ($direction)";
    1.49 -                        } else {
    1.50 +                        if ($this->_sort_arr['field'] === $field['name']) {
    1.51                              $selected = $sort_selected;
    1.52                          }
    1.53                      }
    1.54 -
    1.55                      $href = $this->_page_url . "results={$this->_per_page}&amp;" .
    1.56                                  "order={$field['name']}&amp;direction=$direction";
    1.57  
    1.58 -                    if ($this->_style == 'table') {
    1.59 -                        $text = "<a href=\"$href\">$text</a>";
    1.60 -                    }
    1.61 +                    // Write field
    1.62 +                    $list_templates->set_var('sort_text', $text);
    1.63 +                    $list_templates->set_var('sort_href', $href);
    1.64 +                    $list_templates->set_var('sort_selected', $selected);
    1.65 +                    $list_templates->parse('page_sort', 'sort', true);
    1.66                  }
    1.67 -
    1.68 -                // Write field
    1.69 -                $list_templates->set_var('sort_text', $text);
    1.70 -                $list_templates->set_var('sort_href', $href);
    1.71 -                $list_templates->set_var('sort_selected', $selected);
    1.72 -                $list_templates->parse('page_sort', 'sort', true);
    1.73              }
    1.74          }
    1.75