r84572 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84571‎ | r84572 | r84573 >
Date:22:07, 22 March 2011
Author:hashar
Status:reverted (Comments)
Tags:
Comment:
Convert special pages form actions to nice URLs

This make use of the recent SpecialPage->getFormAction() method introduced
with r84571. Using it to replace our ugly $wgScript / $title->getTitle etc.
Modified paths:
  • /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,12 +95,9 @@
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();
10199
102100 $out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
103 - $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
104 - $out .= Html::hidden( 'title', $t->getPrefixedText() );
 101+ $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $this->getFormAction() ) );
105102 $out .= Xml::openElement( 'fieldset' );
106103 $out .= Xml::element( 'legend', null, wfMsg( 'allpages' ) );
107104 $out .= Xml::openElement( 'table', array( 'id' => 'nsselect', 'class' => 'allpages' ) );
Index: branches/hashar/prettyURL/includes/specials/SpecialUserrights.php
@@ -372,10 +372,14 @@
373373 * Output a form to allow searching for a user
374374 */
375375 function switchForm() {
376 - global $wgOut, $wgScript;
 376+ global $wgOut;
377377 $wgOut->addHTML(
378 - Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'name' => 'uluser', 'id' => 'mw-userrights-form1' ) ) .
379 - Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
 378+ Html::openElement( 'form', array(
 379+ 'action' => $this->getFormAction(),
 380+ 'id' => 'mw-userrights-form1',
 381+ 'method' => 'get',
 382+ 'name' => 'uluser',
 383+ ) ) .
380384 Xml::fieldset( wfMsg( 'userrights-lookup-user' ) ) .
381385 Xml::inputLabel( wfMsg( 'userrights-user-editname' ), 'user', 'username', 30, str_replace( '_', ' ', $this->mTarget ) ) . ' ' .
382386 Xml::submitButton( wfMsg( 'editusergroup' ) ) .
@@ -438,7 +442,12 @@
439443 $grouplist .= '<p>' . $autogrouplistintro . ' ' . $wgLang->listToText( $autolist ) . "</p>\n";
440444 }
441445 $wgOut->addHTML(
442 - Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL(), 'name' => 'editGroup', 'id' => 'mw-userrights-form2' ) ) .
 446+ Xml::openElement( 'form', array(
 447+ 'action' => $this->getFormAction(),
 448+ 'id' => 'mw-userrights-form2',
 449+ 'method' => 'post',
 450+ 'name' => 'editGroup',
 451+ ) ) .
443452 Html::hidden( 'user', $this->mTarget ) .
444453 Html::hidden( 'wpEditToken', $wgUser->editToken( $this->mTarget ) ) .
445454 Xml::openElement( 'fieldset' ) .
Index: branches/hashar/prettyURL/includes/specials/SpecialAllmessages.php
@@ -83,14 +83,11 @@
8484 }
8585
8686 function buildForm() {
87 - global $wgScript;
88 -
8987 $languages = Language::getLanguageNames( false );
9088 ksort( $languages );
9189
92 - $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-allmessages-form' ) ) .
 90+ $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $this->getFormAction(), 'id' => 'mw-allmessages-form' ) ) .
9391 Xml::fieldset( wfMsg( 'allmessages-filter-legend' ) ) .
94 - Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
9592 Xml::openElement( 'table', array( 'class' => 'mw-allmessages-table' ) ) . "\n" .
9693 '<tr>
9794 <td class="mw-label">' .
Index: branches/hashar/prettyURL/includes/specials/SpecialUndelete.php
@@ -718,16 +718,15 @@
719719 }
720720
721721 function showSearchForm() {
722 - global $wgOut, $wgScript;
 722+ global $wgOut;
723723 $wgOut->addWikiMsg( 'undelete-header' );
724724
725725 $wgOut->addHTML(
726726 Xml::openElement( 'form', array(
727727 'method' => 'get',
728 - 'action' => $wgScript ) ) .
 728+ 'action' => $this->getFormAction(),
 729+ ) ) .
