r112233 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112232‎ | r112233 | r112234 >
Date:19:49, 23 February 2012
Author:jeroendedauw
Status:ok
Tags:
Comment:
follow up r111749 r110692
Modified paths:
  • /trunk/extensions/CreatePage/CreatePage.alias.php (modified) (history)
  • /trunk/extensions/CreatePage/CreatePage.i18n.php (modified) (history)
  • /trunk/extensions/CreatePage/CreatePage.php (modified) (history)
  • /trunk/extensions/CreatePage/SpecialCreatePage.php (deleted) (history)
  • /trunk/extensions/CreatePage/SpecialCreatePageRedirect.php (added) (history)

Diff [purge]

Index: trunk/extensions/CreatePage/SpecialCreatePage.php
@@ -1,42 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Redirect the submission request of the createpage parser hook to the actual page.
6 - *
7 - * @since 0.1
8 - *
9 - * @file SpecialCreatePage.php
10 - * @ingroup CreatePage
11 - *
12 - * @licence GNU GPL v3 or later
13 - * @author Jeroen De Dauw < jeroendedauw@gmail.com >
14 - */
15 -class SpecialCreatePage extends UnlistedSpecialPage {
16 -
17 - public function __construct() {
18 - parent::__construct( 'CreatePage' );
19 - }
20 -
21 - public function execute( $subPage ) {
22 - $req = $this->getRequest();
23 -
24 - if ( $req->wasPosted() && $req->getCheck( 'pagename' ) ) {
25 - $parts = array( $req->getText( 'pagename' ) );
26 -
27 - if ( $req->getCheck( 'pagens' ) ) {
28 - array_unshift( $parts, $req->getText( 'pagens' ) );
29 - }
30 -
31 - $target = Title::newFromText( implode( ':', $parts ) )->getLocalUrl( array(
32 - 'action' => 'edit',
33 - 'redlink' => '1'
34 - ) );
35 - }
36 - else {
37 - $target = Title::newMainPage()->getLocalURL();
38 - }
39 -
40 - $this->getOutput()->redirect( $target );
41 - }
42 -
43 -}
\ No newline at end of file
Index: trunk/extensions/CreatePage/CreatePage.alias.php
@@ -18,5 +18,5 @@
1919 * @author Jeroen De Dauw
2020 */
2121 $specialPageAliases['en'] = array(
22 - 'CreatePage' => array( 'CreatePage' ),
 22+ 'CreatePageRedirect' => array( 'CreatePageRedirect' ),
2323 );
\ No newline at end of file
Index: trunk/extensions/CreatePage/CreatePage.i18n.php
@@ -18,10 +18,18 @@
1919 * @author Jeroen De Dauw
2020 */
2121 $messages['en'] = array(
22 - 'cp-desc' => 'Allows placing an input that takes the name of a new page into pages',
 22+ 'cp-desc' => 'Allows embedding an input into which users can enter the name of a page to be created and are taken to that page when they click create.',
2323 'cp-create' => 'Create page',
2424 );
2525
 26+/** Message documentation (Message documentation)
 27+ * @author Jeroen De Dauw
 28+ */
 29+$messages['qqq'] = array(
 30+ 'cp-desc' => 'Extension description for Special:Version',
 31+ 'cp-create' => 'Create button text',
 32+);
 33+
2634 /** Asturian (Asturianu)
2735 * @author Xuacu
2836 */
Index: trunk/extensions/CreatePage/CreatePage.php
@@ -47,12 +47,12 @@
4848 $wgExtensionMessagesFiles['CreatePageMagic'] = dirname( __FILE__ ) . '/CreatePage.magic.php';
4949
5050 $wgAutoloadClasses['SpecialCreatePage'] = dirname( __FILE__ ) . '/SpecialCreatePage.php';
51 -$wgSpecialPages['CreatePage'] = 'SpecialCreatePage';
 51+$wgSpecialPages['CreatePageRedirect'] = 'SpecialCreatePageRedirect';
5252
5353 $wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
5454 $parser->setFunctionHook( 'createpage', function( Parser $parser, PPFrame $frame, array $args ) {
5555 $html = Html::openElement( 'form', array(
56 - 'action' => SpecialPage::getTitleFor( 'CreatePage' )->getLocalURL(),
 56+ 'action' => SpecialPage::getTitleFor( 'CreatePageRedirect' )->getLocalURL(),
5757 'method' => 'post',
5858 'style' => 'display: inline',
5959 ) );
Index: trunk/extensions/CreatePage/SpecialCreatePageRedirect.php
@@ -0,0 +1,42 @@
 2+<?php
 3+
 4+/**
 5+ * Redirect the submission request of the createpage parser hook to the actual page.
 6+ *
 7+ * @since 0.1
 8+ *
 9+ * @file SpecialCreatePage.php
 10+ * @ingroup CreatePage
 11+ *
 12+ * @licence GNU GPL v3 or later
 13+ * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 14+ */
 15+class SpecialCreatePageRedirect extends UnlistedSpecialPage {
 16+
 17+ public function __construct() {
 18+ parent::__construct( 'CreatePageRedirect' );
 19+ }
 20+
 21+ public function execute( $subPage ) {
 22+ $req = $this->getRequest();
 23+
 24+ if ( $req->wasPosted() && $req->getCheck( 'pagename' ) ) {
 25+ $parts = array( $req->getText( 'pagename' ) );
 26+
 27+ if ( $req->getCheck( 'pagens' ) ) {
 28+ array_unshift( $parts, $req->getText( 'pagens' ) );
 29+ }
 30+
 31+ $target = Title::newFromText( implode( ':', $parts ) )->getLocalUrl( array(
 32+ 'action' => 'edit',
 33+ 'redlink' => '1'
 34+ ) );
 35+ }
 36+ else {
 37+ $target = Title::newMainPage()->getLocalURL();
 38+ }
 39+
 40+ $this->getOutput()->redirect( $target, '301' );
 41+ }
 42+
 43+}
\ No newline at end of file
Property changes on: trunk/extensions/CreatePage/SpecialCreatePageRedirect.php
___________________________________________________________________
Added: svn:eol-style
144 + native

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r110692importing CreatePage extensionjeroendedauw00:10, 4 February 2012
r111749r110692: Register extension for translatewiki.net.raymond14:31, 17 February 2012

Status & tagging log