Ignore:
Timestamp:
Jun 3, 2006 7:47:48 PM (18 years ago)
Author:
scdev
Message:

Q - Merged branches/2.0singleton into trunk. Completed updating classes to use singleton methods. Implemented tests. Fixed some bugs. Changed some interfaces.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/SortOrder.inc.php

    r119 r136  
    6969    function setDefault($default_sort = '', $default_order = '')
    7070    {
     71        $prefs =& Prefs::getInstance();
     72
    7173        // Which column to sort by?
    7274        // (1) By GET or POST specification, if available.
     
    7678        if (!empty($new_sort_by)) {
    7779            $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']);
    8183        } else {
    8284            $this->sort_by = $default_sort;
     
    9092        if (!empty($new_order)) {
    9193            $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']);
    9597        } else {
    9698            $this->order = $default_order;
     
    109111    function set($sort = null, $order = null)
    110112    {
     113        $prefs =& Prefs::getInstance();
     114
    111115        // Set new sort value.
    112116        if (isset($sort)) {
    113117            $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']);
    115119        }
    116120
     
    118122        if (isset($order)) {
    119123            $this->order = $order;
    120             Prefs::setValue('sort_order', $this->order, $_SERVER['PHP_SELF']);
     124            $prefs->set('sort_order', $this->order, $_SERVER['PHP_SELF']);
    121125        }
    122126    }
     
    128132    function getSortOrderSQL()
    129133    {
     134        $app =& App::getInstance();
     135        $db =& DB::getInstance();
     136
    130137        if (!isset($this->_columns[strtolower($this->sort_by)])) {
    131138            $this->sort_by = $this->default_sort;
     
    137144
    138145        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)]));
    140147        } 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__);
    142149            return '';
    143150        }
     
    155162    function printSortHeader($col, $col_name, $default_order='ASC')
    156163    {
     164        $app =& App::getInstance();
     165
    157166        if ($this->sort_by == $col) {
    158167            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; ?><?php
     168                ?><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
    160169            } 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; ?><?php
     170                ?><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
    162171            }
    163172        } 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><?php
     173            ?><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
    165174        }
    166175    }
Note: See TracChangeset for help on using the changeset viewer.