r84694 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84693‎ | r84694 | r84695 >
Date:19:26, 24 March 2011
Author:hashar
Status:ok (Comments)
Tags:
Comment:
reverts pretty URL in forms.

The correct fix is to use HTMLForm which generates pretty URLs

reverts r84571 r84572 & r84578
Modified paths:
  • /branches/hashar/prettyURL/includes/SpecialPage.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialAllmessages.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialAllpages.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialBooksources.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialFileDuplicateSearch.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialFilepath.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialLinkSearch.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialMIMEsearch.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialMergeHistory.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialNewpages.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialPrefixindex.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialProtectedpages.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialProtectedtitles.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialRecentchanges.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialSearch.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialUndelete.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialUserrights.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialWhatlinkshere.php (modified) (history)
  • /branches/hashar/prettyURL/includes/specials/SpecialWithoutinterwiki.php (modified) (history)

Diff [purge]

Index: branches/hashar/prettyURL/includes/specials/SpecialAllpages.php
@@ -95,9 +95,12 @@
9696 * @param $to String: dbKey we are ending listing at.
9797 */
9898 function namespaceForm( $namespace = NS_MAIN, $from = '', $to = '' ) {
 99+ global $wgScript;
 100+ $t = $this->getTitle();
99101
100102 $out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
101 - $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $this->getFormAction() ) );
 103+ $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
 104+ $out .= Html::hidden( 'title', $t->getPrefixedText() );
102105 $out .= Xml::openElement( 'fieldset' );
103106 $out .= Xml::element( 'legend', null, wfMsg( 'allpages' ) );
104107 $out .= Xml::openElement( 'table', array( 'id' => 'nsselect', 'class' => 'allpages' ) );
Index: branches/hashar/prettyURL/includes/specials/SpecialUserrights.php
@@ -372,14 +372,10 @@
373373 * Output a form to allow searching for a user
374374 */
375375 function switchForm() {
376 - global $wgOut;
 376+ global $wgOut, $wgScript;
377377 $wgOut->addHTML(
378 - Html::openElement( 'form', array(
379 - 'action' => $this->getFormAction(),
380 - 'id' => 'mw-userrights-form1',
381 - 'method' => 'get',
382 - 'name' => 'uluser',
383 - ) ) .
 378+ Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'name' => 'uluser', 'id' => 'mw-userrights-form1' ) ) .
 379+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
384380 Xml::fieldset( wfMsg( 'userrights-lookup-user' ) ) .
385381 Xml::inputLabel( wfMsg( 'userrights-user-editname' ), 'user', 'username', 30, str_replace( '_', ' ', $this->mTarget ) ) . ' ' .
386382 Xml::submitButton( wfMsg( 'editusergroup' ) ) .
@@ -442,12 +438,7 @@
443439 $grouplist .= '<p>' . $autogrouplistintro . ' ' . $wgLang->listToText( $autolist ) . "</p>\n";
444440 }
445441 $wgOut->addHTML(
446 - Xml::openElement( 'form', array(
447 - 'action' => $this->getFormAction(),
448 - 'id' => 'mw-userrights-form2',
449 - 'method' => 'post',
450 - 'name' => 'editGroup',
451 - ) ) .
 442+ Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL(), 'name' => 'editGroup', 'id' => 'mw-userrights-form2' ) ) .
452443 Html::hidden( 'user', $this->mTarget ) .
453444 Html::hidden( 'wpEditToken', $wgUser->editToken( $this->mTarget ) ) .
454445 Xml::openElement( 'fieldset' ) .
Index: branches/hashar/prettyURL/includes/specials/SpecialAllmessages.php
@@ -83,11 +83,14 @@
8484 }
8585
8686 function buildForm() {
 87+ global $wgScript;
 88+
8789 $languages = Language::getLanguageNames( false );
8890 ksort( $languages );
8991
90 - $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $this->getFormAction(), 'id' => 'mw-allmessages-form' ) ) .
 92+ $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-allmessages-form' ) ) .
