r48804 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48803‎ | r48804 | r48805 >
Date:11:04, 25 March 2009
Author:nad
Status:deferred
Tags:
Comment:
format code and remove hash from bodyContent id
Modified paths:
  • /trunk/extensions/EmailPage/EmailPage.php (modified) (history)
  • /trunk/extensions/EmailPage/EmailPage_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EmailPage/EmailPage_body.php
@@ -1,5 +1,5 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) die();
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
44
55 class SpecialEmailPage extends SpecialPage {
66
@@ -19,190 +19,194 @@
2020
2121 public function __construct() {
2222 global $wgEmailPageGroup;
23 - SpecialPage::SpecialPage('EmailPage', $wgEmailPageGroup);
 23+ SpecialPage::SpecialPage( 'EmailPage', $wgEmailPageGroup );
2424 }
2525
2626 /**
2727 * Override SpecialPage::execute($param = '')
2828 */
29 - function execute($param) {
 29+ function execute( $param ) {
3030 global $wgOut, $wgUser, $wgRequest, $wgParser, $wgEmailPageContactsCat, $wgGroupPermissions, $wgSitename,
3131 $wgRecordAdminCategory, $wgEmailPageCss, $wgEmailPageAllowAllUsers;
3232
33 - $db =& wfGetDB(DB_SLAVE);
34 - $param = str_replace('_', ' ', $param);
 33+ $db = wfGetDB(DB_SLAVE);
 34+ $param = str_replace( '_', ' ', $param );
3535 wfLoadExtensionMessages( 'EmailPage' );
3636 $this->setHeaders();
3737
3838 # Get info from request or set to defaults
39 - $this->title = $wgRequest->getText('ea-title', $param);
40 - $this->subject = $wgRequest->getText('ea-subject', wfMsg('ea-pagesend', $this->title, $wgSitename ));
41 - $this->header = $wgRequest->getText('ea-header');
42 - $this->cat = $wgRequest->getText('ea-cat');
43 - $this->group = $wgRequest->getText('ea-group');
44 - $this->list = $wgRequest->getText('ea-list');
45 - $this->textonly = $wgRequest->getText('ea-textonly', false);
46 - $this->css = $wgRequest->getText('ea-css', $wgEmailPageCss);
47 - $this->record = $wgRequest->getText('ea-record', false);
 39+ $this->title = $wgRequest->getText( 'ea-title', $param );
 40+ $this->subject = $wgRequest->getText( 'ea-subject', wfMsg( 'ea-pagesend', $this->title, $wgSitename ) );
 41+ $this->header = $wgRequest->getText( 'ea-header' );
 42+ $this->cat = $wgRequest->getText( 'ea-cat' );
 43+ $this->group = $wgRequest->getText( 'ea-group' );
 44+ $this->list = $wgRequest->getText( 'ea-list' );
 45+ $this->textonly = $wgRequest->getText( 'ea-textonly', false );
 46+ $this->css = $wgRequest->getText( 'ea-css', $wgEmailPageCss );
 47+ $this->record = $wgRequest->getText( 'ea-record', false );
4848 $this->db = $db;
4949 $this->parser = $wgParser;
5050
5151 # Bail if no page title to send has been specified
52 - if ($this->title) $wgOut->addWikiText(wfMsg('ea-heading', $this->title));
53 - else return $wgOut->addWikiText(wfMsg('ea-nopage'));
 52+ if ( $this->title ) $wgOut->addWikiText( wfMsg( 'ea-heading', $this->title ) );
 53+ else return $wgOut->addWikiText( wfMsg( 'ea-nopage' ) );
5454
5555 # If the send button was clicked, attempt to send and exit
56 - if (isset($_REQUEST['ea-send'])) return $this->send();
 56+ if ( isset( $_REQUEST['ea-send'] ) ) return $this->send();
5757
5858 # Render form
59 - $special = Title::makeTitle(NS_SPECIAL, 'EmailPage');
60 - $wgOut->addHTML(Xml::element('form',array(
 59+ $special = Title::makeTitle( NS_SPECIAL, 'EmailPage' );
 60+ $wgOut->addHTML( Xml::element( 'form', array(
6161 'class' => 'EmailPage',
62 - 'action' => $special->getLocalURL('action=submit'),
 62+ 'action' => $special->getLocalURL( 'action=submit' ),
6363 'method' => 'POST'
64 - ),null));
65 - $wgOut->addHTML('<fieldset><legend>'.wfMsg('ea-selectrecipients').'</legend>');
66 - $wgOut->addHTML('<table style="padding:0;margin:0;border:none;">');
 64+ ), null ) );
 65+ $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'ea-selectrecipients' ) . '</legend>' );
 66+ $wgOut->addHTML( '<table style="padding:0;margin:0;border:none;">' );
6767
6868 # If $wgEmailPageContactsCat is set, create a select list of all categories
69 - if ($wgEmailPageContactsCat) {
 69+ if ( $wgEmailPageContactsCat ) {
7070 $cats = '';
7171 $res = $db->select(
7272 'categorylinks',
7373 'cl_from',
74 - 'cl_to = '.$db->addQuotes($wgEmailPageContactsCat),
 74+ 'cl_to = '.$db->addQuotes( $wgEmailPageContactsCat ),
7575 __METHOD__,
76 - array('ORDER BY' => 'cl_sortkey')
 76+ array( 'ORDER BY' => 'cl_sortkey' )
7777 );
78 - while ($row = $db->fetchRow($res)) {
79 - $t = Title::newFromID($row[0]);
80 - if ($t->getNamespace() == NS_CATEGORY) {
 78+ while ( $row = $db->fetchRow( $res ) ) {
 79+ $t = Title::newFromID( $row[0] );
 80+ if ( $t->getNamespace() == NS_CATEGORY ) {
8181 $cat = $t->getText();
8282 $selected = $cat == $this->cat ? ' selected' : '';
8383 $cats .= "<option$selected>$cat</option>";
8484 }
8585 }
86 - $db->freeResult($res);
87 - if ($cats) $wgOut->addHTML("<tr><td>From category:</td><td><select name=\"ea-cat\"><option/>$cats</select></td></tr>\n");
 86+ $db->freeResult( $res );
 87+ if ( $cats ) $wgOut->addHTML( "<tr><td>From category:</td><td><select name=\"ea-cat\"><option/>$cats</select></td></tr>\n" );
8888 }
8989
9090 # Allow selection of a group
91 - $groups = '<option/>';
92 - foreach (array_keys($wgGroupPermissions) as $group) if ($group != '*') {
 91+ $groups = "<option />";
 92+ foreach ( array_keys( $wgGroupPermissions ) as $group ) if ( $group != '*' ) {
9393 $selected = $group == $this->group ? ' selected' : '';
94 - if ($wgEmailPageAllowAllUsers || $group != 'user') $groups .= "<option$selected>$group</option>";
 94+ if ( $wgEmailPageAllowAllUsers ) $groups .= "<option$selected>$group</option>";
9595 }
96 - $wgOut->addHTML("<tr><td>".wfMsg('ea-fromgroup')."</td><td><select name=\"ea-group\">$groups</select></td></tr>\n");
97 - $wgOut->addHTML('</table>');
 96+ $wgOut->addHTML( "<tr><td>" . wfMsg( 'ea-fromgroup' ) . "</td><td><select name=\"ea-group\">$groups</select></td></tr>\n" );
 97+ $wgOut->addHTML( "</table>" );
9898
9999 # Addition of named list
100 - $wgOut->addWikiText(wfMsg('ea-selectlist'));
101 - $wgOut->addHTML("<textarea name=\"ea-list\" rows=\"5\">{$this->list}</textarea><br />\n");
102 - $wgOut->addHTML('</fieldset>');
 100+ $wgOut->addWikiText( wfMsg( 'ea-selectlist' ) );
 101+ $wgOut->addHTML( "<textarea name=\"ea-list\" rows=\"5\">{$this->list}</textarea><br />\n" );
 102+ $wgOut->addHTML( "</fieldset>" );
103103
104 - $wgOut->addHTML('<fieldset><legend>'.wfMsg('ea-compose').'</legend>');
 104+ $wgOut->addHTML( "<fieldset><legend>" . wfMsg( 'ea-compose' ) . "</legend>" );
105105
106106 # Subject
107 - $wgOut->addWikiText(wfMsg('ea-subject'));
108 - $wgOut->addHTML(Xml::element('input',array('type' => 'text', 'name' => 'ea-subject', 'value' => $this->subject, 'style' => "width:100%")));
 107+ $wgOut->addWikiText( wfMsg( 'ea-subject' ) );
 108+ $wgOut->addHTML(
 109+ Xml::element( 'input', array( 'type' => 'text', 'name' => 'ea-subject', 'value' => $this->subject, 'style' => "width:100%" ) )
 110+ );
109111
110112 # Header
111 - $wgOut->addWikiText(wfMsg('ea-header'));
112 - $wgOut->addHTML("<textarea name=\"ea-header\" rows=\"5\">{$this->header}</textarea><br />\n");
 113+ $wgOut->addWikiText( wfMsg( 'ea-header' ) );
 114+ $wgOut->addHTML( "<textarea name=\"ea-header\" rows=\"5\">{$this->header}</textarea><br />\n" );
113115
114116 # CSS
115 - $options = '<option value="">'.$wgEmailPageCss.'</option>';
 117+ $options = "<option value=''>$wgEmailPageCss</option>";
116118 $res = $db->select(
117119 'page',
118120 'page_id',
119121 'page_title LIKE \'%.css\'',
120122 __METHOD__,
121 - array('ORDER BY' => 'page_title')
 123+ array( 'ORDER BY' => 'page_title' )
122124 );
123 - while ($row = $db->fetchRow($res)) {
124 - $t = Title::newFromID($row[0])->getPrefixedText();
 125+ while ( $row = $db->fetchRow( $res ) ) {
 126+ $t = Title::newFromID( $row[0] )->getPrefixedText();
125127 $selected = $t == $this->css ? ' selected' : '';
126128 $options .= "<option$selected>$t</option>";
127129 }
128 - $db->freeResult($res);
129 - if ($options) $wgOut->addHTML(wfMsg('ea-selectcss')." <select name=\"ea-css\">$options</select><br>\n");
 130+ $db->freeResult( $res );
 131+ if ( $options ) $wgOut->addHTML( wfMsg( 'ea-selectcss' ) . " <select name=\"ea-css\">$options</select><br>\n" );
130132
131133 # Get titles in Category:Records and build option list
132 - $options = '<option/>';
133 - $cl = $db->tableName('categorylinks');
134 - $cat = $db->addQuotes($wgRecordAdminCategory ? $wgRecordAdminCategory : 'Records');
135 - $res = $db->select($cl, 'cl_from', "cl_to = $cat", __METHOD__, array('ORDER BY' => 'cl_sortkey'));
136 - while ($row = $db->fetchRow($res)) {
137 - $t = Title::newFromID($row[0])->getText();
 134+ $options = "<option />";
 135+ $cl = $db->tableName( 'categorylinks' );
 136+ $cat = $db->addQuotes( $wgRecordAdminCategory ? $wgRecordAdminCategory : 'Records' );
 137+ $res = $db->select( $cl, 'cl_from', "cl_to = $cat", __METHOD__, array( 'ORDER BY' => 'cl_sortkey' ) );
 138+ while ( $row = $db->fetchRow( $res ) ) {
 139+ $t = Title::newFromID( $row[0] )->getText();
138140 $selected = $t == $this->record ? ' selected' : '';
139141 $options .= "<option$selected>$t</option>";
140142 }
141 - $db->freeResult($res);
142 - $wgOut->addHTML(wfMsg('ea-selectrecord')." <select name=\"ea-record\">$options</select>");
 143+ $db->freeResult( $res );
 144+ $wgOut->addHTML( wfMsg( 'ea-selectrecord' ) . " <select name=\"ea-record\">$options</select>" );
 145+ $wgOut->addHTML( "</fieldset>" );
143146
144 - $wgOut->addHTML("</fieldset>");
145 -
146147 # Submit buttons & hidden values
147 - $wgOut->addHTML(Xml::element('input', array('type' => 'submit', 'name' => 'ea-send', 'value' => wfMsg('ea-send'))));
148 - $wgOut->addHTML(Xml::element('input', array('type' => 'submit', 'name' => 'ea-show', 'value' => wfMsg('ea-show'))));
149 - $wgOut->addHTML(Xml::element('input', array('type' => 'hidden', 'name' => 'ea-title', 'value' => $this->title)));
 148+ $wgOut->addHTML(Xml::element( 'input', array( 'type' => 'submit', 'name' => 'ea-send', 'value' => wfMsg( 'ea-send' ) ) ) . '&nbsp;' );
 149+ $wgOut->addHTML(Xml::element( 'input', array( 'type' => 'submit', 'name' => 'ea-show', 'value' => wfMsg( 'ea-show' ) ) ) );
 150+ $wgOut->addHTML(Xml::element( 'input', array( 'type' => 'hidden', 'name' => 'ea-title', 'value' => $this->title ) ) );
150151
151 - $wgOut->addHTML('</form>');
 152+ $wgOut->addHTML( "</form>" );
152153
153154 # If the show button was clicked, render the list
154 - if (isset($_REQUEST['ea-show'])) return $this->send(false);
 155+ if ( isset( $_REQUEST['ea-show'] ) ) return $this->send( false );
155156 }
156157
157 - # Send the message to the recipients (or just list them if arg = false)
158 - function send($send = true) {
 158+ /**
 159+ * Send the message to the recipients (or just list them if arg = false)
 160+ */
 161+ function send( $send = true ) {
159162 global $wgOut, $wgUser, $wgParser, $wgServer, $wgScript, $wgArticlePath, $wgScriptPath,
160163 $wgEmailPageCss, $wgEmailPageGroup, $wgEmailPageAllowRemoteAddr, $wgEmailPageAllowAllUsers;
161164
162165 # Set error and bail if user not in postmaster group, and request not from trusted address
163 - if ($wgEmailPageGroup && !in_array($wgEmailPageGroup, $wgUser->getGroups()) && !in_array($_SERVER['REMOTE_ADDR'], $wgEmailPageAllowRemoteAddr)) {
164 - $denied = wfMsg('ea-denied');
165 - $wgOut->addWikiText( wfMsg('ea-error', $this->title, $denied ));
 166+ if ( $wgEmailPageGroup && !in_array( $wgEmailPageGroup, $wgUser->getGroups() )
 167+ && !in_array( $_SERVER['REMOTE_ADDR'], $wgEmailPageAllowRemoteAddr ) ) {
 168+ $denied = wfMsg( 'ea-denied' );
 169+ $wgOut->addWikiText( wfMsg( 'ea-error', $this->title, $denied ) );
166170 return false;
167171 }
168172
169 - $db = wfGetDB(DB_SLAVE);
170 - $title = Title::newFromText($this->title);
 173+ $db = wfGetDB( DB_SLAVE );
 174+ $title = Title::newFromText( $this->title );
171175 $opt = new ParserOptions;
172176
173177 # Get contact page titles from selected cat
174 - if ($this->cat) {
 178+ if ( $this->cat ) {
175179 $res = $db->select(
176180 'categorylinks',
177181 'cl_from',
178 - 'cl_to = '.$db->addQuotes($this->cat),
 182+ 'cl_to = '.$db->addQuotes( $this->cat ),
179183 __METHOD__,
180 - array('ORDER BY' => 'cl_sortkey')
 184+ array( 'ORDER BY' => 'cl_sortkey' )
181185 );
182 - if ($res) while ($row = $db->fetchRow($res)) $this->addRecipient(Title::newFromID($row[0]));
183 - $db->freeResult($res);
 186+ if ( $res ) while ( $row = $db->fetchRow( $res ) ) $this->addRecipient( Title::newFromID( $row[0] ) );
 187+ $db->freeResult( $res );
184188 }
185189
186190 # Get email addresses from users in selected group
187 - if ($this->group && ($wgEmailPageAllowAllUsers || $this->group != 'user')) {
188 - $group = $db->addQuotes($this->group);
 191+ if ( $this->group && ( $wgEmailPageAllowAllUsers || $this->group != 'user' ) ) {
 192+ $group = $db->addQuotes( $this->group );
189193 $res = $this->group == 'user'
190 - ? $db->select('user', 'user_email', 'user_email != \'\'', __METHOD__)
191 - : $db->select(array('user', 'user_groups'), 'user_email', "ug_user = user_id AND ug_group = $group", __METHOD__);
192 - while ($row = $db->fetchRow($res)) $this->addRecipient($row[0]);
193 - $db->freeResult($res);
 194+ ? $db->select( 'user', 'user_email', 'user_email != \'\'', __METHOD__ )
 195+ : $db->select( array( 'user', 'user_groups' ), 'user_email', "ug_user = user_id AND ug_group = $group", __METHOD__ );
 196+ while ( $row = $db->fetchRow( $res ) ) $this->addRecipient( $row[0] );
 197+ $db->freeResult( $res );
194198 }
195199
196200 # Recipients from list (expand templates in wikitext)
197 - $list = $wgParser->preprocess($this->list, $title, $opt);
198 - foreach (preg_split("/[\\x00-\\x1f,;*]+/", $list) as $item) $this->addRecipient($item);
 201+ $list = $wgParser->preprocess( $this->list, $title, $opt );
 202+ foreach ( preg_split( "/[\\x00-\\x1f,;*]+/", $list ) as $item ) $this->addRecipient( $item );
199203
200204 # Compose the wikitext content of the page to send
201 - $page = new Article($title);
 205+ $page = new Article( $title );
202206 $message = $page->getContent();
203 - if ($this->header) $message = "{$this->header}\n\n$message";
 207+ if ( $this->header ) $message = "{$this->header}\n\n$message";
204208
205209 # Convert the message text to html unless textonly
206 - if ($this->textonly == '') {
 210+ if ( $this->textonly == '' ) {
207211
208212 # Parse the wikitext using absolute URL's for local page links
209213 $tmp = array($wgArticlePath, $wgScriptPath, $wgScript);
@@ -213,47 +217,47 @@
214218 list($wgArticlePath,$wgScriptPath,$wgScript) = $tmp;
215219
216220 # Get CSS content if any
217 - if ($this->css) {
218 - $page = new Article(Title::newFromText($this->css));
219 - $css = '<style type="text/css">'.$page->getContent().'</style>';
220 - } else $css = '';
 221+ if ( $this->css ) {
 222+ $page = new Article( Title::newFromText( $this->css ) );
 223+ $css = "<style type='text/css'>" . $page->getContent() . "</style>";
 224+ } else $css = '';
221225
222226 # Create a html wrapper for the message
223227 $head = "<head>$css</head>";
224 - $message = "<html>$head<body style=\"margin:10px\"><div id=\"#bodyContent\">$message</div></body></html>";
 228+ $message = "<html>$head<body style=\"margin:10px\"><div id=\"bodyContent\">$message</div></body></html>";
225229 }
226230
227231 # Send message or list recipients
228 - $count = count($this->recipients);
229 - if ($count > 0) {
 232+ $count = count( $this->recipients );
 233+ if ( $count > 0 ) {
230234
231235 # Set up new mailer instance if sending
232 - if ($send) {
 236+ if ( $send ) {
233237 $mail = new PHPMailer();
234 - $mail->From = $wgUser->isValidEmailAddr($wgUser->getEmail()) ? $wgUser->getEmail() : "wiki@$wgServer";
235 - $mail->FromName = User::whoIsReal($wgUser->getId());
 238+ $mail->From = $wgUser->isValidEmailAddr( $wgUser->getEmail() ) ? $wgUser->getEmail() : "wiki@$wgServer";
 239+ $mail->FromName = User::whoIsReal( $wgUser->getId() );
236240 $mail->Subject = $this->subject;
237241 $mail->Body = $message;
238 - $mail->IsHTML(!$this->textonly);
 242+ $mail->IsHTML( !$this->textonly );
239243 }
240 - else $msg = wfMsg('ea-listrecipients', $count);
 244+ else $msg = wfMsg( 'ea-listrecipients', $count );
241245
242246 # Loop through recipients sending or adding to list
243 - foreach ($this->recipients as $recipient) {
 247+ foreach ( $this->recipients as $recipient ) {
244248 $error = '';
245 - if ($send) {
246 - if ($this->record) $mail->Body = $this->replaceFields($message, $recipient);
247 - $mail->AddAddress($recipient);
248 - if ($state = $mail->Send()) $msg = wfMsg('ea-sent', $this->title, $count, $wgUser->getName());
 249+ if ( $send ) {
 250+ if ( $this->record ) $mail->Body = $this->replaceFields( $message, $recipient );
 251+ $mail->AddAddress( $recipient );
 252+ if ( $state = $mail->Send() ) $msg = wfMsg( 'ea-sent', $this->title, $count, $wgUser->getName() );
249253 else $error .= "Couldn't send to $recipient: {$mail->ErrorInfo}<br>\n";
250254 $mail->ClearAddresses();
251255 } else $msg .= "\n*[mailto:$recipient $recipient]";
252 - if ($error) $msg = wfMsg('ea-error', $this->title, $error);
 256+ if ( $error ) $msg = wfMsg( 'ea-error', $this->title, $error );
253257 }
254258 }
255 - else $msg = wfMsg('ea-error', $this->title, wfMsg('ea-norecipients'));
 259+ else $msg = wfMsg( 'ea-error', $this->title, wfMsg( 'ea-norecipients' ) );
256260
257 - $wgOut->addWikiText($msg);
 261+ $wgOut->addWikiText( $msg );
258262 return $send ? $state : $count;
259263 }
260264
@@ -261,13 +265,13 @@
262266 * Add a recipient the list
263267 * - accepts title objects for page containing email address, or string of actual address
264268 */
265 - function addRecipient($recipient) {
266 - if (is_object($recipient) && $recipient->exists()) {
267 - $page = new Article($recipient);
268 - if (preg_match("|[a-z0-9_.-]+@[a-z0-9_.-]+|i", $page->getContent(), $emails)) $recipient = $emails[0];
 269+ function addRecipient( $recipient ) {
 270+ if ( is_object( $recipient ) && $recipient->exists() ) {
 271+ $page = new Article( $recipient );
 272+ if ( preg_match( "|[a-z0-9_.-]+@[a-z0-9_.-]+|i", $page->getContent(), $emails ) ) $recipient = $emails[0];
269273 else $recipient = '';
270274 }
271 - if ($valid = User::isValidEmailAddr($recipient)) $this->recipients[] = $recipient;
 275+ if ( $valid = User::isValidEmailAddr( $recipient ) ) $this->recipients[] = $recipient;
272276 return $valid;
273277 }
274278
@@ -275,44 +279,43 @@
276280 * Replace fields in message (enclosed in single braces)
277281 * - fields can have a default value, eg {name|default}
278282 */
279 - function replaceFields($text, $email) {
 283+ function replaceFields( $text, $email ) {
280284
281285 # Scan all records of this type for the first containing matching email address
282286 $dbr = $this->db;
283 - $tbl = $dbr->tableName('templatelinks');
284 - $type = $dbr->addQuotes($this->record);
285 - $res = $dbr->select($tbl, 'tl_from', "tl_namespace = 10 AND tl_title = $type", __METHOD__);
286 - while ($row = $dbr->fetchRow($res)) {
287 - $a = new Article(Title::newFromID($row[0]));
 287+ $tbl = $dbr->tableName( 'templatelinks' );
 288+ $type = $dbr->addQuotes( $this->record );
 289+ $res = $dbr->select( $tbl, 'tl_from', "tl_namespace = 10 AND tl_title = $type", __METHOD__ );
 290+ while ( $row = $dbr->fetchRow( $res ) ) {
 291+ $a = new Article( Title::newFromID( $row[0] ) );
288292 $c = $a->getContent();
289293
290294 # Check if this records email address matches
291 - if (preg_match("|\s*\|\s*\w+\s*=\s*$email\s*(?=[\|\}])|s", $c)) {
 295+ if ( preg_match( "|\s*\|\s*\w+\s*=\s*$email\s*(?=[\|\}])|s", $c ) ) {
292296
293297 # Extract all the fields from the content (should use examineBraces here)
294298 $this->args = array();
295 - preg_match_all("|\|\s*(.+?)\s*=\s*(.*?)\s*(?=[\|\}])|s", $c, $m);
296 - foreach ($m[1] as $i => $k) $this->args[strtolower($k)] = $m[2][$i];
 299+ preg_match_all( "|\|\s*(.+?)\s*=\s*(.*?)\s*(?=[\|\}])|s", $c, $m );
 300+ foreach ( $m[1] as $i => $k ) $this->args[strtolower( $k )] = $m[2][$i];
297301
298302 # Replace any fields in the message text with our extracted args (should use wiki parser for this)
299 - $text = preg_replace_callback("|\{(\w+)(\|(.+?))?\}|s", array($this, 'replaceField'), $text);
 303+ $text = preg_replace_callback( "|\{(\w+)(\|(.+?))?\}|s", array( $this, 'replaceField' ), $text );
300304
301305 break;
302306 }
303307 }
304 - $dbr->freeResult($res);
 308+ $dbr->freeResult( $res );
305309 return $text;
306310 }
307311
308312 /**
309313 * Replace a single field
310314 */
311 - function replaceField($match) {
312 - $key = strtolower($match[1]);
313 - $default = isset($match[3]) ? $match[3] : false;
314 - if (array_key_exists($key, $this->args)) $replace = $this->args[$key];
 315+ function replaceField( $match ) {
 316+ $key = strtolower( $match[1] );
 317+ $default = isset( $match[3] ) ? $match[3] : false;
 318+ if ( array_key_exists( $key, $this->args ) ) $replace = $this->args[$key];
315319 else $replace = $default ? $default : $match[0];
316320 return $replace;
317321 }
318 -
319322 }
Index: trunk/extensions/EmailPage/EmailPage.php
@@ -13,7 +13,7 @@
1414
1515 if (!defined('MEDIAWIKI')) die('Not an entry point.');
1616
17 -define('EMAILPAGE_VERSION', '1.3.1, 2008-11-05');
 17+define('EMAILPAGE_VERSION', '1.3.2, 2008-11-05');
1818
1919 $wgEmailPageGroup = 'sysop'; # Users must belong to this group to send emails (empty string means anyone can send)
2020 $wgEmailPageContactsCat = ''; # This specifies the name of a category containing categories of contact pages

Status & tagging log