r91335 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91334‎ | r91335 | r91336 >
Date:23:53, 1 July 2011
Author:reedy
Status:ok
Tags:
Comment:
Documentation and whitespace
Modified paths:
  • /trunk/extensions/WikiLove/WikiLove.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiLove/WikiLove.hooks.php
@@ -1,18 +1,20 @@
22 <?php
33 /**
44 * Hooks for WikiLove extension
5 - *
 5+ *
66 * @file
77 * @ingroup Extensions
88 */
99
1010 class WikiLoveHooks {
1111 private static $recipient = '';
12 -
 12+
1313 /**
1414 * LoadExtensionSchemaUpdates hook
1515 *
1616 * @param $updater DatabaseUpdater
 17+ *
 18+ * @return true
1719 */
1820 public static function loadExtensionSchemaUpdates( $updater = null ) {
1921 if ( $updater === null ) {
@@ -22,16 +24,18 @@
2325 } else {
2426 $updater->addExtensionUpdate( array( 'addTable', 'wikilove_log',
2527 dirname( __FILE__ ) . '/patches/WikiLoveLog.sql', true ) );
26 - $updater->addExtensionUpdate( array( 'addTable', 'wikilove_image_log',
 28+ $updater->addExtensionUpdate( array( 'addTable', 'wikilove_image_log',
2729 dirname( __FILE__ ) . '/patches/WikiLoveImageLog.sql', true ) );
2830 }
2931 return true;
3032 }
31 -
 33+
3234 /**
3335 * Add the preference in the user preferences with the GetPreferences hook.
3436 * @param $user User
35 - * @param $preferences
 37+ * @param $preferences array
 38+ *
 39+ * @return true
3640 */
3741 public static function getPreferences( $user, &$preferences ) {
3842 global $wgWikiLoveGlobal;
@@ -44,19 +48,21 @@
4549 }
4650 return true;
4751 }
48 -
 52+
4953 /**
5054 * Adds the required module if we are on a user (talk) page.
5155 *
52 - * @param $output
 56+ * @param $out OutputPage
5357 * @param $skin Skin
 58+ *
 59+ * @return true
5460 */
5561 public static function beforePageDisplay( $out, $skin ) {
5662 global $wgWikiLoveGlobal, $wgUser;
5763 if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) {
5864 return true;
5965 }
60 -
 66+
6167 $title = self::getUserTalkPage( $skin->getTitle() );
6268 if ( !is_null( $title ) ) {
6369 $out->addModules( array( 'ext.wikiLove.icon', 'ext.wikiLove.init' ) );
@@ -64,15 +70,19 @@
6571 }
6672 return true;
6773 }
68 -
 74+
6975 /**
7076 * Exports wikilove-recipient and edittoken variables to JS
 77+ *
 78+ * @param $vars array
 79+ *
 80+ * @return true
7181 */
7282 public static function makeGlobalVariablesScript( &$vars ) {
7383 global $wgUser;
7484 $vars['wikilove-recipient'] = self::$recipient;
7585 $vars['wikilove-edittoken'] = $wgUser->edittoken();
76 -
 86+
7787 $vars['wikilove-anon'] = 0;
7888 if ( self::$recipient !== '' ) {
7989 $receiver = User::newFromName( self::$recipient );
@@ -80,7 +90,7 @@
8191 }
8292 return true;
8393 }
84 -
 94+
8595 /**
8696 * Adds a tab the old way (before MW 1.18)
8797 */
@@ -88,27 +98,26 @@
8999 self::skinConfigViewsLinks( $skin, $contentActions );
90100 return true;
91101 }
92 -
 102+
93103 /**
94104 * Adds a tab or an icon the new way (MW >1.18)
95105 */
96106 public static function skinTemplateNavigation( &$skin, &$links ) {
97107 if ( self::showIcon( $skin ) ) {
98108 self::skinConfigViewsLinks( $skin, $links['views']);
99 - }
100 - else {
 109+ } else {
101110 self::skinConfigViewsLinks( $skin, $links['actions']);
102111 }
103112 return true;
104113 }
105 -
 114+
106115 /**
107116 * Configure views links.
108117 * Helper function for SkinTemplateTabs and SkinTemplateNavigation hooks
109118 * to configure views links.
110119 *
111120 * @param $skin Skin
112 - * @param $views
 121+ * @param $views array
113122 */
114123 private static function skinConfigViewsLinks( $skin, &$views ) {
115124 global $wgWikiLoveGlobal, $wgUser;
@@ -117,7 +126,7 @@
118127 if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) {
119128 return true;
120129 }
121 -
 130+
122131 if ( !is_null( self::getUserTalkPage( $skin->getTitle() ) ) ) {
123132 $views['wikilove'] = array(
124133 'text' => wfMsg( 'wikilove-tab-text' ),
@@ -129,17 +138,19 @@
130139 }
131140 }
132141 }
133 -
 142+
134143 /**
135144 * Only show an icon when the global preference is enabled and the current skin is Vector.
136145 *
137146 * @param $skin Skin
 147+ *
 148+ * @return bool
138149 */
139150 private static function showIcon( $skin ) {
140151 global $wgWikiLoveTabIcon;
141152 return $wgWikiLoveTabIcon && $skin->getSkinName() == 'vector';
142153 }
143 -
 154+
144155 /**
145156 * Find the editable talk page of the user we're looking at, or null
146157 * if such page does not exist.
@@ -153,15 +164,15 @@
154165 if ( !$wgUser->isLoggedIn() ) {
155166 return null;
156167 }
157 -
 168+
158169 $ns = $title->getNamespace();
159170 // return quickly if we're in the wrong namespace anyway
160171 if ( $ns != NS_USER && $ns != NS_USER_TALK ) {
161172 return null;
162173 }
163 -
 174+
164175 $baseTitle = Title::newFromText( $title->getBaseText(), $ns );
165 -
 176+
166177 if ( $ns == NS_USER_TALK && $baseTitle->quickUserCan( 'edit' ) ) {
167178 return $baseTitle;
168179 } elseif ( $ns == NS_USER ) {
@@ -172,4 +183,4 @@
173184 }
174185 return null;
175186 }
176 -}
\ No newline at end of file
 187+}

Status & tagging log