Created
January 14, 2011 17:56
-
-
Save airways/779961 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
/** | |
* Hooked HTML Table Generating Class | |
* | |
* @package Wallace | |
* @subpackage Libraries | |
* @author Isaac Raway | |
* @link http://metasushi.com/ | |
*/ | |
class EE_Table extends CI_Table { | |
function set_heading() | |
{ | |
$EE =& get_instance(); | |
// this function tags it's arguments as an array or as a variable number | |
// of arguments - we want to convert either one to a single array so we | |
// can pass it to the filtering hook | |
$args = func_get_args(); | |
if(count($args) > 0) { | |
if(is_array($args[0]) && !array_key_exists('data', $args[0])) { | |
$args = $args[0]; | |
} | |
} | |
// call the hook | |
if($EE->extensions->active_hook('filter_table_headings')) | |
{ | |
$args = $EE->extensions->call('filter_table_headings', $args); | |
} | |
// pass on filtered data to the real set_heading() | |
return parent::set_heading($args); | |
} | |
function generate($table_data = NULL) | |
{ | |
$EE =& get_instance(); | |
// The table data can optionally be passed to this function | |
// either as a database result object or an array | |
if ( ! is_null($table_data)) | |
{ | |
if (is_object($table_data)) | |
{ | |
$this->_set_from_object($table_data); | |
} | |
elseif (is_array($table_data)) | |
{ | |
$set_heading = (count($this->heading) == 0 AND $this->auto_heading == FALSE) ? FALSE : TRUE; | |
$this->_set_from_array($table_data, $set_heading); | |
} | |
} | |
// get data form result of _set* call | |
$table_data = &$this->rows; | |
unset($this->rows); | |
// call the hook | |
if($EE->extensions->active_hook('filter_table_data')) | |
{ | |
$table_data = $EE->extensions->call('filter_table_data', $table_data); | |
} | |
// pass on filtered data to the real generate() | |
return parent::generate($table_data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment