r51537 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51536‎ | r51537 | r51538 >
Date:15:38, 6 June 2009
Author:siebrand
Status:ok
Tags:
Comment:
Follow-up to r49973 (Revert r49880, r49883, r49885 - add uniwiki/CreatePage extension to core)
* Special page addition was not reverted.
Modified paths:
  • /trunk/phase3/includes/specials/SpecialCreatePage.php (deleted) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialCreatePage.php
@@ -1,101 +0,0 @@
2 -<?php
3 -/* This code was adapted from CreatePage.php from: Travis Derouin <travis@wikihow.com> for the Uniwiki extension CreatePage
4 - * Originally licensed as: GNU GPL v2.0 or later
5 - *
6 - * This page has been copied and adapted from the Uniwiki extension CreatePage
7 - * Originally licensed as: http://www.gnu.org/licenses/gpl-3.0.txt
8 - *
9 - * @license GNU GPL v3.0 http://www.gnu.org/licenses/gpl-3.0.txt
10 - * @author Travis Derouin
11 - * @author Merrick Schaefer
12 - * @author Mark Johnston
13 - * @author Evan Wheeler
14 - * @author Adam Mckaig (at UNICEF)
15 - * @author Siebrand Mazeland (integrated into MediaWiki core)
16 - * @addtogroup SpecialPage
17 - */
18 -
19 -class SpecialCreatePage extends SpecialPage {
20 -
21 - public function __construct() {
22 - parent::__construct( 'CreatePage', 'createpage' );
23 - }
24 -
25 - public function execute( $params ) {
26 - global $wgOut, $wgRequest, $wgUser;
27 -
28 - $this->setHeaders();
29 -
30 - if ( !$this->userCanExecute( $wgUser ) ) {
31 - $this->displayRestrictionError();
32 - return;
33 - }
34 -
35 - $wgOut->addWikiMsg( 'createpage-summary' );
36 -
37 - // check to see if we are trying to create a page
38 - $target = $wgRequest->getVal ( 'target' );
39 - $title = Title::newFromText ( $target );
40 -
41 - // check for no title
42 - if ( $wgRequest->wasPosted() && $target === '' ) {
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 ) {
51 - // if the title exists then let the user know and give other options
52 - $wgOut->addWikiText ( wfMsg ( 'createpage-titleexists', $title->getFullText() ) . "<br />" );
53 - $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 - );
59 - return;
60 - } else {
61 - /* TODO - may want to search for closely named pages and give
62 - * other options here... */
63 -
64 - // otherwise, redirect them to the edit page for their title
65 - $wgOut->redirect ( $title->getEditURL() );
66 - }
67 - }
68 -
69 - // if this is just a normal GET, then output the form
70 -
71 - // prefill the input with the title, if it was passed along
72 - $newTitle = false;
73 - $newTitleText = $wgRequest->getVal( 'newtitle', null );
74 - if ( $newTitleText != null ) {
75 - $newTitle = Title::newFromURL( $newTitleText );
76 - if ( is_null( $newTitle ) )
77 - $newTitle = $newTitleText;
78 - else
79 - $newTitle = $newTitle->getText();
80 - }
81 -
82 - // output the form
83 - $form = Xml::openElement( 'fieldset' ) .
84 - Xml::element( 'legend', null, wfMsg( 'createpage' ) ) . # This should really use a different message
85 - wfMsgWikiHtml( 'createpage-instructions' ) .
86 - Xml::openElement( 'form', array( 'method' => 'post', 'name' => 'createpageform', 'action' => '' ) ) .
87 - Xml::element( 'input', array( 'type' => 'text', 'name' => 'target', 'size' => 50, 'value' => $newTitle ) ) .
88 - '<br />' .
89 - Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsgHtml( 'createpage-submitbutton' ) ) ) .
90 - Xml::closeElement( 'form' ) .
91 - Xml::closeElement( 'fieldset' );
92 - $wgOut->addHTML( $form );
93 - }
94 - /*
95 - * Function to output an error message
96 - * @param $msg String: message text or HTML
97 - */
98 - function error( $msg ) {
99 - global $wgOut;
100 - $wgOut->addHTML( Xml::element( 'p', array( 'class' => 'error' ), $msg ) );
101 - }
102 -}

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r49880* add uniwiki/CreatePage extension to core...siebrand18:47, 25 April 2009
r49883Follow up to r49880. Fix casing for CreatePage in $wgSpecialPageGroupssiebrand19:07, 25 April 2009
r49885Follow-up r49880, tweaks to Special:CreatePage:...ialex19:40, 25 April 2009
r49973Revert r49880, r49883, r49885 - add uniwiki/CreatePage extension to core...brion19:04, 27 April 2009

Status & tagging log