Changeset 132


Ignore:
Timestamp:
May 30, 2006 10:05:54 PM (18 years ago)
Author:
scdev
Message:

updated Prefs:: and SessionCache::

Location:
branches/2.0singleton
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0singleton/bin/module_maker/skel/admin.php

    r130 r132  
    3232// The object to validate form input.
    3333$fv = new FormValidator();
     34
     35$cache =& SessionCache::getInstance();
    3436
    3537%SORT_ORDER%
     
    5658if (getFormData('break_list_cache', false)) {
    5759    // Break the cache because we are changing the list data.
    58     SessionCache::breakCache($_SERVER['PHP_SELF']);
     60    $cache->breakCache($_SERVER['PHP_SELF']);
    5961}
    6062
     
    248250    global $lock;
    249251    $db =& DB::getInstance();
     252    $cache =& SessionCache::getInstance();
    250253   
    251254    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id);
     
    255258
    256259    // Break the cache because we are changing the list data.
    257     SessionCache::breakCache($_SERVER['PHP_SELF']);
     260    $cache->breakCache($_SERVER['PHP_SELF']);
    258261
    259262    // Get the information for this object.
     
    282285    global $auth;
    283286    $db =& DB::getInstance();
     287    $cache =& SessionCache::getInstance();
    284288   
    285289    // Break the cache because we are changing the list data.
    286     SessionCache::breakCache($_SERVER['PHP_SELF']);
     290    $cache->breakCache($_SERVER['PHP_SELF']);
    287291
    288292%INSERT%
     
    300304function updateRecord($frm)
    301305{
    302     global $auth, $lock;
    303 
     306    global $auth, $lock;
     307    $app =& App::getInstance();
     308    $cache =& SessionCache::getInstance();
     309   
    304310    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%']);
    305311    if ($lock->isLocked() && !$lock->isMine()) {
     
    308314
    309315    // Break the cache because we are changing the list data.
    310     SessionCache::breakCache($_SERVER['PHP_SELF']);
     316    $cache->breakCache($_SERVER['PHP_SELF']);
    311317
    312318%UPDATE%
     
    327333    global $so;
    328334    $db =& DB::getInstance();
     335    $prefs =& Prefs::getInstance();
     336    $cache =& SessionCache::getInstance();
    329337   
    330338    $where_clause = '';
     
    375383    // without knowing the hash.
    376384    $cache_hash = md5($sql . '|' . $page->total_items);
    377     if (Prefs::getValue('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) {
    378         SessionCache::breakCache($_SERVER['PHP_SELF']);
    379         Prefs::setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
    380     }
    381 
    382     if (SessionCache::isCached($_SERVER['PHP_SELF'])) {
     385    if ($prefs->getValue('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) {
     386        $cache->breakCache($_SERVER['PHP_SELF']);
     387        $prefs->setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
     388    }
     389
     390    if ($cache->isCached($_SERVER['PHP_SELF'])) {
    383391        // Get the cached results.
    384         $list = SessionCache::getCache($_SERVER['PHP_SELF']);
     392        $list = $cache->getCache($_SERVER['PHP_SELF']);
    385393    } else {
    386394        // If the list is not already cached, query now.
     
    393401        if (isset($list) && !empty($list)) {
    394402            // Cache the results.
    395             SessionCache::putCache($list, $_SERVER['PHP_SELF']);
     403            $cache->putCache($list, $_SERVER['PHP_SELF']);
    396404        }
    397405    }
     
    403411{
    404412    $db =& DB::getInstance();
     413    $cache =& SessionCache::getInstance();
    405414   
    406415    if (!is_array($ranks)) {
     
    410419
    411420    // Break the cache because we are changing the list data.
    412     SessionCache::breakCache($_SERVER['PHP_SELF']);
     421    $cache->breakCache($_SERVER['PHP_SELF']);
    413422
    414423    // Count the ranks with invalid numbers
  • branches/2.0singleton/lib/PageNumbers.inc.php

    r130 r132  
    7272    function setPerPage($per_page, $default=25, $save_value=true)
    7373    {
    74         // (1) By provided argument, if valid.
     74        $prefs =& Prefs::getInstance();
     75   
     76        // (1) By provided argument, if valid.
    7577        // (2) By saved preference, if available.
    7678        // (3) Set to default value if provided and valid.
     
    7981            $this->_per_page = $per_page;
    8082            if ($save_value) {
    81                 Prefs::setValue('items_per_page', $this->_per_page, $_SERVER['PHP_SELF']);
    82             }
    83         } else if ($save_value && Prefs::exists('items_per_page', $_SERVER['PHP_SELF'])) {
    84             $this->_per_page = (int)Prefs::getValue('items_per_page', $_SERVER['PHP_SELF']);
     83                $prefs->setValue('items_per_page', $this->_per_page, $_SERVER['PHP_SELF']);
     84            }
     85        } else if ($save_value && $prefs->exists('items_per_page', $_SERVER['PHP_SELF'])) {
     86            $this->_per_page = (int)$prefs->getValue('items_per_page', $_SERVER['PHP_SELF']);
    8587        } else if (is_numeric($default) && $default > 0) {
    8688            $this->_per_page = $default;
     
    9496    function setPageNumber($page_number, $save_value=true)
    9597    {
    96         // (1) By provided argument, if valid.
     98        $prefs =& Prefs::getInstance();
     99   
     100    // (1) By provided argument, if valid.
    97101        // (2) By saved preference, if available.
    98102        // (3) Don't change from what was provided at class instantiation.
     
    105109            }
    106110            if ($save_value) {
    107                 Prefs::setValue('page_number', $this->current_page, $_SERVER['PHP_SELF']);
    108             }
    109         } else if ($save_value && Prefs::exists('page_number', $_SERVER['PHP_SELF'])) {
    110             $this->current_page = (int)Prefs::getValue('page_number', $_SERVER['PHP_SELF']);
     111                $prefs->setValue('page_number', $this->current_page, $_SERVER['PHP_SELF']);
     112            }
     113        } else if ($save_value && $prefs->exists('page_number', $_SERVER['PHP_SELF'])) {
     114            $this->current_page = (int)$prefs->getValue('page_number', $_SERVER['PHP_SELF']);
    111115        }
    112116        $this->set_page_number_initialized = true;
  • branches/2.0singleton/lib/SortOrder.inc.php

    r130 r132  
    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->setValue('sort_by', $this->sort_by, $_SERVER['PHP_SELF']);
     81        } else if ($prefs->exists('sort_by', $_SERVER['PHP_SELF'])) {
     82            $this->sort_by = $prefs->getValue('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->setValue('sort_order', $this->order, $_SERVER['PHP_SELF']);
     95        } else if ($prefs->exists('sort_order', $_SERVER['PHP_SELF'])) {
     96            $this->order = $prefs->getValue('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->setValue('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->setValue('sort_order', $this->order, $_SERVER['PHP_SELF']);
    121125        }
    122126    }
  • branches/2.0singleton/services/admins.php

    r130 r132  
    2929// The object to validate form input.
    3030$fv = new FormValidator();
     31
     32$cache =& SessionCache::getInstance();
    3133
    3234// Instantiate a sorting object with the default sort and order. Add SQL for each column.
     
    6971if (getFormData('break_list_cache', false)) {
    7072    // Break the cache because we are changing the list data.
    71     SessionCache::breakCache($_SERVER['PHP_SELF']);
     73    $cache->breakCache($_SERVER['PHP_SELF']);
    7274}
    7375
     
    317319    $app =& App::getInstance();
    318320    $db =& DB::getInstance();
     321    $cache =& SessionCache::getInstance();
    319322   
    320323    $lock->select('admin_tbl', 'admin_id', $id);
     
    324327
    325328    // Break the cache because we are changing the list data.
    326     SessionCache::breakCache($_SERVER['PHP_SELF']);
     329    $cache->breakCache($_SERVER['PHP_SELF']);
    327330
    328331    // Get the information for this object.
     
    364367    $app =& App::getInstance();
    365368    $db =& DB::getInstance();
     369    $cache =& SessionCache::getInstance();
    366370   
    367371    // Break the cache because we are changing the list data.
    368     SessionCache::breakCache($_SERVER['PHP_SELF']);
     372    $cache->breakCache($_SERVER['PHP_SELF']);
    369373
    370374    // Insert record data.
     
    407411    $app =& App::getInstance();
    408412    $db =& DB::getInstance();
     413    $cache =& SessionCache::getInstance();
    409414   
    410415    $lock->select('admin_tbl', 'admin_id', $frm['admin_id']);
     
    414419
    415420    // Break the cache because we are changing the list data.
    416     SessionCache::breakCache($_SERVER['PHP_SELF']);
     421    $cache->breakCache($_SERVER['PHP_SELF']);
    417422
    418423    // If the userpass is left blank or with the filler **** characters, we don't want to update it.
     
    450455    global $so;
    451456    $db =& DB::getInstance();
     457    $prefs =& Prefs::getInstance();
     458    $cache =& SessionCache::getInstance();
    452459   
    453 
    454460    $where_clause = '';
    455461
     
    501507    // without knowing the hash.
    502508    $cache_hash = md5($sql . '|' . $page->total_items);
    503     if (Prefs::getValue('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) {
    504         SessionCache::breakCache($_SERVER['PHP_SELF']);
    505         Prefs::setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
    506     }
    507 
    508     if (SessionCache::isCached($_SERVER['PHP_SELF']) && false) {
     509    if ($prefs->getValue('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) {
     510        $cache->breakCache($_SERVER['PHP_SELF']);
     511        $prefs->setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
     512    }
     513
     514    if ($cache->isCached($_SERVER['PHP_SELF']) && false) {
    509515        // Get the cached results.
    510         $list = SessionCache::getCache($_SERVER['PHP_SELF']);
     516        $list = $cache->getCache($_SERVER['PHP_SELF']);
    511517    } else {
    512518        // If the list is not already cached, query now.
     
    519525        if (isset($list) && !empty($list)) {
    520526            // Cache the results.
    521             SessionCache::putCache($list, $_SERVER['PHP_SELF']);
     527            $cache->putCache($list, $_SERVER['PHP_SELF']);
    522528        }
    523529    }
  • branches/2.0singleton/services/logs.php

    r129 r132  
    3939
    4040// Set the defaults and catch incoming settings.
    41 Prefs::setDefault('log_file', $app->getParam('log_filename'), 'logs_module');
    42 Prefs::setValue('log_file', getFormData('log'), 'logs_module');
     41$prefs =& Prefs::getInstance();
     42$prefs->setDefault('log_file', $app->getParam('log_filename'), 'logs_module');
     43$prefs->setValue('log_file', getFormData('log'), 'logs_module');
    4344
    4445// Titles and navigation header.
    45 $nav->addPage(sprintf(_("Viewing log: <em>%s</em>"), Prefs::getValue('log_file', 'logs_module')), '/admin/logs.php');
     46$nav->addPage(sprintf(_("Viewing log: <em>%s</em>"), $prefs->getValue('log_file', 'logs_module')), '/admin/logs.php');
    4647
    4748/******************************************************************************
     
    5657case 'delete' :
    5758//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
    58     deleteLog(Prefs::getValue('log_file', 'logs_module'));
    59     Prefs::setValue('log_file', $app->getParam('log_filename'), 'logs_module');
     59    deleteLog($prefs->getValue('log_file', 'logs_module'));
     60    $prefs->setValue('log_file', $app->getParam('log_filename'), 'logs_module');
    6061    if ($app->validBoomerangURL('app_log')) {
    6162        // Display boomerang page.
     
    6869case 'clear' :
    6970//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
    70     clearLog(Prefs::getValue('log_file', 'logs_module'));
     71    clearLog($prefs->getValue('log_file', 'logs_module'));
    7172    if ($app->validBoomerangURL('app_log')) {
    7273        // Display boomerang page.
     
    7980case 'archive' :
    8081//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
    81     if (archiveLog(Prefs::getValue('log_file', 'logs_module'))) {
     82    if (archiveLog($prefs->getValue('log_file', 'logs_module'))) {
    8283        // Now flush current log.
    8384        $app->dieURL($_SERVER['PHP_SELF'] . '?op=clear');
     
    9798case 'download' :
    9899    header('Content-Type: application/octet-stream');
    99     header(sprintf('Content-Disposition: attachment; filename=%s.txt', Prefs::getValue('log_file', 'logs_module')));
    100     printLog(Prefs::getValue('log_file', 'logs_module'));
     100    header(sprintf('Content-Disposition: attachment; filename=%s.txt', $prefs->getValue('log_file', 'logs_module')));
     101    printLog($prefs->getValue('log_file', 'logs_module'));
    101102    die;
    102103    break;
    103104
    104105default :
    105     $list =& getLog(Prefs::getValue('log_file', 'logs_module'), getFormData('search_query'));
     106    $list =& getLog($prefs->getValue('log_file', 'logs_module'), getFormData('search_query'));
    106107    $main_template = 'log_list.ihtml';
    107108    break;
     
    125126include 'header.ihtml';
    126127if ('output' == $main_template) {
    127     printLog(Prefs::getValue('log_file', 'logs_module'));
     128    printLog($prefs->getValue('log_file', 'logs_module'));
    128129} else {
    129130    include 'codebase/services/templates/' . $main_template;
  • branches/2.0singleton/services/templates/log_list.ihtml

    r131 r132  
    1010        <tr class="commandtext">
    1111            <td>
    12                 <?php if ($l['filename'] == Prefs::getValue('log_file', 'logs_module')) { ?>
     12                <?php if ($l['filename'] == $prefs->getValue('log_file', 'logs_module')) { ?>
    1313                    <span class="commanditem"><strong><?php echo sprintf(_("%s"), $l['filename']); ?></strong></span>
    1414                <?php } else { ?>
Note: See TracChangeset for help on using the changeset viewer.