729730 Xml::fieldset( wfMsg( 'undelete-search-box' ) ) .
730 - Html::hidden( 'title',
731 - $this->getTitle()->getPrefixedDbKey() ) .
732731 Xml::inputLabel( wfMsg( 'undelete-search-prefix' ),
733732 'prefix', 'prefix', 20,
734733 $this->mSearchPrefix ) . ' ' .
Index: branches/hashar/prettyURL/includes/specials/SpecialNewpages.php
@@ -203,7 +203,7 @@
204204 }
205205
206206 protected function form() {
207 - global $wgOut, $wgEnableNewpagesUserFilter, $wgScript;
 207+ global $wgOut, $wgEnableNewpagesUserFilter;
208208
209209 // Consume values
210210 $this->opts->consumeValue( 'offset' ); // don't carry offset, DWIW
@@ -227,8 +227,7 @@
228228 list( $tagFilterLabel, $tagFilterSelector ) = $tagFilter;
229229 }
230230
231 - $form = Xml::openElement( 'form', array( 'action' => $wgScript ) ) .
232 - Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
 231+ $form = Xml::openElement( 'form', array( 'action' => $this->getFormAction() ) ) .
233232 Xml::fieldset( wfMsg( 'newpages' ) ) .
234233 Xml::openElement( 'table', array( 'id' => 'mw-newpages-table' ) ) .
235234 '<tr>
Index: branches/hashar/prettyURL/includes/specials/SpecialFilepath.php
@@ -71,13 +71,12 @@
7272 }
7373
7474 function showForm( $title ) {
75 - global $wgOut, $wgScript;
 75+ global $wgOut;
7676
7777 $wgOut->addHTML(
78 - Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'specialfilepath' ) ) .
 78+ Html::openElement( 'form', array( 'method' => 'get', 'action' => $this->getFormAction(), 'id' => 'specialfilepath' ) ) .
7979 Html::openElement( 'fieldset' ) .
8080 Html::element( 'legend', null, wfMsg( 'filepath' ) ) .
81 - Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
8281 Xml::inputLabel( wfMsg( 'filepath-page' ), 'file', 'file', 25, is_object( $title ) ? $title->getText() : '' ) . ' ' .
8382 Xml::submitButton( wfMsg( 'filepath-submit' ) ) . "\n" .
8483 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, $wgScript;
 95+ global $wgRequest, $wgOut, $wgLang, $wgContLang;
9696
9797 $this->setHeaders();
9898 $this->outputHeader();
@@ -106,8 +106,7 @@
107107
108108 # Create the input form
109109 $wgOut->addHTML(
110 - Xml::openElement( 'form', array( 'id' => 'fileduplicatesearch', 'method' => 'get', 'action' => $wgScript ) ) .
111 - Html::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
 110+ Xml::openElement( 'form', array( 'id' => 'fileduplicatesearch', 'method' => 'get', 'action' => $this->getFormAction() ) ) .
112111 Xml::openElement( 'fieldset' ) .
113112 Xml::element( 'legend', null, wfMsg( 'fileduplicatesearch-legend' ) ) .
114113 Xml::inputLabel( wfMsg( 'fileduplicatesearch-filename' ), 'filename', 'filename', 50, $this->filename ) . ' ' .
Index: branches/hashar/prettyURL/includes/specials/SpecialWhatlinkshere.php
@@ -380,10 +380,9 @@
381381 $namespace = $this->opts->consumeValue( 'namespace' );
382382
383383 # Build up the form
384 - $f = Xml::openElement( 'form', array( 'action' => $wgScript ) );
 384+ $f = Xml::openElement( 'form', array( 'action' => $this->getFormAction() ) );
385385
386386 # Values that should not be forgotten
387 - $f .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() );
388387 foreach ( $this->opts->getUnconsumedValues() as $name => $value ) {
389388 $f .= Html::hidden( $name, $value );
390389 }
Index: branches/hashar/prettyURL/includes/specials/SpecialRecentchanges.php
@@ -510,9 +510,7 @@
511511 $out .= Html::hidden( $key, $value );
512512 }
513513
514 - $t = $this->getTitle();
515 - $out .= Html::hidden( 'title', $t->getPrefixedText() );
516 - $form = Xml::tags( 'form', array( 'action' => $wgScript ), $out );
 514+ $form = Xml::tags( 'form', array( 'action' => $this->getFormAction() ), $out );
