[geeklog-cvs] geeklog: Implemented standard PHP callback function into the lis...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Tue Mar 31 19:41:29 EDT 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/08364e03181e
changeset: 6886:08364e03181e
user: Sami Barakat
date: Wed Apr 01 00:39:22 2009 +0100
description:
Implemented standard PHP callback function into the listfactory, provided by jmucchiello (bug #0000755)
diffstat:
2 files changed, 8 insertions(+), 23 deletions(-)
system/classes/listfactory.class.php | 29 +++++++----------------------
system/classes/search.class.php | 2 +-
diffs (75 lines):
diff -r 798b4a89704c -r 08364e03181e system/classes/listfactory.class.php
--- a/system/classes/listfactory.class.php Tue Mar 31 23:45:11 2009 +0100
+++ b/system/classes/listfactory.class.php Wed Apr 01 00:39:22 2009 +0100
@@ -140,7 +140,6 @@
var $_per_page = 0;
var $_page_limits = array();
var $_function = '';
- var $_class_instance = null;
var $_preset_rows = array();
var $_page_url = '';
var $_style = 'table';
@@ -230,14 +229,12 @@
* Sets the callback function that gets called when formatting a row
*
* @access public
- * @param string $function The name given to a call back function that can format the results
- * @param object $inst The instance of the class that contains the function
+ * @param callback $function Any callable function, method or lambda
*
*/
- function setRowFunction( $function, $inst = null )
+ function setRowFunction( $callback )
{
- $this->_function = $function;
- $this->_class_instance = $inst;
+ $this->_function = $callback;
}
/**
@@ -430,14 +427,8 @@
// Need to call the format function before and after
// sorting the results.
- $function = $this->_function;
- if ($function != '')
- {
- if (function_exists($function)) {
- $col = $function(true, $col);
- } else if ($this->_class_instance != null) {
- $col = $this->_class_instance->$function(true, $col);
- }
+ if (is_callable($this->_function)) {
+ $col = call_user_func_array($this->_function, array(true, $col));
}
$rows_arr[] = $col;
@@ -587,14 +578,8 @@
$r = 1;
foreach ($rows_arr as $row)
{
- $function = $this->_function;
- if ($function != '')
- {
- if (function_exists($function)) {
- $row = $function(false, $row);
- } else if ($this->_class_instance != null) {
- $row = $this->_class_instance->$function(false, $row);
- }
+ if (is_callable($this->_function)) {
+ $row = call_user_func_array($this->_function, array(false, $row));
}
foreach ($this->_fields as $field)
diff -r 798b4a89704c -r 08364e03181e system/classes/search.class.php
--- a/system/classes/search.class.php Tue Mar 31 23:45:11 2009 +0100
+++ b/system/classes/search.class.php Wed Apr 01 00:39:22 2009 +0100
@@ -487,7 +487,7 @@
$url = "{$this->_searchURL}&type={$this->_type}&mode=";
$obj = new ListFactory($url.'search', $_CONF['search_limits'], $_CONF['num_search_results']);
- $obj->setRowFunction('searchFormatCallBack', $this);
+ $obj->setRowFunction(array($this, 'searchFormatCallBack'));
$obj->setField('ID', 'id', false);
$obj->setField('URL', 'url', false);
More information about the geeklog-cvs
mailing list