Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, October 14, 2026

Diff for Metafox/lib/PEAR.php between version 1.1 and 1.2

version 1.1, 2005/06/05 12:13:52 version 1.2, 2005/11/07 20:37:10
Line 1 
Line 1 
 <?php  <?php
 //  /**
 // +--------------------------------------------------------------------+   * PEAR, the PHP Extension and Application Repository
 // | PEAR, the PHP Extension and Application Repository                 |   *
 // +--------------------------------------------------------------------+   * PEAR class and PEAR_Error class
 // | Copyright (c) 1997-2004 The PHP Group                              |   *
 // +--------------------------------------------------------------------+   * PHP versions 4 and 5
 // | This source file is subject to version 3.0 of the PHP license,     |   *
 // | that is bundled with this package in the file LICENSE, and is      |   * LICENSE: This source file is subject to version 3.0 of the PHP license
 // | available through the world-wide-web at the following url:         |   * that is available through the world-wide-web at the following URI:
 // | http://www.php.net/license/3_0.txt.                                |   * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
 // | If you did not receive a copy of the PHP license and are unable to |   * the PHP License and are unable to obtain it through the web, please
 // | obtain it through the world-wide-web, please send a note to        |   * send a note to license@php.net so we can mail you a copy immediately.
 // | license@php.net so we can mail you a copy immediately.             |   *
 // +--------------------------------------------------------------------+   * @category   pear
 // | Authors: Sterling Hughes <sterling@php.net>                        |   * @package    PEAR
 // |          Stig Bakken <ssb@php.net>                                 |   * @author     Sterling Hughes <sterling@php.net>
 // |          Tomas V.V.Cox <cox@idecnet.com>                           |   * @author     Stig Bakken <ssb@php.net>
 // +--------------------------------------------------------------------+   * @author     Tomas V.V.Cox <cox@idecnet.com>
 //   * @author     Greg Beaver <cellog@php.net>
 // $Id$   * @copyright  1997-2005 The PHP Group
 //   * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
    * @version    CVS: $Id$
 define('PEAR_ERROR_RETURN',     1);   * @link       http://pear.php.net/package/PEAR
 define('PEAR_ERROR_PRINT',      2);   * @since      File available since Release 0.1
 define('PEAR_ERROR_TRIGGER',    4);   */
 define('PEAR_ERROR_DIE',        8);  
 define('PEAR_ERROR_CALLBACK',  16);  /**#@+
 /**   * ERROR constants
  * WARNING: obsolete   */
  * @deprecated  define('PEAR_ERROR_RETURN',     1);
  */  define('PEAR_ERROR_PRINT',      2);
 define('PEAR_ERROR_EXCEPTION', 32);  define('PEAR_ERROR_TRIGGER',    4);
 define('PEAR_ZE2', (function_exists('version_compare') &&  define('PEAR_ERROR_DIE',        8);
                     version_compare(zend_version(), "2-dev", "ge")));  define('PEAR_ERROR_CALLBACK',  16);
   /**
 if (substr(PHP_OS, 0, 3) == 'WIN') {   * WARNING: obsolete
     define('OS_WINDOWS', true);   * @deprecated
     define('OS_UNIX',    false);   */
     define('PEAR_OS',    'Windows');  define('PEAR_ERROR_EXCEPTION', 32);
 } else {  /**#@-*/
     define('OS_WINDOWS', false);  define('PEAR_ZE2', (function_exists('version_compare') &&
     define('OS_UNIX',    true);                      version_compare(zend_version(), "2-dev", "ge")));
     define('PEAR_OS',    'Unix'); // blatant assumption  
 }  if (substr(PHP_OS, 0, 3) == 'WIN') {
       define('OS_WINDOWS', true);
 // instant backwards compatibility      define('OS_UNIX',    false);
 if (!defined('PATH_SEPARATOR')) {      define('PEAR_OS',    'Windows');
     if (OS_WINDOWS) {  } else {
         define('PATH_SEPARATOR', ';');      define('OS_WINDOWS', false);
     } else {      define('OS_UNIX',    true);
         define('PATH_SEPARATOR', ':');      define('PEAR_OS',    'Unix'); // blatant assumption
     }  }
 }  
   // instant backwards compatibility
 $GLOBALS['_PEAR_default_error_mode']     = PEAR_ERROR_RETURN;  if (!defined('PATH_SEPARATOR')) {
 $GLOBALS['_PEAR_default_error_options']  = E_USER_NOTICE;      if (OS_WINDOWS) {
 $GLOBALS['_PEAR_destructor_object_list'] = array();          define('PATH_SEPARATOR', ';');
 $GLOBALS['_PEAR_shutdown_funcs']         = array();      } else {
 $GLOBALS['_PEAR_error_handler_stack']    = array();          define('PATH_SEPARATOR', ':');
       }
 @ini_set('track_errors', true);  }
   
 /**  $GLOBALS['_PEAR_default_error_mode']     = PEAR_ERROR_RETURN;
  * Base class for other PEAR classes.  Provides rudimentary  $GLOBALS['_PEAR_default_error_options']  = E_USER_NOTICE;
  * emulation of destructors.  $GLOBALS['_PEAR_destructor_object_list'] = array();
  *  $GLOBALS['_PEAR_shutdown_funcs']         = array();
  * If you want a destructor in your class, inherit PEAR and make a  $GLOBALS['_PEAR_error_handler_stack']    = array();
  * destructor method called _yourclassname (same name as the  
  * constructor, but with a "_" prefix).  Also, in your constructor you  @ini_set('track_errors', true);
  * have to call the PEAR constructor: $this->PEAR();.  
  * The destructor method will be called without parameters.  Note that  /**
  * at in some SAPI implementations (such as Apache), any output during   * Base class for other PEAR classes.  Provides rudimentary
  * the request shutdown (in which destructors are called) seems to be   * emulation of destructors.
  * discarded.  If you need to get any debug information from your   *
  * destructor, use error_log(), syslog() or something similar.   * If you want a destructor in your class, inherit PEAR and make a
  *   * destructor method called _yourclassname (same name as the
  * IMPORTANT! To use the emulated destructors you need to create the   * constructor, but with a "_" prefix).  Also, in your constructor you
  * objects by reference: $obj =& new PEAR_child;   * have to call the PEAR constructor: $this->PEAR();.
  *   * The destructor method will be called without parameters.  Note that
  * @since PHP 4.0.2   * at in some SAPI implementations (such as Apache), any output during
  * @author Stig Bakken <ssb@php.net>   * the request shutdown (in which destructors are called) seems to be
  * @see http://pear.php.net/manual/   * discarded.  If you need to get any debug information from your
  */   * destructor, use error_log(), syslog() or something similar.
 class PEAR   *
 {   * IMPORTANT! To use the emulated destructors you need to create the
     // {{{ properties   * objects by reference: $obj =& new PEAR_child;
    *
     /**   * @category   pear
      * Whether to enable internal debug messages.   * @package    PEAR
      *   * @author     Stig Bakken <ssb@php.net>
      * @var     bool   * @author     Tomas V.V. Cox <cox@idecnet.com>
      * @access  private   * @author     Greg Beaver <cellog@php.net>
      */   * @copyright  1997-2005 The PHP Group
     var $_debug = false;   * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
    * @version    Release: 1.4.4
     /**   * @link       http://pear.php.net/package/PEAR
      * Default error mode for this object.   * @see        PEAR_Error
      *   * @since      Class available since PHP 4.0.2
      * @var     int   * @link        http://pear.php.net/manual/en/core.pear.php#core.pear.pear
      * @access  private   */
      */  class PEAR
     var $_default_error_mode = null;  {
       // {{{ properties
     /**  
      * Default error options used for this object when error mode      /**
      * is PEAR_ERROR_TRIGGER.       * Whether to enable internal debug messages.
      *       *
      * @var     int       * @var     bool
      * @access  private       * @access  private
      */       */
     var $_default_error_options = null;      var $_debug = false;
   
     /**      /**
      * Default error handler (callback) for this object, if error mode is       * Default error mode for this object.
      * PEAR_ERROR_CALLBACK.       *
      *       * @var     int
      * @var     string       * @access  private
      * @access  private       */
      */      var $_default_error_mode = null;
     var $_default_error_handler = '';  
       /**
     /**       * Default error options used for this object when error mode
      * Which class to use for error objects.       * is PEAR_ERROR_TRIGGER.
      *       *
      * @var     string       * @var     int
      * @access  private       * @access  private
      */       */
     var $_error_class = 'PEAR_Error';      var $_default_error_options = null;
   
     /**      /**
      * An array of expected errors.       * Default error handler (callback) for this object, if error mode is
      *       * PEAR_ERROR_CALLBACK.
      * @var     array       *
      * @access  private       * @var     string
      */       * @access  private
     var $_expected_errors = array();       */
       var $_default_error_handler = '';
     // }}}  
       /**
     // {{{ constructor       * Which class to use for error objects.
        *
     /**       * @var     string
      * Constructor.  Registers this object in       * @access  private
      * $_PEAR_destructor_object_list for destructor emulation if a       */
      * destructor object exists.      var $_error_class = 'PEAR_Error';
      *  
      * @param string $error_class  (optional) which class to use for      /**
      *        error objects, defaults to PEAR_Error.       * An array of expected errors.
      * @access public       *
      * @return void       * @var     array
      */       * @access  private
     function PEAR($error_class = null)       */
     {      var $_expected_errors = array();
         $classname = strtolower(get_class($this));  
         if ($this->_debug) {      // }}}
             print "PEAR constructor called, class=$classname\n";  
         }      // {{{ constructor
         if ($error_class !== null) {  
             $this->_error_class = $error_class;      /**
         }       * Constructor.  Registers this object in
         while ($classname && strcasecmp($classname, "pear")) {       * $_PEAR_destructor_object_list for destructor emulation if a
             $destructor = "_$classname";       * destructor object exists.
             if (method_exists($this, $destructor)) {       *
                 global $_PEAR_destructor_object_list;       * @param string $error_class  (optional) which class to use for
                 $_PEAR_destructor_object_list[] = &$this;       *        error objects, defaults to PEAR_Error.
                 if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {       * @access public
                     register_shutdown_function("_PEAR_call_destructors");       * @return void
                     $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;       */
                 }      function PEAR($error_class = null)
                 break;      {
             } else {          $classname = strtolower(get_class($this));
                 $classname = get_parent_class($classname);          if ($this->_debug) {
             }              print "PEAR constructor called, class=$classname\n";
         }          }
     }          if ($error_class !== null) {
               $this->_error_class = $error_class;
     // }}}          }
     // {{{ destructor          while ($classname && strcasecmp($classname, "pear")) {
               $destructor = "_$classname";
     /**              if (method_exists($this, $destructor)) {
      * Destructor (the emulated type of...).  Does nothing right now,                  global $_PEAR_destructor_object_list;
      * but is included for forward compatibility, so subclass                  $_PEAR_destructor_object_list[] = &$this;
      * destructors should always call it.                  if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
      *                      register_shutdown_function("_PEAR_call_destructors");
      * See the note in the class desciption about output from                      $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
      * destructors.                  }
      *                  break;
      * @access public              } else {
      * @return void                  $classname = get_parent_class($classname);
      */              }
     function _PEAR() {          }
         if ($this->_debug) {      }
             printf("PEAR destructor called, class=%s\n", strtolower(get_class($this)));  
         }      // }}}
     }      // {{{ destructor
   
     // }}}      /**
     // {{{ getStaticProperty()       * Destructor (the emulated type of...).  Does nothing right now,
        * but is included for forward compatibility, so subclass
     /**       * destructors should always call it.
     * If you have a class that's mostly/entirely static, and you need static       *
     * properties, you can use this method to simulate them. Eg. in your method(s)       * See the note in the class desciption about output from
     * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');       * destructors.
     * You MUST use a reference, or they will not persist!       *
     *       * @access public
     * @access public       * @return void
     * @param  string $class  The calling classname, to prevent clashes       */
     * @param  string $var    The variable to retrieve.      function _PEAR() {
     * @return mixed   A reference to the variable. If not set it will be          if ($this->_debug) {
     *                 auto initialised to NULL.              printf("PEAR destructor called, class=%s\n", strtolower(get_class($this)));
     */          }
     function &getStaticProperty($class, $var)      }
     {  
         static $properties;      // }}}
         return $properties[$class][$var];      // {{{ getStaticProperty()
     }  
       /**
     // }}}      * If you have a class that's mostly/entirely static, and you need static
     // {{{ registerShutdownFunc()      * properties, you can use this method to simulate them. Eg. in your method(s)
       * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');
     /**      * You MUST use a reference, or they will not persist!
     * Use this function to register a shutdown method for static      *
     * classes.      * @access public
     *      * @param  string $class  The calling classname, to prevent clashes
     * @access public      * @param  string $var    The variable to retrieve.
     * @param  mixed $func  The function name (or array of class/method) to call      * @return mixed   A reference to the variable. If not set it will be
     * @param  mixed $args  The arguments to pass to the function      *                 auto initialised to NULL.
     * @return void      */
     */      function &getStaticProperty($class, $var)
     function registerShutdownFunc($func, $args = array())      {
     {          static $properties;
         $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);          return $properties[$class][$var];
     }      }
   
     // }}}      // }}}
     // {{{ isError()      // {{{ registerShutdownFunc()
   
     /**      /**
      * Tell whether a value is a PEAR error.      * Use this function to register a shutdown method for static
      *      * classes.
      * @param   mixed $data   the value to test      *
      * @param   int   $code   if $data is an error object, return true      * @access public
      *                        only if $code is a string and      * @param  mixed $func  The function name (or array of class/method) to call
      *                        $obj->getMessage() == $code or      * @param  mixed $args  The arguments to pass to the function
      *                        $code is an integer and $obj->getCode() == $code      * @return void
      * @access  public      */
      * @return  bool    true if parameter is an error      function registerShutdownFunc($func, $args = array())
      */      {
     function isError($data, $code = null)          $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
     {      }
         if (is_a($data, 'PEAR_Error')) {  
             if (is_null($code)) {      // }}}
                 return true;      // {{{ isError()
             } elseif (is_string($code)) {  
                 return $data->getMessage() == $code;      /**
             } else {       * Tell whether a value is a PEAR error.
                 return $data->getCode() == $code;       *
             }       * @param   mixed $data   the value to test
         }       * @param   int   $code   if $data is an error object, return true
         return false;       *                        only if $code is a string and
     }       *                        $obj->getMessage() == $code or
        *                        $code is an integer and $obj->getCode() == $code
     // }}}       * @access  public
     // {{{ setErrorHandling()       * @return  bool    true if parameter is an error
        */
     /**      function isError($data, $code = null)
      * Sets how errors generated by this object should be handled.      {
      * Can be invoked both in objects and statically.  If called          if (is_a($data, 'PEAR_Error')) {
      * statically, setErrorHandling sets the default behaviour for all              if (is_null($code)) {
      * PEAR objects.  If called in an object, setErrorHandling sets                  return true;
      * the default behaviour for that object.              } elseif (is_string($code)) {
      *                  return $data->getMessage() == $code;
      * @param int $mode              } else {
      *        One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,                  return $data->getCode() == $code;
      *        PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,              }
      *        PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION.          }
      *          return false;
      * @param mixed $options      }
      *        When $mode is PEAR_ERROR_TRIGGER, this is the error level (one  
      *        of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).      // }}}
      *      // {{{ setErrorHandling()
      *        When $mode is PEAR_ERROR_CALLBACK, this parameter is expected  
      *        to be the callback function or method.  A callback      /**
      *        function is a string with the name of the function, a       * Sets how errors generated by this object should be handled.
      *        callback method is an array of two elements: the element       * Can be invoked both in objects and statically.  If called
      *        at index 0 is the object, and the element at index 1 is       * statically, setErrorHandling sets the default behaviour for all
      *        the name of the method to call in the object.       * PEAR objects.  If called in an object, setErrorHandling sets
      *       * the default behaviour for that object.
      *        When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is       *
      *        a printf format string used when printing the error       * @param int $mode
      *        message.       *        One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
      *       *        PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
      * @access public       *        PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION.
      * @return void       *
      * @see PEAR_ERROR_RETURN       * @param mixed $options
      * @see PEAR_ERROR_PRINT       *        When $mode is PEAR_ERROR_TRIGGER, this is the error level (one
      * @see PEAR_ERROR_TRIGGER       *        of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
      * @see PEAR_ERROR_DIE       *
      * @see PEAR_ERROR_CALLBACK       *        When $mode is PEAR_ERROR_CALLBACK, this parameter is expected
      * @see PEAR_ERROR_EXCEPTION       *        to be the callback function or method.  A callback
      *       *        function is a string with the name of the function, a
      * @since PHP 4.0.5       *        callback method is an array of two elements: the element
      */       *        at index 0 is the object, and the element at index 1 is
        *        the name of the method to call in the object.
     function setErrorHandling($mode = null, $options = null)       *
     {       *        When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is
         if (isset($this) && is_a($this, 'PEAR')) {       *        a printf format string used when printing the error
             $setmode     = &$this->_default_error_mode;       *        message.
             $setoptions  = &$this->_default_error_options;       *
         } else {       * @access public
             $setmode     = &$GLOBALS['_PEAR_default_error_mode'];       * @return void
             $setoptions  = &$GLOBALS['_PEAR_default_error_options'];       * @see PEAR_ERROR_RETURN
         }       * @see PEAR_ERROR_PRINT
        * @see PEAR_ERROR_TRIGGER
         switch ($mode) {       * @see PEAR_ERROR_DIE
             case PEAR_ERROR_EXCEPTION:       * @see PEAR_ERROR_CALLBACK
             case PEAR_ERROR_RETURN:       * @see PEAR_ERROR_EXCEPTION
             case PEAR_ERROR_PRINT:       *
             case PEAR_ERROR_TRIGGER:       * @since PHP 4.0.5
             case PEAR_ERROR_DIE:       */
             case null:  
                 $setmode = $mode;      function setErrorHandling($mode = null, $options = null)
                 $setoptions = $options;      {
                 break;          if (isset($this) && is_a($this, 'PEAR')) {
               $setmode     = &$this->_default_error_mode;
             case PEAR_ERROR_CALLBACK:              $setoptions  = &$this->_default_error_options;
                 $setmode = $mode;          } else {
                 // class/object method callback              $setmode     = &$GLOBALS['_PEAR_default_error_mode'];
                 if (is_callable($options)) {              $setoptions  = &$GLOBALS['_PEAR_default_error_options'];
                     $setoptions = $options;          }
                 } else {  
                     trigger_error("invalid error callback", E_USER_WARNING);          switch ($mode) {
                 }              case PEAR_ERROR_EXCEPTION:
                 break;              case PEAR_ERROR_RETURN:
               case PEAR_ERROR_PRINT:
             default:              case PEAR_ERROR_TRIGGER:
                 trigger_error("invalid error mode", E_USER_WARNING);              case PEAR_ERROR_DIE:
                 break;              case null:
         }                  $setmode = $mode;
     }                  $setoptions = $options;
                   break;
     // }}}  
     // {{{ expectError()              case PEAR_ERROR_CALLBACK:
                   $setmode = $mode;
     /**                  // class/object method callback
      * This method is used to tell which errors you expect to get.                  if (is_callable($options)) {
      * Expected errors are always returned with error mode                      $setoptions = $options;
      * PEAR_ERROR_RETURN.  Expected error codes are stored in a stack,                  } else {
      * and this method pushes a new element onto it.  The list of                      trigger_error("invalid error callback", E_USER_WARNING);
      * expected errors are in effect until they are popped off the                  }
      * stack with the popExpect() method.                  break;
      *  
      * Note that this method can not be called statically              default:
      *                  trigger_error("invalid error mode", E_USER_WARNING);
      * @param mixed $code a single error code or an array of error codes to expect                  break;
      *          }
      * @return int     the new depth of the "expected errors" stack      }
      * @access public  
      */      // }}}
     function expectError($code = '*')      // {{{ expectError()
     {  
         if (is_array($code)) {      /**
             array_push($this->_expected_errors, $code);       * This method is used to tell which errors you expect to get.
         } else {       * Expected errors are always returned with error mode
             array_push($this->_expected_errors, array($code));       * PEAR_ERROR_RETURN.  Expected error codes are stored in a stack,
         }       * and this method pushes a new element onto it.  The list of
         return sizeof($this->_expected_errors);       * expected errors are in effect until they are popped off the
     }       * stack with the popExpect() method.
        *
     // }}}       * Note that this method can not be called statically
     // {{{ popExpect()       *
        * @param mixed $code a single error code or an array of error codes to expect
     /**       *
      * This method pops one element off the expected error codes       * @return int     the new depth of the "expected errors" stack
      * stack.       * @access public
      *       */
      * @return array   the list of error codes that were popped      function expectError($code = '*')
      */      {
     function popExpect()          if (is_array($code)) {
     {              array_push($this->_expected_errors, $code);
         return array_pop($this->_expected_errors);          } else {
     }              array_push($this->_expected_errors, array($code));
           }
     // }}}          return sizeof($this->_expected_errors);
     // {{{ _checkDelExpect()      }
   
     /**      // }}}
      * This method checks unsets an error code if available      // {{{ popExpect()
      *  
      * @param mixed error code      /**
      * @return bool true if the error code was unset, false otherwise       * This method pops one element off the expected error codes
      * @access private       * stack.
      * @since PHP 4.3.0       *
      */       * @return array   the list of error codes that were popped
     function _checkDelExpect($error_code)       */
     {      function popExpect()
         $deleted = false;      {
           return array_pop($this->_expected_errors);
         foreach ($this->_expected_errors AS $key => $error_array) {      }
             if (in_array($error_code, $error_array)) {  
                 unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);      // }}}
                 $deleted = true;      // {{{ _checkDelExpect()
             }  
       /**
             // clean up empty arrays       * This method checks unsets an error code if available
             if (0 == count($this->_expected_errors[$key])) {       *
                 unset($this->_expected_errors[$key]);       * @param mixed error code
             }       * @return bool true if the error code was unset, false otherwise
         }       * @access private
         return $deleted;       * @since PHP 4.3.0
     }       */
       function _checkDelExpect($error_code)
     // }}}      {
     // {{{ delExpect()          $deleted = false;
   
     /**          foreach ($this->_expected_errors AS $key => $error_array) {
      * This method deletes all occurences of the specified element from              if (in_array($error_code, $error_array)) {
      * the expected error codes stack.                  unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
      *                  $deleted = true;
      * @param  mixed $error_code error code that should be deleted              }
      * @return mixed list of error codes that were deleted or error  
      * @access public              // clean up empty arrays
      * @since PHP 4.3.0              if (0 == count($this->_expected_errors[$key])) {
      */                  unset($this->_expected_errors[$key]);
     function delExpect($error_code)              }
     {          }
         $deleted = false;          return $deleted;
       }
         if ((is_array($error_code) && (0 != count($error_code)))) {  
             // $error_code is a non-empty array here;      // }}}
             // we walk through it trying to unset all      // {{{ delExpect()
             // values  
             foreach($error_code as $key => $error) {      /**
                 if ($this->_checkDelExpect($error)) {       * This method deletes all occurences of the specified element from
                     $deleted =  true;       * the expected error codes stack.
                 } else {       *
                     $deleted = false;       * @param  mixed $error_code error code that should be deleted
                 }       * @return mixed list of error codes that were deleted or error
             }       * @access public
             return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME       * @since PHP 4.3.0
         } elseif (!empty($error_code)) {       */
             // $error_code comes alone, trying to unset it      function delExpect($error_code)
             if ($this->_checkDelExpect($error_code)) {      {
                 return true;          $deleted = false;
             } else {  
                 return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME          if ((is_array($error_code) && (0 != count($error_code)))) {
             }              // $error_code is a non-empty array here;
         } else {              // we walk through it trying to unset all
             // $error_code is empty              // values
             return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME              foreach($error_code as $key => $error) {
         }                  if ($this->_checkDelExpect($error)) {
     }                      $deleted =  true;
                   } else {
     // }}}                      $deleted = false;
     // {{{ raiseError()                  }
               }
     /**              return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
      * This method is a wrapper that returns an instance of the          } elseif (!empty($error_code)) {
      * configured error class with this object's default error              // $error_code comes alone, trying to unset it
      * handling applied.  If the $mode and $options parameters are not              if ($this->_checkDelExpect($error_code)) {
      * specified, the object's defaults are used.                  return true;
      *              } else {
      * @param mixed $message a text error message or a PEAR error object                  return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
      *              }
      * @param int $code      a numeric error code (it is up to your class          } else {
      *                  to define these if you want to use codes)              // $error_code is empty
      *              return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
      * @param int $mode      One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,          }
      *                  PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,      }
      *                  PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION.  
      *      // }}}
      * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter      // {{{ raiseError()
      *                  specifies the PHP-internal error level (one of  
      *                  E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).      /**
      *                  If $mode is PEAR_ERROR_CALLBACK, this       * This method is a wrapper that returns an instance of the
      *                  parameter specifies the callback function or       * configured error class with this object's default error
      *                  method.  In other error modes this parameter       * handling applied.  If the $mode and $options parameters are not
      *                  is ignored.       * specified, the object's defaults are used.
      *       *
      * @param string $userinfo If you need to pass along for example debug       * @param mixed $message a text error message or a PEAR error object
      *                  information, this parameter is meant for that.       *
      *       * @param int $code      a numeric error code (it is up to your class
      * @param string $error_class The returned error object will be       *                  to define these if you want to use codes)
      *                  instantiated from this class, if specified.       *
      *       * @param int $mode      One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
      * @param bool $skipmsg If true, raiseError will only pass error codes,       *                  PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
      *                  the error message parameter will be dropped.       *                  PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION.
      *       *
      * @access public       * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter
      * @return object   a PEAR error object       *                  specifies the PHP-internal error level (one of
      * @see PEAR::setErrorHandling       *                  E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
      * @since PHP 4.0.5       *                  If $mode is PEAR_ERROR_CALLBACK, this
      */       *                  parameter specifies the callback function or
     function raiseError($message = null,       *                  method.  In other error modes this parameter
                          $code = null,       *                  is ignored.
                          $mode = null,       *
                          $options = null,       * @param string $userinfo If you need to pass along for example debug
                          $userinfo = null,       *                  information, this parameter is meant for that.
                          $error_class = null,       *
                          $skipmsg = false)       * @param string $error_class The returned error object will be
     {       *                  instantiated from this class, if specified.
         // The error is yet a PEAR error object       *
         if (is_object($message)) {       * @param bool $skipmsg If true, raiseError will only pass error codes,
             $code        = $message->getCode();       *                  the error message parameter will be dropped.
             $userinfo    = $message->getUserInfo();       *
             $error_class = $message->getType();       * @access public
             $message->error_message_prefix = '';       * @return object   a PEAR error object
             $message     = $message->getMessage();       * @see PEAR::setErrorHandling
         }       * @since PHP 4.0.5
        */
         if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {      function &raiseError($message = null,
             if ($exp[0] == "*" ||                           $code = null,
                 (is_int(reset($exp)) && in_array($code, $exp)) ||                           $mode = null,
                 (is_string(reset($exp)) && in_array($message, $exp))) {                           $options = null,
                 $mode = PEAR_ERROR_RETURN;                           $userinfo = null,
             }                           $error_class = null,
         }                           $skipmsg = false)
         // No mode given, try global ones      {
         if ($mode === null) {          // The error is yet a PEAR error object
             // Class error handler          if (is_object($message)) {
             if (isset($this) && isset($this->_default_error_mode)) {              $code        = $message->getCode();
                 $mode    = $this->_default_error_mode;              $userinfo    = $message->getUserInfo();
                 $options = $this->_default_error_options;              $error_class = $message->getType();
             // Global error handler              $message->error_message_prefix = '';
             } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {              $message     = $message->getMessage();
                 $mode    = $GLOBALS['_PEAR_default_error_mode'];          }
                 $options = $GLOBALS['_PEAR_default_error_options'];  
             }          if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
         }              if ($exp[0] == "*" ||
                   (is_int(reset($exp)) && in_array($code, $exp)) ||
         if ($error_class !== null) {                  (is_string(reset($exp)) && in_array($message, $exp))) {
             $ec = $error_class;                  $mode = PEAR_ERROR_RETURN;
         } elseif (isset($this) && isset($this->_error_class)) {              }
             $ec = $this->_error_class;          }
         } else {          // No mode given, try global ones
             $ec = 'PEAR_Error';          if ($mode === null) {
         }              // Class error handler
         if ($skipmsg) {              if (isset($this) && isset($this->_default_error_mode)) {
             return new $ec($code, $mode, $options, $userinfo);                  $mode    = $this->_default_error_mode;
         } else {                  $options = $this->_default_error_options;
             return new $ec($message, $code, $mode, $options, $userinfo);              // Global error handler
         }              } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
     }                  $mode    = $GLOBALS['_PEAR_default_error_mode'];
                   $options = $GLOBALS['_PEAR_default_error_options'];
     // }}}              }
     // {{{ throwError()          }
   
     /**          if ($error_class !== null) {
      * Simpler form of raiseError with fewer options.  In most cases              $ec = $error_class;
      * message, code and userinfo are enough.          } elseif (isset($this) && isset($this->_error_class)) {
      *              $ec = $this->_error_class;
      * @param string $message          } else {
      *              $ec = 'PEAR_Error';
      */          }
     function throwError($message = null,          if ($skipmsg) {
                          $code = null,              $a = &new $ec($code, $mode, $options, $userinfo);
                          $userinfo = null)              return $a;
     {          } else {
         if (isset($this) && is_a($this, 'PEAR')) {              $a = &new $ec($message, $code, $mode, $options, $userinfo);
             return $this->raiseError($message, $code, null, null, $userinfo);              return $a;
         } else {          }
             return PEAR::raiseError($message, $code, null, null, $userinfo);      }
         }  
     }      // }}}
       // {{{ throwError()
     // }}}  
     function staticPushErrorHandling($mode, $options = null)      /**
     {       * Simpler form of raiseError with fewer options.  In most cases
         $stack = &$GLOBALS['_PEAR_error_handler_stack'];       * message, code and userinfo are enough.
         $def_mode    = &$GLOBALS['_PEAR_default_error_mode'];       *
         $def_options = &$GLOBALS['_PEAR_default_error_options'];       * @param string $message
         $stack[] = array($def_mode, $def_options);       *
         switch ($mode) {       */
             case PEAR_ERROR_EXCEPTION:      function &throwError($message = null,
             case PEAR_ERROR_RETURN:                           $code = null,
             case PEAR_ERROR_PRINT:                           $userinfo = null)
             case PEAR_ERROR_TRIGGER:      {
             case PEAR_ERROR_DIE:          if (isset($this) && is_a($this, 'PEAR')) {
             case null:              $a = &$this->raiseError($message, $code, null, null, $userinfo);
                 $def_mode = $mode;              return $a;
                 $def_options = $options;          } else {
                 break;              $a = &PEAR::raiseError($message, $code, null, null, $userinfo);
               return $a;
             case PEAR_ERROR_CALLBACK:          }
                 $def_mode = $mode;      }
                 // class/object method callback  
                 if (is_callable($options)) {      // }}}
                     $def_options = $options;      function staticPushErrorHandling($mode, $options = null)
                 } else {      {
                     trigger_error("invalid error callback", E_USER_WARNING);          $stack = &$GLOBALS['_PEAR_error_handler_stack'];
                 }          $def_mode    = &$GLOBALS['_PEAR_default_error_mode'];
                 break;          $def_options = &$GLOBALS['_PEAR_default_error_options'];
           $stack[] = array($def_mode, $def_options);
             default:          switch ($mode) {
                 trigger_error("invalid error mode", E_USER_WARNING);              case PEAR_ERROR_EXCEPTION:
                 break;              case PEAR_ERROR_RETURN:
         }              case PEAR_ERROR_PRINT:
         $stack[] = array($mode, $options);              case PEAR_ERROR_TRIGGER:
         return true;              case PEAR_ERROR_DIE:
     }              case null:
                   $def_mode = $mode;
     function staticPopErrorHandling()                  $def_options = $options;
     {                  break;
         $stack = &$GLOBALS['_PEAR_error_handler_stack'];  
         $setmode     = &$GLOBALS['_PEAR_default_error_mode'];              case PEAR_ERROR_CALLBACK:
         $setoptions  = &$GLOBALS['_PEAR_default_error_options'];                  $def_mode = $mode;
         array_pop($stack);                  // class/object method callback
         list($mode, $options) = $stack[sizeof($stack) - 1];                  if (is_callable($options)) {
         array_pop($stack);                      $def_options = $options;
         switch ($mode) {                  } else {
             case PEAR_ERROR_EXCEPTION:                      trigger_error("invalid error callback", E_USER_WARNING);
             case PEAR_ERROR_RETURN:                  }
             case PEAR_ERROR_PRINT:                  break;
             case PEAR_ERROR_TRIGGER:  
             case PEAR_ERROR_DIE:              default:
             case null:                  trigger_error("invalid error mode", E_USER_WARNING);
                 $setmode = $mode;                  break;
                 $setoptions = $options;          }
                 break;          $stack[] = array($mode, $options);
           return true;
             case PEAR_ERROR_CALLBACK:      }
                 $setmode = $mode;  
                 // class/object method callback      function staticPopErrorHandling()
                 if (is_callable($options)) {      {
                     $setoptions = $options;          $stack = &$GLOBALS['_PEAR_error_handler_stack'];
                 } else {          $setmode     = &$GLOBALS['_PEAR_default_error_mode'];
                     trigger_error("invalid error callback", E_USER_WARNING);          $setoptions  = &$GLOBALS['_PEAR_default_error_options'];
                 }          array_pop($stack);
                 break;          list($mode, $options) = $stack[sizeof($stack) - 1];
           array_pop($stack);
             default:          switch ($mode) {
                 trigger_error("invalid error mode", E_USER_WARNING);              case PEAR_ERROR_EXCEPTION:
                 break;              case PEAR_ERROR_RETURN:
         }              case PEAR_ERROR_PRINT:
         return true;              case PEAR_ERROR_TRIGGER:
     }              case PEAR_ERROR_DIE:
               case null:
     // {{{ pushErrorHandling()                  $setmode = $mode;
                   $setoptions = $options;
     /**                  break;
      * Push a new error handler on top of the error handler options stack. With this  
      * you can easily override the actual error handler for some code and restore              case PEAR_ERROR_CALLBACK:
      * it later with popErrorHandling.                  $setmode = $mode;
      *                  // class/object method callback
      * @param mixed $mode (same as setErrorHandling)                  if (is_callable($options)) {
      * @param mixed $options (same as setErrorHandling)                      $setoptions = $options;
      *                  } else {
      * @return bool Always true                      trigger_error("invalid error callback", E_USER_WARNING);
      *                  }
      * @see PEAR::setErrorHandling                  break;
      */  
     function pushErrorHandling($mode, $options = null)              default:
     {                  trigger_error("invalid error mode", E_USER_WARNING);
         $stack = &$GLOBALS['_PEAR_error_handler_stack'];                  break;
         if (isset($this) && is_a($this, 'PEAR')) {          }
             $def_mode    = &$this->_default_error_mode;          return true;
             $def_options = &$this->_default_error_options;      }
         } else {  
             $def_mode    = &$GLOBALS['_PEAR_default_error_mode'];      // {{{ pushErrorHandling()
             $def_options = &$GLOBALS['_PEAR_default_error_options'];  
         }      /**
         $stack[] = array($def_mode, $def_options);       * Push a new error handler on top of the error handler options stack. With this
        * you can easily override the actual error handler for some code and restore
         if (isset($this) && is_a($this, 'PEAR')) {       * it later with popErrorHandling.
             $this->setErrorHandling($mode, $options);       *
         } else {       * @param mixed $mode (same as setErrorHandling)
             PEAR::setErrorHandling($mode, $options);       * @param mixed $options (same as setErrorHandling)
         }       *
         $stack[] = array($mode, $options);       * @return bool Always true
         return true;       *
     }       * @see PEAR::setErrorHandling
        */
     // }}}      function pushErrorHandling($mode, $options = null)
     // {{{ popErrorHandling()      {
           $stack = &$GLOBALS['_PEAR_error_handler_stack'];
     /**          if (isset($this) && is_a($this, 'PEAR')) {
     * Pop the last error handler used              $def_mode    = &$this->_default_error_mode;
     *              $def_options = &$this->_default_error_options;
     * @return bool Always true          } else {
     *              $def_mode    = &$GLOBALS['_PEAR_default_error_mode'];
     * @see PEAR::pushErrorHandling              $def_options = &$GLOBALS['_PEAR_default_error_options'];
     */          }
     function popErrorHandling()          $stack[] = array($def_mode, $def_options);
     {  
         $stack = &$GLOBALS['_PEAR_error_handler_stack'];          if (isset($this) && is_a($this, 'PEAR')) {
         array_pop($stack);              $this->setErrorHandling($mode, $options);
         list($mode, $options) = $stack[sizeof($stack) - 1];          } else {
         array_pop($stack);              PEAR::setErrorHandling($mode, $options);
         if (isset($this) && is_a($this, 'PEAR')) {          }
             $this->setErrorHandling($mode, $options);          $stack[] = array($mode, $options);
         } else {          return true;
             PEAR::setErrorHandling($mode, $options);      }
         }  
         return true;      // }}}
     }      // {{{ popErrorHandling()
   
     // }}}      /**
     // {{{ loadExtension()      * Pop the last error handler used
       *
     /**      * @return bool Always true
     * OS independant PHP extension load. Remember to take care      *
     * on the correct extension name for case sensitive OSes.      * @see PEAR::pushErrorHandling
     *      */
     * @param string $ext The extension name      function popErrorHandling()
     * @return bool Success or not on the dl() call      {
     */          $stack = &$GLOBALS['_PEAR_error_handler_stack'];
     function loadExtension($ext)          array_pop($stack);
     {          list($mode, $options) = $stack[sizeof($stack) - 1];
         if (!extension_loaded($ext)) {          array_pop($stack);
             // if either returns true dl() will produce a FATAL error, stop that          if (isset($this) && is_a($this, 'PEAR')) {
             if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {              $this->setErrorHandling($mode, $options);
                 return false;          } else {
             }              PEAR::setErrorHandling($mode, $options);
             if (OS_WINDOWS) {          }
                 $suffix = '.dll';          return true;
             } elseif (PHP_OS == 'HP-UX') {      }
                 $suffix = '.sl';  
             } elseif (PHP_OS == 'AIX') {      // }}}
                 $suffix = '.a';      // {{{ loadExtension()
             } elseif (PHP_OS == 'OSX') {  
                 $suffix = '.bundle';      /**
             } else {      * OS independant PHP extension load. Remember to take care
                 $suffix = '.so';      * on the correct extension name for case sensitive OSes.
             }      *
             return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);      * @param string $ext The extension name
         }      * @return bool Success or not on the dl() call
         return true;      */
     }      function loadExtension($ext)
       {
     // }}}          if (!extension_loaded($ext)) {
 }              // if either returns true dl() will produce a FATAL error, stop that
               if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {
 // {{{ _PEAR_call_destructors()                  return false;
               }
 function _PEAR_call_destructors()              if (OS_WINDOWS) {
 {                  $suffix = '.dll';
     global $_PEAR_destructor_object_list;              } elseif (PHP_OS == 'HP-UX') {
     if (is_array($_PEAR_destructor_object_list) &&                  $suffix = '.sl';
         sizeof($_PEAR_destructor_object_list))              } elseif (PHP_OS == 'AIX') {
     {                  $suffix = '.a';
         reset($_PEAR_destructor_object_list);              } elseif (PHP_OS == 'OSX') {
         if (@PEAR::getStaticProperty('PEAR', 'destructlifo')) {                  $suffix = '.bundle';
             $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);              } else {
         }                  $suffix = '.so';
         while (list($k, $objref) = each($_PEAR_destructor_object_list)) {              }
             $classname = get_class($objref);              return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
             while ($classname) {          }
                 $destructor = "_$classname";          return true;
                 if (method_exists($objref, $destructor)) {      }
                     $objref->$destructor();  
                     break;      // }}}
                 } else {  }
                     $classname = get_parent_class($classname);  
                 }  // {{{ _PEAR_call_destructors()
             }  
         }  function _PEAR_call_destructors()
         // Empty the object list to ensure that destructors are  {
         // not called more than once.      global $_PEAR_destructor_object_list;
         $_PEAR_destructor_object_list = array();      if (is_array($_PEAR_destructor_object_list) &&
     }          sizeof($_PEAR_destructor_object_list))
       {
     // Now call the shutdown functions          reset($_PEAR_destructor_object_list);
     if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) {          if (@PEAR::getStaticProperty('PEAR', 'destructlifo')) {
         foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) {              $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);
             call_user_func_array($value[0], $value[1]);          }
         }          while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
     }              $classname = get_class($objref);
 }              while ($classname) {
                   $destructor = "_$classname";
 // }}}                  if (method_exists($objref, $destructor)) {
                       $objref->$destructor();
 class PEAR_Error                      break;
 {                  } else {
     // {{{ properties                      $classname = get_parent_class($classname);
                   }
     var $error_message_prefix = '';              }
     var $mode                 = PEAR_ERROR_RETURN;          }
     var $level                = E_USER_NOTICE;          // Empty the object list to ensure that destructors are
     var $code                 = -1;          // not called more than once.
     var $message              = '';          $_PEAR_destructor_object_list = array();
     var $userinfo             = '';      }
     var $backtrace            = null;  
       // Now call the shutdown functions
     // }}}      if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) {
     // {{{ constructor          foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) {
               call_user_func_array($value[0], $value[1]);
     /**          }
      * PEAR_Error constructor      }
      *  }
      * @param string $message  message  
      *  // }}}
      * @param int $code     (optional) error code  /**
      *   * Standard PEAR error class for PHP 4
      * @param int $mode     (optional) error mode, one of: PEAR_ERROR_RETURN,   *
      * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER,   * This class is supserseded by {@link PEAR_Exception} in PHP 5
      * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION   *
      *   * @category   pear
      * @param mixed $options   (optional) error level, _OR_ in the case of   * @package    PEAR
      * PEAR_ERROR_CALLBACK, the callback function or object/method   * @author     Stig Bakken <ssb@php.net>
      * tuple.   * @author     Tomas V.V. Cox <cox@idecnet.com>
      *   * @author     Gregory Beaver <cellog@php.net>
      * @param string $userinfo (optional) additional user/debug info   * @copyright  1997-2005 The PHP Group
      *   * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
      * @access public   * @version    Release: 1.4.4
      *   * @link       http://pear.php.net/manual/en/core.pear.pear-error.php
      */   * @see        PEAR::raiseError(), PEAR::throwError()
     function PEAR_Error($message = 'unknown error', $code = null,   * @since      Class available since PHP 4.0.2
                         $mode = null, $options = null, $userinfo = null)   */
     {  class PEAR_Error
         if ($mode === null) {  {
             $mode = PEAR_ERROR_RETURN;      // {{{ properties
         }  
         $this->message   = $message;      var $error_message_prefix = '';
         $this->code      = $code;      var $mode                 = PEAR_ERROR_RETURN;
         $this->mode      = $mode;      var $level                = E_USER_NOTICE;
         $this->userinfo  = $userinfo;      var $code                 = -1;
         if (function_exists("debug_backtrace")) {      var $message              = '';
             if (@!PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) {      var $userinfo             = '';
                 $this->backtrace = debug_backtrace();      var $backtrace            = null;
             }  
         }      // }}}
         if ($mode & PEAR_ERROR_CALLBACK) {      // {{{ constructor
             $this->level = E_USER_NOTICE;  
             $this->callback = $options;      /**
         } else {       * PEAR_Error constructor
             if ($options === null) {       *
                 $options = E_USER_NOTICE;       * @param string $message  message
             }       *
             $this->level = $options;       * @param int $code     (optional) error code
             $this->callback = null;       *
         }       * @param int $mode     (optional) error mode, one of: PEAR_ERROR_RETURN,
         if ($this->mode & PEAR_ERROR_PRINT) {       * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER,
             if (is_null($options) || is_int($options)) {       * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION
                 $format = "%s";       *
             } else {       * @param mixed $options   (optional) error level, _OR_ in the case of
                 $format = $options;       * PEAR_ERROR_CALLBACK, the callback function or object/method
             }       * tuple.
             printf($format, $this->getMessage());       *
         }       * @param string $userinfo (optional) additional user/debug info
         if ($this->mode & PEAR_ERROR_TRIGGER) {       *
             trigger_error($this->getMessage(), $this->level);       * @access public
         }       *
         if ($this->mode & PEAR_ERROR_DIE) {       */
             $msg = $this->getMessage();      function PEAR_Error($message = 'unknown error', $code = null,
             if (is_null($options) || is_int($options)) {                          $mode = null, $options = null, $userinfo = null)
                 $format = "%s";      {
                 if (substr($msg, -1) != "\n") {          if ($mode === null) {
                     $msg .= "\n";              $mode = PEAR_ERROR_RETURN;
                 }          }
             } else {          $this->message   = $message;
                 $format = $options;          $this->code      = $code;
             }          $this->mode      = $mode;
             die(sprintf($format, $msg));          $this->userinfo  = $userinfo;
         }          if (function_exists("debug_backtrace")) {
         if ($this->mode & PEAR_ERROR_CALLBACK) {              if (@!PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) {
             if (is_callable($this->callback)) {                  $this->backtrace = debug_backtrace();
                 call_user_func($this->callback, $this);              }
             }          }
         }          if ($mode & PEAR_ERROR_CALLBACK) {
         if ($this->mode & PEAR_ERROR_EXCEPTION) {              $this->level = E_USER_NOTICE;
             trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_ErrorStack for exceptions", E_USER_WARNING);              $this->callback = $options;
             eval('$e = new Exception($this->message, $this->code);$e->PEAR_Error = $this;throw($e);');          } else {
         }              if ($options === null) {
     }                  $options = E_USER_NOTICE;
               }
     // }}}              $this->level = $options;
     // {{{ getMode()              $this->callback = null;
           }
     /**          if ($this->mode & PEAR_ERROR_PRINT) {
      * Get the error mode from an error object.              if (is_null($options) || is_int($options)) {
      *                  $format = "%s";
      * @return int error mode              } else {
      * @access public                  $format = $options;
      */              }
     function getMode() {              printf($format, $this->getMessage());
         return $this->mode;          }
     }          if ($this->mode & PEAR_ERROR_TRIGGER) {
               trigger_error($this->getMessage(), $this->level);
     // }}}          }
     // {{{ getCallback()          if ($this->mode & PEAR_ERROR_DIE) {
               $msg = $this->getMessage();
     /**              if (is_null($options) || is_int($options)) {
      * Get the callback function/method from an error object.                  $format = "%s";
      *                  if (substr($msg, -1) != "\n") {
      * @return mixed callback function or object/method array                      $msg .= "\n";
      * @access public                  }
      */              } else {
     function getCallback() {                  $format = $options;
         return $this->callback;              }
     }              die(sprintf($format, $msg));
           }
     // }}}          if ($this->mode & PEAR_ERROR_CALLBACK) {
     // {{{ getMessage()              if (is_callable($this->callback)) {
                   call_user_func($this->callback, $this);
               }
     /**          }
      * Get the error message from an error object.          if ($this->mode & PEAR_ERROR_EXCEPTION) {
      *              trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING);
      * @return  string  full error message              eval('$e = new Exception($this->message, $this->code);throw($e);');
      * @access public          }
      */      }
     function getMessage()  
     {      // }}}
         return ($this->error_message_prefix . $this->message);      // {{{ getMode()
     }  
       /**
        * Get the error mode from an error object.
     // }}}       *
     // {{{ getCode()       * @return int error mode
        * @access public
     /**       */
      * Get error code from an error object      function getMode() {
      *          return $this->mode;
      * @return int error code      }
      * @access public  
      */      // }}}
      function getCode()      // {{{ getCallback()
      {  
         return $this->code;      /**
      }       * Get the callback function/method from an error object.
        *
     // }}}       * @return mixed callback function or object/method array
     // {{{ getType()       * @access public
        */
     /**      function getCallback() {
      * Get the name of this error/exception.          return $this->callback;
      *      }
      * @return string error/exception name (type)  
      * @access public      // }}}
      */      // {{{ getMessage()
     function getType()  
     {  
         return get_class($this);      /**
     }       * Get the error message from an error object.
        *
     // }}}       * @return  string  full error message
     // {{{ getUserInfo()       * @access public
        */
     /**      function getMessage()
      * Get additional user-supplied information.      {
      *          return ($this->error_message_prefix . $this->message);
      * @return string user-supplied information      }
      * @access public  
      */  
     function getUserInfo()      // }}}
     {      // {{{ getCode()
         return $this->userinfo;  
     }      /**
        * Get error code from an error object
     // }}}       *
     // {{{ getDebugInfo()       * @return int error code
        * @access public
     /**       */
      * Get additional debug information supplied by the application.       function getCode()
      *       {
      * @return string debug information          return $this->code;
      * @access public       }
      */  
     function getDebugInfo()      // }}}
     {      // {{{ getType()
         return $this->getUserInfo();  
     }      /**
        * Get the name of this error/exception.
     // }}}       *
     // {{{ getBacktrace()       * @return string error/exception name (type)
        * @access public
     /**       */
      * Get the call backtrace from where the error was generated.      function getType()
      * Supported with PHP 4.3.0 or newer.      {
      *          return get_class($this);
      * @param int $frame (optional) what frame to fetch      }
      * @return array Backtrace, or NULL if not available.  
      * @access public      // }}}
      */      // {{{ getUserInfo()
     function getBacktrace($frame = null)  
     {      /**
         if ($frame === null) {       * Get additional user-supplied information.
             return $this->backtrace;       *
         }       * @return string user-supplied information
         return $this->backtrace[$frame];       * @access public
     }       */
       function getUserInfo()
     // }}}      {
     // {{{ addUserInfo()          return $this->userinfo;
       }
     function addUserInfo($info)  
     {      // }}}
         if (empty($this->userinfo)) {      // {{{ getDebugInfo()
             $this->userinfo = $info;  
         } else {      /**
             $this->userinfo .= " ** $info";       * Get additional debug information supplied by the application.
         }       *
     }       * @return string debug information
        * @access public
     // }}}       */
     // {{{ toString()      function getDebugInfo()
       {
     /**          return $this->getUserInfo();
      * Make a string representation of this object.      }
      *  
      * @return string a string with an object summary      // }}}
      * @access public      // {{{ getBacktrace()
      */  
     function toString() {      /**
         $modes = array();       * Get the call backtrace from where the error was generated.
         $levels = array(E_USER_NOTICE  => 'notice',       * Supported with PHP 4.3.0 or newer.
                         E_USER_WARNING => 'warning',       *
                         E_USER_ERROR   => 'error');       * @param int $frame (optional) what frame to fetch
         if ($this->mode & PEAR_ERROR_CALLBACK) {       * @return array Backtrace, or NULL if not available.
             if (is_array($this->callback)) {       * @access public
                 $callback = (is_object($this->callback[0]) ?       */
                     strtolower(get_class($this->callback[0])) :      function getBacktrace($frame = null)
                     $this->callback[0]) . '::' .      {
                     $this->callback[1];          if (defined('PEAR_IGNORE_BACKTRACE')) {
             } else {              return null;
                 $callback = $this->callback;          }
             }          if ($frame === null) {
             return sprintf('[%s: message="%s" code=%d mode=callback '.              return $this->backtrace;
                            'callback=%s prefix="%s" info="%s"]',          }
                            strtolower(get_class($this)), $this->message, $this->code,          return $this->backtrace[$frame];
                            $callback, $this->error_message_prefix,      }
                            $this->userinfo);  
         }      // }}}
         if ($this->mode & PEAR_ERROR_PRINT) {      // {{{ addUserInfo()
             $modes[] = 'print';  
         }      function addUserInfo($info)
         if ($this->mode & PEAR_ERROR_TRIGGER) {      {
             $modes[] = 'trigger';          if (empty($this->userinfo)) {
         }              $this->userinfo = $info;
         if ($this->mode & PEAR_ERROR_DIE) {          } else {
             $modes[] = 'die';              $this->userinfo .= " ** $info";
         }          }
         if ($this->mode & PEAR_ERROR_RETURN) {      }
             $modes[] = 'return';  
         }      // }}}
         return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.      // {{{ toString()
                        'prefix="%s" info="%s"]',  
                        strtolower(get_class($this)), $this->message, $this->code,      /**
                        implode("|", $modes), $levels[$this->level],       * Make a string representation of this object.
                        $this->error_message_prefix,       *
                        $this->userinfo);       * @return string a string with an object summary
     }       * @access public
        */
     // }}}      function toString() {
 }          $modes = array();
           $levels = array(E_USER_NOTICE  => 'notice',
 /*                          E_USER_WARNING => 'warning',
  * Local Variables:                          E_USER_ERROR   => 'error');
  * mode: php          if ($this->mode & PEAR_ERROR_CALLBACK) {
  * tab-width: 4              if (is_array($this->callback)) {
  * c-basic-offset: 4                  $callback = (is_object($this->callback[0]) ?
  * End:                      strtolower(get_class($this->callback[0])) :
  */                      $this->callback[0]) . '::' .
 ?>                      $this->callback[1];
               } else {
                   $callback = $this->callback;
               }
               return sprintf('[%s: message="%s" code=%d mode=callback '.
                              'callback=%s prefix="%s" info="%s"]',
                              strtolower(get_class($this)), $this->message, $this->code,
                              $callback, $this->error_message_prefix,
                              $this->userinfo);
           }
           if ($this->mode & PEAR_ERROR_PRINT) {
               $modes[] = 'print';
           }
           if ($this->mode & PEAR_ERROR_TRIGGER) {
               $modes[] = 'trigger';
           }
           if ($this->mode & PEAR_ERROR_DIE) {
               $modes[] = 'die';
           }
           if ($this->mode & PEAR_ERROR_RETURN) {
               $modes[] = 'return';
           }
           return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
                          'prefix="%s" info="%s"]',
                          strtolower(get_class($this)), $this->message, $this->code,
                          implode("|", $modes), $levels[$this->level],
                          $this->error_message_prefix,
                          $this->userinfo);
       }
   
       // }}}
   }
   
   /*
    * Local Variables:
    * mode: php
    * tab-width: 4
    * c-basic-offset: 4
    * End:
    */
   ?>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top