Resources
Getting started
Support
Development
User Functions
Don't have an account yet? Sign up as a New User
Lost your password?
|
|
Welcome to Geeklog Thursday, September 09 2010 @ 03:47 AM EDT
| sbarakat |
 |
May 25 2009 15:26 PM (Read 4892 times) |
|
|

Junior
Status: offline
Registered: 04/22/08
Posts: 27
|
This is for those people who have tried out Geeklog 1.6.0 beta 1 and are having issues with the new search engine. Many of these issues stem from variations in the search API, some work was done to provide backwards compatibility but there is only so much I can do. The old API just did not return the data that was needed. So here I have provided some patches for some of the main plugins. Hopefully this will give you a better user experience.
DISCLAIMER
Before you start make sure to take a backup of the /plugins/<plugin_name>/functions.inc file. I cannot be held responsible for any damage that's done to your websites. I am simply providing this information to help people out, its up to you whether or not you want to try it. I have not used any of these plugins before so this code has not been fully tested. The code was built upon the plugins versions that were found on this site (whether these are the latest...I don't know).
But it *should* work... 
To apply these patches open up the relevant /plugins/<plugin_name>/functions.inc file and find the plugin_dopluginsearch_<plugin_name> function. Then simply replace the entire function with the relevant one below.
FAQ Manager 0.8.1 PHP Formatted Code /**
* This searches for faqs matching the user query and returns an object
* back to search.php where it will be formated and printed.
*
* @param string $query Keywords user is looking for
* @param date $datestart Start date to get results for (not used)
* @param date $dateend End date to get results for (not used)
* @param string $topic The topic they were searching in (not used)
* @param string $type Type of items they are searching, or 'all' (deprecated)
* @param int $author Get all results by this author (not used)
* @param string $keyType search key type: 'all', 'phrase', 'any'
* @param int $page page number of current search (deprecated)
* @param int $perpage number of results per page (deprecated)
* @return object search result object
*
*/
function plugin_dopluginsearch_faqman ($query, $datestart, $dateend, $topic, $type, $author, $keyType, $page, $perpage)
{
global $_TABLES, $LANG_FAQ;
// Make sure the query is SQL safe
$query = trim(addslashes($query));
$sql = "SELECT topicID AS id, question AS title, answer AS description, ";
$sql .= "CONCAT('/faqman/index.php?op=view&t=', topicID) AS url ";
$sql .= "FROM {$_TABLES['faq_topics']} topic LEFT JOIN {$_TABLES['faq_categories']} category ON topic.catID = category.catID ";
$sql .= "WHERE 1=1 ";
$search = new SearchCriteria ('faqman', $LANG_FAQ['searchlabel']);
$columns = array('title' => 'question', 'answer', 'keywords');
list($sql, $ftsql) = $search-> buildSearchSQL($keyType, $query, $columns, $sql);
$search-> setSQL($sql);
$search-> setFTSQL($ftsql);
$search-> setRank(3);
return $search;
}
File Management 1.5.3 PHP Formatted Code /**
* This searches for files matching the user query and returns an object
* back to search.php where it will be formated and printed.
*
* @param string $query Keywords user is looking for
* @param date $datestart Start date to get results for
* @param date $dateend End date to get results for
* @param string $topic The topic they were searching in
* @param string $type Type of items they are searching, or 'all' (deprecated)
* @param int $author Get all results by this author
* @param string $keyType search key type: 'all', 'phrase', 'any'
* @param int $page page number of current search (deprecated)
* @param int $perpage number of results per page (deprecated)
* @return object search result object
*
*/
function plugin_dopluginsearch_filemgmt ($query, $datestart, $dateend, $topic, $type, $author, $keyType, $page, $perpage)
{
global $_FM_TABLES, $LANG_FILEMGMT;
// Make sure the query is SQL safe
$query = trim(addslashes($query));
$sql = "SELECT a.lid AS id, a.submitter AS uid, a.title, a.hits, a.date, c.description, ";
$sql .= "CONCAT('/filemgmt/index.php?id=', a.lid) AS url ";
$sql .= "FROM {$_FM_TABLES['filemgmt_filedetail']} a ";
$sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_cat']} b ON b.cid=a.cid ";
$sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_filedesc']} c ON c.lid=a.lid ";
$sql .= filemgmt_buildAccessSql ('WHERE') . " AND a.status > 0 ";
if (! empty($datestart) && ! empty($dateend))
{
$delim = substr($datestart, 4, 1);
if (! empty($delim))
{
$DS = explode($delim, $datestart);
$DE = explode($delim, $dateend);
$startdate = mktime(0, 0, 0, $DS[1], $DS[2], $DS[0]);
$enddate = mktime(23, 59, 59, $DE[1], $DE[2], $DE[0]);
$sql .= "AND (date BETWEEN '$startdate' AND '$enddate') ";
}
}
if (! empty($author)) {
$sql .= "AND (submitter = '$author') ";
}
$search = new SearchCriteria ('filemgmt', $LANG_FILEMGMT['searchlabel']);
$columns = array('title' => 'a.title', 'c.description');
list($sql, $ftsql) = $search-> buildSearchSQL($keyType, $query, $columns, $sql);
$search-> setSQL($sql);
$search-> setFTSQL($ftsql);
$search-> setRank(3);
return $search;
}
Forum 2.7.2 PHP Formatted Code /**
* This searches for forum posts matching the user query and returns an object
* back to search.php where it will be formated and printed.
*
* @param string $query Keywords user is looking for
* @param date $datestart Start date to get results for
* @param date $dateend End date to get results for
* @param string $topic The topic they were searching in
* @param string $type Type of items they are searching, or 'all' (deprecated)
* @param int $author Get all results by this author
* @param string $keyType search key type: 'all', 'phrase', 'any'
* @param int $page page number of current search (deprecated)
* @param int $perpage number of results per page (deprecated)
* @return object search result object
*
*/
function plugin_dopluginsearch_forum ($query, $datestart, $dateend, $topic, $type, $author, $keyType, $page, $perpage)
{
global $_TABLES, $LANG_GF00;
// Make sure the query is SQL safe
$query = trim(addslashes($query));
$sql = "SELECT id, uid, date, subject AS title, comment AS description, views AS hits, ";
$sql .= "CONCAT('/forum/viewtopic.php?forum=', forum, '&showtopic=', id) AS url ";
$sql .= "FROM {$_TABLES['gf_topic']} WHERE 1=1 ";
if (! empty($datestart) && ! empty($dateend))
{
$delim = substr($datestart, 4, 1);
if (! empty($delim))
{
$DS = explode($delim, $datestart);
$DE = explode($delim, $dateend);
$startdate = mktime(0, 0, 0, $DS[1], $DS[2], $DS[0]);
$enddate = mktime(23, 59, 59, $DE[1], $DE[2], $DE[0]);
$sql .= "AND (date BETWEEN '$startdate' AND '$enddate') ";
}
}
if (! empty ($author)) {
$sql .= "AND (uid = '$author') ";
}
$search = new SearchCriteria ('forum', $LANG_GF00['searchlabel']);
$columns = array('title' => 'subject', 'comment');
list($sql, $ftsql) = $search-> buildSearchSQL($keyType, $query, $columns, $sql);
$search-> setSQL($sql);
$search-> setFTSQL($ftsql);
$search-> setRank(3);
return $search;
}
|
| |
|
|
| Anonymous: Guest |
 |
