public function GetAsHTML($sValue, $oHostObject = null, $bLocalize = true)
 {
     return Str::pure2html((string) $sValue);
 }
예제 #2
0
 public static function get_callstack($iLevelsToIgnore = 0, $aCallStack = null)
 {
     if ($aCallStack == null) {
         $aCallStack = debug_backtrace();
     }
     $aCallStack = array_slice($aCallStack, $iLevelsToIgnore);
     $aDigestCallStack = array();
     $bFirstLine = true;
     foreach ($aCallStack as $aCallInfo) {
         $sLine = empty($aCallInfo['line']) ? "" : $aCallInfo['line'];
         $sFile = empty($aCallInfo['file']) ? "" : $aCallInfo['file'];
         if ($sFile != '') {
             $sFile = str_replace('\\', '/', $sFile);
             $sAppRoot = str_replace('\\', '/', APPROOT);
             $iPos = strpos($sFile, $sAppRoot);
             if ($iPos !== false) {
                 $sFile = substr($sFile, strlen($sAppRoot));
             }
         }
         $sClass = empty($aCallInfo['class']) ? "" : $aCallInfo['class'];
         $sType = empty($aCallInfo['type']) ? "" : $aCallInfo['type'];
         $sFunction = empty($aCallInfo['function']) ? "" : $aCallInfo['function'];
         if ($bFirstLine) {
             $bFirstLine = false;
             // For this line do not display the "function name" because
             // that will be the name of our error handler for sure !
             $sFunctionInfo = "N/A";
         } else {
             $args = '';
             if (empty($aCallInfo['args'])) {
                 $aCallInfo['args'] = array();
             }
             foreach ($aCallInfo['args'] as $a) {
                 if (!empty($args)) {
                     $args .= ', ';
                 }
                 switch (gettype($a)) {
                     case 'integer':
                     case 'double':
                         $args .= $a;
                         break;
                     case 'string':
                         $a = Str::pure2html(self::beautifulstr($a, 64, true, false));
                         $args .= "\"{$a}\"";
                         break;
                     case 'array':
                         $args .= 'array(' . count($a) . ')';
                         break;
                     case 'object':
                         $args .= 'Object(' . get_class($a) . ')';
                         break;
                     case 'resource':
                         $args .= 'Resource(' . strstr($a, '#') . ')';
                         break;
                     case 'boolean':
                         $args .= $a ? 'true' : 'false';
                         break;
                     case 'NULL':
                         $args .= 'null';
                         break;
                     default:
                         $args .= 'Unknown';
                 }
             }
             $sFunctionInfo = "{$sClass}{$sType}{$sFunction}({$args})";
         }
         $aDigestCallStack[] = array('File' => $sFile, 'Line' => $sLine, 'Function' => $sFunctionInfo);
     }
     return $aDigestCallStack;
 }