Index: trunk/phase3/includes/specials/SpecialCreatePage.php |
— | — | @@ -1,4 +1,5 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /* This code was adapted from CreatePage.php from: Travis Derouin <travis@wikihow.com> for the Uniwiki extension CreatePage |
4 | 5 | * Originally licensed as: GNU GPL v2.0 or later |
5 | 6 | * |
— | — | @@ -12,16 +13,15 @@ |
13 | 14 | * @author Evan Wheeler |
14 | 15 | * @author Adam Mckaig (at UNICEF) |
15 | 16 | * @author Siebrand Mazeland (integrated into MediaWiki core) |
16 | | - * @addtogroup SpecialPage |
| 17 | + * @ingroup SpecialPage |
17 | 18 | */ |
18 | | - |
19 | 19 | class SpecialCreatePage extends SpecialPage { |
20 | 20 | |
21 | 21 | function __construct() { |
22 | 22 | SpecialPage::SpecialPage( 'CreatePage', 'createpage' ); |
23 | 23 | } |
24 | 24 | |
25 | | - public function execute( $params ) { |
| 25 | + public function execute( $par ) { |
26 | 26 | global $wgOut, $wgRequest, $wgUser; |
27 | 27 | |
28 | 28 | $this->setHeaders(); |
— | — | @@ -31,37 +31,34 @@ |
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | | - $wgOut->addWikiMsg( 'createpage-summary' ); |
| 35 | + $this->outputHeader(); |
36 | 36 | |
37 | 37 | // 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 ); |
40 | 40 | |
41 | 41 | // check for no title |
42 | 42 | if ( $wgRequest->wasPosted() && $target === '' ) { |
43 | 43 | $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 ) { |
51 | 49 | // 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 />' ); |
53 | 52 | $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 ); |
59 | 56 | return; |
60 | 57 | } else { |
61 | 58 | /* TODO - may want to search for closely named pages and give |
62 | 59 | * other options here... */ |
63 | 60 | |
64 | 61 | // otherwise, redirect them to the edit page for their title |
65 | | - $wgOut->redirect ( $title->getEditURL() ); |
| 62 | + $wgOut->redirect( $title->getEditURL() ); |
66 | 63 | } |
67 | 64 | } |
68 | 65 | |
— | — | @@ -79,16 +76,17 @@ |
80 | 77 | } |
81 | 78 | |
82 | 79 | // output the form |
83 | | - $form = Xml::openElement( 'fieldset' ) . |
| 80 | + $wgOut->addHTML( |
| 81 | + Xml::openElement( 'fieldset' ) . |
84 | 82 | Xml::element( 'legend', null, wfMsg( 'createpage' ) ) . # This should really use a different message |
85 | 83 | 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() ) ) . |
87 | 85 | Xml::element( 'input', array( 'type' => 'text', 'name' => 'target', 'size' => 50, 'value' => $newTitle ) ) . |
88 | 86 | '<br />' . |
89 | | - Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsgHtml( 'createpage-submitbutton' ) ) ) . |
| 87 | + Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsg( 'createpage-submitbutton' ) ) ) . |
90 | 88 | Xml::closeElement( 'form' ) . |
91 | | - Xml::closeElement( 'fieldset' ); |
92 | | - $wgOut->addHTML( $form ); |
| 89 | + Xml::closeElement( 'fieldset' ) |
| 90 | + ); |
93 | 91 | } |
94 | 92 | /* |
95 | 93 | * Function to output an error message |