1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
|
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Wildfire
* @subpackage Plugin
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Message.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* A message envelope that can be passed to Zend_Wildfire_Plugin_FirePhp to be
* logged to Firebug instead of a variable.
*
* @category Zend
* @package Zend_Wildfire
* @subpackage Plugin
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Wildfire_Plugin_FirePhp_Message
{
/**
* The style of the message
* @var string
*/
protected $_style = null;
/**
* The label of the message
* @var string
*/
protected $_label = null;
/**
* The message value
* @var mixed
*/
protected $_message = null;
/**
* Flag indicating if message buffering is enabled
* @var boolean
*/
protected $_buffered = false;
/**
* Flag indicating if message should be destroyed and not delivered
* @var boolean
*/
protected $_destroy = false;
/**
* Random unique ID used to identify message in comparison operations
* @var string
*/
protected $_ruid = false;
/**
* Options for the object
* @var array
*/
protected $_options = array(
'traceOffset' => null, /* The offset in the trace which identifies the source of the message */
'includeLineNumbers' => null /* Whether to include line and file info for this message */
);
/**
* Creates a new message with the given style and message
*
* @param string $style Style of the message.
* @param mixed $message The message
* @return void
*/
function __construct($style, $message)
{
$this->_style = $style;
$this->_message = $message;
$this->_ruid = md5(microtime().mt_rand());
}
/**
* Set the label of the message
*
* @param string $label The label to be set
* @return void
*/
public function setLabel($label)
{
$this->_label = $label;
}
/**
* Get the label of the message
*
* @return string The label of the message
*/
public function getLabel()
{
return $this->_label;
}
/**
* Enable or disable message buffering
*
* If a message is buffered it can be updated for the duration of the
* request and is only flushed at the end of the request.
*
* @param boolean $buffered TRUE to enable buffering FALSE otherwise
* @return boolean Returns previous buffering value
*/
public function setBuffered($buffered)
{
$previous = $this->_buffered;
$this->_buffered = $buffered;
return $previous;
}
/**
* Determine if buffering is enabled or disabled
*
* @return boolean Returns TRUE if buffering is enabled, FALSE otherwise.
*/
public function getBuffered()
{
return $this->_buffered;
}
/**
* Destroy the message to prevent delivery
*
* @param boolean $destroy TRUE to destroy FALSE otherwise
* @return boolean Returns previous destroy value
*/
public function setDestroy($destroy)
{
$previous = $this->_destroy;
$this->_destroy = $destroy;
return $previous;
}
/**
* Determine if message should be destroyed
*
* @return boolean Returns TRUE if message should be destroyed, FALSE otherwise.
*/
public function getDestroy()
{
return $this->_destroy;
}
/**
* Set the style of the message
*
* @return void
*/
public function setStyle($style)
{
$this->_style = $style;
}
/**
* Get the style of the message
*
* @return string The style of the message
*/
public function getStyle()
{
return $this->_style;
}
/**
* Set the actual message to be sent in its final format.
*
* @return void
*/
public function setMessage($message)
{
$this->_message = $message;
}
/**
* Get the actual message to be sent in its final format.
*
* @return mixed Returns the message to be sent.
*/
public function getMessage()
{
return $this->_message;
}
/**
* Set a single option
*
* @param string $key The name of the option
* @param mixed $value The value of the option
* @return mixed The previous value of the option
*/
public function setOption($key, $value)
{
if(!array_key_exists($key,$this->_options)) {
throw new Zend_Wildfire_Exception('Option with name "'.$key.'" does not exist!');
}
$previous = $this->_options[$key];
$this->_options[$key] = $value;
return $previous;
}
/**
* Retrieve a single option
*
* @param string $key The name of the option
* @return mixed The value of the option
*/
public function getOption($key)
{
if(!array_key_exists($key,$this->_options)) {
throw new Zend_Wildfire_Exception('Option with name "'.$key.'" does not exist!');
}
return $this->_options[$key];
}
/**
* Retrieve all options
*
* @return array All options
*/
public function getOptions()
{
return $this->_options;
}
}
|