Page 1 of 1

some searchhighlight plugin improvements

Posted: Thu Sep 30, 2010 4:41 pm
by Timbalu
Hi

Since I have worked with the serendipity search option and discovered some odd behaviour in bp pagination and the cores asterisk search option, I have updated the searchhighlight event plugin too, to support the wildcard(*) search, which was added in core some time ago.
This plugin will now act like a fuzzy search, if you enter an asterisk search.
Now 'word*' or '*word' will highlight case insensive all occurences of '%word%'.

Also I added the searchengine Bing (untested) and added the ability to highlight search results in static pages to the config, which are appended at the end of the search page. This does not work in the teaser itself, but well in the opened static pages by link. (Maybe someone else will have an idea how to support the teasers get highlighted too)

If you want to use this, you may have to apply Garvins Patch in functions_entries.inc.php (http://svn.berlios.de/viewvc/serendipit ... 70&r2=2701), which will ship with serendipity's next version.

regards,
Ian
serendipity_event_searchhighlight_v1.7.zip
(15.45 KiB) Downloaded 246 times

Re: some searchhighlight plugin improvements

Posted: Fri Oct 01, 2010 11:55 am
by garvinhicking
Hi!

Great, I'll see to commit this next week!

Regards,
Garvin

Re: some searchhighlight plugin improvements

Posted: Mon Oct 04, 2010 10:46 am
by garvinhicking
Hi!

Done, it's put up to the current s9y trunk.

Regards,
Garvin

Re: some searchhighlight plugin improvements

Posted: Mon Oct 04, 2010 4:23 pm
by Timbalu
Hi Garvin

Sorry for this, but I had to change the case: PLUGIN_EVENT_SEARCHHIGHLIGHT_S9Y to ensure highlighting in static pages again, in case of not having a ['GET']['searchTerm'] request.
Additionally I think we don't need the #.. $_REQUEST['serendipity']['searchTerm'], or is there any POST search data using this plugin?

Code: Select all

            case PLUGIN_EVENT_SEARCHHIGHLIGHT_S9Y:
                $query = $pStr['serendipity']['searchTerm'];
                
                #if (!empty($_REQUEST['serendipity']['searchTerm'])) {
                #    $query = $_REQUEST['serendipity']['searchTerm'];
                #}
                if (!empty($serendipity['GET']['searchTerm'])) {
                    $query = $serendipity['GET']['searchTerm'];
                } 
                /* highlight selected static page, if not having a ['GET']['searchTerm'] REQUEST, but coming from a /search/ referrer */
                if(empty($query)) { 
                    // look out for path or query depending mod_rewrite setting
                    $urlpath = (($serendipity['rewrite'] == 'rewrite')  ? parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH)
                                                                        : parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY)
                                );
                    if ( strpos($urlpath, 'search/') ) { 
                        $path = explode('/', urldecode($urlpath));
                        $query = $path[(array_search('search', $path)+1)];
                    }
                }
                break;
If you have an idea how to highlight the static page teasers on the search pages without changing template tpls or the staticpage_event_plugin, please tell me.

Regards
Ian

Update2
Please forget the question about highlighting the teasers, its useless.

Re: some searchhighlight plugin improvements

Posted: Fri Oct 08, 2010 11:59 am
by garvinhicking
Hi!

Please link to a DIFF-File and I'll patch it

Regards,
Garvin

Re: some searchhighlight plugin improvements

Posted: Mon Oct 11, 2010 1:00 pm
by Timbalu
Hi Garvin

I'm sorry I am not familiar with diff patches, so I'll upload the file itself set to v.1.8
You still have to change it to the new

@serendipity_plugin_api::load_language(dirname(__FILE__));

Regards
Ian
searchhighlight_upd_1.8.zip
(3.43 KiB) Downloaded 224 times

Re: some searchhighlight plugin improvements

Posted: Tue Oct 12, 2010 2:18 pm
by garvinhicking
Hi!

Is there a specific reason you removed the $_REQUEST thing? I believe it could be that the searchterm comes from a POST request and it should be regarded... that can surely happen. And what bad does it do?! I always try not to remove things that are already there. ;-)

I committed the rest of the patch though! Thanks a lot! :)

Regards,
Garvin

Re: some searchhighlight plugin improvements

Posted: Tue Oct 12, 2010 3:45 pm
by Timbalu
Yeah that was my question though, but then I found:
garvinhicking wrote: "search requests are performed via GET"
http://board.s9y.org/viewtopic.php?f=4& ... rch#p94361
;-)
Ian

Re: some searchhighlight plugin improvements

Posted: Tue Oct 12, 2010 5:00 pm
by garvinhicking
Hi!
Timbalu wrote:Yeah that was my question though, but then I found:
garvinhicking wrote: "search requests are performed via GET"
http://board.s9y.org/viewtopic.php?f=4& ... rch#p94361
;-)
Ian
Yeah, that's how it generally works; but there might of course be plugins or other things out there that use POST; I don't think the code for that was added just for fun, so better not to run a changing system ;)