9193 Xml::fieldset( wfMsg( 'allmessages-filter-legend' ) ) .
 94+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
9295 Xml::openElement( 'table', array( 'class' => 'mw-allmessages-table' ) ) . "\n" .
9396 '<tr>
9497 <td class="mw-label">' .
Index: branches/hashar/prettyURL/includes/specials/SpecialUndelete.php
@@ -718,15 +718,16 @@
719719 }
720720
721721 function showSearchForm() {
722 - global $wgOut;
 722+ global $wgOut, $wgScript;
723723 $wgOut->addWikiMsg( 'undelete-header' );
724724
725725 $wgOut->addHTML(
726726 Xml::openElement( 'form', array(
727727 'method' => 'get',
728 - 'action' => $this->getFormAction(),
729 - ) ) .
 728+ 'action' => $wgScript ) ) .
730729 Xml::fieldset( wfMsg( 'undelete-search-box' ) ) .
 730+ Html::hidden( 'title',
 731+ $this->getTitle()->getPrefixedDbKey() ) .
731732 Xml::inputLabel( wfMsg( 'undelete-search-prefix' ),
732733 'prefix', 'prefix', 20,
733734 $this->mSearchPrefix ) . ' ' .
Index: branches/hashar/prettyURL/includes/specials/SpecialNewpages.php
@@ -203,7 +203,7 @@
204204 }
205205
206206 protected function form() {
207 - global $wgOut, $wgEnableNewpagesUserFilter;
 207+ global $wgOut, $wgEnableNewpagesUserFilter, $wgScript;
208208
209209 // Consume values
210210 $this->opts->consumeValue( 'offset' ); // don't carry offset, DWIW
@@ -227,7 +227,8 @@
228228 list( $tagFilterLabel, $tagFilterSelector ) = $tagFilter;
229229 }
230230
231 - $form = Xml::openElement( 'form', array( 'action' => $this->getFormAction() ) ) .
 231+ $form = Xml::openElement( 'form', array( 'action' => $wgScript ) ) .
 232+ Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
232233 Xml::fieldset( wfMsg( 'newpages' ) ) .
233234 Xml::openElement( 'table', array( 'id' => 'mw-newpages-table' ) ) .
234235 '<tr>
Index: branches/hashar/prettyURL/includes/specials/SpecialFilepath.php
@@ -71,12 +71,13 @@
7272 }
7373
7474 function showForm( $title ) {
75 - global $wgOut;
 75+ global $wgOut, $wgScript;
7676
7777 $wgOut->addHTML(
78 - Html::openElement( 'form', array( 'method' => 'get', 'action' => $this->getFormAction(), 'id' => 'specialfilepath' ) ) .
 78+ Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'specialfilepath' ) ) .
7979 Html::openElement( 'fieldset' ) .
8080 Html::element( 'legend', null, wfMsg( 'filepath' ) ) .
 81+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
