r45544 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45543‎ | r45544 | r45545 >
Date:05:48, 8 January 2009
Author:yaron
Status:deferred
Tags:
Comment:
Some code improvements per Aaron Schulz's code review
Modified paths:
  • /trunk/extensions/ReplaceText/SpecialReplaceText.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ReplaceText/SpecialReplaceText.php
@@ -12,7 +12,7 @@
1313 wfLoadExtensionMessages('ReplaceText');
1414 }
1515
16 - function execute( $para ) {
 16+ function execute( $query ) {
1717 global $wgUser, $wgOut;
1818
1919 if ( ! $wgUser->isAllowed('replacetext') ) {
@@ -155,7 +155,7 @@
156156 $res = $dbr->query($sql);
157157 $contextchars = $wgUser->getOption( 'contextchars', 40 );
158158 while( $row = $dbr->fetchObject( $res ) ) {
159 - $title = Title::newFromText($row->title, $row->namespace);
 159+ $title = Title::makeTitleSafe($row->namespace, $row->title);
160160 $article_text = $row->text;
161161 $target_pos = strpos($article_text, $target_str);
162162 $context_str = str_replace($angle_brackets, $escaped_angle_brackets, $wgContLang->truncate(substr($article_text, 0, $target_pos), -$contextchars, '...' ));
@@ -172,11 +172,11 @@
173173 ORDER BY p.page_namespace, p.page_title";
174174 $res = $dbr->query($sql2);
175175 while( $row = $dbr->fetchObject( $res ) ) {
176 - $title = Title::newFromText($row->title, $row->namespace);
 176+ $title = Title::makeTitleSafe($row->namespace, $row->title);
177177 // see if this move can happen
178178 $cur_page_name = str_replace('_', ' ', $row->title);
179179 $new_page_name = str_replace($target_str, $replacement_str, $cur_page_name);
180 - $new_title = Title::newFromText($new_page_name, $row->namespace);
 180+ $new_title = Title::makeTitleSafe($row->namespace, $new_page_name);
181181 $err = $title->isValidMoveOperation($new_title);
182182 if ($title->userCanMove(true) && (! is_array($err))) {
183183 $titles_for_move[] = $title;
@@ -225,12 +225,14 @@
226226 END;
227227 foreach ($found_titles as $value_pair) {
228228 list($title, $context_str) = $value_pair;
229 - $text .= "<input type=\"checkbox\" name=\"{$title->getArticleID()}\" checked /> {$skin->makeLinkObj( $title, $title->prefix($title->getText()) )} - <small>$context_str</small><br />\n";
 229+ $text .= Xml::check($title->getArticleID(), true);
 230+ $text .= " " . $skin->makeLinkObj( $title, $title->prefix($title->getText()) ) . " - <small>$context_str</small><br />\n";
230231 }
231232 if (count($titles_for_move) > 0) {
232233 $text .= "<p>$choose_pages_for_move_label</p>\n";
233234 foreach ($titles_for_move as $title) {
234 - $text .= "<input type=\"checkbox\" name=\"move-{$title->getArticleID()}\" checked /> {$skin->makeLinkObj( $title, $title->prefix($title->getText()) )}<br />\n";
 235+ $text .= Xml::check('move-' . $title->getArticleID(), true);
 236+ $text .= " " . $skin->makeLinkObj( $title, $title->prefix($title->getText()) ) . "<br />\n";
235237 }
236238 }
237239 $text .=<<<END

Status & tagging log