summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/libraries/Table.php72
-rw-r--r--user_guide_src/source/changelog.rst6
-rw-r--r--user_guide_src/source/libraries/table.rst15
3 files changed, 53 insertions, 40 deletions
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
index b77fcf19d..1d4320855 100644
--- a/system/libraries/Table.php
+++ b/system/libraries/Table.php
@@ -117,7 +117,7 @@ class CI_Table {
/**
* Set the template
*
- * @param array
+ * @param array $template
* @return bool
*/
public function set_template($template)
@@ -139,12 +139,13 @@ class CI_Table {
* Can be passed as an array or discreet params
*
* @param mixed
- * @return void
+ * @return CI_Table
*/
public function set_heading($args = array())
{
$args = func_get_args();
$this->heading = $this->_prep_args($args);
+ return $this;
}
// --------------------------------------------------------------------
@@ -155,9 +156,9 @@ class CI_Table {
* columns. This allows a single array with many elements to be
* displayed in a table that has a fixed column count.
*
- * @param array
- * @param int
- * @return void
+ * @param array $array
+ * @param int $col_limit
+ * @return array
*/
public function make_columns($array = array(), $col_limit = 0)
{
@@ -202,12 +203,13 @@ class CI_Table {
*
* Can be passed as an array or discreet params
*
- * @param mixed
- * @return void
+ * @param mixed $value
+ * @return CI_Table
*/
public function set_empty($value)
{
$this->empty_cells = $value;
+ return $this;
}
// --------------------------------------------------------------------
@@ -218,12 +220,13 @@ class CI_Table {
* Can be passed as an array or discreet params
*
* @param mixed
- * @return void
+ * @return CI_Table
*/
public function add_row($args = array())
{
$args = func_get_args();
$this->rows[] = $this->_prep_args($args);
+ return $this;
}
// --------------------------------------------------------------------
@@ -271,8 +274,8 @@ class CI_Table {
/**
* Add a table caption
*
- * @param string
- * @return void
+ * @param string $caption
+ * @return CI_Table
*/
public function set_caption($caption)
{
@@ -284,7 +287,7 @@ class CI_Table {
/**
* Generate the table
*
- * @param mixed
+ * @param mixed $table_data
* @return string
*/
public function generate($table_data = NULL)
@@ -417,13 +420,14 @@ class CI_Table {
/**
* Clears the table arrays. Useful if multiple tables are being generated
*
- * @return void
+ * @return CI_Table
*/
public function clear()
{
- $this->rows = array();
- $this->heading = array();
- $this->auto_heading = TRUE;
+ $this->rows = array();
+ $this->heading = array();
+ $this->auto_heading = TRUE;
+ return $this;
}
// --------------------------------------------------------------------
@@ -528,31 +532,31 @@ class CI_Table {
protected function _default_template()
{
return array(
- 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
+ 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
- 'thead_open' => '<thead>',
- 'thead_close' => '</thead>',
+ 'thead_open' => '<thead>',
+ 'thead_close' => '</thead>',
- 'heading_row_start' => '<tr>',
- 'heading_row_end' => '</tr>',
- 'heading_cell_start' => '<th>',
- 'heading_cell_end' => '</th>',
+ 'heading_row_start' => '<tr>',
+ 'heading_row_end' => '</tr>',
+ 'heading_cell_start' => '<th>',
+ 'heading_cell_end' => '</th>',
- 'tbody_open' => '<tbody>',
- 'tbody_close' => '</tbody>',
+ 'tbody_open' => '<tbody>',
+ 'tbody_close' => '</tbody>',
- 'row_start' => '<tr>',
- 'row_end' => '</tr>',
- 'cell_start' => '<td>',
- 'cell_end' => '</td>',
+ 'row_start' => '<tr>',
+ 'row_end' => '</tr>',
+ 'cell_start' => '<td>',
+ 'cell_end' => '</td>',
- 'row_alt_start' => '<tr>',
- 'row_alt_end' => '</tr>',
- 'cell_alt_start' => '<td>',
- 'cell_alt_end' => '</td>',
+ 'row_alt_start' => '<tr>',
+ 'row_alt_end' => '</tr>',
+ 'cell_alt_start' => '<td>',
+ 'cell_alt_end' => '</td>',
- 'table_close' => '</table>'
- );
+ 'table_close' => '</table>'
+ );
}
}
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index f90fa42bf..4a54593f0 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -387,7 +387,11 @@ Release Date: Not Released
- Added check to detect if robots are pretending to be mobile clients (helps with e.g. Google indexing mobile website versions).
- Added method ``parse()`` to allow parsing a custom user-agent string, different from the current visitor's.
- - Added support for setting :doc:`Table <libraries/table>` class defaults in a config file.
+ - :doc:`HTML Table Library <libraries/table>` changes include:
+
+ - Added method chaining support.
+ - Added support for setting table class defaults in a config file.
+
- :doc:`Zip Library <libraries/zip>` method ``read_file()`` can now also alter the original file path/name while adding files to an archive.
- Core
diff --git a/user_guide_src/source/libraries/table.rst b/user_guide_src/source/libraries/table.rst
index ea0c417c4..6e011083e 100644
--- a/user_guide_src/source/libraries/table.rst
+++ b/user_guide_src/source/libraries/table.rst
@@ -167,7 +167,8 @@ Class Reference
.. method:: set_caption($caption)
:param string $caption: Table caption
- :rtype: void
+ :returns: CI_Table instance (method chaining)
+ :rtype: CI_Table
Permits you to add a caption to the table.
::
@@ -177,7 +178,8 @@ Class Reference
.. method:: set_heading([$args = array()[, ...]])
:param mixed $args: An array or multiple strings containing the table column titles
- :rtype: void
+ :returns: CI_Table instance (method chaining)
+ :rtype: CI_Table
Permits you to set the table heading. You can submit an array or discrete params::
@@ -188,7 +190,8 @@ Class Reference
.. method:: add_row([$args = array()[, ...]])
:param mixed $args: An array or multiple strings containing the row values
- :rtype: void
+ :returns: CI_Table instance (method chaining)
+ :rtype: CI_Table
Permits you to add a row to your table. You can submit an array or discrete params::
@@ -253,7 +256,8 @@ Class Reference
.. method:: set_empty($value)
:param mixed $value: Value to put in empty cells
- :rtype: void
+ :returns: CI_Table instance (method chaining)
+ :rtype: CI_Table
Lets you set a default value for use in any table cells that are empty.
You might, for example, set a non-breaking space::
@@ -262,7 +266,8 @@ Class Reference
.. method:: clear()
- :rtype: void
+ :returns: CI_Table instance (method chaining)
+ :rtype: CI_Table
Lets you clear the table heading and row data. If you need to show multiple tables with different data you should to call this method
after each table has been generated to clear the previous table information. Example::