PageRenderTime 98ms CodeModel.GetById 36ms app.highlight 3ms RepoModel.GetById 57ms app.codeStats 0ms

/library/Zend/Wildfire/Plugin/FirePhp/Message.php

https://bitbucket.org/baruffaldi/cms-php-bfcms
PHP | 195 lines | 60 code | 19 blank | 116 comment | 0 complexity | a1964780bd4cc4f7c3735307af8112bb MD5 | raw file
  1<?php
  2/**
  3 * Zend Framework
  4 *
  5 * LICENSE
  6 *
  7 * This source file is subject to the new BSD license that is bundled
  8 * with this package in the file LICENSE.txt.
  9 * It is also available through the world-wide-web at this URL:
 10 * http://framework.zend.com/license/new-bsd
 11 * If you did not receive a copy of the license and are unable to
 12 * obtain it through the world-wide-web, please send an email
 13 * to license@zend.com so we can send you a copy immediately.
 14 *
 15 * @category   Zend
 16 * @package    Zend_Wildfire
 17 * @subpackage Plugin
 18 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 19 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 20 */
 21
 22
 23/**
 24 * A message envelope that can be passed to Zend_Wildfire_Plugin_FirePhp to be
 25 * logged to Firebug instead of a variable.
 26 * 
 27 * @category   Zend
 28 * @package    Zend_Wildfire
 29 * @subpackage Plugin
 30 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 31 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 32 */
 33class Zend_Wildfire_Plugin_FirePhp_Message
 34{
 35    /**
 36     * The style of the message
 37     * @var string
 38     */
 39    protected $_style = null;
 40    
 41    /**
 42     * The label of the message
 43     * @var string
 44     */
 45    protected $_label = null;
 46    
 47    /**
 48     * The message value
 49     * @var mixed
 50     */
 51    protected $_message = null;
 52    
 53    /**
 54     * Flag indicating if message buffering is enabled
 55     * @var boolean
 56     */
 57    protected $_buffered = false;
 58
 59    /**
 60     * Flag indicating if message should be destroyed and not delivered
 61     * @var boolean
 62     */
 63    protected $_destroy = false;
 64
 65    /**
 66     * Random unique ID used to identify message in comparison operations
 67     * @var string
 68     */
 69    protected $_ruid = false;
 70
 71    /**
 72     * Creates a new message with the given style and message
 73     * 
 74     * @param string $style Style of the message.
 75     * @param mixed $message The message
 76     * @return void
 77     */
 78    function __construct($style, $message)
 79    {
 80        $this->_style = $style;
 81        $this->_message = $message;    
 82        $this->_ruid = md5(microtime().mt_rand());
 83    }
 84    
 85    /**
 86     * Set the label of the message
 87     * 
 88     * @param string $label The label to be set
 89     * @return void
 90     */
 91    public function setLabel($label)
 92    {
 93        $this->_label = $label;
 94    }
 95    
 96    /**
 97     * Get the label of the message
 98     * 
 99     * @return string The label of the message
100     */
101    public function getLabel()
102    {
103        return $this->_label;
104    }
105    
106    /**
107     * Enable or disable message buffering
108     * 
109     * If a message is buffered it can be updated for the duration of the
110     * request and is only flushed at the end of the request.
111     * 
112     * @param boolean $buffered TRUE to enable buffering FALSE otherwise
113     * @return boolean Returns previous buffering value
114     */
115    public function setBuffered($buffered)
116    {
117        $previous = $this->_buffered;
118        $this->_buffered = $buffered;
119        return $previous;
120    }
121
122    /**
123     * Determine if buffering is enabled or disabled
124     * 
125     * @return boolean Returns TRUE if buffering is enabled, FALSE otherwise. 
126     */
127    public function getBuffered()
128    {
129        return $this->_buffered;
130    }
131    
132    /**
133     * Destroy the message to prevent delivery
134     * 
135     * @param boolean $destroy TRUE to destroy FALSE otherwise
136     * @return boolean Returns previous destroy value
137     */
138    public function setDestroy($destroy)
139    {
140        $previous = $this->_destroy;
141        $this->_destroy = $destroy;
142        return $previous;
143    }
144    
145    /**
146     * Determine if message should be destroyed
147     * 
148     * @return boolean Returns TRUE if message should be destroyed, FALSE otherwise. 
149     */
150    public function getDestroy()
151    {
152        return $this->_destroy;
153    }
154
155    /**
156     * Set the style of the message
157     * 
158     * @return void
159     */
160    public function setStyle($style)
161    {
162        $this->_style = $style;
163    }
164
165    /**
166     * Get the style of the message
167     * 
168     * @return string The style of the message
169     */
170    public function getStyle()
171    {
172        return $this->_style;
173    }
174
175    /**
176     * Set the actual message to be sent in its final format.
177     * 
178     * @return void
179     */
180    public function setMessage($message)
181    {
182        $this->_message = $message;
183    }
184
185    /**
186     * Get the actual message to be sent in its final format.
187     * 
188     * @return mixed Returns the message to be sent.
189     */
190    public function getMessage()
191    {
192        return $this->_message;
193    }
194}
195