517515 $panel[] = $form;
518516 $panelString = implode( "\n", $panel );
519517
Index: branches/hashar/prettyURL/includes/specials/SpecialProtectedtitles.php
@@ -112,14 +112,10 @@
113113 * @private
114114 */
115115 function showOptions( $namespace, $type='edit', $level ) {
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" .
 116+ # FIXME use Xml: or Html: methods to build the form
 117+ return "<form action=\"". $this->getFormAction()."\" method=\"get\">\n" .
121118 '<fieldset>' .
122119 Xml::element( 'legend', array(), wfMsg( 'protectedtitles' ) ) .
123 - Html::hidden( 'title', $special ) . "&#160;\n" .
124120 $this->getNamespaceMenu( $namespace ) . "&#160;\n" .
125121 $this->getLevelMenu( $level ) . "&#160;\n" .
126122 "&#160;" . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
Index: branches/hashar/prettyURL/includes/specials/SpecialPrefixindex.php
@@ -77,12 +77,9 @@
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();
8381
8482 $out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) );
85 - $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
86 - $out .= Html::hidden( 'title', $t->getPrefixedText() );
 83+ $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $this->getFormAction() ) );
8784 $out .= Xml::openElement( 'fieldset' );
8885 $out .= Xml::element( 'legend', null, wfMsg( 'allpages' ) );
8986 $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 $wgScript, $wgMiserMode;
 45+ global $wgMiserMode;
4646
4747 # Do not show useless input form if wiki is running in misermode
4848 if( $wgMiserMode ) {
@@ -49,12 +49,10 @@
5050 }
5151
5252 $prefix = $this->prefix;
53 - $t = SpecialPage::getTitleFor( $this->getName() );
5453
55 - return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
 54+ return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $this->getFormAction() ) ) .
5655 Xml::openElement( 'fieldset' ) .
5756 Xml::element( 'legend', null, wfMsg( 'withoutinterwiki-legend' ) ) .
58 - Html::hidden( 'title', $t->getPrefixedText() ) .
5957 Xml::inputLabel( wfMsg( 'allpagesprefix' ), 'prefix', 'wiprefix', 20, $prefix ) . ' ' .
6058 Xml::submitButton( wfMsg( 'withoutinterwiki-submit' ) ) .
6159 Xml::closeElement( 'fieldset' ) .
Index: branches/hashar/prettyURL/includes/specials/SpecialBooksources.php
@@ -114,11 +114,8 @@
115115 * @return string
116116 */
117117 private function makeForm() {
118 - global $wgScript;
119 - $title = self::getTitleFor( 'Booksources' );
120118 $form = '<fieldset><legend>' . wfMsgHtml( 'booksources-search-legend' ) . '</legend>';
121 - $form .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
122 - $form .= Html::hidden( 'title', $title->getPrefixedText() );
 119+ $form .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $this->getFormAction() ) );
123120 $form .= '<p>' . Xml::inputLabel( wfMsg( 'booksources-isbn' ), 'isbn', 'isbn', 20, $this->isbn );
124121 $form .= '&#160;' . Xml::submitButton( wfMsg( 'booksources-go' ) ) . '</p>';
125122 $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' => $wgScript
 222+ 'action' => $this->getFormAction(),
223223 )
224224 )
225225 );
@@ -836,7 +836,6 @@
837837 $namespaceTables .
838838 Xml::element( 'div', array( 'class' => 'divider' ), '', false ) .
839839 $redirects .
840 - Html::hidden( 'title', SpecialPage::getTitleFor( 'Search' )->getPrefixedText() ) .
841840 Html::hidden( 'advanced', $this->searchAdvanced ) .
842841 Html::hidden( 'fulltext', 'Advanced search' ) .
843842 Xml::closeElement( 'fieldset' );
@@ -960,8 +959,6 @@
961960 }
962961
963962 protected function shortDialog( $term ) {
964 - $searchTitle = SpecialPage::getTitleFor( 'Search' );
965 - $out = Html::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n";
966963 // Keep redirect setting
967964 $out .= Html::hidden( "redirs", (int)$this->searchRedirects ) . "\n";
968965 // Term box
Index: branches/hashar/prettyURL/includes/specials/SpecialProtectedpages.php
@@ -159,12 +159,9 @@
160160 * @return String: input form
161161 */
162162 protected function showOptions( $namespace, $type='edit', $level, $sizetype, $size, $indefOnly, $cascadeOnly ) {
163 - global $wgScript;
164 - $title = SpecialPage::getTitleFor( 'Protectedpages' );
165 - return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
 163+ return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $this->getFormAction() ) ) .
