AJAX
[ class tree: AJAX ] [ index: AJAX ] [ all elements ]

Source for file Debug.php

Documentation is available at Debug.php

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

Documentation generated on Mon, 11 Mar 2019 14:11:19 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.