r65347 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65346‎ | r65347 | r65348 >
Date:22:06, 20 April 2010
Author:siebrand
Status:deferred
Tags:
Comment:
stylize.php, trailing whitespace removed, indentation updated
Modified paths:
  • /trunk/extensions/CategoryWatch/CategoryWatch.i18n.php (modified) (history)
  • /trunk/extensions/CategoryWatch/CategoryWatch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryWatch/CategoryWatch.i18n.php
@@ -3,7 +3,7 @@
44 * Internationalisation file for extension CategoryWatch.
55 *
66 * @addtogroup Extensions
7 -*/
 7+ */
88
99 $messages = array();
1010
Index: trunk/extensions/CategoryWatch/CategoryWatch.php
@@ -13,9 +13,9 @@
1414 * @licence GNU General Public Licence 2.0 or later
1515 */
1616
17 -if ( !defined('MEDIAWIKI' ) ) die( 'Not an entry point.' );
 17+if ( !defined( 'MEDIAWIKI' ) ) die( 'Not an entry point.' );
1818
19 -define( 'CATEGORYWATCH_VERSION', '1.1.0, 2009-04-21' );
 19+define( 'CATEGORYWATCH_VERSION', '1.1.1, 2010-04-21' );
2020
2121 $wgCategoryWatchNotifyEditor = true;
2222 $wgCategoryWatchUseAutoCat = false;
@@ -30,10 +30,9 @@
3131 'version' => CATEGORYWATCH_VERSION,
3232 );
3333
34 -$wgExtensionMessagesFiles['CategoryWatch'] = dirname(__FILE__) . '/CategoryWatch.i18n.php';
 34+$wgExtensionMessagesFiles['CategoryWatch'] = dirname( __FILE__ ) . '/CategoryWatch.i18n.php';