8182 Xml::inputLabel( wfMsg( 'filepath-page' ), 'file', 'file', 25, is_object( $title ) ? $title->getText() : '' ) . ' ' .
8283 Xml::submitButton( wfMsg( 'filepath-submit' ) ) . "\n" .
8384 Html::closeElement( 'fieldset' ) .
Index: branches/hashar/prettyURL/includes/specials/SpecialFileDuplicateSearch.php
@@ -91,7 +91,7 @@
9292 }
9393
9494 function execute( $par ) {
95 - global $wgRequest, $wgOut, $wgLang, $wgContLang;
 95+ global $wgRequest, $wgOut, $wgLang, $wgContLang, $wgScript;
9696
9797 $this->setHeaders();
9898 $this->outputHeader();
@@ -106,7 +106,8 @@
107107
108108 # Create the input form
109109 $wgOut->addHTML(
110 - Xml::openElement( 'form', array( 'id' => 'fileduplicatesearch', 'method' => 'get', 'action' => $this->getFormAction() ) ) .
 110+ Xml::openElement( 'form', array( 'id' => 'fileduplicatesearch', 'method' => 'get', 'action' => $wgScript ) ) .
 111+ Html::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
111112 Xml::openElement( 'fieldset' ) .
112113 Xml::element( 'legend', null, wfMsg( 'fileduplicatesearch-legend' ) ) .
113114 Xml::inputLabel( wfMsg( 'fileduplicatesearch-filename' ), 'filename', 'filename', 50, $this->filename ) . ' ' .
Index: branches/hashar/prettyURL/includes/specials/SpecialWhatlinkshere.php
@@ -380,9 +380,10 @@
381381 $namespace = $this->opts->consumeValue( 'namespace' );
382382
383383 # Build up the form
384 - $f = Xml::openElement( 'form', array( 'action' => $this->getFormAction() ) );
 384+ $f = Xml::openElement( 'form', array( 'action' => $wgScript ) );
385385
386386 # Values that should not be forgotten
 387+ $f .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() );
387388 foreach ( $this->opts->getUnconsumedValues() as $name => $value ) {
388389 $f .= Html::hidden( $name, $value );
389390 }
Index: branches/hashar/prettyURL/includes/specials/SpecialRecentchanges.php
@@ -510,7 +510,9 @@
511511 $out .= Html::hidden( $key, $value );
512512 }
513513
514 - $form = Xml::tags( 'form', array( 'action' => $this->getFormAction() ), $out );
 514+ $t = $this->getTitle();
 515+ $out .= Html::hidden( 'title', $t->getPrefixedText() );
 516+ $form = Xml::tags( 'form', array( 'action' => $wgScript ), $out );
515517 $panel[] = $form;
516518 $panelString = implode( "\n", $panel );
517519
Index: branches/hashar/prettyURL/includes/specials/SpecialProtectedtitles.php
@@ -112,10 +112,14 @@
113113 * @private
114114 */
115115 function showOptions( $namespace, $type='edit', $level ) {
116 - # FIXME use Xml: or Html: methods to build the form
117 - return "<form action=\"". $this->getFormAction()."\" method=\"get\">\n" .
 116+ global $wgScript;
 117+ $action = htmlspecialchars( $wgScript );
 118+ $title = SpecialPage::getTitleFor( 'Protectedtitles' );
 119+ $special = htmlspecialchars( $title->getPrefixedDBkey() );
 120+ return "<form action=\"$action\" method=\"get\">\n" .
118121 '<fieldset>' .
119122 Xml::element( 'legend', array(), wfMsg( 'protectedtitles' ) ) .
 123+ Html::hidden( 'title', $special ) . "&#160;\n" .
120124 $this->getNamespaceMenu( $namespace ) . "&#160;\n" .
121125 $this->getLevelMenu( $level ) . "&#160;\n" .
122126 "&#160;" . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
Index: branches/hashar/prettyURL/includes/specials/SpecialPrefixindex.php
@@ -77,9 +77,12 @@
7878 * @param $from String: dbKey we are starting listing at.
7979 */
8080 function namespacePrefixForm( $namespace = NS_MAIN, $from = '' ) {
 81+ global $wgScript;
 82+ $t = $this->getTitle();
8183
8284 $out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
83 - $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $this->getFormAction() ) );
 85+ $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
 86+ $out .= Html::hidden( 'title', $t->getPrefixedText() );
8487 $out .= Xml::openElement( 'fieldset' );
8588 $out .= Xml::element( 'legend', null, wfMsg( 'allpages' ) );
8689 $out .= Xml::openElement( 'table', array( 'id' => 'nsselect', 'class' => 'allpages' ) );
Index: branches/hashar/prettyURL/includes/specials/SpecialWithoutinterwiki.php
@@ -41,7 +41,7 @@
4242 }
4343
4444 function getPageHeader() {
45 - global $wgMiserMode;
 45+ global $wgScript, $wgMiserMode;
4646
4747 # Do not show useless input form if wiki is running in misermode
4848 if( $wgMiserMode ) {
@@ -49,10 +49,12 @@
5050 }
5151
5252 $prefix = $this->prefix;
 53+ $t = SpecialPage::getTitleFor( $this->getName() );
5354
54 - return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $this->getFormAction() ) ) .
 55+ return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
