Update of /cvsroot/php-blog/additional_plugins/serendipity_plugin_google_last_query
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6664/serendipity_plugin_google_last_query
Added Files:
serendipity_plugin_google_last_query.php
Log Message:
Google Queries Plugin
--- NEW FILE: serendipity_plugin_google_last_query.php ---
<?php
// Google Last Query Plugin for Serendipity
// 10/2004 by Thomas Nesges <th...@tn...>
switch ($serendipity['lang']) {
default:
case 'en':
@define('PLUGIN_GOOGLE_LAST_QUERY_TITLE', "Last Google Search");
@define('PLUGIN_GOOGLE_LAST_QUERY_DESC', "Shows the last Google Search which led to this Blog");
@define('PLUGIN_GOOGLE_LAST_QUERY_PROP_TITLE', "Title");
@define('PLUGIN_GOOGLE_LAST_QUERY_PROP_TITLE_DESC', "Title of Sidebarblock");
@define('PLUGIN_GOOGLE_LAST_QUERY_PROP_COUNT', "Count");
@define('PLUGIN_GOOGLE_LAST_QUERY_PROP_COUNT_DESC', "How many Searchwords should be shown?");
break;
case 'de':
@define('PLUGIN_GOOGLE_LAST_QUERY_TITLE', "Letzte Google Suche");
@define('PLUGIN_GOOGLE_LAST_QUERY_DESC', "Zeigt den Inhalt der letzten Google Suche(n), die zu diesem Blog geführt hat/haben, an");
@define('PLUGIN_GOOGLE_LAST_QUERY_PROP_TITLE', "Titel");
@define('PLUGIN_GOOGLE_LAST_QUERY_PROP_TITLE_DESC', "Titel des Sidebarblocks");
@define('PLUGIN_GOOGLE_LAST_QUERY_PROP_COUNT', "Anzahl");
@define('PLUGIN_GOOGLE_LAST_QUERY_PROP_COUNT_DESC', "Wieviele Suchworte anzeigen?");
break;
}
class serendipity_plugin_google_last_query extends serendipity_plugin {
function introspect(&$propbag) {
$propbag->add('name', PLUGIN_GOOGLE_LAST_QUERY_TITLE);
$propbag->add('description', PLUGIN_GOOGLE_LAST_QUERY_DESC);
$propbag->add('configuration', array('title', 'count'));
}
function introspect_config_item($name, &$propbag) {
switch($name) {
case 'title':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_GOOGLE_LAST_QUERY_PROP_TITLE);
$propbag->add('description', PLUGIN_GOOGLE_LAST_QUERY_PROP_TITLE_DESC);
$propbag->add('default', PLUGIN_GOOGLE_LAST_QUERY_TITLE);
break;
case 'count':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_GOOGLE_LAST_QUERY_PROP_COUNT);
$propbag->add('description', PLUGIN_GOOGLE_LAST_QUERY_PROP_COUNT_DESC);
$propbag->add('default', '1');
break;
default:
return false;
}
return true;
}
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");
foreach($rows as $row) {
if(preg_match("/(q|query)=(.*?)(&|$)/", $row[3], $matches)) {
echo "<a href='".$row[0]."://".$row[1].$row[2]."?query=".$matches[2]."'>". utf8_decode(urldecode($matches[2]))."</a><br>";
}
}
}
}
/ vim: set sts=4 ts=4 expandtab : /
?>
|