May 25 2009 15:40 PM |
|
|
|
|
You do realize 99% of the admins won't find this thread in the future, right? In other words, v1.6 would break every major plugin for 99% of the admins.
|
| |
|
|
| Dirk |
 |
May 25 2009 15:50 PM |
|
|

Admin
 Status: offline
Registered: 01/12/02
Posts: 12713
|
Quote by: GuestYou do realize 99% of the admins won't find this thread in the future, right? In other words, v1.6 would break every major plugin for 99% of the admins.
Great way to encourage people
Hint: Plugins can be updated. 1.6.0 is not out yet. Once it is, "official" updates will follow.
Sami: Thanks for those. I did actually update the search for the File Management Plugin already myself (running here on geeklog.net). Will be interesting to compare with your implementation. I'll update the plugins on here tomorrow.
bye, Dirk
|
| |
|
|
| sbarakat |
 |
May 25 2009 16:08 PM |
|
|

Junior
Status: offline
Registered: 04/22/08
Posts: 27
|
Quote by: GuestYou do realize 99% of the admins won't find this thread in the future, right? In other words, v1.6 would break every major plugin for 99% of the admins. The idea is to get the new API tested properly before v1.6 goes final. This post should also help plugin authors update their plugins as it provides a starting point...hopefully resulting in quicker official releases.
Quote by: DirkSami: Thanks for those. I did actually update the search for the File Management Plugin already myself (running here on geeklog.net). Will be interesting to compare with your implementation. I'll update the plugins on here tomorrow. Let me know if there is anything that needs changing and I can update the first post. I wrote and tested these very quickly so I may have missed something.
-Sami
|
| |
|
|
| Anonymous: Guset |
 |
