home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / HTML / AJAX / Debug.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  3.3 KB  |  145 lines

  1. <?php
  2. /**
  3.  * AJAX Debugging implementation
  4.  *
  5.  * SVN Rev: $Id$
  6.  */
  7.  
  8. /**
  9.  * Newline to use
  10.  */
  11. define ("HTML_AJAX_NEWLINE", "\n");
  12.  
  13. // {{{ class HTML_AJAX_Debug
  14. /**
  15.  * AJAX Debugging implementation
  16.  *
  17.  * @category   HTML
  18.  * @package    AJAX
  19.  * @author     David Coallier <davidc@php.net>
  20.  * @copyright  2005 David Coallier 
  21.  * @license    http://www.opensource.org/licenses/lgpl-license.php  LGPL
  22.  * @version    Release: 0.5.6
  23.  */
  24. class HTML_AJAX_Debug {
  25.     // {{{ properties
  26.     /**
  27.      * This is the error message.
  28.      *
  29.      * @access private
  30.      */
  31.     var $errorMsg;
  32.  
  33.     /**
  34.      * The line where the error occured.
  35.      *
  36.      * @access private
  37.      */
  38.     var $errorLine;
  39.  
  40.     /**
  41.      * The error code.
  42.      *
  43.      * @access private
  44.      */
  45.     var $errorCode;
  46.     
  47.     /**
  48.      * The file where the error occured.
  49.      *
  50.      * @access private
  51.      */
  52.     var $errorFile;
  53.  
  54.     /**
  55.      * Time the error occured
  56.      *
  57.      * @access private
  58.      */
  59.     var $_timeOccured;
  60.  
  61.     /**
  62.      * The whole error itself
  63.      *
  64.      * @access private
  65.      * @see errorMsg
  66.      * @see errorLine
  67.      * @see errorFile
  68.      * @see errorCode
  69.      */
  70.     var $error;
  71.  
  72.     /**
  73.      * The file to save the error to.
  74.      *
  75.      * @access private
  76.      * @default ajaxErrLog.xml
  77.      */
  78.     var $file = 'ajaxErrLog.xml';
  79.     // }}}
  80.     // {{{ constructor
  81.     /**
  82.      * The constructor.
  83.      *
  84.      * @param string $errorMsg   The error message.
  85.      * @param string $errLine    The line where error occured.
  86.      * @param string $errCode    The error Code.
  87.      * @param string $errFile    The file where error occured.
  88.      */
  89.     function HTML_AJAX_Debug($errMsg, $errLine, $errCode, $errFile)
  90.     {
  91.         $this->errorMsg    = $errMsg;
  92.         $this->errorLine   = $errLine;
  93.         $this->errorCode   = $errCode;
  94.         $this->errorFile   = $errFile;
  95.         $this->_timeOccured = date("Y-m-d H:i:s", time());
  96.         $this->xmlError();
  97.     }
  98.     // }}}
  99.     // {{{ xmlError
  100.     /**
  101.      * This functions formats the error to xml format then we can save it.
  102.      *
  103.      * @access protected
  104.      * @return $this->error   the main error.
  105.      */
  106.     function xmlError()
  107.     {
  108.         $error  = " <when>{$this->_timeOccured}</when>" . HTML_AJAX_NEWLINE;
  109.         $error .= " <msg>{$this->errorMsg}</msg>"       . HTML_AJAX_NEWLINE;
  110.         $error .= " <code>{$this->errorCode}</code>"    . HTML_AJAX_NEWLINE;
  111.         $error .= " <line>{$this->errorLine}</line>"    . HTML_AJAX_NEWLINE;
  112.         $error .= " <file>{$this->errorFile}</file>"    . HTML_AJAX_NEWLINE . HTML_AJAX_NEWLINE;
  113.         return $this->error = $error; 
  114.     }
  115.     // }}}
  116.     // {{{ sessionError
  117.     /**
  118.      * This function pushes the array $_SESSION['html_ajax_debug']['time'][]
  119.      * with the values inside of $this->error
  120.      *
  121.      * @access public
  122.      */
  123.     function sessionError() 
  124.     {
  125.         $_SESSION['html_ajax_debug']['time'][] = $this->error;
  126.     }
  127.     // }}}
  128.     // {{{ _saveError
  129.     /**
  130.      * This function saves the error to a file
  131.      * appending to this file.
  132.      *
  133.      * @access private.
  134.      */
  135.     function _saveError()
  136.     {
  137.         if ($handle = fopen($this->file, 'a')) {
  138.             fwrite($handle, $this->error);
  139.         }
  140.     }
  141.     // }}}
  142. }
  143. // }}}
  144. ?>
  145.