r49885 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49884‎ | r49885 | r49886 >
Date:19:40, 25 April 2009
Author:ialex
Status:reverted (Comments)
Tags:
Comment:
Follow-up r49880, tweaks to Special:CreatePage:
* Fix doc, use @ingroup, NOT @addtogroup
* Allow to use the subpage paramter if the "target" URL parameter is not passed
* Fixed a fatal error when calling Special:CreatePage?target=> (GET request with invalid target)
* Escaping messages used for Skin::makeLinkObj() since they won't be escaped by that function
* Fixed double escaping for 'createpage-submitbutton'
* Whitespaces tweaks
Modified paths:
  • /trunk/phase3/includes/specials/SpecialCreatePage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialCreatePage.php
@@ -1,4 +1,5 @@
22 <?php
 3+
34 /* This code was adapted from CreatePage.php from: Travis Derouin <travis@wikihow.com> for the Uniwiki extension CreatePage
45 * Originally licensed as: GNU GPL v2.0 or later
56 *
@@ -12,16 +13,15 @@
1314 * @author Evan Wheeler
1415 * @author Adam Mckaig (at UNICEF)
1516 * @author Siebrand Mazeland (integrated into MediaWiki core)
16 - * @addtogroup SpecialPage
 17+ * @ingroup SpecialPage
1718 */
18 -
1919 class SpecialCreatePage extends SpecialPage {
2020
2121 function __construct() {
2222 SpecialPage::SpecialPage( 'CreatePage', 'createpage' );
2323 }
2424
25 - public function execute( $params ) {
 25+ public function execute( $par ) {
2626 global $wgOut, $wgRequest, $wgUser;
2727
2828 $this->setHeaders();
@@ -31,37 +31,34 @@
3232 return;
3333 }
3434
35 - $wgOut->addWikiMsg( 'createpage-summary' );
 35+ $this->outputHeader();
3636
3737 // check to see if we are trying to create a page
38 - $target = $wgRequest->getVal ( 'target' );
39 - $title = Title::newFromText ( $target );
 38+ $target = $wgRequest->getVal( 'target', $par );
 39+ $title = Title::newFromText( $target );
4040
4141 // check for no title
4242 if ( $wgRequest->wasPosted() && $target === '' ) {
4343 $this->error( wfMsg( 'createpage-entertitle' ) );
44 - }
45 - // check for invalid title
46 - elseif ( $wgRequest->wasPosted() && is_null( $title ) ) {
47 - $this->error( wfMsg( 'createpage-badtitle', $target ) );
48 - }
49 - elseif ( $target != null ) {
50 - if ( $title->getArticleID() > 0 ) {
 44+ } elseif ( $target !== '' ) {
 45+ if ( !$title instanceof Title ) {
 46+ // check for invalid title
 47+ $this->error( wfMsg( 'createpage-badtitle', $target ) );
 48+ } else if ( $title->getArticleID() > 0 ) {
5149 // if the title exists then let the user know and give other options
52 - $wgOut->addWikiText ( wfMsg ( 'createpage-titleexists', $title->getFullText() ) . "<br />" );
 50+ $wgOut->addWikiMsg( 'createpage-titleexists', $title->getFullText() );
 51+ $wgOut->addHTML( '<br />' );
5352 $skin = $wgUser->getSkin();
54 - $editlink = $skin->makeLinkObj( $title, wfMsg ( 'createpage-editexisting' ), 'action=edit' );
55 - $thisPage = Title::newFromText ( 'CreatePage', NS_SPECIAL );
56 - $wgOut->addHTML ( $editlink . '<br />'
57 - . $skin->makeLinkObj ( $thisPage, wfMsg ( 'createpage-tryagain' ) )
58 - );
 53+ $editlink = $skin->makeLinkObj( $title, wfMsgHTML( 'createpage-editexisting' ), 'action=edit' );
 54+ $thislink = $skin->makeLinkObj( $this->getTitle(), wfMsgHTML( 'createpage-tryagain' ) );
 55+ $wgOut->addHTML( $editlink . '<br />' . $editlink );
5956 return;
6057 } else {
6158 /* TODO - may want to search for closely named pages and give
6259 * other options here... */
6360
6461 // otherwise, redirect them to the edit page for their title
65 - $wgOut->redirect ( $title->getEditURL() );
 62+ $wgOut->redirect( $title->getEditURL() );
6663 }
6764 }
6865
@@ -79,16 +76,17 @@
8077 }
8178
8279 // output the form
83 - $form = Xml::openElement( 'fieldset' ) .
 80+ $wgOut->addHTML(
 81+ Xml::openElement( 'fieldset' ) .
8482 Xml::element( 'legend', null, wfMsg( 'createpage' ) ) . # This should really use a different message
8583 wfMsgWikiHtml( 'createpage-instructions' ) .
86 - Xml::openElement( 'form', array( 'method' => 'post', 'name' => 'createpageform', 'action' => '' ) ) .
 84+ Xml::openElement( 'form', array( 'method' => 'post', 'name' => 'createpageform', 'action' => $this->getTitle()->getLocalUrl() ) ) .
8785 Xml::element( 'input', array( 'type' => 'text', 'name' => 'target', 'size' => 50, 'value' => $newTitle ) ) .
8886 '<br />' .
89 - Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsgHtml( 'createpage-submitbutton' ) ) ) .
 87+ Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsg( 'createpage-submitbutton' ) ) ) .
9088 Xml::closeElement( 'form' ) .
91 - Xml::closeElement( 'fieldset' );
92 - $wgOut->addHTML( $form );
 89+ Xml::closeElement( 'fieldset' )
 90+ );
9391 }
9492 /*
9593 * Function to output an error message

Follow-up revisions

RevisionCommit summaryAuthorDate
r49973Revert r49880, r49883, r49885 - add uniwiki/CreatePage extension to core...brion19:04, 27 April 2009
r51537Follow-up to r49973 (Revert r49880, r49883, r49885 - add uniwiki/CreatePage e...siebrand15:38, 6 June 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r49880* add uniwiki/CreatePage extension to core...siebrand18:47, 25 April 2009

Comments

#Comment by Raymond (talk | contribs)   06:15, 26 April 2009

Calling the special page w/o parameter, http://translatewiki.net/wiki/Special:CreatePage , shows an error:

"" cannot be used as a page title

#Comment by IAlex (talk | contribs)   06:49, 26 April 2009

fixed in r49894.

#Comment by Brion VIBBER (talk | contribs)   19:04, 27 April 2009

Reverted in r49973

Status & tagging log