some searchhighlight plugin improvements

Creating and modifying plugins.
Post Reply
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

some searchhighlight plugin improvements

Post 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 245 times
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: some searchhighlight plugin improvements

Post by garvinhicking »

Hi!

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

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: some searchhighlight plugin improvements

Post by garvinhicking »

Hi!

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

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: some searchhighlight plugin improvements

Post 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.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: some searchhighlight plugin improvements

Post by garvinhicking »

Hi!

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

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: some searchhighlight plugin improvements

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: some searchhighlight plugin improvements

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: some searchhighlight plugin improvements

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: some searchhighlight plugin improvements

Post 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 ;)
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply