Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 12:12 pm EST
Geeklog Forums
Plugin updates for the new search API
Page navigation
sbarakat
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
* 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
* 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
* 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;
}
Guest
Dirk
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.
Great way to encourage people :shock:
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
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.
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.
-Sami
Guset
Hint: 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? :shock:
Guest
Dirk
bye, Dirk
sbarakat
It seems to return results when searching for an author. It can be stopped by by placing this code just after the global declarations:
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
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
suprsidr
I guess they are not.
-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
sbarakat
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
suprsidr
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?
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
using SearchCriteria->setResults
the Doc's say to format your results:
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.
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
By the way I like how you show your gallery images in the what's new block on your homepage.
Tom
One of the Geeklog Core Developers.
suprsidr
Thanks for that, I had my session handler commented out. - fixed.
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
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
One of the Geeklog Core Developers.
Page navigation
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content