Index: trunk/extensions/CreatePage/CreatePage.i18n.php |
— | — | @@ -0,0 +1,23 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Internationalization file for the Create Page extension. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file CreatePage.i18n.php |
| 10 | + * @ingroup CreatePage |
| 11 | + * |
| 12 | + * @licence GNU GPL v3+ |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | + |
| 16 | +$messages = array(); |
| 17 | + |
| 18 | +/** English |
| 19 | + * @author Jeroen De Dauw |
| 20 | + */ |
| 21 | +$messages['en'] = array( |
| 22 | + 'cp-desc' => 'Allows placing an input that takes the name of a new page into pages.', |
| 23 | + 'cp-create' => 'Create page', |
| 24 | +); |
Property changes on: trunk/extensions/CreatePage/CreatePage.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 25 | + native |
Index: trunk/extensions/CreatePage/CreatePage.magic.php |
— | — | @@ -0,0 +1,22 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Internationalization file for the Create Page extension. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file CreatePage.magic.php |
| 10 | + * @ingroup CreatePage |
| 11 | + * |
| 12 | + * @licence GNU GPL v3+ |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | + |
| 16 | +$magicWords = array(); |
| 17 | + |
| 18 | +/** English |
| 19 | + * @author Jeroen De Dauw |
| 20 | + */ |
| 21 | +$magicWords['en'] = array( |
| 22 | + 'createpage' => array( 0, 'createpage' ), |
| 23 | +); |
Property changes on: trunk/extensions/CreatePage/CreatePage.magic.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 24 | + native |
Index: trunk/extensions/CreatePage/CreatePage.php |
— | — | @@ -0,0 +1,82 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Initialization file for the Create Page extension. |
| 6 | + * |
| 7 | + * Documentation: https://www.mediawiki.org/wiki/Extension:Create_Page |
| 8 | + * Support https://www.mediawiki.org/wiki/Extension_talk:Create_Page |
| 9 | + * Source code: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/CreatePage |
| 10 | + * |
| 11 | + * @file CreatePage.php |
| 12 | + * @ingroup CreatePage |
| 13 | + * |
| 14 | + * @licence GNU GPL v3+ |
| 15 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 16 | + */ |
| 17 | + |
| 18 | +/** |
| 19 | + * This documentation group collects source code files belonging to Create Page. |
| 20 | + * |
| 21 | + * @defgroup CreatePage Create Page |
| 22 | + */ |
| 23 | + |
| 24 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 25 | + die( 'Not an entry point.' ); |
| 26 | +} |
| 27 | + |
| 28 | +if ( version_compare( $wgVersion, '1.18c', '<' ) ) { // Needs to be 1.18c because version_compare() works in confusing ways. |
| 29 | + die( '<b>Error:</b> Create Page requires MediaWiki 1.18 or above.' ); |
| 30 | +} |
| 31 | + |
| 32 | +define( 'CP_VERSION', '0.1' ); |
| 33 | + |
| 34 | +$wgExtensionCredits['other'][] = array( |
| 35 | + 'path' => __FILE__, |
| 36 | + 'name' => 'Create Page', |
| 37 | + 'version' => CP_VERSION, |
| 38 | + 'author' => array( |
| 39 | + '[http://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]', |
| 40 | + ), |
| 41 | + 'url' => 'https://www.mediawiki.org/wiki/Extension:Create_Page', |
| 42 | + 'descriptionmsg' => 'cp-desc' |
| 43 | +); |
| 44 | + |
| 45 | +// i18n |
| 46 | +$wgExtensionMessagesFiles['CreatePage'] = dirname( __FILE__ ) . '/CreatePage.i18n.php'; |
| 47 | +$wgExtensionMessagesFiles['CreatePageAlias'] = dirname( __FILE__ ) . '/CreatePage.alias.php'; |
| 48 | +$wgExtensionMessagesFiles['CreatePageMagic'] = dirname( __FILE__ ) . '/CreatePage.magic.php'; |
| 49 | + |
| 50 | +$wgAutoloadClasses['SpecialCreatePage'] = dirname( __FILE__ ) . '/SpecialCreatePage.php'; |
| 51 | +$wgSpecialPages['CreatePage'] = 'SpecialCreatePage'; |
| 52 | + |
| 53 | +$wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) { |
| 54 | + $parser->setFunctionHook( 'createpage', function( Parser $parser, PPFrame $frame, array $args ) { |
| 55 | + $html = Html::openElement( 'form', array( |
| 56 | + 'action' => SpecialPage::getTitleFor( 'CreatePage' )->getLocalURL(), |
| 57 | + 'method' => 'post', |
| 58 | + ) ); |
| 59 | + |
| 60 | + $html .= Html::input( |
| 61 | + 'pagename', |
| 62 | + array_key_exists( 1, $args ) ? trim( $frame->expand( $args[1] ) ) : '' |
| 63 | + ); |
| 64 | + |
| 65 | + if ( array_key_exists( 0, $args ) ) { |
| 66 | + $html .= Html::hidden( 'pagens', trim( $frame->expand( $args[0] ) ) ); |
| 67 | + } |
| 68 | + |
| 69 | + $html .= ' '; |
| 70 | + |
| 71 | + $html .= Html::input( |
| 72 | + 'createpage', |
| 73 | + array_key_exists( 2, $args ) ? trim( $frame->expand( $args[2] ) ) : wfMsg( 'cp-create' ), |
| 74 | + 'submit' |
| 75 | + ); |
| 76 | + |
| 77 | + $html .= '</form>'; |
| 78 | + |
| 79 | + return array( $html, 'isHTML' => true ); |
| 80 | + }, SFH_OBJECT_ARGS ); |
| 81 | + |
| 82 | + return true; |
| 83 | +}; |
Property changes on: trunk/extensions/CreatePage/CreatePage.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 84 | + native |
Index: trunk/extensions/CreatePage/SpecialCreatePage.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 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 |
Property changes on: trunk/extensions/CreatePage/SpecialCreatePage.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 44 | + native |
Index: trunk/extensions/CreatePage/CreatePage.alias.php |
— | — | @@ -0,0 +1,22 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Aliases for the special pages of the Create Page extension. |
| 6 | + * |
| 7 | + * @since 0.1 |
| 8 | + * |
| 9 | + * @file CreatePage.alias.php |
| 10 | + * @ingroup CreatePage |
| 11 | + * |
| 12 | + * @licence GNU GPL v3+ |
| 13 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 14 | + */ |
| 15 | + |
| 16 | +$specialPageAliases = array(); |
| 17 | + |
| 18 | +/** English |
| 19 | + * @author Jeroen De Dauw |
| 20 | + */ |
| 21 | +$specialPageAliases['en'] = array( |
| 22 | + 'CreatePage' => array( 'CreatePage' ), |
| 23 | +); |
\ No newline at end of file |
Property changes on: trunk/extensions/CreatePage/CreatePage.alias.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 24 | + native |