May 25 2009 19:29 PM |
|
|
|
|
Quote by: DirkHint: Plugins can be updated. 1.6.0 is not out yet. Once it is, "official" updates will follow.
Hint: Most of Geeklog's major plugins weren't updated in years. What makes you think their AWOL authors would suddenly be back from the dead?
|
| |
|
|
| Dirk |
 |
May 26 2009 13:53 PM |
|
|

Admin
 Status: offline
Registered: 01/12/02
Posts: 12713
|
Quote by: GusetHint: Most of Geeklog's major plugins weren't updated in years.
Other than maybe the File Management Plugin - which "major" plugins are you talking about?
bye, Dirk
|
| |
|
|
| Anonymous: Guest |
 |
May 26 2009 19:21 PM |
|
|
|
|
Forum, Faqman, MG. Chatterblock too but it's not searchable anyway.
|
| |
|
|
| Dirk |
 |
May 27 2009 03:54 AM |
|
|

Admin
 Status: offline
Registered: 01/12/02
Posts: 12713
|
Quote by: GuestForum, Faqman, MG.
They've all had updates in recent months (Media Gallery being the oldest, back in September). You're exaggerating.
bye, Dirk
|
| |
|
|
| Dirk |
 |
June 11 2009 13:14 PM |
|
|

Admin
 Status: offline
Registered: 01/12/02
Posts: 12713
|
Minor improvement for the forum search: You don't need the 'forum=' parameter, which makes for shorter URLs:
PHP Formatted Code $sql .= "CONCAT('/forum/viewtopic.php?showtopic=', id) AS url ";
bye, Dirk
|
| |
|
|
| sbarakat |
 |
June 30 2009 18:51 PM |
|
|

Junior
Status: offline
Registered: 04/22/08
Posts: 27
|
A little update for the FAQ Manager plugin...
It seems to return results when searching for an author. It can be stopped by by placing this code just after the global declarations:
PHP Formatted Code if (! empty($author)) {
return;
}
It also may be worth doing the same with $datestart and $dateend.
I cant seem to edit my first post so this will have to do.
Sami
|
| |
|
|
| suprsidr |
 |
August 30 2009 22:37 PM |
|
|

Full Member
Status: offline
Registered: 12/29/04
Posts: 398
|
Decided to add gallery search to the G2Bridge plugin.
It appears the new search API does not allow me to return results. But instead only search params for searching geeklog's tables.
So how are plugins with external apps or dependencies supposed to contribute to search results?
-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
|
| |
|
|
| jmucchiello |
 |
August 31 2009 00:36 AM |
|
|

Full Member
Status: offline
Registered: 08/29/05
Posts: 976
|
I didn't say that specifically but the big SQL query search api was a concern of mine all those months ago.
|
| |
|
|
| suprsidr |
 |
September 01 2009 22:24 PM |
|
|

Full Member
Status: offline
Registered: 12/29/04
Posts: 398
|
So how are plugins with external apps or dependencies supposed to contribute to search results?
I guess they are not.
-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
|
| |
|
|
| sbarakat |
 |
