blob: fb410e9fdeceee747ad797028cee12ac4bcdf572 [file] [log] [blame]
Andrey Andreevfe9b9a92011-12-25 16:11:01 +02001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Derek Allard2067d1a2008-11-13 22:59:24 +00002/**
3 * CodeIgniter
4 *
Greg Aker741de1c2010-11-10 14:52:57 -06005 * An open source application development framework for PHP 5.1.6 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05007 * NOTICE OF LICENSE
Andrey Andreevfe9b9a92011-12-25 16:11:01 +02008 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05009 * Licensed under the Open Software License version 3.0
Andrey Andreevfe9b9a92011-12-25 16:11:01 +020010 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -050011 * This source file is subject to the Open Software License (OSL 3.0) that is
12 * bundled with this package in the files license.txt / license.rst. It is
13 * also available through the world wide web at this URL:
14 * http://opensource.org/licenses/OSL-3.0
15 * If you did not receive a copy of the license and are unable to obtain it
16 * through the world wide web, please send an email to
17 * licensing@ellislab.com so we can send you a copy immediately.
18 *
Derek Allard2067d1a2008-11-13 22:59:24 +000019 * @package CodeIgniter
Derek Jonesf4a4bd82011-10-20 12:18:42 -050020 * @author EllisLab Dev Team
21 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
22 * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
Derek Allard2067d1a2008-11-13 22:59:24 +000023 * @link http://codeigniter.com
24 * @since Version 1.3.1
25 * @filesource
26 */
27
28// ------------------------------------------------------------------------
29
30/**
31 * HTML Table Generating Class
32 *
33 * Lets you create tables manually or from database result objects, or arrays.
34 *
35 * @package CodeIgniter
36 * @subpackage Libraries
37 * @category HTML Tables
Derek Jonesf4a4bd82011-10-20 12:18:42 -050038 * @author EllisLab Dev Team
Gerry6b590892011-09-25 00:16:39 +080039 * @link http://codeigniter.com/user_guide/libraries/table.html
Derek Allard2067d1a2008-11-13 22:59:24 +000040 */
41class CI_Table {
42
Andrey Andreevfe9b9a92011-12-25 16:11:01 +020043 public $rows = array();
44 public $heading = array();
45 public $auto_heading = TRUE;
46 public $caption = NULL;
47 public $template = NULL;
48 public $newline = "\n";
49 public $empty_cells = '';
50 public $function = FALSE;
Barry Mienydd671972010-10-04 16:33:58 +020051
Greg Akera9263282010-11-10 15:26:43 -060052 public function __construct()
Derek Allard2067d1a2008-11-13 22:59:24 +000053 {
54 log_message('debug', "Table Class Initialized");
55 }
56
57 // --------------------------------------------------------------------
58
59 /**
60 * Set the template
61 *
62 * @access public
63 * @param array
64 * @return void
65 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +020066 public function set_template($template)
Derek Allard2067d1a2008-11-13 22:59:24 +000067 {
68 if ( ! is_array($template))
69 {
70 return FALSE;
71 }
Barry Mienydd671972010-10-04 16:33:58 +020072
Derek Allard2067d1a2008-11-13 22:59:24 +000073 $this->template = $template;
74 }
75
76 // --------------------------------------------------------------------
77
78 /**
79 * Set the table heading
80 *
81 * Can be passed as an array or discreet params
82 *
83 * @access public
84 * @param mixed
85 * @return void
86 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +020087 public function set_heading()
Derek Allard2067d1a2008-11-13 22:59:24 +000088 {
89 $args = func_get_args();
Derek Jones7b5b0e22010-03-02 22:48:53 -060090 $this->heading = $this->_prep_args($args);
Derek Allard2067d1a2008-11-13 22:59:24 +000091 }
92
93 // --------------------------------------------------------------------
94
95 /**
Derek Jones4b9c6292011-07-01 17:40:48 -050096 * Set columns. Takes a one-dimensional array as input and creates
Derek Allard2067d1a2008-11-13 22:59:24 +000097 * a multi-dimensional array with a depth equal to the number of
Derek Jones4b9c6292011-07-01 17:40:48 -050098 * columns. This allows a single array with many elements to be
Derek Allard2067d1a2008-11-13 22:59:24 +000099 * displayed in a table that has a fixed column count.
100 *
101 * @access public
102 * @param array
103 * @param int
104 * @return void
105 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200106 public function make_columns($array = array(), $col_limit = 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000107 {
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200108 if ( ! is_array($array) OR count($array) === 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000109 {
110 return FALSE;
111 }
Barry Mienydd671972010-10-04 16:33:58 +0200112
113 // Turn off the auto-heading feature since it's doubtful we
Derek Allard2067d1a2008-11-13 22:59:24 +0000114 // will want headings from a one-dimensional array
115 $this->auto_heading = FALSE;
Barry Mienydd671972010-10-04 16:33:58 +0200116
Derek Allard2067d1a2008-11-13 22:59:24 +0000117 if ($col_limit == 0)
118 {
119 return $array;
120 }
Barry Mienydd671972010-10-04 16:33:58 +0200121
Derek Allard2067d1a2008-11-13 22:59:24 +0000122 $new = array();
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200123 do
Barry Mienydd671972010-10-04 16:33:58 +0200124 {
125 $temp = array_splice($array, 0, $col_limit);
126
Derek Allard2067d1a2008-11-13 22:59:24 +0000127 if (count($temp) < $col_limit)
128 {
129 for ($i = count($temp); $i < $col_limit; $i++)
130 {
131 $temp[] = '&nbsp;';
132 }
133 }
Barry Mienydd671972010-10-04 16:33:58 +0200134
Derek Allard2067d1a2008-11-13 22:59:24 +0000135 $new[] = $temp;
136 }
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200137 while (count($array) > 0);
Barry Mienydd671972010-10-04 16:33:58 +0200138
Derek Allard2067d1a2008-11-13 22:59:24 +0000139 return $new;
140 }
141
142 // --------------------------------------------------------------------
143
144 /**
145 * Set "empty" cells
146 *
147 * Can be passed as an array or discreet params
148 *
149 * @access public
150 * @param mixed
151 * @return void
152 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200153 public function set_empty($value)
Derek Allard2067d1a2008-11-13 22:59:24 +0000154 {
155 $this->empty_cells = $value;
156 }
Barry Mienydd671972010-10-04 16:33:58 +0200157
Derek Allard2067d1a2008-11-13 22:59:24 +0000158 // --------------------------------------------------------------------
159
160 /**
161 * Add a table row
162 *
163 * Can be passed as an array or discreet params
164 *
165 * @access public
166 * @param mixed
167 * @return void
168 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200169 public function add_row()
Derek Allard2067d1a2008-11-13 22:59:24 +0000170 {
171 $args = func_get_args();
Derek Jones7b5b0e22010-03-02 22:48:53 -0600172 $this->rows[] = $this->_prep_args($args);
Derek Allard2067d1a2008-11-13 22:59:24 +0000173 }
174
175 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200176
Derek Jones7b5b0e22010-03-02 22:48:53 -0600177 /**
178 * Prep Args
179 *
180 * Ensures a standard associative array format for all cell data
181 *
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200182 * @access private
Derek Jones7b5b0e22010-03-02 22:48:53 -0600183 * @param type
184 * @return type
185 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200186 private function _prep_args($args)
Derek Jones7b5b0e22010-03-02 22:48:53 -0600187 {
188 // If there is no $args[0], skip this and treat as an associative array
189 // This can happen if there is only a single key, for example this is passed to table->generate
190 // array(array('foo'=>'bar'))
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200191 if (isset($args[0]) AND (count($args) === 1 && is_array($args[0])))
Derek Jones7b5b0e22010-03-02 22:48:53 -0600192 {
193 // args sent as indexed array
194 if ( ! isset($args[0]['data']))
195 {
196 foreach ($args[0] as $key => $val)
197 {
198 if (is_array($val) && isset($val['data']))
199 {
200 $args[$key] = $val;
201 }
202 else
203 {
Barry Mienydd671972010-10-04 16:33:58 +0200204 $args[$key] = array('data' => $val);
Derek Jones7b5b0e22010-03-02 22:48:53 -0600205 }
Barry Mienydd671972010-10-04 16:33:58 +0200206 }
Derek Jones7b5b0e22010-03-02 22:48:53 -0600207 }
208 }
209 else
210 {
211 foreach ($args as $key => $val)
212 {
213 if ( ! is_array($val))
214 {
215 $args[$key] = array('data' => $val);
216 }
217 }
218 }
Barry Mienydd671972010-10-04 16:33:58 +0200219
Derek Jones7b5b0e22010-03-02 22:48:53 -0600220 return $args;
221 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000222
Derek Jones7b5b0e22010-03-02 22:48:53 -0600223 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200224
Derek Allard2067d1a2008-11-13 22:59:24 +0000225 /**
226 * Add a table caption
227 *
228 * @access public
229 * @param string
230 * @return void
231 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200232 public function set_caption($caption)
Derek Allard2067d1a2008-11-13 22:59:24 +0000233 {
234 $this->caption = $caption;
Barry Mienydd671972010-10-04 16:33:58 +0200235 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000236
237 // --------------------------------------------------------------------
238
239 /**
240 * Generate the table
241 *
242 * @access public
243 * @param mixed
244 * @return string
245 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200246 public function generate($table_data = NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000247 {
248 // The table data can optionally be passed to this function
249 // either as a database result object or an array
250 if ( ! is_null($table_data))
251 {
252 if (is_object($table_data))
253 {
254 $this->_set_from_object($table_data);
255 }
256 elseif (is_array($table_data))
257 {
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200258 $set_heading = (count($this->heading) === 0 AND $this->auto_heading == FALSE) ? FALSE : TRUE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000259 $this->_set_from_array($table_data, $set_heading);
260 }
261 }
Barry Mienydd671972010-10-04 16:33:58 +0200262
Derek Jones4b9c6292011-07-01 17:40:48 -0500263 // Is there anything to display? No? Smite them!
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200264 if (count($this->heading) === 0 AND count($this->rows) === 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000265 {
266 return 'Undefined table data';
267 }
Barry Mienydd671972010-10-04 16:33:58 +0200268
Derek Allard2067d1a2008-11-13 22:59:24 +0000269 // Compile and validate the template date
270 $this->_compile_template();
Barry Mienydd671972010-10-04 16:33:58 +0200271
Derek Jones7b5b0e22010-03-02 22:48:53 -0600272 // set a custom cell manipulation function to a locally scoped variable so its callable
273 $function = $this->function;
Barry Mienydd671972010-10-04 16:33:58 +0200274
Derek Allard2067d1a2008-11-13 22:59:24 +0000275 // Build the table!
Barry Mienydd671972010-10-04 16:33:58 +0200276
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200277 $out = $this->template['table_open'].$this->newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000278
279 // Add any caption here
280 if ($this->caption)
281 {
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200282 $out .= $this->newline.'<caption>'.$this->caption.'</caption>'.$this->newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000283 }
284
285 // Is there a table heading to display?
286 if (count($this->heading) > 0)
287 {
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200288 $out .= $this->template['thead_open'].$this->newline.$this->template['heading_row_start'].$this->newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000289
Pascal Kriete14287f32011-02-14 13:39:34 -0500290 foreach ($this->heading as $heading)
Derek Allard2067d1a2008-11-13 22:59:24 +0000291 {
Derek Jones7b5b0e22010-03-02 22:48:53 -0600292 $temp = $this->template['heading_cell_start'];
Barry Mienydd671972010-10-04 16:33:58 +0200293
Derek Jones7b5b0e22010-03-02 22:48:53 -0600294 foreach ($heading as $key => $val)
295 {
296 if ($key != 'data')
297 {
298 $temp = str_replace('<th', "<th $key='$val'", $temp);
Barry Mienydd671972010-10-04 16:33:58 +0200299 }
Derek Jones7b5b0e22010-03-02 22:48:53 -0600300 }
301
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200302 $out .= $temp.(isset($heading['data']) ? $heading['data'] : '').$this->template['heading_cell_end'];
Derek Allard2067d1a2008-11-13 22:59:24 +0000303 }
304
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200305 $out .= $this->template['heading_row_end'].$this->newline.$this->template['thead_close'].$this->newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000306 }
Barry Mienydd671972010-10-04 16:33:58 +0200307
Derek Allard2067d1a2008-11-13 22:59:24 +0000308 // Build the table rows
309 if (count($this->rows) > 0)
310 {
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200311 $out .= $this->template['tbody_open'].$this->newline;
Barry Mienydd671972010-10-04 16:33:58 +0200312
Derek Allard2067d1a2008-11-13 22:59:24 +0000313 $i = 1;
Pascal Kriete14287f32011-02-14 13:39:34 -0500314 foreach ($this->rows as $row)
Derek Allard2067d1a2008-11-13 22:59:24 +0000315 {
316 if ( ! is_array($row))
317 {
318 break;
319 }
Barry Mienydd671972010-10-04 16:33:58 +0200320
Derek Allard2067d1a2008-11-13 22:59:24 +0000321 // We use modulus to alternate the row colors
322 $name = (fmod($i++, 2)) ? '' : 'alt_';
Barry Mienydd671972010-10-04 16:33:58 +0200323
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200324 $out .= $this->template['row_'.$name.'start'].$this->newline;
Barry Mienydd671972010-10-04 16:33:58 +0200325
Pascal Kriete14287f32011-02-14 13:39:34 -0500326 foreach ($row as $cell)
Derek Allard2067d1a2008-11-13 22:59:24 +0000327 {
Derek Jones7b5b0e22010-03-02 22:48:53 -0600328 $temp = $this->template['cell_'.$name.'start'];
Barry Mienydd671972010-10-04 16:33:58 +0200329
Derek Jones7b5b0e22010-03-02 22:48:53 -0600330 foreach ($cell as $key => $val)
331 {
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200332 if ($key !== 'data')
Derek Jones7b5b0e22010-03-02 22:48:53 -0600333 {
334 $temp = str_replace('<td', "<td $key='$val'", $temp);
Barry Mienydd671972010-10-04 16:33:58 +0200335 }
Derek Jones7b5b0e22010-03-02 22:48:53 -0600336 }
Barry Mienydd671972010-10-04 16:33:58 +0200337
Derek Jones7b5b0e22010-03-02 22:48:53 -0600338 $cell = isset($cell['data']) ? $cell['data'] : '';
339 $out .= $temp;
340
Derek Allardd8270582010-01-15 17:10:56 +0000341 if ($cell === "" OR $cell === NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000342 {
343 $out .= $this->empty_cells;
344 }
345 else
346 {
Derek Jones7b5b0e22010-03-02 22:48:53 -0600347 if ($function !== FALSE && is_callable($function))
348 {
Phil Sturgeon6c597f82010-12-27 17:35:35 +0000349 $out .= call_user_func($function, $cell);
Derek Jones7b5b0e22010-03-02 22:48:53 -0600350 }
351 else
352 {
353 $out .= $cell;
354 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000355 }
Barry Mienydd671972010-10-04 16:33:58 +0200356
Derek Allard2067d1a2008-11-13 22:59:24 +0000357 $out .= $this->template['cell_'.$name.'end'];
358 }
Barry Mienydd671972010-10-04 16:33:58 +0200359
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200360 $out .= $this->template['row_'.$name.'end'].$this->newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000361 }
Barry Mienydd671972010-10-04 16:33:58 +0200362
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200363 $out .= $this->template['tbody_close'].$this->newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000364 }
365
366 $out .= $this->template['table_close'];
Barry Mienydd671972010-10-04 16:33:58 +0200367
Greg Aker02b3a5b2011-02-01 01:29:21 -0600368 // Clear table class properties before generating the table
369 $this->clear();
370
Derek Allard2067d1a2008-11-13 22:59:24 +0000371 return $out;
372 }
Barry Mienydd671972010-10-04 16:33:58 +0200373
Derek Allard2067d1a2008-11-13 22:59:24 +0000374 // --------------------------------------------------------------------
375
376 /**
Derek Jones4b9c6292011-07-01 17:40:48 -0500377 * Clears the table arrays. Useful if multiple tables are being generated
Derek Allard2067d1a2008-11-13 22:59:24 +0000378 *
379 * @access public
380 * @return void
381 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200382 public function clear()
Derek Allard2067d1a2008-11-13 22:59:24 +0000383 {
384 $this->rows = array();
385 $this->heading = array();
Barry Mienydd671972010-10-04 16:33:58 +0200386 $this->auto_heading = TRUE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000387 }
Barry Mienydd671972010-10-04 16:33:58 +0200388
Derek Allard2067d1a2008-11-13 22:59:24 +0000389 // --------------------------------------------------------------------
390
391 /**
392 * Set table data from a database result object
393 *
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200394 * @access private
Derek Allard2067d1a2008-11-13 22:59:24 +0000395 * @param object
396 * @return void
397 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200398 private function _set_from_object($query)
Derek Allard2067d1a2008-11-13 22:59:24 +0000399 {
400 if ( ! is_object($query))
401 {
402 return FALSE;
403 }
Barry Mienydd671972010-10-04 16:33:58 +0200404
Derek Allard2067d1a2008-11-13 22:59:24 +0000405 // First generate the headings from the table column names
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200406 if (count($this->heading) === 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000407 {
408 if ( ! method_exists($query, 'list_fields'))
409 {
410 return FALSE;
411 }
Barry Mienydd671972010-10-04 16:33:58 +0200412
Derek Jones7b5b0e22010-03-02 22:48:53 -0600413 $this->heading = $this->_prep_args($query->list_fields());
Derek Allard2067d1a2008-11-13 22:59:24 +0000414 }
Barry Mienydd671972010-10-04 16:33:58 +0200415
Derek Allard2067d1a2008-11-13 22:59:24 +0000416 // Next blast through the result array and build out the rows
Barry Mienydd671972010-10-04 16:33:58 +0200417
Derek Allard2067d1a2008-11-13 22:59:24 +0000418 if ($query->num_rows() > 0)
419 {
420 foreach ($query->result_array() as $row)
421 {
Derek Jones7b5b0e22010-03-02 22:48:53 -0600422 $this->rows[] = $this->_prep_args($row);
Derek Allard2067d1a2008-11-13 22:59:24 +0000423 }
424 }
425 }
426
427 // --------------------------------------------------------------------
428
429 /**
430 * Set table data from an array
431 *
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200432 * @access private
Derek Allard2067d1a2008-11-13 22:59:24 +0000433 * @param array
434 * @return void
435 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200436 private function _set_from_array($data, $set_heading = TRUE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000437 {
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200438 if ( ! is_array($data) OR count($data) === 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000439 {
440 return FALSE;
441 }
Barry Mienydd671972010-10-04 16:33:58 +0200442
Derek Allard2067d1a2008-11-13 22:59:24 +0000443 $i = 0;
444 foreach ($data as $row)
Barry Mienydd671972010-10-04 16:33:58 +0200445 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000446 // If a heading hasn't already been set we'll use the first row of the array as the heading
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200447 if ($i++ === 0 AND count($data) > 1 AND count($this->heading) === 0 AND $set_heading == TRUE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000448 {
Derek Jones7b5b0e22010-03-02 22:48:53 -0600449 $this->heading = $this->_prep_args($row);
Derek Allard2067d1a2008-11-13 22:59:24 +0000450 }
451 else
452 {
Derek Jones7b5b0e22010-03-02 22:48:53 -0600453 $this->rows[] = $this->_prep_args($row);
Derek Allard2067d1a2008-11-13 22:59:24 +0000454 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000455 }
456 }
457
458 // --------------------------------------------------------------------
459
460 /**
461 * Compile Template
462 *
463 * @access private
464 * @return void
465 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200466 private function _compile_template()
Barry Mienydd671972010-10-04 16:33:58 +0200467 {
468 if ($this->template == NULL)
469 {
470 $this->template = $this->_default_template();
471 return;
472 }
473
Derek Allard2067d1a2008-11-13 22:59:24 +0000474 $this->temp = $this->_default_template();
Derek Jones7b5b0e22010-03-02 22:48:53 -0600475 foreach (array('table_open', 'thead_open', 'thead_close', 'heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end', 'tbody_open', 'tbody_close', 'row_start', 'row_end', 'cell_start', 'cell_end', 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end', 'table_close') as $val)
Derek Allard2067d1a2008-11-13 22:59:24 +0000476 {
477 if ( ! isset($this->template[$val]))
478 {
479 $this->template[$val] = $this->temp[$val];
480 }
Barry Mienydd671972010-10-04 16:33:58 +0200481 }
482 }
483
Derek Allard2067d1a2008-11-13 22:59:24 +0000484 // --------------------------------------------------------------------
485
486 /**
487 * Default Template
488 *
489 * @access private
490 * @return void
491 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200492 private function _default_template()
Derek Allard2067d1a2008-11-13 22:59:24 +0000493 {
Derek Jones4b9c6292011-07-01 17:40:48 -0500494 return array (
Barry Mienydd671972010-10-04 16:33:58 +0200495 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
496
Derek Jones7b5b0e22010-03-02 22:48:53 -0600497 'thead_open' => '<thead>',
498 'thead_close' => '</thead>',
Barry Mienydd671972010-10-04 16:33:58 +0200499
500 'heading_row_start' => '<tr>',
501 'heading_row_end' => '</tr>',
Derek Allard2067d1a2008-11-13 22:59:24 +0000502 'heading_cell_start' => '<th>',
503 'heading_cell_end' => '</th>',
504
Derek Jones7b5b0e22010-03-02 22:48:53 -0600505 'tbody_open' => '<tbody>',
506 'tbody_close' => '</tbody>',
Barry Mienydd671972010-10-04 16:33:58 +0200507
508 'row_start' => '<tr>',
509 'row_end' => '</tr>',
Derek Allard2067d1a2008-11-13 22:59:24 +0000510 'cell_start' => '<td>',
511 'cell_end' => '</td>',
512
Barry Mienydd671972010-10-04 16:33:58 +0200513 'row_alt_start' => '<tr>',
514 'row_alt_end' => '</tr>',
Derek Allard2067d1a2008-11-13 22:59:24 +0000515 'cell_alt_start' => '<td>',
516 'cell_alt_end' => '</td>',
517
Barry Mienydd671972010-10-04 16:33:58 +0200518 'table_close' => '</table>'
519 );
Derek Allard2067d1a2008-11-13 22:59:24 +0000520 }
Barry Mienydd671972010-10-04 16:33:58 +0200521
Derek Allard2067d1a2008-11-13 22:59:24 +0000522
523}
524
Derek Allard2067d1a2008-11-13 22:59:24 +0000525/* End of file Table.php */
Gerry6b590892011-09-25 00:16:39 +0800526/* Location: ./system/libraries/Table.php */