r114279 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114278‎ | r114279 | r114280 >
Date:16:37, 20 March 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
moved refresh tab hooks
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/SemanticMediaWiki.hooks.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_RefreshTab.php (deleted) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/SemanticMediaWiki.hooks.php
@@ -234,4 +234,48 @@
235235 return true;
236236 }
237237
 238+ /**
 239+ * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateTabs
 240+ * This is here for compatibility with MediaWiki 1.17. Once we can require 1.18, we can ditch this code :)
 241+ *
 242+ * @since 0.1
 243+ *
 244+ * @param SkinTemplate $skinTemplate
 245+ * @param array $contentActions
 246+ *
 247+ * @return true
 248+ */
 249+ public static function addRefreshTab( SkinTemplate $skinTemplate, array &$contentActions ) {
 250+ global $wgUser;
 251+
 252+ if ( $wgUser->isAllowed( 'purge' ) ) {
 253+ $contentActions['purge'] = array(
 254+ 'class' => false,
 255+ 'text' => wfMsg( 'smw_purge' ),
 256+ 'href' => $skinTemplate->getTitle()->getLocalUrl( array( 'action' => 'purge' ) )
 257+ );
 258+ }
 259+
 260+ return true;
 261+ }
 262+
 263+ /**
 264+ * Alter the structured navigation links in SkinTemplates.
 265+ * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateNavigation
 266+ *
 267+ * @since 1.8
 268+ *
 269+ * @param SkinTemplate $skinTemplate
 270+ * @param array $links
 271+ *
 272+ * @return true
 273+ */
 274+ public static function addStructuredRefreshTab( SkinTemplate &$skinTemplate, array &$links ) {
 275+ $actions = $links['actions'];
 276+ self::addRefreshTab( $skinTemplate, $actions );
 277+ $links['actions'] = $actions;
 278+
 279+ return true;
 280+ }
 281+
238282 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_RefreshTab.php
@@ -1,47 +0,0 @@
2 -<?php
3 -/**
4 - * @file
5 - * @ingroup SMW
6 - */
7 -
8 -/**
9 - * Protect against register_globals vulnerabilities.
10 - * This line must be present before any global variable is referenced.
11 - */
12 -if ( !defined( 'MEDIAWIKI' ) ) {
13 - die();
14 -}
15 -
16 -global $wgHooks;
17 -
18 -$wgHooks['SkinTemplateTabs'][] = 'smwfAddRefreshTab'; // basic tab addition
19 -$wgHooks['SkinTemplateNavigation'][] = 'smwfAddStructuredRefreshTab'; // structured version for "Vector"-type skins
20 -
21 -/**
22 - * Extends the provided array of content actions with an action that refreshes the article,
23 - * i.e. it purges the article from the cache and thus refreshes the inline queries.
24 - */
25 -function smwfAddRefreshTab( $skin, &$content_actions ) {
26 - global $wgUser;
27 - if ( $wgUser->isAllowed( 'purge' ) ) {
28 - // Skin::getTitle() was added in MW 1.16
29 - $title = is_callable( array( $skin, 'getTitle' ) ) ? $skin->getTitle() : $skin->mTitle;
30 - $content_actions['purge'] = array(
31 - 'class' => false,
32 - 'text' => wfMsg( 'smw_purge' ),
33 - 'href' => $title->getLocalUrl( 'action=purge' )
34 - );
35 - }
36 - return true; // always return true, in order not to stop MW's hook processing!
37 -}
38 -
39 -/**
40 - * Adds the refresh action like smwfAddRefreshTab(), but places it into
41 - * the structure of actions as used in new "Vector"-type skins
42 - */
43 -function smwfAddStructuredRefreshTab( $skin, &$links ) {
44 - $actions = $links['actions'];
45 - smwfAddRefreshTab( $skin, $actions );
46 - $links['actions'] = $actions;
47 - return true;
48 -}
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php
@@ -93,6 +93,9 @@
9494 $wgHooks['ArticleFromTitle'][] = 'SMWHooks::onArticleFromTitle'; // special implementations for property/type articles
9595 $wgHooks['ParserFirstCallInit'][] = 'SMWHooks::onParserFirstCallInit';
9696
 97+ $wgHooks['SkinTemplateTabs'][] = 'SMWHooks::addRefreshTab'; // basic tab addition
 98+ $wgHooks['SkinTemplateNavigation'][] = 'SMWHooks::addStructuredRefreshTab'; // structured version for "Vector"-type skins
 99+
97100 if ( $GLOBALS['smwgToolboxBrowseLink'] ) {
98101 $wgHooks['SkinTemplateToolboxEnd'][] = 'SMWHooks::showBrowseLink';
99102 }
@@ -419,9 +422,6 @@
420423 $smwgMasterStore = null;
421424 $smwgIQRunningNumber = 0;
422425
423 - ///// register hooks /////
424 - require_once( $smwgIP . 'includes/SMW_RefreshTab.php' );
425 -
426426 if ( isset($wgFooterIcons["poweredby"])
427427 && isset($wgFooterIcons["poweredby"]["semanticmediawiki"])
428428 && is_null( $wgFooterIcons["poweredby"]["semanticmediawiki"]["src"] ) ) {

Status & tagging log