Extension:Log Searches

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.svg
Log Searches

Release status:Extension status experimental

ImplementationTemplate:Extension#type User interface
DescriptionTemplate:Extension#description logs searches into file
Author(s)Template:Extension#username Flominator
MediaWikiTemplate:Extension#mediawiki tested with 1.67
LicenseTemplate:Extension#license No license specified
Download No link

Translate the Log Searches extension if it is available at translatewiki.net

Check usage and version matrix.

At the moment, this one is just a dirty hack in order to log your search results into a comma separated file, which can be analyzed manually. This originally was a response to Project:Extension_requests#Search_statistics and is far from complete. In order to turn this into a "real" extension a new hook would have to added into Special:Search. --Flominator 09:21, 25 October 2007 (UTC)

Update: Although the hooks are now included, Extension:SearchLog might be a better solution. --Flominator 09:49, 27 June 2009 (UTC)

Installation[edit]

Place this code in /extensions/LogSearches.php ...

<?php

function log_goResult($term)
{
	logSearch("Artikelsuche;$term");
}

function log_showResults($term)
{
	logSearch("Volltextsuche;$term");

}
function logSearch($line)
{
	$f = fopen("./extensions/searchlog.csv", "a");
	fputs($f, $_SERVER['REMOTE_ADDR'] .';'. strftime("%Y-%m-%d;%H:%M").";$line;$time\n");
	fclose($f);
}
?>

... and this one in /LocalSettings.php ...

require_once("$IP/extensions/LogSearches.php")

... and modify /includes/SpecialSearch.php:

line 83:

function goResult( $term ) {
 log_goResult($term);
global $wgOut;

line 129

function showResults( $term ) {
 log_showResults($term);
$fname = 'SpecialSearch::showResults';

Promised solution[edit]

Looks like MW 1.13alpha has the solution for the patching above:

'SpecialSearchResults': called before search result display when there are matches
$term: string of search term
$titleMatches: empty or SearchResultSet object
$textMatches: empty or SearchResultSet object

Then release is scheduled around July 2008 ...