r45775 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45774‎ | r45775 | r45776 >
Date:17:42, 15 January 2009
Author:werdna
Status:deferred
Tags:
Comment:
Quickie extension to preview wikitext. Still needs to be able to specify a title, but I couldn't be bothered. No localisation or credits or anything, because it's only supposed to be used for development and testing.
Modified paths:
  • /trunk/extensions/Preview (added) (history)
  • /trunk/extensions/Preview/Preview.php (added) (history)

Diff [purge]

Index: trunk/extensions/Preview/Preview.php
@@ -0,0 +1,30 @@
 2+<?php
 3+
 4+if (!defined('MEDIAWIKI'))
 5+ die;
 6+
 7+$wgSpecialPages['Preview'] = 'SpecialPreview';
 8+
 9+class SpecialPreview extends SpecialPage {
 10+ function __construct() {
 11+ parent::__construct( 'Preview' );
 12+ }
 13+
 14+ function execute( $subpage ) {
 15+ global $wgRequest, $wgOut;
 16+
 17+ $wgOut->setPageTitle( 'Wikitext Preview' );
 18+
 19+ if ( $wikitext = $wgRequest->getText( 'wikitext' ) ) {
 20+ $wgOut->addHTML( Xml::fieldset( 'Wikitext preview', $wgOut->parse( $wikitext ) ) );
 21+ }
 22+
 23+ $f = Xml::textarea( 'wikitext', $wikitext );
 24+ $f .= Xml::submitButton( 'Preview wikitext' );
 25+
 26+ $f .= Xml::hidden( 'title', $this->getTitle()->getPrefixedText() );
 27+ $f = Xml::tags( 'form', array( 'method' => 'POST', 'action' => $this->getTitle()->getLocalURL() ), $f );
 28+
 29+ $wgOut->addHTML( Xml::fieldset( 'Preview wikitext', $f ) );
 30+ }
 31+}

Status & tagging log