summaryrefslogtreecommitdiffstats
path: root/system/libraries/Table.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-06-07 21:25:16 +0200
committerAndrey Andreev <narf@bofh.bg>2012-06-07 21:25:16 +0200
commit27af930d4ed1daf9f2710b005d103c7f1c7d919d (patch)
treeffe257a549ae70749dcf4646695a0d73535e237e /system/libraries/Table.php
parent87ac4260063e3a62805cc8f6f73cd2eb18da663a (diff)
parent928b9aa6340654b1dbb69af44c41468456f0b7b6 (diff)
Merge upstream branch
Diffstat (limited to 'system/libraries/Table.php')
-rw-r--r--system/libraries/Table.php62
1 files changed, 55 insertions, 7 deletions
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
index 3777d29ff..0f8404d85 100644
--- a/system/libraries/Table.php
+++ b/system/libraries/Table.php
@@ -38,13 +38,60 @@
*/
class CI_Table {
+ /**
+ * Data for table rows
+ *
+ * @var array
+ */
public $rows = array();
+
+ /**
+ * Data for table heading
+ *
+ * @var array
+ */
public $heading = array();
+
+ /**
+ * Whether or not to automatically create the table header
+ *
+ * @var bool
+ */
public $auto_heading = TRUE;
+
+ /**
+ * Table caption
+ *
+ * @var string
+ */
public $caption = NULL;
+
+ /**
+ * Table layout template
+ *
+ * @var array
+ */
public $template = NULL;
+
+ /**
+ * Newline setting
+ *
+ * @var string
+ */
public $newline = "\n";
+
+ /**
+ * Contents of empty cells
+ *
+ * @var string
+ */
public $empty_cells = '';
+
+ /**
+ * Callback for custom table layout
+ *
+ * @var function
+ */
public $function = FALSE;
/**
@@ -93,7 +140,7 @@ class CI_Table {
* @param mixed
* @return void
*/
- public function set_heading()
+ public function set_heading($args = array())
{
$args = func_get_args();
$this->heading = $this->_prep_args($args);
@@ -122,7 +169,7 @@ class CI_Table {
// will want headings from a one-dimensional array
$this->auto_heading = FALSE;
- if ($col_limit == 0)
+ if ($col_limit === 0)
{
return $array;
}
@@ -172,7 +219,7 @@ class CI_Table {
* @param mixed
* @return void
*/
- public function add_row()
+ public function add_row($args = array())
{
$args = func_get_args();
$this->rows[] = $this->_prep_args($args);
@@ -251,7 +298,7 @@ class CI_Table {
}
elseif (is_array($table_data))
{
- $set_heading = (count($this->heading) !== 0 OR $this->auto_heading != FALSE);
+ $set_heading = (count($this->heading) !== 0 OR $this->auto_heading !== FALSE);
$this->_set_from_array($table_data, $set_heading);
}
}
@@ -289,7 +336,7 @@ class CI_Table {
foreach ($heading as $key => $val)
{
- if ($key != 'data')
+ if ($key !== 'data')
{
$temp = str_replace('<th', '<th '.$key.'="'.$val.'"', $temp);
}
@@ -420,6 +467,7 @@ class CI_Table {
* Set table data from an array
*
* @param array
+ * @param bool
* @return void
*/
protected function _set_from_array($data, $set_heading = TRUE)
@@ -433,7 +481,7 @@ class CI_Table {
foreach ($data as $row)
{
// If a heading hasn't already been set we'll use the first row of the array as the heading
- if ($i++ === 0 && count($data) > 1 && count($this->heading) === 0 && $set_heading == TRUE)
+ if ($i++ === 0 && count($data) > 1 && count($this->heading) === 0 && $set_heading === TRUE)
{
$this->heading = $this->_prep_args($row);
}
@@ -453,7 +501,7 @@ class CI_Table {
*/
protected function _compile_template()
{
- if ($this->template == NULL)
+ if ($this->template === NULL)
{
$this->template = $this->_default_template();
return;