Changeset 136 for trunk/lib/CSS.inc.php


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/CSS.inc.php

    r92 r136  
    2828    function setParam($params)
    2929    {
     30        $app =& App::getInstance();
     31   
    3032        if (isset($params) && is_array($params)) {
    3133            // Merge new parameters with old overriding only those passed.
    3234            $this->_params = array_merge($this->_params, $params);
    3335        } else {
    34             App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
     36            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
    3537        }
    3638    }
     
    4547    function getParam($param)
    4648    {
     49        $app =& App::getInstance();
     50   
    4751        if (isset($this->_params[$param])) {
    4852            return $this->_params[$param];
    4953        } else {
    50             App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
     54            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
    5155            return null;
    5256        }
     
    5862     * @access  public
    5963     * @param   string  $file   Include path to css files.
    60      * @param   mixed   $apps   App name string or array of app names.
     64     * @param   mixed   $realms   Realm name string or array of realm names.
    6165     * @return  bool    True on success, false on failure.
    6266     */
    63     function setFile($file, $apps='')
     67    function setFile($file, $realms='')
    6468    {
    65         if (!is_array($apps)) {
    66             $apps = array($apps);
     69        $app =& App::getInstance();
     70   
     71        if (!is_array($realms)) {
     72            $realms = array($realms);
    6773        }
    6874
    6975        if ($fp = fopen($file, 'r', true)) {
    70             foreach ($apps as $app) {
    71                 $app = '' == $app ? 'default' : $app;
    72                 $this->_css_files[$app][] = $file;
     76            foreach ($realms as $realm) {
     77                $realm = '' == $realm ? 'default' : $realm;
     78                $this->_css_files[$realm][] = $file;
    7379            }
    7480            fclose($fp);
    7581            return true;
    7682        } else {
    77             App::logMsg(sprintf('CSS file non-existent: %s', $file), LOG_ERR, __FILE__, __LINE__);
     83            $app->logMsg(sprintf('CSS file non-existent: %s', $file), LOG_ERR, __FILE__, __LINE__);
    7884            return false;
    7985        }
     
    8793     * @return  bool    False if no files have been set.
    8894     */
    89     function headers($app='')
     95    function headers($realm='')
    9096    {
    91         $app = '' == $app ? 'default' : $app;
     97        $app =& App::getInstance();
     98   
     99        $realm = '' == $realm ? 'default' : $realm;
    92100
    93         if (empty($this->_css_files[$app])) {
    94             App::logMsg(sprintf('CSS::headers called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__);
     101        if (empty($this->_css_files[$realm])) {
     102            $app->logMsg(sprintf('CSS::headers called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__);
    95103            return false;
    96104        }
     
    98106        // Get time of latest modified file, including this class file.
    99107        $files_mtime = array();
    100         foreach (array_merge($this->_css_files[$app], array(__FILE__)) as $file) {
     108        foreach (array_merge($this->_css_files[$realm], array(__FILE__)) as $file) {
    101109            $files_mtime[] = statIncludePath($file, 'mtime');
    102110        }
     
    122130     * @return  bool    False if no files have been set.
    123131     */
    124     function output($app='')
     132    function output($realm='')
    125133    {
    126         $app = '' == $app ? 'default' : $app;
     134        $realm = '' == $realm ? 'default' : $realm;
    127135
    128         if (empty($this->_css_files[$app])) {
    129             App::logMsg(sprintf('CSS::output called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__);
     136        if (empty($this->_css_files[$realm])) {
     137            $app->logMsg(sprintf('CSS::output called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__);
    130138            return false;
    131139        }
    132140
    133         foreach ($this->_css_files[$app] as $file) {
     141        foreach ($this->_css_files[$realm] as $file) {
    134142            include $file;
    135143        }
Note: See TracChangeset for help on using the changeset viewer.