3535
3636 class CategoryWatch {
37 -
3837 function __construct() {
3938 global $wgHooks;
4039 $wgHooks['ArticleSave'][] = $this;
@@ -45,7 +44,7 @@
4645 */
4746 function onArticleSave( &$article, &$user, &$text ) {
4847 global $wgCategoryWatchUseAutoCat;
49 -
 48+
5049 $this->before = array();
5150 $dbr = wfGetDB( DB_SLAVE );
5251 $cl = $dbr->tableName( 'categorylinks' );
@@ -64,7 +63,7 @@
6564 $wtbl = $dbr->tableName( 'watchlist' );
6665 $sql = "SELECT user_id FROM $utbl LEFT JOIN $wtbl ON user_id=wl_user AND wl_title LIKE '%$like%' WHERE wl_user IS NULL";
6766 $res = $dbr->query( $sql );
68 -
 67+
6968 # Insert an entry into watchlist for each
7069 while ( $row = $dbr->fetchRow( $res ) ) {
7170 $uname = User::newFromId( $row[0] )->getName();
@@ -72,7 +71,7 @@
7372 $dbr->insert( $wtbl, array( 'wl_user' => $row[0], 'wl_namespace' => NS_CATEGORY, 'wl_title' => $wl_title ) );
7473 }
7574 $dbr->freeResult( $res );
76 - }
 75+ }
7776
7877 return true;
7978 }
@@ -81,7 +80,6 @@
8281 * Find changes in categorisation and send messages to watching users
8382 */
8483 function onArticleSaveComplete( &$article, &$user, &$text, &$summary, &$medit ) {
85 -
8684 # Get cats after update
8785 $this->after = array();
8886 $dbr = wfGetDB( DB_SLAVE );
@@ -97,12 +95,11 @@
9896
9997 # Notify watchers of each cat about the addition or removal of this article
10098 if ( count( $add ) > 0 || count( $sub ) > 0 ) {
101 -
10299 $page = $article->getTitle();
103100 $pagename = $page->getPrefixedText();
104101 $pageurl = $page->getFullUrl();
105102 $page = "$pagename ($pageurl)";
106 -
 103+
107104 if ( count( $add ) == 1 && count( $sub ) == 1 ) {
108105 $add = array_shift( $add );
109106 $sub = array_shift( $sub );
@@ -111,23 +108,21 @@
112109 $message = wfMsg( 'categorywatch-catmovein', $page, $this->friendlyCat( $add ), $this->friendlyCat( $sub ) );
113110 $this->notifyWatchers( $title, $user, $message, $summary, $medit );
114111
115 - #$title = Title::newFromText( $sub, NS_CATEGORY );
116 - #$message = wfMsg( 'categorywatch-catmoveout', $page, $this->friendlyCat( $sub ), $this->friendlyCat( $add ) );
117 - #$this->notifyWatchers( $title, $user, $message, $summary, $medit );
118 - }
119 - else {
120 -
 112+ # $title = Title::newFromText( $sub, NS_CATEGORY );
 113+ # $message = wfMsg( 'categorywatch-catmoveout', $page, $this->friendlyCat( $sub ), $this->friendlyCat( $add ) );
 114+ # $this->notifyWatchers( $title, $user, $message, $summary, $medit );
 115+ } else {
121116 foreach ( $add as $cat ) {
122117 $title = Title::newFromText( $cat, NS_CATEGORY );
123118 $message = wfMsg( 'categorywatch-catadd', $page, $this->friendlyCat( $cat ) );
124119 $this->notifyWatchers( $title, $user, $message, $summary, $medit );
125120 }
126121
127 - #foreach ( $sub as $cat ) {
 122+ # foreach ( $sub as $cat ) {
128123 # $title = Title::newFromText( $cat, NS_CATEGORY );
129124 # $message = wfMsg( 'categorywatch-catsub', $page, $this->friendlyCat( $cat ) );
130125 # $this->notifyWatchers( $title, $user, $message, $summary, $medit );
131 - #}
 126+ # }
132127 }
133128 }
134129
@@ -151,7 +146,7 @@
152147 # Get list of users watching this category
153148 $dbr = wfGetDB( DB_SLAVE );
154149 $conds = array( 'wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace() );
155 - if ( !$wgCategoryWatchNotifyEditor) $conds[] = 'wl_user <> ' . intval( $editor->getId() );
 150+ if ( !$wgCategoryWatchNotifyEditor ) $conds[] = 'wl_user <> ' . intval( $editor->getId() );
156151 $res = $dbr->select( 'watchlist', array( 'wl_user' ), $conds, __METHOD__ );
157152
158153 # Wrap message with common body and send to each watcher
@@ -164,8 +159,8 @@
165160 $watchingUser = User::newFromId( $row[0] );
166161 $timecorrection = $watchingUser->getOption( 'timecorrection' );
167162 $editdate = $wgLang->timeanddate( wfTimestampNow(), true, false, $timecorrection );
 163+
168164 if ( $watchingUser->getOption( 'enotifwatchlistpages' ) && $watchingUser->isEmailConfirmed() ) {
169 -
170165 $to = new MailAddress( $watchingUser );
171166 $subject = wfMsg( 'categorywatch-emailsubject', $page );
172167 $body = wfMsgForContent( 'enotif_body' );
@@ -218,8 +213,11 @@
219214 # Replace keys, wrap text and send
220215 $body = strtr( $body, $keys );
221216 $body = wordwrap( $body, 72 );
222 - if ( function_exists( 'userMailer' ) ) userMailer( $to, $from, $subject, $body, $replyto );
223 - else UserMailer::send( $to, $from, $subject, $body, $replyto );
 217+ if ( function_exists( 'userMailer' ) ) {
 218+ userMailer( $to, $from, $subject, $body, $replyto );
 219+ } else {
 220+ UserMailer::send( $to, $from, $subject, $body, $replyto );
 221+ }
224222 }
225223 }
226224
@@ -239,5 +237,4 @@
240238
241239 # Instantiate the CategoryWatch singleton now that the environment is prepared
242240 $wgCategoryWatch = new CategoryWatch();
243 -
244241 }

Status & tagging log