blob: 8f6ac8d4573b90995eab6c9e913a1958aae38668 [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
Greg Aker0defe5d2012-01-01 18:46:41 -060021 * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
Derek Jonesf4a4bd82011-10-20 12:18:42 -050022 * @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 *
Derek Allard2067d1a2008-11-13 22:59:24 +000062 * @param array
63 * @return void
64 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +020065 public function set_template($template)
Derek Allard2067d1a2008-11-13 22:59:24 +000066 {
67 if ( ! is_array($template))
68 {
69 return FALSE;
70 }
Barry Mienydd671972010-10-04 16:33:58 +020071
Derek Allard2067d1a2008-11-13 22:59:24 +000072 $this->template = $template;
73 }
74
75 // --------------------------------------------------------------------
76
77 /**
78 * Set the table heading
79 *
80 * Can be passed as an array or discreet params
81 *
Derek Allard2067d1a2008-11-13 22:59:24 +000082 * @param mixed
83 * @return void
84 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +020085 public function set_heading()
Derek Allard2067d1a2008-11-13 22:59:24 +000086 {
87 $args = func_get_args();
Derek Jones7b5b0e22010-03-02 22:48:53 -060088 $this->heading = $this->_prep_args($args);
Derek Allard2067d1a2008-11-13 22:59:24 +000089 }
90
91 // --------------------------------------------------------------------
92
93 /**
Derek Jones4b9c6292011-07-01 17:40:48 -050094 * Set columns. Takes a one-dimensional array as input and creates
Derek Allard2067d1a2008-11-13 22:59:24 +000095 * a multi-dimensional array with a depth equal to the number of
Derek Jones4b9c6292011-07-01 17:40:48 -050096 * columns. This allows a single array with many elements to be
Derek Allard2067d1a2008-11-13 22:59:24 +000097 * displayed in a table that has a fixed column count.
98 *
Derek Allard2067d1a2008-11-13 22:59:24 +000099 * @param array
100 * @param int
101 * @return void
102 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200103 public function make_columns($array = array(), $col_limit = 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000104 {
Taufan Aditya8749bc72012-03-11 05:43:45 +0700105 if ( ! is_array($array) OR count($array) === 0 OR ! is_int($col_limit))
Derek Allard2067d1a2008-11-13 22:59:24 +0000106 {
107 return FALSE;
108 }
Barry Mienydd671972010-10-04 16:33:58 +0200109
110 // Turn off the auto-heading feature since it's doubtful we
Derek Allard2067d1a2008-11-13 22:59:24 +0000111 // will want headings from a one-dimensional array
112 $this->auto_heading = FALSE;
Barry Mienydd671972010-10-04 16:33:58 +0200113
Derek Allard2067d1a2008-11-13 22:59:24 +0000114 if ($col_limit == 0)
115 {
116 return $array;
117 }
Barry Mienydd671972010-10-04 16:33:58 +0200118
Derek Allard2067d1a2008-11-13 22:59:24 +0000119 $new = array();
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200120 do
Barry Mienydd671972010-10-04 16:33:58 +0200121 {
122 $temp = array_splice($array, 0, $col_limit);
123
Derek Allard2067d1a2008-11-13 22:59:24 +0000124 if (count($temp) < $col_limit)
125 {
126 for ($i = count($temp); $i < $col_limit; $i++)
127 {
128 $temp[] = '&nbsp;';
129 }
130 }
Barry Mienydd671972010-10-04 16:33:58 +0200131
Derek Allard2067d1a2008-11-13 22:59:24 +0000132 $new[] = $temp;
133 }
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200134 while (count($array) > 0);
Barry Mienydd671972010-10-04 16:33:58 +0200135
Derek Allard2067d1a2008-11-13 22:59:24 +0000136 return $new;
137 }
138
139 // --------------------------------------------------------------------
140
141 /**
142 * Set "empty" cells
143 *
144 * Can be passed as an array or discreet params
145 *
Derek Allard2067d1a2008-11-13 22:59:24 +0000146 * @param mixed
147 * @return void
148 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200149 public function set_empty($value)
Derek Allard2067d1a2008-11-13 22:59:24 +0000150 {
151 $this->empty_cells = $value;
152 }
Barry Mienydd671972010-10-04 16:33:58 +0200153
Derek Allard2067d1a2008-11-13 22:59:24 +0000154 // --------------------------------------------------------------------
155
156 /**
157 * Add a table row
158 *
159 * Can be passed as an array or discreet params
160 *
Derek Allard2067d1a2008-11-13 22:59:24 +0000161 * @param mixed
162 * @return void
163 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200164 public function add_row()
Derek Allard2067d1a2008-11-13 22:59:24 +0000165 {
166 $args = func_get_args();
Derek Jones7b5b0e22010-03-02 22:48:53 -0600167 $this->rows[] = $this->_prep_args($args);
Derek Allard2067d1a2008-11-13 22:59:24 +0000168 }
169
170 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200171
Derek Jones7b5b0e22010-03-02 22:48:53 -0600172 /**
173 * Prep Args
174 *
175 * Ensures a standard associative array format for all cell data
176 *
Derek Jones7b5b0e22010-03-02 22:48:53 -0600177 * @param type
178 * @return type
179 */
Andrey Andreev49ddaa32011-12-26 16:54:10 +0200180 protected function _prep_args($args)
Derek Jones7b5b0e22010-03-02 22:48:53 -0600181 {
182 // If there is no $args[0], skip this and treat as an associative array
183 // This can happen if there is only a single key, for example this is passed to table->generate
184 // array(array('foo'=>'bar'))
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200185 if (isset($args[0]) AND (count($args) === 1 && is_array($args[0])))
Derek Jones7b5b0e22010-03-02 22:48:53 -0600186 {
187 // args sent as indexed array
188 if ( ! isset($args[0]['data']))
189 {
190 foreach ($args[0] as $key => $val)
191 {
192 if (is_array($val) && isset($val['data']))
193 {
194 $args[$key] = $val;
195 }
196 else
197 {
Barry Mienydd671972010-10-04 16:33:58 +0200198 $args[$key] = array('data' => $val);
Derek Jones7b5b0e22010-03-02 22:48:53 -0600199 }
Barry Mienydd671972010-10-04 16:33:58 +0200200 }
Derek Jones7b5b0e22010-03-02 22:48:53 -0600201 }
202 }
203 else
204 {
205 foreach ($args as $key => $val)
206 {
207 if ( ! is_array($val))
208 {
209 $args[$key] = array('data' => $val);
210 }
211 }
212 }
Barry Mienydd671972010-10-04 16:33:58 +0200213
Derek Jones7b5b0e22010-03-02 22:48:53 -0600214 return $args;
215 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000216
Derek Jones7b5b0e22010-03-02 22:48:53 -0600217 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200218
Derek Allard2067d1a2008-11-13 22:59:24 +0000219 /**
220 * Add a table caption
221 *
Derek Allard2067d1a2008-11-13 22:59:24 +0000222 * @param string
223 * @return void
224 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200225 public function set_caption($caption)
Derek Allard2067d1a2008-11-13 22:59:24 +0000226 {
227 $this->caption = $caption;
Barry Mienydd671972010-10-04 16:33:58 +0200228 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000229
230 // --------------------------------------------------------------------
231
232 /**
233 * Generate the table
234 *
Derek Allard2067d1a2008-11-13 22:59:24 +0000235 * @param mixed
236 * @return string
237 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200238 public function generate($table_data = NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000239 {
240 // The table data can optionally be passed to this function
241 // either as a database result object or an array
242 if ( ! is_null($table_data))
243 {
244 if (is_object($table_data))
245 {
246 $this->_set_from_object($table_data);
247 }
248 elseif (is_array($table_data))
249 {
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200250 $set_heading = (count($this->heading) === 0 AND $this->auto_heading == FALSE) ? FALSE : TRUE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000251 $this->_set_from_array($table_data, $set_heading);
252 }
253 }
Barry Mienydd671972010-10-04 16:33:58 +0200254
Derek Jones4b9c6292011-07-01 17:40:48 -0500255 // Is there anything to display? No? Smite them!
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200256 if (count($this->heading) === 0 AND count($this->rows) === 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000257 {
258 return 'Undefined table data';
259 }
Barry Mienydd671972010-10-04 16:33:58 +0200260
Derek Allard2067d1a2008-11-13 22:59:24 +0000261 // Compile and validate the template date
262 $this->_compile_template();
Barry Mienydd671972010-10-04 16:33:58 +0200263
Derek Jones7b5b0e22010-03-02 22:48:53 -0600264 // set a custom cell manipulation function to a locally scoped variable so its callable
265 $function = $this->function;
Barry Mienydd671972010-10-04 16:33:58 +0200266
Derek Allard2067d1a2008-11-13 22:59:24 +0000267 // Build the table!
Barry Mienydd671972010-10-04 16:33:58 +0200268
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200269 $out = $this->template['table_open'].$this->newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000270
271 // Add any caption here
272 if ($this->caption)
273 {
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200274 $out .= $this->newline.'<caption>'.$this->caption.'</caption>'.$this->newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000275 }
276
277 // Is there a table heading to display?
278 if (count($this->heading) > 0)
279 {
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200280 $out .= $this->template['thead_open'].$this->newline.$this->template['heading_row_start'].$this->newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000281
Pascal Kriete14287f32011-02-14 13:39:34 -0500282 foreach ($this->heading as $heading)
Derek Allard2067d1a2008-11-13 22:59:24 +0000283 {
Derek Jones7b5b0e22010-03-02 22:48:53 -0600284 $temp = $this->template['heading_cell_start'];
Barry Mienydd671972010-10-04 16:33:58 +0200285
Derek Jones7b5b0e22010-03-02 22:48:53 -0600286 foreach ($heading as $key => $val)
287 {
288 if ($key != 'data')
289 {
290 $temp = str_replace('<th', "<th $key='$val'", $temp);
Barry Mienydd671972010-10-04 16:33:58 +0200291 }
Derek Jones7b5b0e22010-03-02 22:48:53 -0600292 }
293
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200294 $out .= $temp.(isset($heading['data']) ? $heading['data'] : '').$this->template['heading_cell_end'];
Derek Allard2067d1a2008-11-13 22:59:24 +0000295 }
296
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200297 $out .= $this->template['heading_row_end'].$this->newline.$this->template['thead_close'].$this->newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000298 }
Barry Mienydd671972010-10-04 16:33:58 +0200299
Derek Allard2067d1a2008-11-13 22:59:24 +0000300 // Build the table rows
301 if (count($this->rows) > 0)
302 {
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200303 $out .= $this->template['tbody_open'].$this->newline;
Barry Mienydd671972010-10-04 16:33:58 +0200304
Derek Allard2067d1a2008-11-13 22:59:24 +0000305 $i = 1;
Pascal Kriete14287f32011-02-14 13:39:34 -0500306 foreach ($this->rows as $row)
Derek Allard2067d1a2008-11-13 22:59:24 +0000307 {
308 if ( ! is_array($row))
309 {
310 break;
311 }
Barry Mienydd671972010-10-04 16:33:58 +0200312
Derek Allard2067d1a2008-11-13 22:59:24 +0000313 // We use modulus to alternate the row colors
314 $name = (fmod($i++, 2)) ? '' : 'alt_';
Barry Mienydd671972010-10-04 16:33:58 +0200315
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200316 $out .= $this->template['row_'.$name.'start'].$this->newline;
Barry Mienydd671972010-10-04 16:33:58 +0200317
Pascal Kriete14287f32011-02-14 13:39:34 -0500318 foreach ($row as $cell)
Derek Allard2067d1a2008-11-13 22:59:24 +0000319 {
Derek Jones7b5b0e22010-03-02 22:48:53 -0600320 $temp = $this->template['cell_'.$name.'start'];
Barry Mienydd671972010-10-04 16:33:58 +0200321
Derek Jones7b5b0e22010-03-02 22:48:53 -0600322 foreach ($cell as $key => $val)
323 {
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200324 if ($key !== 'data')
Derek Jones7b5b0e22010-03-02 22:48:53 -0600325 {
326 $temp = str_replace('<td', "<td $key='$val'", $temp);
Barry Mienydd671972010-10-04 16:33:58 +0200327 }
Derek Jones7b5b0e22010-03-02 22:48:53 -0600328 }
Barry Mienydd671972010-10-04 16:33:58 +0200329
Derek Jones7b5b0e22010-03-02 22:48:53 -0600330 $cell = isset($cell['data']) ? $cell['data'] : '';
331 $out .= $temp;
332
Derek Allardd8270582010-01-15 17:10:56 +0000333 if ($cell === "" OR $cell === NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000334 {
335 $out .= $this->empty_cells;
336 }
337 else
338 {
Derek Jones7b5b0e22010-03-02 22:48:53 -0600339 if ($function !== FALSE && is_callable($function))
340 {
Phil Sturgeon6c597f82010-12-27 17:35:35 +0000341 $out .= call_user_func($function, $cell);
Derek Jones7b5b0e22010-03-02 22:48:53 -0600342 }
343 else
344 {
345 $out .= $cell;
346 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000347 }
Barry Mienydd671972010-10-04 16:33:58 +0200348
Derek Allard2067d1a2008-11-13 22:59:24 +0000349 $out .= $this->template['cell_'.$name.'end'];
350 }
Barry Mienydd671972010-10-04 16:33:58 +0200351
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200352 $out .= $this->template['row_'.$name.'end'].$this->newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000353 }
Barry Mienydd671972010-10-04 16:33:58 +0200354
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200355 $out .= $this->template['tbody_close'].$this->newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000356 }
357
358 $out .= $this->template['table_close'];
Barry Mienydd671972010-10-04 16:33:58 +0200359
Greg Aker02b3a5b2011-02-01 01:29:21 -0600360 // Clear table class properties before generating the table
361 $this->clear();
362
Derek Allard2067d1a2008-11-13 22:59:24 +0000363 return $out;
364 }
Barry Mienydd671972010-10-04 16:33:58 +0200365
Derek Allard2067d1a2008-11-13 22:59:24 +0000366 // --------------------------------------------------------------------
367
368 /**
Derek Jones4b9c6292011-07-01 17:40:48 -0500369 * Clears the table arrays. Useful if multiple tables are being generated
Derek Allard2067d1a2008-11-13 22:59:24 +0000370 *
Derek Allard2067d1a2008-11-13 22:59:24 +0000371 * @return void
372 */
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200373 public function clear()
Derek Allard2067d1a2008-11-13 22:59:24 +0000374 {
375 $this->rows = array();
376 $this->heading = array();
Barry Mienydd671972010-10-04 16:33:58 +0200377 $this->auto_heading = TRUE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000378 }
Barry Mienydd671972010-10-04 16:33:58 +0200379
Derek Allard2067d1a2008-11-13 22:59:24 +0000380 // --------------------------------------------------------------------
381
382 /**
383 * Set table data from a database result object
384 *
Derek Allard2067d1a2008-11-13 22:59:24 +0000385 * @param object
386 * @return void
387 */
Andrey Andreev49ddaa32011-12-26 16:54:10 +0200388 protected function _set_from_object($query)
Derek Allard2067d1a2008-11-13 22:59:24 +0000389 {
390 if ( ! is_object($query))
391 {
392 return FALSE;
393 }
Barry Mienydd671972010-10-04 16:33:58 +0200394
Derek Allard2067d1a2008-11-13 22:59:24 +0000395 // First generate the headings from the table column names
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200396 if (count($this->heading) === 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000397 {
Taufan Aditya8749bc72012-03-11 05:43:45 +0700398 if ( ! is_callable(array($query, 'list_fields')))
Derek Allard2067d1a2008-11-13 22:59:24 +0000399 {
400 return FALSE;
401 }
Barry Mienydd671972010-10-04 16:33:58 +0200402
Derek Jones7b5b0e22010-03-02 22:48:53 -0600403 $this->heading = $this->_prep_args($query->list_fields());
Derek Allard2067d1a2008-11-13 22:59:24 +0000404 }
Barry Mienydd671972010-10-04 16:33:58 +0200405
Derek Allard2067d1a2008-11-13 22:59:24 +0000406 // Next blast through the result array and build out the rows
Barry Mienydd671972010-10-04 16:33:58 +0200407
Derek Allard2067d1a2008-11-13 22:59:24 +0000408 if ($query->num_rows() > 0)
409 {
410 foreach ($query->result_array() as $row)
411 {
Derek Jones7b5b0e22010-03-02 22:48:53 -0600412 $this->rows[] = $this->_prep_args($row);
Derek Allard2067d1a2008-11-13 22:59:24 +0000413 }
414 }
415 }
416
417 // --------------------------------------------------------------------
418
419 /**
420 * Set table data from an array
421 *
Derek Allard2067d1a2008-11-13 22:59:24 +0000422 * @param array
423 * @return void
424 */
Andrey Andreev49ddaa32011-12-26 16:54:10 +0200425 protected function _set_from_array($data, $set_heading = TRUE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000426 {
Andrey Andreevfe9b9a92011-12-25 16:11:01 +0200427 if ( ! is_array($data) OR count($data) === 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000428 {
429 return FALSE;
430 }
Barry Mienydd671972010-10-04 16:33:58 +0200431
Derek Allard2067d1a2008-11-13 22:59:24 +0000432 $i = 0;
433 foreach ($data as $row)
Barry Mienydd671972010-10-04 16:33:58 +0200434 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000435 // 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 +0200436 if ($i++ === 0 AND count($data) > 1 AND count($this->heading) === 0 AND $set_heading == TRUE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000437 {
Derek Jones7b5b0e22010-03-02 22:48:53 -0600438 $this->heading = $this->_prep_args($row);
Derek Allard2067d1a2008-11-13 22:59:24 +0000439 }
440 else
441 {
Derek Jones7b5b0e22010-03-02 22:48:53 -0600442 $this->rows[] = $this->_prep_args($row);
Derek Allard2067d1a2008-11-13 22:59:24 +0000443 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000444 }
445 }
446
447 // --------------------------------------------------------------------
448
449 /**
450 * Compile Template
451 *
Derek Allard2067d1a2008-11-13 22:59:24 +0000452 * @return void
453 */
Andrey Andreev49ddaa32011-12-26 16:54:10 +0200454 protected function _compile_template()
Barry Mienydd671972010-10-04 16:33:58 +0200455 {
456 if ($this->template == NULL)
457 {
458 $this->template = $this->_default_template();
459 return;
460 }
461
Derek Allard2067d1a2008-11-13 22:59:24 +0000462 $this->temp = $this->_default_template();
Derek Jones7b5b0e22010-03-02 22:48:53 -0600463 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 +0000464 {
465 if ( ! isset($this->template[$val]))
466 {
467 $this->template[$val] = $this->temp[$val];
468 }
Barry Mienydd671972010-10-04 16:33:58 +0200469 }
470 }
471
Derek Allard2067d1a2008-11-13 22:59:24 +0000472 // --------------------------------------------------------------------
473
474 /**
475 * Default Template
476 *
Derek Allard2067d1a2008-11-13 22:59:24 +0000477 * @return void
478 */
Andrey Andreev49ddaa32011-12-26 16:54:10 +0200479 protected function _default_template()
Derek Allard2067d1a2008-11-13 22:59:24 +0000480 {
Derek Jones4b9c6292011-07-01 17:40:48 -0500481 return array (
Barry Mienydd671972010-10-04 16:33:58 +0200482 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
483
Derek Jones7b5b0e22010-03-02 22:48:53 -0600484 'thead_open' => '<thead>',
485 'thead_close' => '</thead>',
Barry Mienydd671972010-10-04 16:33:58 +0200486
487 'heading_row_start' => '<tr>',
488 'heading_row_end' => '</tr>',
Derek Allard2067d1a2008-11-13 22:59:24 +0000489 'heading_cell_start' => '<th>',
490 'heading_cell_end' => '</th>',
491
Derek Jones7b5b0e22010-03-02 22:48:53 -0600492 'tbody_open' => '<tbody>',
493 'tbody_close' => '</tbody>',
Barry Mienydd671972010-10-04 16:33:58 +0200494
495 'row_start' => '<tr>',
496 'row_end' => '</tr>',
Derek Allard2067d1a2008-11-13 22:59:24 +0000497 'cell_start' => '<td>',
498 'cell_end' => '</td>',
499
Barry Mienydd671972010-10-04 16:33:58 +0200500 'row_alt_start' => '<tr>',
501 'row_alt_end' => '</tr>',
Derek Allard2067d1a2008-11-13 22:59:24 +0000502 'cell_alt_start' => '<td>',
503 'cell_alt_end' => '</td>',
504
Barry Mienydd671972010-10-04 16:33:58 +0200505 'table_close' => '</table>'
506 );
Derek Allard2067d1a2008-11-13 22:59:24 +0000507 }
Barry Mienydd671972010-10-04 16:33:58 +0200508
Derek Allard2067d1a2008-11-13 22:59:24 +0000509
510}
511
Derek Allard2067d1a2008-11-13 22:59:24 +0000512/* End of file Table.php */
Gerry6b590892011-09-25 00:16:39 +0800513/* Location: ./system/libraries/Table.php */