Changeset 136 for trunk/lib/SortOrder.inc.php
- Timestamp:
- Jun 3, 2006 7:47:48 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/SortOrder.inc.php
r119 r136 69 69 function setDefault($default_sort = '', $default_order = '') 70 70 { 71 $prefs =& Prefs::getInstance(); 72 71 73 // Which column to sort by? 72 74 // (1) By GET or POST specification, if available. … … 76 78 if (!empty($new_sort_by)) { 77 79 $this->sort_by = $new_sort_by; 78 Prefs::setValue('sort_by', $this->sort_by, $_SERVER['PHP_SELF']);79 } else if ( Prefs::exists('sort_by', $_SERVER['PHP_SELF'])) {80 $this->sort_by = Prefs::getValue('sort_by', $_SERVER['PHP_SELF']);80 $prefs->set('sort_by', $this->sort_by, $_SERVER['PHP_SELF']); 81 } else if ($prefs->exists('sort_by', $_SERVER['PHP_SELF'])) { 82 $this->sort_by = $prefs->get('sort_by', $_SERVER['PHP_SELF']); 81 83 } else { 82 84 $this->sort_by = $default_sort; … … 90 92 if (!empty($new_order)) { 91 93 $this->order = $new_order; 92 Prefs::setValue('sort_order', $this->order, $_SERVER['PHP_SELF']);93 } else if ( Prefs::exists('sort_order', $_SERVER['PHP_SELF'])) {94 $this->order = Prefs::getValue('sort_order', $_SERVER['PHP_SELF']);94 $prefs->set('sort_order', $this->order, $_SERVER['PHP_SELF']); 95 } else if ($prefs->exists('sort_order', $_SERVER['PHP_SELF'])) { 96 $this->order = $prefs->get('sort_order', $_SERVER['PHP_SELF']); 95 97 } else { 96 98 $this->order = $default_order; … … 109 111 function set($sort = null, $order = null) 110 112 { 113 $prefs =& Prefs::getInstance(); 114 111 115 // Set new sort value. 112 116 if (isset($sort)) { 113 117 $this->sort_by = $sort; 114 Prefs::setValue('sort_by', $this->sort_by, $_SERVER['PHP_SELF']);118 $prefs->set('sort_by', $this->sort_by, $_SERVER['PHP_SELF']); 115 119 } 116 120 … … 118 122 if (isset($order)) { 119 123 $this->order = $order; 120 Prefs::setValue('sort_order', $this->order, $_SERVER['PHP_SELF']);124 $prefs->set('sort_order', $this->order, $_SERVER['PHP_SELF']); 121 125 } 122 126 } … … 128 132 function getSortOrderSQL() 129 133 { 134 $app =& App::getInstance(); 135 $db =& DB::getInstance(); 136 130 137 if (!isset($this->_columns[strtolower($this->sort_by)])) { 131 138 $this->sort_by = $this->default_sort; … … 137 144 138 145 if (!empty($this->_columns[strtolower($this->sort_by)][strtolower($this->order)])) { 139 return sprintf(' ORDER BY %s ', DB::escapeString($this->_columns[strtolower($this->sort_by)][strtolower($this->order)]));146 return sprintf(' ORDER BY %s ', $db->escapeString($this->_columns[strtolower($this->sort_by)][strtolower($this->order)])); 140 147 } else { 141 App::logMsg(sprintf('Could not find SQL to sort by %s %s.', $this->sort_by, $this->order), LOG_WARNING, __FILE__, __LINE__);148 $app->logMsg(sprintf('Could not find SQL to sort by %s %s.', $this->sort_by, $this->order), LOG_WARNING, __FILE__, __LINE__); 142 149 return ''; 143 150 } … … 155 162 function printSortHeader($col, $col_name, $default_order='ASC') 156 163 { 164 $app =& App::getInstance(); 165 157 166 if ($this->sort_by == $col) { 158 167 if (strtolower($this->order) == 'desc') { 159 ?><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=ASC'); ?>" title="<?php echo _("Change to ascending sort order"); ?>"><?php echo $this->desc_widget; ?></a><?php echo $col_name; ?><?php168 ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=ASC'); ?>" title="<?php echo _("Change to ascending sort order"); ?>"><?php echo $this->desc_widget; ?></a><?php echo $col_name; ?><?php 160 169 } else { 161 ?><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=DESC'); ?>" title="<?php echo _("Change to descending sort order"); ?>"><?php echo $this->asc_widget; ?></a><?php echo $col_name; ?><?php170 ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=DESC'); ?>" title="<?php echo _("Change to descending sort order"); ?>"><?php echo $this->asc_widget; ?></a><?php echo $col_name; ?><?php 162 171 } 163 172 } else { 164 ?><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=' . $default_order); ?>" title="<?php echo sprintf(_("Sort by %s"), $col_name); ?>"><?php echo $col_name; ?></a><?php173 ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=' . $default_order); ?>" title="<?php echo sprintf(_("Sort by %s"), $col_name); ?>"><?php echo $col_name; ?></a><?php 165 174 } 166 175 }
Note: See TracChangeset
for help on using the changeset viewer.