Index: trunk/extensions/CategoryWatch/CategoryWatch.php |
— | — | @@ -98,19 +98,6 @@ |
99 | 99 | # Notify watchers of each cat about the addition or removal of this article |
100 | 100 | if ( count( $add ) > 0 || count( $sub ) > 0 ) { |
101 | 101 | |
102 | | - # Add urls to article and cat names |
103 | | - foreach ( $add as $i => $v ) { |
104 | | - $cat = Title::newFromText( $v, NS_CATEGORY ); |
105 | | - $catname = $cat->getPrefixedText(); |
106 | | - $caturl = $cat->getFullUrl(); |
107 | | - $add[$i] = "$catname ($caturl)"; |
108 | | - } |
109 | | - foreach ( $sub as $i => $v ) { |
110 | | - $cat = Title::newFromText( $v, NS_CATEGORY ); |
111 | | - $catname = $cat->getPrefixedText(); |
112 | | - $caturl = $cat->getFullUrl(); |
113 | | - $sub[$i] = "$catname ($caturl)"; |
114 | | - } |
115 | 102 | $page = $article->getTitle(); |
116 | 103 | $pagename = $page->getPrefixedText(); |
117 | 104 | $pageurl = $page->getFullUrl(); |
— | — | @@ -121,24 +108,24 @@ |
122 | 109 | $sub = array_shift( $sub ); |
123 | 110 | |
124 | 111 | $title = Title::newFromText( $add, NS_CATEGORY ); |
125 | | - $message = wfMsg( 'categorywatch-catmovein', $page, $add, $sub ); |
| 112 | + $message = wfMsg( 'categorywatch-catmovein', $page, $this->friendlyCat( $add ), $this->friendlyCat( $sub ) ); |
126 | 113 | $this->notifyWatchers( $title, $user, $message ); |
127 | 114 | |
128 | 115 | #$title = Title::newFromText( $sub, NS_CATEGORY ); |
129 | | - #$message = wfMsg( 'categorywatch-catmoveout', $page, $sub, $add ); |
| 116 | + #$message = wfMsg( 'categorywatch-catmoveout', $page, $this->friendlyCat( $sub ), $this->friendlyCat( $add ) ); |
130 | 117 | #$this->notifyWatchers( $title, $user, $message ); |
131 | 118 | } |
132 | 119 | else { |
133 | 120 | |
134 | 121 | foreach ( $add as $cat ) { |
135 | 122 | $title = Title::newFromText( $cat, NS_CATEGORY ); |
136 | | - $message = wfMsg( 'categorywatch-catadd', $page, $cat ); |
| 123 | + $message = wfMsg( 'categorywatch-catadd', $page, $this->friendlyCat( $cat ) ); |
137 | 124 | $this->notifyWatchers( $title, $user, $message ); |
138 | 125 | } |
139 | 126 | |
140 | 127 | #foreach ( $sub as $cat ) { |
141 | 128 | # $title = Title::newFromText( $cat, NS_CATEGORY ); |
142 | | - # $message = wfMsg( 'categorywatch-catsub', $page, $cat ); |
| 129 | + # $message = wfMsg( 'categorywatch-catsub', $page, $this->friendlyCat( $cat ) ); |
143 | 130 | # $this->notifyWatchers( $title, $user, $message ); |
144 | 131 | #} |
145 | 132 | } |
— | — | @@ -147,6 +134,16 @@ |
148 | 135 | return true; |
149 | 136 | } |
150 | 137 | |
| 138 | + /** |
| 139 | + * Return "Category:Cat (URL)" from "Cat" |
| 140 | + */ |
| 141 | + function friendlyCat( $cat ) { |
| 142 | + $cat = Title::newFromText( $cat, NS_CATEGORY ); |
| 143 | + $catname = $cat->getPrefixedText(); |
| 144 | + $caturl = $cat->getFullUrl(); |
| 145 | + return "$catname ($caturl)"; |
| 146 | + } |
| 147 | + |
151 | 148 | function notifyWatchers( &$title, &$editor, &$message ) { |
152 | 149 | global $wgLang, $wgEmergencyContact, $wgNoReplyAddress, $wgCategoryWatchNotifyEditor, |
153 | 150 | $wgEnotifRevealEditorAddress, $wgEnotifUseRealName, $wgPasswordSender, $wgEnotifFromEditor; |
— | — | @@ -161,8 +158,8 @@ |
162 | 159 | $page = $title->getPrefixedText(); |
163 | 160 | $adminAddress = new MailAddress( $wgPasswordSender, 'WikiAdmin' ); |
164 | 161 | $editorAddress = new MailAddress( $editor ); |
165 | | - foreach ( $res as $row ) { |
166 | | - $watchingUser = User::newFromId( $row->wl_user ); |
| 162 | + while ( $row = $dbr->fetchRow( $res ) ) { |
| 163 | + $watchingUser = User::newFromId( $row[0] ); |
167 | 164 | $timecorrection = $watchingUser->getOption( 'timecorrection' ); |
168 | 165 | $editdate = $wgLang->timeanddate( wfTimestampNow(), true, false, $timecorrection ); |
169 | 166 | if ( $watchingUser->getOption( 'enotifwatchlistpages' ) && $watchingUser->isEmailConfirmed() ) { |
— | — | @@ -192,10 +189,11 @@ |
193 | 190 | # Define keys for body message |
194 | 191 | $userPage = $editor->getUserPage(); |
195 | 192 | $keys = array( |
| 193 | + '$WATCHINGUSERNAME' => $name, |
196 | 194 | '$NEWPAGE' => $message, |
197 | 195 | '$PAGETITLE' => $page, |
198 | 196 | '$PAGEEDITDATE' => $editdate, |
199 | | - '$CHANGEDORCREATED' => wfMsgForContent( 'created' ), |
| 197 | + '$CHANGEDORCREATED' => wfMsgForContent( 'changed' ), |
200 | 198 | '$PAGETITLE_URL' => $title->getFullUrl(), |
201 | 199 | '$PAGEEDITOR_WIKI' => $userPage->getFullUrl(), |
202 | 200 | '$OLDID' => '', |