September 02 2009 15:38 PM |
|
|

Junior
Status: offline
Registered: 04/22/08
Posts: 27
|
Quote by: suprsidrSo how are plugins with external apps or dependencies supposed to contribute to search results?
I guess they are not.
-s
hey,
your right, currently the search api does not support this, which is obviously a problem. i will look into it and hopefully get it in before the next gl release. the listfactory (which the search engine hangs off) already has to ability to set predefined results, so there will probably be an extra function to the api, eg SearchCriteria::SetResults(array)
-Sami
|
| |
|
|
| LWC |
 |
September 08 2009 12:15 PM |
|
|

Full Member
Status: offline
Registered: 02/19/04
Posts: 781
|
I've just submitted a comment to file 980, but it just took me (without submitting the comment, mind you) to filemgmt/index.php/fileid_980, which is just filemgmt/index.php - is this related to all of this?
|
| |
|
|
| suprsidr |
 |
February 04 2010 21:43 PM |
|
|

Full Member
Status: offline
Registered: 12/29/04
Posts: 398
|
Adding search for my G2Bridge plugin now that GL1.6 .1 allows for external results to be added(Yeah!)
My results are in fact included.
But notice the uid is not translated into a username->profileUrl for all results marked "media"
I am passing just the uid correct?
PHP Formatted Code 'uid'=>DB_getItem ($_TABLES['users'], 'uid', "username = '{$owner->getUserName()}'")
Or am I supposed to build the url myself?
also being these are media objects I was hoping to display a tiny thumb, but it seems any html I pass gets filtered.
is it possible to pass html in the description and/or title fields?
-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
|
| |
|
|
| suprsidr |
 |
February 06 2010 08:25 AM |
|
|

Full Member
Status: offline
Registered: 12/29/04
Posts: 398
|
w/ the lack of a response I answered my own questions:
But notice the uid is not translated into a username->profileUrl .... I am passing just the uid correct? .... Or am I supposed to build the url myself?
using SearchCriteria->setResults
the Doc's say to format your results:
PHP Formatted Code
array(
LF_SOURCE_NAME => 'myplugin',
LF_SOURCE_TITLE => 'My Plugin',
'title' => 'Custom Result 2',
'description' => 'This is a custom result',
'date' => '1256058000',
'url' => '/internal/page/custom2',
'hits' => 20000,
'uid' => 2
)
But you actually want to format the uid as an full html profile url.
http://wiki.geeklog.net/index.php/Using_Geeklog%27s_Improved_Search_Engine#Including_External_Results should be updated.
is it possible to pass html in the description and/or title fields?
I actually tacked it onto the html I passed in the uid field.
So I'm able to provide a preview image.
-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
|
| |
|
|
| Laugh |
 |
February 06 2010 10:11 AM |
|
|

Moderator
 Status: offline
Registered: 09/27/05
Posts: 411
|
That is a good work around (though your example didn't show any images, I searched for "percy" to bring up something). I ran into a similar issue a while back which I just left. I will add this to the search feature request so it can be implemented properly in the future. (Edit: Just added the info - http://project.geeklog.net/tracking/view.php?id=1006)
By the way I like how you show your gallery images in the what's new block on your homepage.
Tom
|
| |
|
|
| suprsidr |
 |
February 06 2010 10:21 AM |
|
|

Full Member
Status: offline
Registered: 12/29/04
Posts: 398
|
though your example didn't show any images, I searched for "percy" to bring up something
Thanks for that, I had my session handler commented out. - fixed.
By the way I like how you show your gallery images in the what's new block on your homepage.
Thanks again... just playing with that idea at the moment - good to get some feedback.
-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
|
| |
|
|
| Laugh |
 |
February 06 2010 10:55 AM |
|
|

Moderator
 Status: offline
Registered: 09/27/05
Posts: 411
|
Thanks again... just playing with that idea at the moment - good to get some feedback.
No problem, you do good work and I have always liked the look of your site. At some point in the future I may talk to you about hiring you to do some graphic/theme work for me.
Tom
|
| |
|
|
| Content generated in: 4.11 seconds |
|
|