5556 Xml::openElement( 'fieldset' ) .
5657 Xml::element( 'legend', null, wfMsg( 'withoutinterwiki-legend' ) ) .
 58+ Html::hidden( 'title', $t->getPrefixedText() ) .
5759 Xml::inputLabel( wfMsg( 'allpagesprefix' ), 'prefix', 'wiprefix', 20, $prefix ) . ' ' .
5860 Xml::submitButton( wfMsg( 'withoutinterwiki-submit' ) ) .
5961 Xml::closeElement( 'fieldset' ) .
Index: branches/hashar/prettyURL/includes/specials/SpecialBooksources.php
@@ -114,8 +114,11 @@
115115 * @return string
116116 */
117117 private function makeForm() {
 118+ global $wgScript;
 119+ $title = self::getTitleFor( 'Booksources' );
118120 $form = '<fieldset><legend>' . wfMsgHtml( 'booksources-search-legend' ) . '</legend>';
119 - $form .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $this->getFormAction() ) );
 121+ $form .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
 122+ $form .= Html::hidden( 'title', $title->getPrefixedText() );
120123 $form .= '<p>' . Xml::inputLabel( wfMsg( 'booksources-isbn' ), 'isbn', 'isbn', 20, $this->isbn );
121124 $form .= '&#160;' . Xml::submitButton( wfMsg( 'booksources-go' ) ) . '</p>';
122125 $form .= Xml::closeElement( 'form' );
Index: branches/hashar/prettyURL/includes/specials/SpecialSearch.php
@@ -218,7 +218,7 @@
219219 array(
220220 'id' => ( $this->searchAdvanced ? 'powersearch' : 'search' ),
221221 'method' => 'get',
222 - 'action' => $this->getFormAction(),
 222+ 'action' => $wgScript
223223 )
224224 )
225225 );
@@ -836,6 +836,7 @@
837837 $namespaceTables .
838838 Xml::element( 'div', array( 'class' => 'divider' ), '', false ) .
839839 $redirects .
 840+ Html::hidden( 'title', SpecialPage::getTitleFor( 'Search' )->getPrefixedText() ) .
840841 Html::hidden( 'advanced', $this->searchAdvanced ) .
841842 Html::hidden( 'fulltext', 'Advanced search' ) .
842843 Xml::closeElement( 'fieldset' );
@@ -959,6 +960,8 @@
960961 }
961962
962963 protected function shortDialog( $term ) {
 964+ $searchTitle = SpecialPage::getTitleFor( 'Search' );
 965+ $out = Html::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n";
963966 // Keep redirect setting
964967 $out .= Html::hidden( "redirs", (int)$this->searchRedirects ) . "\n";
965968 // Term box
Index: branches/hashar/prettyURL/includes/specials/SpecialProtectedpages.php
@@ -159,9 +159,12 @@
160160 * @return String: input form
161161 */
162162 protected function showOptions( $namespace, $type='edit', $level, $sizetype, $size, $indefOnly, $cascadeOnly ) {
163 - return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $this->getFormAction() ) ) .
 163+ global $wgScript;
 164+ $title = SpecialPage::getTitleFor( 'Protectedpages' );
 165+ return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
164166 Xml::openElement( 'fieldset' ) .
165167 Xml::element( 'legend', array(), wfMsg( 'protectedpages' ) ) .
 168+ Html::hidden( 'title', $title->getPrefixedDBkey() ) . "\n" .