166164 Xml::openElement( 'fieldset' ) .
167165 Xml::element( 'legend', array(), wfMsg( 'protectedpages' ) ) .
168 - Html::hidden( 'title', $title->getPrefixedDBkey() ) . "\n" .
169166 $this->getNamespaceMenu( $namespace ) . "&#160;\n" .
170167 $this->getTypeMenu( $type ) . "&#160;\n" .
171168 $this->getLevelMenu( $level ) . "&#160;\n" .
Index: branches/hashar/prettyURL/includes/specials/SpecialMIMEsearch.php
@@ -65,9 +65,8 @@
6666 $this->setHeaders();
6767 $this->outputHeader();
6868 $wgOut->addHTML(
69 - Xml::openElement( 'form', array( 'id' => 'specialmimesearch', 'method' => 'get', 'action' => SpecialPage::getTitleFor( 'MIMEsearch' )->getLocalUrl() ) ) .
 69+ Xml::openElement( 'form', array( 'id' => 'specialmimesearch', 'method' => 'get', 'action' => $this->getFormAction() ) ) .
7070 Xml::openElement( 'fieldset' ) .
71 - Html::hidden( 'title', SpecialPage::getTitleFor( 'MIMEsearch' )->getPrefixedText() ) .
7271 Xml::element( 'legend', null, wfMsg( 'mimesearch' ) ) .
7372 Xml::inputLabel( wfMsg( 'mimetype' ), 'mime', 'mime', 20, $mime ) . ' ' .
7473 Xml::submitButton( wfMsg( 'ilsubmit' ) ) .
Index: branches/hashar/prettyURL/includes/specials/SpecialMergeHistory.php
@@ -131,18 +131,17 @@
132132 }
133133
134134 function showMergeForm() {
135 - global $wgOut, $wgScript;
 135+ global $wgOut ;
136136
137137 $wgOut->addWikiMsg( 'mergehistory-header' );
138138
139139 $wgOut->addHTML(
140140 Xml::openElement( 'form', array(
141141 'method' => 'get',
142 - 'action' => $wgScript ) ) .
 142+ 'action' => $this->getFormAction() ) ) .
143143 '<fieldset>' .
144144 Xml::element( 'legend', array(),
145145 wfMsg( 'mergehistory-box' ) ) .
146 - Html::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
147146 Html::hidden( 'submitted', '1' ) .
148147 Html::hidden( 'mergepoint', $this->mTimestamp ) .
149148 Xml::openElement( 'table' ) .
Index: branches/hashar/prettyURL/includes/specials/SpecialLinkSearch.php
@@ -42,6 +42,7 @@
4343 return false;
4444 }
4545
 46+ /** @todo rewrite this function to make it cleaner! Please? :( */
4647 function execute( $par ) {
4748 global $wgOut, $wgRequest, $wgUrlProtocols, $wgMiserMode, $wgLang;
4849 $this->setHeaders();
@@ -80,8 +81,7 @@
8182 $self = $this->getTitle();
8283
8384 $wgOut->addWikiMsg( 'linksearch-text', '<nowiki>' . $wgLang->commaList( $wgUrlProtocols ) . '</nowiki>' );
84 - $s = Xml::openElement( 'form', array( 'id' => 'mw-linksearch-form', 'method' => 'get', 'action' => $GLOBALS['wgScript'] ) ) .
85 - Html::hidden( 'title', $self->getPrefixedDbKey() ) .
 85+ $s = Xml::openElement( 'form', array( 'id' => 'mw-linksearch-form', 'method' => 'get', 'action' => $this->getFormAction() ) ) .
8686 '<fieldset>' .
8787 Xml::element( 'legend', array(), wfMsg( 'linksearch' ) ) .
8888 Xml::inputLabel( wfMsg( 'linksearch-pat' ), 'target', 'target', 50, $target ) . ' ';

Follow-up revisions

RevisionCommit summaryAuthorDate
r84694reverts pretty URL in forms....hashar19:26, 24 March 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84428branch trunk@r84386 to play with the pretty URL featurehashar22:04, 20 March 2011
r84571new SpecialPage->getFormAction() method...hashar22:05, 22 March 2011

Comments

#Comment by Nikerabbit (talk | contribs)   06:52, 23 March 2011

This will break wikis that use ugly urls. There is no guarantee that browsers wont drop query parameters from action string like example.com/w/index.php?title=Foo and just go example.com/w/index.php. This is also the original reason forms use $wgScript and hidden parameter.

#Comment by Nikerabbit (talk | contribs)   07:07, 23 March 2011

I didn't notice this issue was already noted on previous commit.

Status & tagging log