[geeklog-cvs] geeklog: Better search handling for older plugins
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Thu Apr 30 16:46:14 EDT 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/0950dab49b89
changeset: 6999:0950dab49b89
user: Sami Barakat
date: Thu Apr 30 21:44:45 2009 +0100
description:
Better search handling for older plugins
diffstat:
2 files changed, 12 insertions(+), 5 deletions(-)
system/classes/listfactory.class.php | 11 ++++++++---
system/classes/search.class.php | 6 ++++--
diffs (54 lines):
diff -r 9cf55006cd89 -r 0950dab49b89 system/classes/listfactory.class.php
--- a/system/classes/listfactory.class.php Thu Apr 30 11:25:19 2009 +0200
+++ b/system/classes/listfactory.class.php Thu Apr 30 21:44:45 2009 +0100
@@ -372,8 +372,14 @@
$this->_per_page = COM_applyFilter($_GET['results'], true);
}
+ $rows_arr = $this->_preset_rows;
+ $this->_total_found = count($this->_preset_rows);
+
+ // When the preset rows exceed per_page bail early
+ if ($this->_total_found > $this->_per_page)
+ return array_slice($rows_arr, 0, $this->_per_page);
+
// Calculate the limits for each query
- $this->_total_found = count($this->_preset_rows);
$num_query_results = $this->_per_page - $this->_total_found;
$pp_total = $this->_total_found;
$limits = array();
@@ -392,10 +398,9 @@
$limits = $this->_getLimits($limits);
// Execute each query in turn
- $rows_arr = $this->_preset_rows;
for ($i = 0; $i < count($this->_query_arr); $i++)
{
- if ($limits[$i]['limit'] == 0) {
+ if ($limits[$i]['limit'] <= 0) {
continue;
}
$limit_sql = " LIMIT {$limits[$i]['offset']},{$limits[$i]['limit']}";
diff -r 9cf55006cd89 -r 0950dab49b89 system/classes/search.class.php
--- a/system/classes/search.class.php Thu Apr 30 11:25:19 2009 +0200
+++ b/system/classes/search.class.php Thu Apr 30 21:44:45 2009 +0100
@@ -580,8 +580,9 @@
else if (is_a($result, 'Plugin') && $result->num_searchresults != 0)
{
// Some backwards compatibility
- $debug_info = $result->plugin_name . " using APIv1 with backwards compatibility\n";
- $debug_info .= print_r($result,1);
+ $debug_info = $result->plugin_name . " using APIv1 with backwards compatibility.";
+ $debug_info .= " Count: " . $result->num_searchresults;
+ $debug_info .= " Headings: " . implode(",", $result->searchheading);
COM_errorLog($debug_info);
// Find the column heading names that closely match what we are looking for
@@ -598,6 +599,7 @@
// Extract the results
for ($i = 0; $i < 5; $i++)
{
+ // If the plugin does not repect the $perpage perameter force it here.
$j = ($i + ($page * 5)) - 5;
if ($j >= count($result->searchresults))
break;
More information about the geeklog-cvs
mailing list