From 5549750977304976e8be5bfea2b7529b08d49409 Mon Sep 17 00:00:00 2001 From: David McCabe Date: Tue, 6 Nov 2007 01:16:25 +0000 Subject: [PATCH] The uncontroversial Liquid Threads hooks. The hook SkinTemplateTabAction got left in from a previous attempted commit, but the documentation is added in this commit. The other new hooks here are ChangesListInsertArticleLink, MediaWikiPerformAction, and BeforeWatchlist. --- RELEASE-NOTES | 6 ++++++ docs/hooks.txt | 36 +++++++++++++++++++++++++++++++++++ includes/ChangesList.php | 3 +++ includes/OutputPage.php | 4 ++++ includes/SpecialWatchlist.php | 6 ++++++ includes/Wiki.php | 5 +++++ 6 files changed, 60 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index fdc5a205a7..29f535d1c0 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -49,6 +49,12 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * LogLine hook added to allow formatting custom entries in Special:Log. * Support for Iranian calendar * (bug 1401) Allow hiding logged-in users, bots and patrolled pages on Special:Newpages +* ChangesListInsertArticleLink hook added for adding extra article info to RC. +* MediaWikiPerformAction hook added for diverting control after the main + globals have been set up but before any actions have been taken. +* BeforeWatchlist hook added for filtering or replacing watchlist. +* SkinTemplateTabAction hook added for altering the properties of tab links. +* OutputPage::getRedirect public method added. === Bug fixes in 1.12 === diff --git a/docs/hooks.txt b/docs/hooks.txt index d1216bb9b2..d9adf9603d 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -385,6 +385,13 @@ $out: OutputPage object &$parser: Parser object &$ig: ImageGallery object +'BeforeWatchlist': Override watchlist display or add extra SQL clauses. +$nondefaults: Assoc array with the following keys: + days, hideOwn, hideBots, hideMinor, namespace +$wgUser: wgUser. +&$hookSql: a string which will be inserted without sanitation into the SQL query + used to get the watchlist, at the end of the WHERE part. + 'BlockIp': before an IP address or user is blocked $block: the Block object about to be saved $user: the user _doing_ the block (not the one being blocked) @@ -400,6 +407,14 @@ $output: OutputPage object in use 'CategoryPageView': before viewing a categorypage in CategoryPage::view $catpage: CategoryPage instance +'ChangesListInsertArticleLink': Override or augment link to article in RC list. +&$this: ChangesList instance. +&$articlelink: HTML of link to article (already filled-in). +&$s: HTML of row that is being constructed. +&$rc: RecentChange instance. +$unpatrolled: Whether or not we are showing unpatrolled changes. +$watched: Whether or not the change is watched by the user. + 'ContributionsToolLinks': Change tool links above Special:Contributions $id: User identifier $title: User page title @@ -580,6 +595,15 @@ $mathRenderer: instance of MathRenderer $errmsg: error message, in HTML (string). Nonempty indicates failure of rendering the formula +'MediaWikiPerformAction': Override MediaWiki::performAction(). + Use this to do something completely different, after the basic + globals have been set up, but before ordinary actions take place. +$output: $wgOut +$article: $wgArticle +$title: $wgTitle +$user: $wgUser +$request: $wgRequest + 'OutputPageBeforeHTML': a page has been processed by the parser and the resulting HTML is about to be displayed. $parserOutput: the parserOutput (object) that corresponds to the page @@ -671,6 +695,18 @@ for an example] &$sktemplate: SkinTemplate object &$tpl: Template engine object +'SkinTemplateTabAction': Override SkinTemplate::tabAction(). + You can either create your own array, or alter the parameters for the normal one. +&$this: The SkinTemplate instance. +$title: Title instance for the page. +$message: Visible label of tab. +$selected: Whether this is a selected tab. +$checkEdit: Whether or not the action=edit query should be added if appropriate. +&$classes: Array of CSS classes to apply. +&$query: Query string to add to link. +&$text: Link text. +&$result: Complete assoc. array if you want to return true. + 'SpecialContributionsBeforeMainOutput': Before the form on Special:Contributions $id: User identifier diff --git a/includes/ChangesList.php b/includes/ChangesList.php index 8d0f95086f..617e12e196 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -176,6 +176,9 @@ class ChangesList { global $wgContLang; $articlelink .= $wgContLang->getDirMark(); + wfRunHooks('ChangesListInsertArticleLink', + array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched)); + $s .= ' '.$articlelink; } diff --git a/includes/OutputPage.php b/includes/OutputPage.php index d19e02e278..b756f558f1 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -63,6 +63,10 @@ class OutputPage { $this->mRedirect = str_replace( "\n", '', $url ); $this->mRedirectCode = $responsecode; } + + public function getRedirect() { + return $this->mRedirect; + } /** * Set the HTTP status code to send with the output. diff --git a/includes/SpecialWatchlist.php b/includes/SpecialWatchlist.php index e9aa7e6883..546a8a4d23 100644 --- a/includes/SpecialWatchlist.php +++ b/includes/SpecialWatchlist.php @@ -122,6 +122,11 @@ function wfSpecialWatchlist( $par ) { wfAppendToArrayIfNotDefault( 'hideMinor', (int)$hideMinor, $defaults, $nondefaults ); wfAppendToArrayIfNotDefault('namespace', $nameSpace , $defaults, $nondefaults); + $hookSql = ""; + if( ! wfRunHooks('BeforeWatchlist', array($nondefaults, $wgUser, &$hookSql)) ) { + return; + } + if ( $days <= 0 ) { $andcutoff = ''; } else { @@ -193,6 +198,7 @@ function wfSpecialWatchlist( $par ) { $andHideBots $andHideMinor $nameSpaceClause + $hookSql ORDER BY rc_timestamp DESC $limitWatchlist"; diff --git a/includes/Wiki.php b/includes/Wiki.php index 72a6a61db8..1b2e55745e 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -371,6 +371,11 @@ class MediaWiki { wfProfileIn( 'MediaWiki::performAction' ); + if ( !wfRunHooks('MediaWikiPerformAction', array($output, $article, $title, $user, $request)) ) { + wfProfileOut( 'MediaWiki::performAction' ); + return; + } + $action = $this->getVal('Action'); if( in_array( $action, $this->getVal('DisabledActions',array()) ) ) { /* No such action; this will switch to the default case */ -- 2.20.1