Initial Kohana install
[speedfreak] / Server / system / libraries / Profiler_Table.php
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3  * Provides a table layout for sections in the Profiler library.
4  *
5  * $Id$
6  *
7  * @package    Profiler
8  * @author     Kohana Team
9  * @copyright  (c) 2007-2008 Kohana Team
10  * @license    http://kohanaphp.com/license.html
11  */
12 class Profiler_Table_Core {
13
14         protected $columns = array();
15         protected $rows = array();
16
17         /**
18          * Get styles for table.
19          *
20          * @return  string
21          */
22         public function styles()
23         {
24                 static $styles_output;
25
26                 if ( ! $styles_output)
27                 {
28                         $styles_output = TRUE;
29                         return file_get_contents(Kohana::find_file('views', 'kohana_profiler_table', FALSE, 'css'));
30                 }
31
32                 return '';
33         }
34
35         /**
36          * Add column to table.
37          *
38          * @param  string  CSS class
39          * @param  string  CSS style
40          */
41         public function add_column($class = '', $style = '')
42         {
43                 $this->columns[] = array('class' => $class, 'style' => $style);
44         }
45
46         /**
47          * Add row to table.
48          *
49          * @param  array   data to go in table cells
50          * @param  string  CSS class
51          * @param  string  CSS style
52          */
53         public function add_row($data, $class = '', $style = '')
54         {
55                 $this->rows[] = array('data' => $data, 'class' => $class, 'style' => $style);
56         }
57
58         /**
59          * Render table.
60          *
61          * @return  string
62          */
63         public function render()
64         {
65                 $data['rows'] = $this->rows;
66                 $data['columns'] = $this->columns;
67                 return View::factory('kohana_profiler_table', $data)->render();
68         }
69 }