File indexing completed on 2025-01-26 05:30:06
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Wildfire 0017 * @subpackage Plugin 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** Zend_Controller_Request_Abstract */ 0024 // require_once('Zend/Controller/Request/Abstract.php'); 0025 0026 /** Zend_Controller_Response_Abstract */ 0027 // require_once('Zend/Controller/Response/Abstract.php'); 0028 0029 /** Zend_Wildfire_Channel_HttpHeaders */ 0030 // require_once 'Zend/Wildfire/Channel/HttpHeaders.php'; 0031 0032 /** Zend_Wildfire_Protocol_JsonStream */ 0033 // require_once 'Zend/Wildfire/Protocol/JsonStream.php'; 0034 0035 /** Zend_Wildfire_Plugin_Interface */ 0036 // require_once 'Zend/Wildfire/Plugin/Interface.php'; 0037 0038 /** 0039 * Primary class for communicating with the FirePHP Firefox Extension. 0040 * 0041 * @category Zend 0042 * @package Zend_Wildfire 0043 * @subpackage Plugin 0044 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0045 * @license http://framework.zend.com/license/new-bsd New BSD License 0046 */ 0047 class Zend_Wildfire_Plugin_FirePhp implements Zend_Wildfire_Plugin_Interface 0048 { 0049 /** 0050 * Plain log style. 0051 */ 0052 const LOG = 'LOG'; 0053 0054 /** 0055 * Information style. 0056 */ 0057 const INFO = 'INFO'; 0058 0059 /** 0060 * Warning style. 0061 */ 0062 const WARN = 'WARN'; 0063 0064 /** 0065 * Error style that increments Firebug's error counter. 0066 */ 0067 const ERROR = 'ERROR'; 0068 0069 /** 0070 * Trace style showing message and expandable full stack trace. 0071 */ 0072 const TRACE = 'TRACE'; 0073 0074 /** 0075 * Exception style showing message and expandable full stack trace. 0076 * Also increments Firebug's error counter. 0077 */ 0078 const EXCEPTION = 'EXCEPTION'; 0079 0080 /** 0081 * Table style showing summary line and expandable table 0082 */ 0083 const TABLE = 'TABLE'; 0084 0085 /** 0086 * Dump variable to Server panel in Firebug Request Inspector 0087 */ 0088 const DUMP = 'DUMP'; 0089 0090 /** 0091 * Start a group in the Firebug Console 0092 */ 0093 const GROUP_START = 'GROUP_START'; 0094 0095 /** 0096 * End a group in the Firebug Console 0097 */ 0098 const GROUP_END = 'GROUP_END'; 0099 0100 /** 0101 * The plugin URI for this plugin 0102 */ 0103 const PLUGIN_URI = 'http://meta.firephp.org/Wildfire/Plugin/ZendFramework/FirePHP/1.6.2'; 0104 0105 /** 0106 * The protocol URI for this plugin 0107 */ 0108 const PROTOCOL_URI = Zend_Wildfire_Protocol_JsonStream::PROTOCOL_URI; 0109 0110 /** 0111 * The structure URI for the Dump structure 0112 */ 0113 const STRUCTURE_URI_DUMP = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1'; 0114 0115 /** 0116 * The structure URI for the Firebug Console structure 0117 */ 0118 const STRUCTURE_URI_FIREBUGCONSOLE = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'; 0119 0120 /** 0121 * Singleton instance 0122 * @var Zend_Wildfire_Plugin_FirePhp 0123 */ 0124 protected static $_instance = null; 0125 0126 /** 0127 * Flag indicating whether FirePHP should send messages to the user-agent. 0128 * @var boolean 0129 */ 0130 protected $_enabled = true; 0131 0132 /** 0133 * The channel via which to send the encoded messages. 0134 * @var Zend_Wildfire_Channel_Interface 0135 */ 0136 protected $_channel = null; 0137 0138 /** 0139 * Messages that are buffered to be sent when protocol flushes 0140 * @var array 0141 */ 0142 protected $_messages = array(); 0143 0144 /** 0145 * Options for the object 0146 * @var array 0147 */ 0148 protected $_options = array( 0149 'traceOffset' => 1, /* The offset in the trace which identifies the source of the message */ 0150 'maxTraceDepth' => 99, /* Maximum depth for stack traces */ 0151 'maxObjectDepth' => 10, /* The maximum depth to traverse objects when encoding */ 0152 'maxArrayDepth' => 20, /* The maximum depth to traverse nested arrays when encoding */ 0153 'includeLineNumbers' => true /* Whether to include line and file info for each message */ 0154 ); 0155 0156 /** 0157 * Filters used to exclude object members when encoding 0158 * @var array 0159 */ 0160 protected $_objectFilters = array(); 0161 0162 /** 0163 * A stack of objects used during encoding to detect recursion 0164 * @var array 0165 */ 0166 protected $_objectStack = array(); 0167 0168 /** 0169 * Create singleton instance. 0170 * 0171 * @param string $class OPTIONAL Subclass of Zend_Wildfire_Plugin_FirePhp 0172 * @return Zend_Wildfire_Plugin_FirePhp Returns the singleton Zend_Wildfire_Plugin_FirePhp instance 0173 * @throws Zend_Wildfire_Exception 0174 */ 0175 public static function init($class = null) 0176 { 0177 if (self::$_instance !== null) { 0178 // require_once 'Zend/Wildfire/Exception.php'; 0179 throw new Zend_Wildfire_Exception('Singleton instance of Zend_Wildfire_Plugin_FirePhp already exists!'); 0180 } 0181 if ($class !== null) { 0182 if (!is_string($class)) { 0183 // require_once 'Zend/Wildfire/Exception.php'; 0184 throw new Zend_Wildfire_Exception('Third argument is not a class string'); 0185 } 0186 0187 if (!class_exists($class)) { 0188 // require_once 'Zend/Loader.php'; 0189 Zend_Loader::loadClass($class); 0190 } 0191 self::$_instance = new $class(); 0192 if (!self::$_instance instanceof Zend_Wildfire_Plugin_FirePhp) { 0193 self::$_instance = null; 0194 // require_once 'Zend/Wildfire/Exception.php'; 0195 throw new Zend_Wildfire_Exception('Invalid class to third argument. Must be subclass of Zend_Wildfire_Plugin_FirePhp.'); 0196 } 0197 } else { 0198 self::$_instance = new self(); 0199 } 0200 0201 return self::$_instance; 0202 } 0203 0204 /** 0205 * Constructor 0206 * @return void 0207 */ 0208 protected function __construct() 0209 { 0210 $this->_channel = Zend_Wildfire_Channel_HttpHeaders::getInstance(); 0211 $this->_channel->getProtocol(self::PROTOCOL_URI)->registerPlugin($this); 0212 } 0213 0214 /** 0215 * Get or create singleton instance 0216 * 0217 * @param bool $skipCreate True if an instance should not be created 0218 * @return Zend_Wildfire_Plugin_FirePhp 0219 */ 0220 public static function getInstance($skipCreate=false) 0221 { 0222 if (self::$_instance===null && $skipCreate!==true) { 0223 return self::init(); 0224 } 0225 return self::$_instance; 0226 } 0227 0228 /** 0229 * Destroys the singleton instance 0230 * 0231 * Primarily used for testing. 0232 * 0233 * @return void 0234 */ 0235 public static function destroyInstance() 0236 { 0237 self::$_instance = null; 0238 } 0239 0240 /** 0241 * Enable or disable sending of messages to user-agent. 0242 * If disabled all headers to be sent will be removed. 0243 * 0244 * @param boolean $enabled Set to TRUE to enable sending of messages. 0245 * @return boolean The previous value. 0246 */ 0247 public function setEnabled($enabled) 0248 { 0249 $previous = $this->_enabled; 0250 $this->_enabled = $enabled; 0251 if (!$this->_enabled) { 0252 $this->_messages = array(); 0253 $this->_channel->getProtocol(self::PROTOCOL_URI)->clearMessages($this); 0254 } 0255 return $previous; 0256 } 0257 0258 /** 0259 * Determine if logging to user-agent is enabled. 0260 * 0261 * @return boolean Returns TRUE if logging is enabled. 0262 */ 0263 public function getEnabled() 0264 { 0265 return $this->_enabled; 0266 } 0267 0268 /** 0269 * Set a single option 0270 * 0271 * @param string $key The name of the option 0272 * @param mixed $value The value of the option 0273 * @return mixed The previous value of the option 0274 */ 0275 public function setOption($key, $value) 0276 { 0277 if (!array_key_exists($key,$this->_options)) { 0278 throw new Zend_Wildfire_Exception('Option with name "'.$key.'" does not exist!'); 0279 } 0280 $previous = $this->_options[$key]; 0281 $this->_options[$key] = $value; 0282 return $previous; 0283 } 0284 0285 /** 0286 * Retrieve a single option 0287 * 0288 * @param string $key The name of the option 0289 * @return mixed The value of the option 0290 */ 0291 public function getOption($key) 0292 { 0293 if (!array_key_exists($key,$this->_options)) { 0294 throw new Zend_Wildfire_Exception('Option with name "'.$key.'" does not exist!'); 0295 } 0296 return $this->_options[$key]; 0297 } 0298 0299 /** 0300 * Retrieve all options 0301 * 0302 * @return array All options 0303 */ 0304 public function getOptions() 0305 { 0306 return $this->_options; 0307 } 0308 0309 /** 0310 * Specify a filter to be used when encoding an object 0311 * 0312 * Filters are used to exclude object members. 0313 * 0314 * @param string $Class The class name of the object 0315 * @param array $Filter An array of members to exclude 0316 * @return void 0317 */ 0318 public function setObjectFilter($class, $filter) { 0319 $this->_objectFilters[$class] = $filter; 0320 } 0321 0322 /** 0323 * Starts a group in the Firebug Console 0324 * 0325 * @param string $title The title of the group 0326 * @param array $options OPTIONAL Setting 'Collapsed' to true will initialize group collapsed instead of expanded 0327 * @return TRUE if the group instruction was added to the response headers or buffered. 0328 */ 0329 public static function group($title, $options=array()) 0330 { 0331 return self::send(null, $title, self::GROUP_START, $options); 0332 } 0333 0334 /** 0335 * Ends a group in the Firebug Console 0336 * 0337 * @return TRUE if the group instruction was added to the response headers or buffered. 0338 */ 0339 public static function groupEnd() 0340 { 0341 return self::send(null, null, self::GROUP_END); 0342 } 0343 0344 /** 0345 * Logs variables to the Firebug Console 0346 * via HTTP response headers and the FirePHP Firefox Extension. 0347 * 0348 * @param mixed $var The variable to log. 0349 * @param string $label OPTIONAL Label to prepend to the log event. 0350 * @param string $style OPTIONAL Style of the log event. 0351 * @param array $options OPTIONAL Options to change how messages are processed and sent 0352 * @return boolean Returns TRUE if the variable was added to the response headers or buffered. 0353 * @throws Zend_Wildfire_Exception 0354 */ 0355 public static function send($var, $label=null, $style=null, $options=array()) 0356 { 0357 $firephp = self::getInstance(); 0358 0359 if (!$firephp->getEnabled()) { 0360 return false; 0361 } 0362 0363 if ($var instanceof Zend_Wildfire_Plugin_FirePhp_Message) { 0364 0365 if ($var->getBuffered()) { 0366 if (!in_array($var, self::$_instance->_messages)) { 0367 self::$_instance->_messages[] = $var; 0368 } 0369 return true; 0370 } 0371 0372 if ($var->getDestroy()) { 0373 return false; 0374 } 0375 0376 $style = $var->getStyle(); 0377 $label = $var->getLabel(); 0378 $options = $var->getOptions(); 0379 $var = $var->getMessage(); 0380 } 0381 0382 if (!self::$_instance->_channel->isReady()) { 0383 return false; 0384 } 0385 0386 foreach ($options as $name => $value) { 0387 if ($value===null) { 0388 unset($options[$name]); 0389 } 0390 } 0391 $options = array_merge($firephp->getOptions(), $options); 0392 0393 $trace = null; 0394 0395 $skipFinalEncode = false; 0396 0397 $meta = array(); 0398 $meta['Type'] = $style; 0399 0400 if ($var instanceof Exception) { 0401 0402 $eTrace = $var->getTrace(); 0403 $eTrace = array_splice($eTrace, 0, $options['maxTraceDepth']); 0404 0405 $var = array('Class'=>get_class($var), 0406 'Message'=>$var->getMessage(), 0407 'File'=>$var->getFile(), 0408 'Line'=>$var->getLine(), 0409 'Type'=>'throw', 0410 'Trace'=>$firephp->_encodeTrace($eTrace)); 0411 0412 $meta['Type'] = self::EXCEPTION; 0413 0414 $skipFinalEncode = true; 0415 0416 } else 0417 if ($meta['Type']==self::TRACE) { 0418 0419 if (!$label && $var) { 0420 $label = $var; 0421 $var = null; 0422 } 0423 0424 if (!$trace) { 0425 $trace = $firephp->_getStackTrace(array_merge($options, 0426 array('maxTraceDepth'=>$options['maxTraceDepth']+1))); 0427 } 0428 0429 $var = array('Class'=>$trace[0]['class'], 0430 'Type'=>$trace[0]['type'], 0431 'Function'=>$trace[0]['function'], 0432 'Message'=>$label, 0433 'File'=>isset($trace[0]['file'])?$trace[0]['file']:'', 0434 'Line'=>isset($trace[0]['line'])?$trace[0]['line']:'', 0435 'Args'=>isset($trace[0]['args'])?$firephp->_encodeObject($trace[0]['args']):'', 0436 'Trace'=>$firephp->_encodeTrace(array_splice($trace,1))); 0437 0438 $skipFinalEncode = true; 0439 0440 } else 0441 if ($meta['Type']==self::TABLE) { 0442 0443 $var = $firephp->_encodeTable($var); 0444 0445 $skipFinalEncode = true; 0446 0447 } else { 0448 if ($meta['Type']===null) { 0449 $meta['Type'] = self::LOG; 0450 } 0451 } 0452 0453 if ($label!=null) { 0454 $meta['Label'] = $label; 0455 } 0456 0457 switch ($meta['Type']) { 0458 case self::LOG: 0459 case self::INFO: 0460 case self::WARN: 0461 case self::ERROR: 0462 case self::EXCEPTION: 0463 case self::TRACE: 0464 case self::TABLE: 0465 case self::DUMP: 0466 case self::GROUP_START: 0467 case self::GROUP_END: 0468 break; 0469 default: 0470 // require_once 'Zend/Wildfire/Exception.php'; 0471 throw new Zend_Wildfire_Exception('Log style "'.$meta['Type'].'" not recognized!'); 0472 break; 0473 } 0474 0475 if ($meta['Type'] != self::DUMP && $options['includeLineNumbers']) { 0476 if (!isset($meta['File']) || !isset($meta['Line'])) { 0477 0478 if (!$trace) { 0479 $trace = $firephp->_getStackTrace(array_merge($options, 0480 array('maxTraceDepth'=>$options['maxTraceDepth']+1))); 0481 } 0482 0483 $meta['File'] = isset($trace[0]['file'])?$trace[0]['file']:''; 0484 $meta['Line'] = isset($trace[0]['line'])?$trace[0]['line']:''; 0485 0486 } 0487 } else { 0488 unset($meta['File']); 0489 unset($meta['Line']); 0490 } 0491 0492 if ($meta['Type'] == self::GROUP_START) { 0493 if (isset($options['Collapsed'])) { 0494 $meta['Collapsed'] = ($options['Collapsed'])?'true':'false'; 0495 } 0496 } 0497 0498 if ($meta['Type'] == self::DUMP) { 0499 0500 return $firephp->_recordMessage(self::STRUCTURE_URI_DUMP, 0501 array('key'=>$meta['Label'], 0502 'data'=>$var), 0503 $skipFinalEncode); 0504 0505 } else { 0506 0507 return $firephp->_recordMessage(self::STRUCTURE_URI_FIREBUGCONSOLE, 0508 array('data'=>$var, 0509 'meta'=>$meta), 0510 $skipFinalEncode); 0511 } 0512 } 0513 0514 /** 0515 * Gets a stack trace 0516 * 0517 * @param array $options Options to change how the stack trace is returned 0518 * @return array The stack trace 0519 */ 0520 protected function _getStackTrace($options) 0521 { 0522 $trace = debug_backtrace(); 0523 0524 $trace = array_splice($trace, $options['traceOffset']); 0525 0526 if (!count($trace)) { 0527 return $trace; 0528 } 0529 0530 if (isset($options['fixZendLogOffsetIfApplicable']) && $options['fixZendLogOffsetIfApplicable']) { 0531 if (count($trace) >=3 && 0532 isset($trace[0]['file']) && substr($trace[0]['file'], -7, 7)=='Log.php' && 0533 isset($trace[1]['function']) && $trace[1]['function']=='__call') { 0534 0535 $spliceOffset = 2; 0536 //Debug backtrace changed in PHP 7.0.0 0537 if (version_compare(PHP_VERSION, '7.0.0', '>=')) { 0538 $spliceOffset = 1; 0539 } 0540 $trace = array_splice($trace, $spliceOffset); 0541 } 0542 } 0543 0544 return array_splice($trace, 0, $options['maxTraceDepth']); 0545 } 0546 0547 /** 0548 * Record a message with the given data in the given structure 0549 * 0550 * @param string $structure The structure to be used for the data 0551 * @param array $data The data to be recorded 0552 * @param boolean $skipEncode TRUE if variable encoding should be skipped 0553 * @return boolean Returns TRUE if message was recorded 0554 * @throws Zend_Wildfire_Exception 0555 */ 0556 protected function _recordMessage($structure, $data, $skipEncode=false) 0557 { 0558 switch($structure) { 0559 0560 case self::STRUCTURE_URI_DUMP: 0561 0562 if (!isset($data['key'])) { 0563 // require_once 'Zend/Wildfire/Exception.php'; 0564 throw new Zend_Wildfire_Exception('You must supply a key.'); 0565 } 0566 if (!array_key_exists('data',$data)) { 0567 // require_once 'Zend/Wildfire/Exception.php'; 0568 throw new Zend_Wildfire_Exception('You must supply data.'); 0569 } 0570 0571 $value = $data['data']; 0572 if (!$skipEncode) { 0573 $value = $this->_encodeObject($data['data']); 0574 } 0575 0576 return $this->_channel->getProtocol(self::PROTOCOL_URI)-> 0577 recordMessage($this, 0578 $structure, 0579 array($data['key']=>$value)); 0580 0581 case self::STRUCTURE_URI_FIREBUGCONSOLE: 0582 0583 if (!isset($data['meta']) || 0584 !is_array($data['meta']) || 0585 !array_key_exists('Type',$data['meta'])) { 0586 0587 // require_once 'Zend/Wildfire/Exception.php'; 0588 throw new Zend_Wildfire_Exception('You must supply a "Type" in the meta information.'); 0589 } 0590 if (!array_key_exists('data',$data)) { 0591 // require_once 'Zend/Wildfire/Exception.php'; 0592 throw new Zend_Wildfire_Exception('You must supply data.'); 0593 } 0594 0595 $value = $data['data']; 0596 if (!$skipEncode) { 0597 $value = $this->_encodeObject($data['data']); 0598 } 0599 0600 return $this->_channel->getProtocol(self::PROTOCOL_URI)-> 0601 recordMessage($this, 0602 $structure, 0603 array($data['meta'], 0604 $value)); 0605 0606 default: 0607 // require_once 'Zend/Wildfire/Exception.php'; 0608 throw new Zend_Wildfire_Exception('Structure of name "'.$structure.'" is not recognized.'); 0609 break; 0610 } 0611 return false; 0612 } 0613 0614 /** 0615 * Encodes a table by encoding each row and column with _encodeObject() 0616 * 0617 * @param array $Table The table to be encoded 0618 * @return array 0619 */ 0620 protected function _encodeTable($table) 0621 { 0622 if (!$table) { 0623 return $table; 0624 } 0625 for ($i=0 ; $i<count($table) ; $i++) { 0626 if (is_array($table[$i])) { 0627 for ($j=0 ; $j<count($table[$i]) ; $j++) { 0628 $table[$i][$j] = $this->_encodeObject($table[$i][$j]); 0629 } 0630 } 0631 } 0632 return $table; 0633 } 0634 0635 /** 0636 * Encodes a trace by encoding all "args" with _encodeObject() 0637 * 0638 * @param array $Trace The trace to be encoded 0639 * @return array The encoded trace 0640 */ 0641 protected function _encodeTrace($trace) 0642 { 0643 if (!$trace) { 0644 return $trace; 0645 } 0646 for ($i=0 ; $i<sizeof($trace) ; $i++) { 0647 if (isset($trace[$i]['args'])) { 0648 $trace[$i]['args'] = $this->_encodeObject($trace[$i]['args']); 0649 } 0650 } 0651 return $trace; 0652 } 0653 0654 /** 0655 * Encode an object by generating an array containing all object members. 0656 * 0657 * All private and protected members are included. Some meta info about 0658 * the object class is added. 0659 * 0660 * @param mixed $object The object/array/value to be encoded 0661 * @return array The encoded object 0662 */ 0663 protected function _encodeObject($object, $objectDepth = 1, $arrayDepth = 1) 0664 { 0665 $return = array(); 0666 0667 if (is_resource($object)) { 0668 0669 return '** '.(string)$object.' **'; 0670 0671 } else 0672 if (is_object($object)) { 0673 0674 if ($objectDepth > $this->_options['maxObjectDepth']) { 0675 return '** Max Object Depth ('.$this->_options['maxObjectDepth'].') **'; 0676 } 0677 0678 foreach ($this->_objectStack as $refVal) { 0679 if ($refVal === $object) { 0680 return '** Recursion ('.get_class($object).') **'; 0681 } 0682 } 0683 array_push($this->_objectStack, $object); 0684 0685 $return['__className'] = $class = get_class($object); 0686 0687 $reflectionClass = new ReflectionClass($class); 0688 $properties = array(); 0689 foreach ( $reflectionClass->getProperties() as $property) { 0690 $properties[$property->getName()] = $property; 0691 } 0692 0693 $members = (array)$object; 0694 0695 foreach ($properties as $just_name => $property) { 0696 0697 $name = $raw_name = $just_name; 0698 0699 if ($property->isStatic()) { 0700 $name = 'static:'.$name; 0701 } 0702 if ($property->isPublic()) { 0703 $name = 'public:'.$name; 0704 } else 0705 if ($property->isPrivate()) { 0706 $name = 'private:'.$name; 0707 $raw_name = "\0".$class."\0".$raw_name; 0708 } else 0709 if ($property->isProtected()) { 0710 $name = 'protected:'.$name; 0711 $raw_name = "\0".'*'."\0".$raw_name; 0712 } 0713 0714 if (!(isset($this->_objectFilters[$class]) 0715 && is_array($this->_objectFilters[$class]) 0716 && in_array($just_name,$this->_objectFilters[$class]))) { 0717 0718 if (array_key_exists($raw_name,$members) 0719 && !$property->isStatic()) { 0720 0721 $return[$name] = $this->_encodeObject($members[$raw_name], $objectDepth + 1, 1); 0722 0723 } else { 0724 if (method_exists($property,'setAccessible')) { 0725 $property->setAccessible(true); 0726 $return[$name] = $this->_encodeObject($property->getValue($object), $objectDepth + 1, 1); 0727 } else 0728 if ($property->isPublic()) { 0729 $return[$name] = $this->_encodeObject($property->getValue($object), $objectDepth + 1, 1); 0730 } else { 0731 $return[$name] = '** Need PHP 5.3 to get value **'; 0732 } 0733 } 0734 } else { 0735 $return[$name] = '** Excluded by Filter **'; 0736 } 0737 } 0738 0739 // Include all members that are not defined in the class 0740 // but exist in the object 0741 foreach($members as $just_name => $value) { 0742 0743 $name = $raw_name = $just_name; 0744 0745 if ($name{0} == "\0") { 0746 $parts = explode("\0", $name); 0747 $name = $parts[2]; 0748 } 0749 if (!isset($properties[$name])) { 0750 $name = 'undeclared:'.$name; 0751 0752 if (!(isset($this->objectFilters[$class]) 0753 && is_array($this->objectFilters[$class]) 0754 && in_array($just_name,$this->objectFilters[$class]))) { 0755 0756 $return[$name] = $this->_encodeObject($value, $objectDepth + 1, 1); 0757 } else { 0758 $return[$name] = '** Excluded by Filter **'; 0759 } 0760 } 0761 } 0762 0763 array_pop($this->_objectStack); 0764 0765 } elseif (is_array($object)) { 0766 0767 if ($arrayDepth > $this->_options['maxArrayDepth']) { 0768 return '** Max Array Depth ('.$this->_options['maxArrayDepth'].') **'; 0769 } 0770 0771 foreach ($object as $key => $val) { 0772 0773 // Encoding the $GLOBALS PHP array causes an infinite loop 0774 // if the recursion is not reset here as it contains 0775 // a reference to itself. This is the only way I have come up 0776 // with to stop infinite recursion in this case. 0777 if ($key=='GLOBALS' 0778 && is_array($val) 0779 && array_key_exists('GLOBALS',$val)) { 0780 0781 $val['GLOBALS'] = '** Recursion (GLOBALS) **'; 0782 } 0783 $return[$key] = $this->_encodeObject($val, 1, $arrayDepth + 1); 0784 } 0785 } else { 0786 return $object; 0787 } 0788 return $return; 0789 } 0790 0791 /* 0792 * Zend_Wildfire_Plugin_Interface 0793 */ 0794 0795 /** 0796 * Get the unique indentifier for this plugin. 0797 * 0798 * @return string Returns the URI of the plugin. 0799 */ 0800 public function getUri() 0801 { 0802 return self::PLUGIN_URI; 0803 } 0804 0805 /** 0806 * Flush any buffered data. 0807 * 0808 * @param string $protocolUri The URI of the protocol that should be flushed to 0809 * @return void 0810 */ 0811 public function flushMessages($protocolUri) 0812 { 0813 if (!$this->_messages || $protocolUri!=self::PROTOCOL_URI) { 0814 return; 0815 } 0816 0817 foreach( $this->_messages as $message ) { 0818 if (!$message->getDestroy()) { 0819 $this->send($message->getMessage(), 0820 $message->getLabel(), 0821 $message->getStyle(), 0822 $message->getOptions()); 0823 } 0824 } 0825 0826 $this->_messages = array(); 0827 } 0828 }