Ignore:
Timestamp:
Jul 3, 2007 8:41:36 AM (17 years ago)
Author:
quinn
Message:

Bugfixes found during strangecode site upgrade.

File:
1 edited

Legend:

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

    r241 r266  
    4040class FormValidator extends Validator {
    4141
     42    // Class parameters.
     43    var $_params = array(
     44        'error' => ' sc-msg-error ',
     45        'warning' => ' sc-msg-warning ',
     46        'notice' => ' sc-msg-notice ',
     47        'success' => ' sc-msg-success ',
     48    );
     49
    4250    // Array filling with error messages.
    4351    var $errors = array();
     52   
     53    /**
     54     * Set (or overwrite existing) parameters by passing an array of new parameters.
     55     *
     56     * @access public
     57     * @param  array    $params     Array of parameters (key => val pairs).
     58     */
     59    function setParam($params)
     60    {
     61        $app =& App::getInstance();
     62   
     63        if (isset($params) && is_array($params)) {
     64            // Merge new parameters with old overriding only those passed.
     65            $this->_params = array_merge($this->_params, $params);
     66        } else {
     67            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
     68        }
     69    }
     70
     71    /**
     72     * Return the value of a parameter, if it exists.
     73     *
     74     * @access public
     75     * @param string $param        Which parameter to return.
     76     * @return mixed               Configured parameter value.
     77     */
     78    function getParam($param)
     79    {
     80        $app =& App::getInstance();
     81   
     82        if (isset($this->_params[$param])) {
     83            return $this->_params[$param];
     84        } else {
     85            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
     86            return null;
     87        }
     88    }
    4489   
    4590    /**
     
    164209                case MSG_ERR:
    165210                default:
    166                     echo ' sc-msg-error ';
     211                    echo $this->getParam('error');
    167212                    break;
    168213
    169214                case MSG_WARNING:
    170                     echo ' sc-msg-warning ';
     215                    echo $this->getParam('warning');
    171216                    break;
    172217
     218                case MSG_NOTICE:
     219                    echo $this->getParam('notice');
     220                    break;
     221
    173222                case MSG_SUCCESS:
    174                     echo ' sc-msg-success ';
    175                     break;
    176 
    177                 case MSG_NOTICE:
    178                     echo ' sc-msg-notice ';
     223                    echo $this->getParam('success');
    179224                    break;
    180225                }
Note: See TracChangeset for help on using the changeset viewer.