[geeklog-cvs] geeklog: Implemented Search Improvements
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Mon Feb 2 18:07:34 EST 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/6db77ef26a37
changeset: 6757:6db77ef26a37
user: Sami Barakat
date: Mon Feb 02 23:04:14 2009 +0000
description:
Implemented Search Improvements
diffstat:
18 files changed, 1544 insertions(+), 735 deletions(-)
language/english.php | 26
public_html/admin/install/config-install.php | 14
public_html/docs/config.html | 52
public_html/layout/professional/lists/inline/item_field.thtml | 1
public_html/layout/professional/lists/inline/item_row.thtml | 4
public_html/layout/professional/lists/inline/list.thtml | 14
public_html/layout/professional/lists/inline/page_limit.thtml | 1
public_html/layout/professional/lists/inline/page_sort.thtml | 1
public_html/layout/professional/lists/table/item_field.thtml | 1
public_html/layout/professional/lists/table/item_row.thtml | 3
public_html/layout/professional/lists/table/list.thtml | 16
public_html/layout/professional/lists/table/page_limit.thtml | 1
public_html/layout/professional/lists/table/page_sort.thtml | 1
public_html/lib-common.php | 5
system/classes/listfactory.class.php | 652 +++++
system/classes/search.class.php | 1278 ++++------
system/classes/searchcriteria.class.php | 164 +
system/lib-plugins.php | 45
diffs (truncated from 2591 to 300 lines):
diff -r fcc8b4ab664b -r 6db77ef26a37 language/english.php
--- a/language/english.php Mon Feb 02 10:52:36 2009 +0100
+++ b/language/english.php Mon Feb 02 23:04:14 2009 +0000
@@ -502,7 +502,14 @@
58 => 'More results >>',
59 => 'Results',
60 => 'per page',
- 61 => 'Refine search'
+ 61 => 'Refine search',
+ 62 => '#',
+ 63 => 'Description',
+ 64 => 'Showing %d - %d of %d results',
+ 65 => 'Story',
+ 66 => 'Comment',
+ 67 => 'Show %d Results',
+ 68 => 'Sort By'
);
###############################################################################
@@ -1801,7 +1808,18 @@
'default_permissions_topic' => "Topic Default Permissions",
'atom_max_stories' => "Max. Stories in Webservices Feed",
'disable_webservices' => 'Disable Webservices?',
- 'restrict_webservices' => 'Restrict Webservices?'
+ 'restrict_webservices' => 'Restrict Webservices?',
+ 'search_style' => "Results List Style",
+ 'search_limits' => "Page Limits",
+ 'search_show_num' => "Show Result Number?",
+ 'search_show_type' => "Show Result Type?",
+ 'search_show_user' => "Show Author?",
+ 'search_show_hits' => "Show Number of Hits?",
+ 'search_show_sort' => "Allow User to Sort Results?",
+ 'search_show_limit' => "Show Page Limits?",
+ 'search_no_data' => "If No Data is Avaliable, Display",
+ 'search_separator' => "Group Separator",
+ 'search_def_keytype' => "Default Search Method"
);
$LANG_configsubgroups['Core'] = array(
@@ -1885,7 +1903,9 @@
15 => array('By Number' => 'sortnum', 'Alphabetically' => 'alpha'),
16 => array('No Login required' => 0, 'Advanced Search only' => 1, 'Simple + Advanced Search' => 2),
17 => array('Comments Enabled' => 0, 'Comments Disabled' => -1),
- 18 => array('Disabled' => 0, 'Enabled (Exact Match)' => 1, 'Enabled (Word Beginning)' => 2, 'Enabled (Word Fragment)' => 3)
+ 18 => array('Disabled' => 0, 'Enabled (Exact Match)' => 1, 'Enabled (Word Beginning)' => 2, 'Enabled (Word Fragment)' => 3),
+ 19 => array('Google' => 'google', 'Table' => 'table'),
+ 20 => array('Exact Phrase' => 'phrase', 'All of The Words' => 'all', 'Any of The Words' => 'any')
);
?>
diff -r fcc8b4ab664b -r 6db77ef26a37 public_html/admin/install/config-install.php
--- a/public_html/admin/install/config-install.php Mon Feb 02 10:52:36 2009 +0100
+++ b/public_html/admin/install/config-install.php Mon Feb 02 23:04:14 2009 +0000
@@ -83,7 +83,19 @@
$c->add('mysqldump_options','-Q','text',0,5,NULL,180,TRUE);
$c->add('fs_search', NULL, 'fieldset', 0, 6, NULL, 0, TRUE);
- $c->add('num_search_results',10,'text',0,6,NULL,670,TRUE);
+ $c->add('search_style','google','select',0,6,19,650,TRUE);
+ $c->add('search_limits','10,15,25,30','text',0,6,NULL,660,TRUE);
+ $c->add('num_search_results',30,'text',0,6,NULL,670,TRUE);
+ $c->add('search_show_limit',TRUE,'select',0,6,1,680,TRUE);
+ $c->add('search_show_sort',TRUE,'select',0,6,1,690,TRUE);
+ $c->add('search_show_num',TRUE,'select',0,6,1,700,TRUE);
+ $c->add('search_show_type',TRUE,'select',0,6,1,710,TRUE);
+ $c->add('search_show_user',TRUE,'select',0,6,1,720,TRUE);
+ $c->add('search_show_hits',TRUE,'select',0,6,1,730,TRUE);
+ $c->add('search_no_data','<i>Not available...</i>','text',0,6,NULL,740,TRUE);
+ $c->add('search_separator',' > ','text',0,6,NULL,750,TRUE);
+ $c->add('search_def_keytype','phrase','select',0,6,20,760,TRUE);
+ $c->add('search_use_fulltext',FALSE,'hidden',0,6);
// Subgroup: Stories and Trackback
$c->add('sg_stories', NULL, 'subgroup', 1, 0, NULL, 0, TRUE);
diff -r fcc8b4ab664b -r 6db77ef26a37 public_html/docs/config.html
--- a/public_html/docs/config.html Mon Feb 02 10:52:36 2009 +0100
+++ b/public_html/docs/config.html Mon Feb 02 23:04:14 2009 +0000
@@ -263,9 +263,57 @@
<th style="width:29%">Default Value</th>
<th style="width:63%">Description</th></tr>
<tr>
+ <td valign="top"><a name="desc_search_style">search_style</a></td>
+ <td valign="top">'google'</td>
+ <td valign="top">Sets the style of the results page. Can be either 'google' or 'table'</td></tr>
+<tr>
+ <td valign="top"><a name="desc_search_limits">search_limits</a></td>
+ <td valign="top">10,15,25,30</td>
+ <td valign="top">The result limits a user can select. Each value <b>must</b> be seperated with a comma.</td></tr>
+<tr>
<td valign="top"><a name="desc_num_search_results">num_search_results</a></td>
- <td valign="top">10</td>
- <td valign="top">Number of search results per page (and per type).</td></tr>
+ <td valign="top">30</td>
+ <td valign="top">The default number of results per page. Should be a value from 'search_limits' above.</td></tr>
+<tr>
+ <td valign="top"><a name="desc_search_show_limit">search_show_limit</a></td>
+ <td valign="top">true</td>
+ <td valign="top">Shows (= true) or hides (= false) the page limits selection box.</td></tr>
+<tr>
+ <td valign="top"><a name="desc_search_show_sort">search_show_sort</a></td>
+ <td valign="top">true</td>
+ <td valign="top">Shows (= true) or hides (= false) the 'Sort By' selection box. (When using the table style it will enable/disable column sorting)</td></tr>
+<tr>
+ <td valign="top"><a name="desc_search_show_num">search_show_num</a></td>
+ <td valign="top">true</td>
+ <td valign="top">Shows (= true) or hides (= false) the result number.</td></tr>
+<tr>
+ <td valign="top"><a name="desc_search_show_type">search_show_type</a></td>
+ <td valign="top">true</td>
+ <td valign="top">Shows (= true) or hides (= false) the plugin name the result came from.</td></tr>
+<tr>
+ <td valign="top"><a name="desc_search_show_user">search_show_user</a></td>
+ <td valign="top">true</td>
+ <td valign="top">Shows (= true) or hides (= false) the author of a result.</td></tr>
+<tr>
+ <td valign="top"><a name="desc_search_show_hits">search_show_hits</a></td>
+ <td valign="top">true</td>
+ <td valign="top">Shows (= true) or hides (= false) the number of hits a result has received.</td></tr>
+<tr>
+ <td valign="top"><a name="desc_search_no_data">search_no_data</a></td>
+ <td valign="top"><i>Not available...</i></td>
+ <td valign="top">When there is an incompatibility between plugin and Geeklog display this string.</td></tr>
+<tr>
+ <td valign="top"><a name="desc_search_separator">search_separator</a></td>
+ <td valign="top"> > (Space before and after character)</td>
+ <td valign="top">The character to display between result type sub groups.</td></tr>
+<tr>
+ <td valign="top"><a name="desc_search_def_keytype">search_def_keytype</a></td>
+ <td valign="top">'phrase'</td>
+ <td valign="top">Default to one of these search methods:<ul>
+ <li>'all': results must contain all of the search terms.</li>
+ <li>'any': results may contain any of the search terms.</li>
+ <li>'phrase': search for the exact phrase as entered. (default)</li>
+ </ul></td></tr>
</table>
diff -r fcc8b4ab664b -r 6db77ef26a37 public_html/layout/professional/lists/inline/item_field.thtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/layout/professional/lists/inline/item_field.thtml Mon Feb 02 23:04:14 2009 +0000
@@ -0,0 +1,1 @@
+ {field_text}
diff -r fcc8b4ab664b -r 6db77ef26a37 public_html/layout/professional/lists/inline/item_row.thtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/layout/professional/lists/inline/item_row.thtml Mon Feb 02 23:04:14 2009 +0000
@@ -0,0 +1,4 @@
+ <div>
+ {item_field}
+ </div>
+ <br>
diff -r fcc8b4ab664b -r 6db77ef26a37 public_html/layout/professional/lists/inline/list.thtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/layout/professional/lists/inline/list.thtml Mon Feb 02 23:04:14 2009 +0000
@@ -0,0 +1,14 @@
+ {list_top}
+ <div class="admin-list-search">
+ <select name="page_limit" style="{show_limit}">
+ {page_limit}
+ </select>
+ <select name="page_sort" style="{show_sort}">
+ {page_sort}
+ </select>
+ </div>
+ {item_row}
+ <p class="aligncenter" style="{show_message}"><b>{message}</b></p>
+ <br{xhtml}>
+ {google_paging}
+ {list_bottom}
diff -r fcc8b4ab664b -r 6db77ef26a37 public_html/layout/professional/lists/inline/page_limit.thtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/layout/professional/lists/inline/page_limit.thtml Mon Feb 02 23:04:14 2009 +0000
@@ -0,0 +1,1 @@
+<option{limit_selected}{limit_subtags}>{limit_text}</option>
diff -r fcc8b4ab664b -r 6db77ef26a37 public_html/layout/professional/lists/inline/page_sort.thtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/layout/professional/lists/inline/page_sort.thtml Mon Feb 02 23:04:14 2009 +0000
@@ -0,0 +1,1 @@
+<option{sort_selected}{sort_subtags}>{sort_text}</option>
diff -r fcc8b4ab664b -r 6db77ef26a37 public_html/layout/professional/lists/table/item_field.thtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/layout/professional/lists/table/item_field.thtml Mon Feb 02 23:04:14 2009 +0000
@@ -0,0 +1,1 @@
+ <td>{field_text}</td>
diff -r fcc8b4ab664b -r 6db77ef26a37 public_html/layout/professional/lists/table/item_row.thtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/layout/professional/lists/table/item_row.thtml Mon Feb 02 23:04:14 2009 +0000
@@ -0,0 +1,3 @@
+ <tr class="pluginRow{cssid}" onmouseover="className='pluginRollOver';" onmouseout="className='pluginRow{cssid}';">
+ {item_field}
+ </tr>
diff -r fcc8b4ab664b -r 6db77ef26a37 public_html/layout/professional/lists/table/list.thtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/layout/professional/lists/table/list.thtml Mon Feb 02 23:04:14 2009 +0000
@@ -0,0 +1,16 @@
+ {list_top}
+ <div class="admin-list-search">
+ <select name="page_limit" style="{show_limit}">
+ {page_limit}
+ </select>
+ </div>
+ <table class="admin-list-table" style="{show_sort}">
+ <tr style="background:#FFFFFF;">
+ {page_sort}
+ </tr>
+ {item_row}
+ </table>
+ <p class="aligncenter" style="{show_message}"><b>{message}</b></p>
+ <br{xhtml}>
+ {google_paging}
+ {list_bottom}
diff -r fcc8b4ab664b -r 6db77ef26a37 public_html/layout/professional/lists/table/page_limit.thtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/layout/professional/lists/table/page_limit.thtml Mon Feb 02 23:04:14 2009 +0000
@@ -0,0 +1,1 @@
+<option{limit_selected}{limit_subtags}>{limit_text}</option>
diff -r fcc8b4ab664b -r 6db77ef26a37 public_html/layout/professional/lists/table/page_sort.thtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/layout/professional/lists/table/page_sort.thtml Mon Feb 02 23:04:14 2009 +0000
@@ -0,0 +1,1 @@
+<th class="admin-list-headerfield"{sort_subtags}>{sort_text}{sort_selected}</th>
diff -r fcc8b4ab664b -r 6db77ef26a37 public_html/lib-common.php
--- a/public_html/lib-common.php Mon Feb 02 10:52:36 2009 +0100
+++ b/public_html/lib-common.php Mon Feb 02 23:04:14 2009 +0000
@@ -5759,10 +5759,11 @@
*
* @param string $text the text
* @param string $query the search query
+* @param string $class html class to use to highlight
* @return string the text with highlighted search words
*
*/
-function COM_highlightQuery( $text, $query )
+function COM_highlightQuery( $text, $query, $class = 'highlight' )
{
$query = str_replace( '+', ' ', $query );
@@ -5783,7 +5784,7 @@
{
$searchword = preg_quote( str_replace( "'", "\'", $searchword ));
$searchword = str_replace('/', '\\/', $searchword);
- $text = preg_replace( '/(\>(((?>[^><]+)|(?R))*)\<)/ie', "preg_replace('/(?>$searchword+)/i','<span class=\"highlight\">\\\\0</span>','\\0')", '<!-- x -->' . $text . '<!-- x -->' );
+ $text = preg_replace( '/(\>(((?>[^><]+)|(?R))*)\<)/ie', "preg_replace('/(?>$searchword+)/i','<span class=\"$class\">\\\\0</span>','\\0')", '<!-- x -->' . $text . '<!-- x -->' );
}
}
diff -r fcc8b4ab664b -r 6db77ef26a37 system/classes/listfactory.class.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/system/classes/listfactory.class.php Mon Feb 02 23:04:14 2009 +0000
@@ -0,0 +1,652 @@
+<?php
+
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Geeklog 1.6 |
+// +---------------------------------------------------------------------------+
+// | listfactory.class.php |
+// | |
+// | This class allows personalised lists or tables to be easily generated |
+// | from arrays or SQL statements. It will also supports the sorting and |
+// | paging of results. |
+// +---------------------------------------------------------------------------+
+// | Copyright (C) 2000-2009 by the following authors: |
+// | |
+// | Authors: Sami Barakat - s.m.barakat AT gmail DOT com |
+// +---------------------------------------------------------------------------+
+// | |
+// | This program is free software; you can redistribute it and/or |
+// | modify it under the terms of the GNU General Public License |
+// | as published by the Free Software Foundation; either version 2 |
+// | of the License, or (at your option) any later version. |
+// | |
+// | This program is distributed in the hope that it will be useful, |
+// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+// | GNU General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software Foundation, |
+// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
+// | |
+// +---------------------------------------------------------------------------+
+
+if (strpos(strtolower($_SERVER['PHP_SELF']), 'listfactory.class.php') !== false) {
+ die('This file can not be used on its own.');
+}
+
+/* Example Use
+
+ // Initiate an instance of the class with the URL of the current page
+ $url = $_SERVER['PHP_SELF'];
+ $obj = new ListFactory($url);
+
+ // Set up some hidden fields that will be used to help format the data later on
+ $obj->setField('ID', 'id', false);
+
+ // Set up the fields that will be seen by the user
+ $obj->setField(
+ '#', // Title of the field
+ ROW_NUMBER, // The field identifier can be either:
+ // ROW_NUMBER - The number of each row will be displayed
More information about the geeklog-cvs
mailing list