<?php
+
/* This code was adapted from CreatePage.php from: Travis Derouin <travis@wikihow.com> for the Uniwiki extension CreatePage
* Originally licensed as: GNU GPL v2.0 or later
*
* @author Evan Wheeler
* @author Adam Mckaig (at UNICEF)
* @author Siebrand Mazeland (integrated into MediaWiki core)
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
*/
-
class SpecialCreatePage extends SpecialPage {
function __construct() {
SpecialPage::SpecialPage( 'CreatePage', 'createpage' );
}
- public function execute( $params ) {
+ public function execute( $par ) {
global $wgOut, $wgRequest, $wgUser;
$this->setHeaders();
return;
}
- $wgOut->addWikiMsg( 'createpage-summary' );
+ $this->outputHeader();
// check to see if we are trying to create a page
- $target = $wgRequest->getVal ( 'target' );
- $title = Title::newFromText ( $target );
+ $target = $wgRequest->getVal( 'target', $par );
+ $title = Title::newFromText( $target );
// check for no title
if ( $wgRequest->wasPosted() && $target === '' ) {
$this->error( wfMsg( 'createpage-entertitle' ) );
- }
- // check for invalid title
- elseif ( $wgRequest->wasPosted() && is_null( $title ) ) {
- $this->error( wfMsg( 'createpage-badtitle', $target ) );
- }
- elseif ( $target != null ) {
- if ( $title->getArticleID() > 0 ) {
+ } elseif ( $target !== '' ) {
+ if ( !$title instanceof Title ) {
+ // check for invalid title
+ $this->error( wfMsg( 'createpage-badtitle', $target ) );
+ } else if ( $title->getArticleID() > 0 ) {
// if the title exists then let the user know and give other options
- $wgOut->addWikiText ( wfMsg ( 'createpage-titleexists', $title->getFullText() ) . "<br />" );
+ $wgOut->addWikiMsg( 'createpage-titleexists', $title->getFullText() );
+ $wgOut->addHTML( '<br />' );
$skin = $wgUser->getSkin();
- $editlink = $skin->makeLinkObj( $title, wfMsg ( 'createpage-editexisting' ), 'action=edit' );
- $thisPage = Title::newFromText ( 'CreatePage', NS_SPECIAL );
- $wgOut->addHTML ( $editlink . '<br />'
- . $skin->makeLinkObj ( $thisPage, wfMsg ( 'createpage-tryagain' ) )
- );
+ $editlink = $skin->makeLinkObj( $title, wfMsgHTML( 'createpage-editexisting' ), 'action=edit' );
+ $thislink = $skin->makeLinkObj( $this->getTitle(), wfMsgHTML( 'createpage-tryagain' ) );
+ $wgOut->addHTML( $editlink . '<br />' . $editlink );
return;
} else {
/* TODO - may want to search for closely named pages and give
* other options here... */
// otherwise, redirect them to the edit page for their title
- $wgOut->redirect ( $title->getEditURL() );
+ $wgOut->redirect( $title->getEditURL() );
}
}
}
// output the form
- $form = Xml::openElement( 'fieldset' ) .
+ $wgOut->addHTML(
+ Xml::openElement( 'fieldset' ) .
Xml::element( 'legend', null, wfMsg( 'createpage' ) ) . # This should really use a different message
wfMsgWikiHtml( 'createpage-instructions' ) .
- Xml::openElement( 'form', array( 'method' => 'post', 'name' => 'createpageform', 'action' => '' ) ) .
+ Xml::openElement( 'form', array( 'method' => 'post', 'name' => 'createpageform', 'action' => $this->getTitle()->getLocalUrl() ) ) .
Xml::element( 'input', array( 'type' => 'text', 'name' => 'target', 'size' => 50, 'value' => $newTitle ) ) .
'<br />' .
- Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsgHtml( 'createpage-submitbutton' ) ) ) .
+ Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsg( 'createpage-submitbutton' ) ) ) .
Xml::closeElement( 'form' ) .
- Xml::closeElement( 'fieldset' );
- $wgOut->addHTML( $form );
+ Xml::closeElement( 'fieldset' )
+ );
}
/*
* Function to output an error message