166169 $this->getNamespaceMenu( $namespace ) . "&#160;\n" .
167170 $this->getTypeMenu( $type ) . "&#160;\n" .
168171 $this->getLevelMenu( $level ) . "&#160;\n" .
Index: branches/hashar/prettyURL/includes/specials/SpecialMIMEsearch.php
@@ -65,8 +65,9 @@
6666 $this->setHeaders();
6767 $this->outputHeader();
6868 $wgOut->addHTML(
69 - Xml::openElement( 'form', array( 'id' => 'specialmimesearch', 'method' => 'get', 'action' => $this->getFormAction() ) ) .
 69+ Xml::openElement( 'form', array( 'id' => 'specialmimesearch', 'method' => 'get', 'action' => SpecialPage::getTitleFor( 'MIMEsearch' )->getLocalUrl() ) ) .
7070 Xml::openElement( 'fieldset' ) .
 71+ Html::hidden( 'title', SpecialPage::getTitleFor( 'MIMEsearch' )->getPrefixedText() ) .
7172 Xml::element( 'legend', null, wfMsg( 'mimesearch' ) ) .
7273 Xml::inputLabel( wfMsg( 'mimetype' ), 'mime', 'mime', 20, $mime ) . ' ' .
7374 Xml::submitButton( wfMsg( 'ilsubmit' ) ) .
Index: branches/hashar/prettyURL/includes/specials/SpecialMergeHistory.php
@@ -131,17 +131,18 @@
132132 }
133133
134134 function showMergeForm() {
135 - global $wgOut ;
 135+ global $wgOut, $wgScript;
136136
137137 $wgOut->addWikiMsg( 'mergehistory-header' );
138138
139139 $wgOut->addHTML(
140140 Xml::openElement( 'form', array(
141141 'method' => 'get',
142 - 'action' => $this->getFormAction() ) ) .
 142+ 'action' => $wgScript ) ) .
143143 '<fieldset>' .
144144 Xml::element( 'legend', array(),
145145 wfMsg( 'mergehistory-box' ) ) .
 146+ Html::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
146147 Html::hidden( 'submitted', '1' ) .
147148 Html::hidden( 'mergepoint', $this->mTimestamp ) .
148149 Xml::openElement( 'table' ) .
Index: branches/hashar/prettyURL/includes/specials/SpecialLinkSearch.php
@@ -42,7 +42,6 @@
4343 return false;
4444 }
4545
46 - /** @todo rewrite this function to make it cleaner! Please? :( */
4746 function execute( $par ) {
4847 global $wgOut, $wgRequest, $wgUrlProtocols, $wgMiserMode, $wgLang;
4948 $this->setHeaders();
@@ -81,7 +80,8 @@
8281 $self = $this->getTitle();
8382
8483 $wgOut->addWikiMsg( 'linksearch-text', '<nowiki>' . $wgLang->commaList( $wgUrlProtocols ) . '</nowiki>' );
85 - $s = Xml::openElement( 'form', array( 'id' => 'mw-linksearch-form', 'method' => 'get', 'action' => $this->getFormAction() ) ) .
 84+ $s = Xml::openElement( 'form', array( 'id' => 'mw-linksearch-form', 'method' => 'get', 'action' => $GLOBALS['wgScript'] ) ) .
 85+ Html::hidden( 'title', $self->getPrefixedDbKey() ) .
8686 '<fieldset>' .
8787 Xml::element( 'legend', array(), wfMsg( 'linksearch' ) ) .
8888 Xml::inputLabel( wfMsg( 'linksearch-pat' ), 'target', 'target', 50, $target ) . ' ';
Index: branches/hashar/prettyURL/includes/SpecialPage.php
@@ -944,15 +944,6 @@
945945 }
946946
947947 /**
948 - * Get a local URL suitable for <form action="">
949 - *
950 - * @return String this title local URL
951 - */
952 - function getFormAction( $subpage = false ) {
953 - return self::getTitleFor( $this->mName, $subpage )->getLocalURL();
954 - }
955 -
956 - /**
957948 * Set whether this page is listed in Special:Specialpages, at run-time
958949 */
959950 function setListed( $listed ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84571new SpecialPage->getFormAction() method...hashar22:05, 22 March 2011
r84572Convert special pages form actions to nice URLs...hashar22:07, 22 March 2011
r84578fix @return docblock for SpecialPage::getFormAction...hashar22:43, 22 March 2011

Comments

#Comment by MarkAHershberger (talk | contribs)   04:28, 25 March 2011

please don't mark your own changes "ok"

Status & tagging log