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.
16 * @package Zend_Wildfire
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: TableMessage.php 16971 2009-07-22 18:05:45Z mikaelkael $
23 /** Zend_Wildfire_Plugin_FirePhp */
24 require_once 'Zend/Wildfire/Plugin/FirePhp.php';
26 /** Zend_Wildfire_Plugin_FirePhp_Message */
27 require_once 'Zend/Wildfire/Plugin/FirePhp/Message.php';
30 * A message envelope that can be updated for the duration of the requet before
31 * it gets flushed at the end of the request.
34 * @package Zend_Wildfire
36 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
37 * @license http://framework.zend.com/license/new-bsd New BSD License
39 class Zend_Wildfire_Plugin_FirePhp_TableMessage
extends Zend_Wildfire_Plugin_FirePhp_Message
42 * The header of the table containing all columns
45 protected $_header = null;
48 * The rows of the table
51 protected $_rows = array();
56 * @param string $label The label of the table
58 function __construct($label)
60 parent
::__construct(Zend_Wildfire_Plugin_FirePhp
::TABLE
, null);
61 $this->setLabel($label);
65 * Set the table header
67 * @param array $header The header columns
70 public function setHeader($header)
72 $this->_header
= $header;
76 * Append a row to the end of the table.
78 * @param array $row An array of column values representing a row.
81 public function addRow($row)
83 $this->_rows
[] = $row;
87 * Get the actual message to be sent in its final format.
89 * @return mixed Returns the message to be sent.
91 public function getMessage()
93 $table = $this->_rows
;
95 array_unshift($table,$this->_header
);
101 * Returns the row at the given index
103 * @param integer $index The index of the row
104 * @return array Returns the row
105 * @throws Zend_Wildfire_Exception
107 public function getRowAt($index)
109 $count = $this->getRowCount();
111 if($index < 0 ||
$index > $count-1) {
112 require_once 'Zend/Wildfire/Exception.php';
113 throw new Zend_Wildfire_Exception('Row index('.$index.') out of bounds('.$count.')!');
116 return $this->_rows
[$index];
120 * Sets the row on the given index to a new row
122 * @param integer $index The index of the row
123 * @param array $row The new data for the row
124 * @throws Zend_Wildfire_Exception
126 public function setRowAt($index, $row)
128 $count = $this->getRowCount();
130 if($index < 0 ||
$index > $count-1) {
131 require_once 'Zend/Wildfire/Exception.php';
132 throw new Zend_Wildfire_Exception('Row index('.$index.') out of bounds('.$count.')!');
135 $this->_rows
[$index] = $row;
139 * Returns the number of rows
143 public function getRowCount()
145 return count($this->_rows
);
149 * Returns the last row of the table
151 * @return array Returns the last row
152 * @throws Zend_Wildfire_Exception
154 public function getLastRow()
156 $count = $this->getRowCount();
159 require_once 'Zend/Wildfire/Exception.php';
160 throw new Zend_Wildfire_Exception('Cannot get last row as no rows exist!');
163 return $this->_rows
[$count-1];