Page 1 of 1

Google last query plugin and charset

Posted: Wed Apr 19, 2006 10:44 pm
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?

Re: Google last query plugin and charset

Posted: Thu Apr 20, 2006 10:21 am
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

Posted: Thu Apr 20, 2006 10:49 am
by Matthias
great, now it works. Thank you very much.