Difference between revisions of "Extension:SearchLog.php"
m |
(recommended special page way not working, using older way) |
||
Line 19: | Line 19: | ||
); | ); | ||
− | # | + | require_once "$IP/includes/SpecialPage.php"; |
− | function | + | |
− | + | class SpecialSearchLog extends SpecialPage | |
− | + | ||
+ | # Constructor | ||
+ | function SpecialSearchLog() { | ||
+ | SpecialPage::SpecialPage('SearchLog'); | ||
+ | } | ||
+ | |||
+ | # Override SpecialPage::execute() | ||
+ | function execute() { | ||
+ | global $wgOut; | ||
+ | $title = Title::makeTitle(NS_SPECIAL,'SearchLog'); | ||
+ | |||
+ | # Render a dropdown of months/years covered by the range of the log entries | ||
+ | $wgOut->addHTML( | ||
+ | wfElement('form',array('action' => $title->getLocalURL('action=submit'),'method' => 'POST'),null) | ||
+ | . '<textarea name="target" cols=25 rows=10></textarea>' | ||
+ | . wfElement('input',array('type' => 'submit')) | ||
+ | . '</form>' | ||
+ | ); | ||
+ | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
# Called from $wgExtensionFunctions array when initialising extensions | # Called from $wgExtensionFunctions array when initialising extensions | ||
function wfSetupSearchLog() { | function wfSetupSearchLog() { | ||
− | global $ | + | global $wgLanguageCode,$wgMessageCache,$wgSearchLogPath,$wgUser; |
# If a search has been posted, log the info | # If a search has been posted, log the info | ||
Line 56: | Line 67: | ||
# Add the specialpage to the environment | # Add the specialpage to the environment | ||
− | + | SpecialPage::addPage(new SpecialSearchLog()); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
?> | ?> |
Revision as of 22:15, 20 May 2007
<?php
- Extension:SearchLog
{{#Security:*|dev}}{{#Security:view|*}}Template:Php
- - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
- - Author: User:NadCategory:Extensions created with Template:SpecialPage
if (!defined('MEDIAWIKI')) die('Not an entry point.');
define('SEARCHLOG_VERSION','0.0.0, 2007-05-20');
$wgSearchLogPath = dirname(__FILE__); $wgExtensionFunctions[] = 'wfSetupSearchLog';
$wgExtensionCredits['specialpage'][] = array( 'name' => 'Special:SearchLog', 'author' => 'User:Nad', 'description' => 'Logs usage of the search box and allows reporting of keyword totals during given time periods', 'url' => 'http://www.mediawiki.org/wiki/Extension:SearchLog', 'version' => SEARCHLOG_VERSION );
require_once "$IP/includes/SpecialPage.php";
class SpecialSearchLog extends SpecialPage
# Constructor function SpecialSearchLog() { SpecialPage::SpecialPage('SearchLog'); }
# Override SpecialPage::execute() function execute() { global $wgOut; $title = Title::makeTitle(NS_SPECIAL,'SearchLog');
# Render a dropdown of months/years covered by the range of the log entries $wgOut->addHTML( wfElement('form',array('action' => $title->getLocalURL('action=submit'),'method' => 'POST'),null) . '<textarea name="target" cols=25 rows=10></textarea>' . wfElement('input',array('type' => 'submit')) . '</form>' ); }
}
- Called from $wgExtensionFunctions array when initialising extensions
function wfSetupSearchLog() { global $wgLanguageCode,$wgMessageCache,$wgSearchLogPath,$wgUser;
# If a search has been posted, log the info if (isset($_REQUEST['search'])) { if (isset($_REQUEST['go'])) $type = 'go'; else if (isset($_REQUEST['go'])) $type = 'fulltext'; else $type = 'other';
# Append the data to the file if ($fh = fopen("$wgSearchLogPath/search.log",'a')) { #fwrite($fh,... fclose($fh); } }
# Add the messages used by the specialpage $wgMessageCache->addMessages(array( 'searchlog' => 'Search Log', ));
# Add the specialpage to the environment SpecialPage::addPage(new SpecialSearchLog()); } ?>