Google last query plugin and charset

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Matthias
Regular
Posts: 47
Joined: Wed Mar 01, 2006 4:33 pm
Contact:

Google last query plugin and charset

Post by Matthias »

I just have installed google_last_query plugin and I have troubles with umlauts (ä,ü...) and special characters (ß) as you can see here on my blog´s sidebar. In admin panel I set UTF-8 as charset and in "lang/UTF-8/serendipity_lang_de.inc.php" I changed this line "@define('DATE_LOCALES', 'de_DE.UTF-8, german, de_DE, de, de_DE@euro, de_DE.ISO8859-1');" to solve calender problem (März-problem).

Can this problem be corrected?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Google last query plugin and charset

Post by garvinhicking »

Hi!

That's true. This fix should help, just replace the generate_content function with this:

Code: Select all

    function generate_content(&$title) {
        global $serendipity;

        $title = $this->get_config('title');
        $count = $this->get_config('count');
        if($count<1) {
            $count = 1;
        }

        $rows = serendipity_db_query("select scheme, host, path, query from {$serendipity['dbPrefix']}referrers where host like '%.google.%' and path like '/search' order by day desc, count asc limit $count");

        if (!is_array($rows)) {
            return true;
        }

        foreach($rows as $row) {
            if (preg_match("/(q|query)=(.*?)(&|$)/", $row[3], $matches)) {
                if (LANG_CHARSET != 'UTF-8') {
                    $out = utf8_decode(urldecode($matches[2]));
                } else {
                    $out = urldecode($matches[2]);
                }
                echo "<a href='".$row[0]."://".htmlspecialchars($row[1].$row[2])."?query=".htmlspecialchars($matches[2])."'>". htmlspecialchars($out) ."</a><br />";
            }
        }
    }

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/
Matthias
Regular
Posts: 47
Joined: Wed Mar 01, 2006 4:33 pm
Contact:

Post by Matthias »

great, now it works. Thank you very much.
Post Reply