r13885 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13884‎ | r13885 | r13886 >
Date:12:35, 27 April 2006
Author:magnusmanske
Status:old
Tags:
Comment:
Now handles extensions for (X)HTML output (via $wgParser)
Modified paths:
  • /trunk/wiki2xml/php/xml2xhtml.php (modified) (history)

Diff [purge]

Index: trunk/wiki2xml/php/xml2xhtml.php
@@ -136,6 +136,34 @@
137137
138138
139139
 140+ function tag_extension ( $open , &$attrs ) {
 141+ if( !defined( 'MEDIAWIKI' ) ) return ; # Only as MediaWiki extension
 142+
 143+
 144+ if ( $open ) {
 145+ $this->extension_name = $attrs['EXTENSION_NAME'] ;
 146+ $this->extension_attrs = $attrs ;
 147+ unset ( $this->extension_attrs['EXTENSION_NAME'] ) ;
 148+ $this->extension_text_before = $this->s ;
 149+ $this->s = "" ;
 150+ } else {
 151+ $extension_text = trim ( $this->s ) ;
 152+ $this->s = $this->extension_text_before ;
 153+ $this->extension_text_before = "" ;
 154+
 155+ global $wgParser , $wgTitle ;
 156+ if ( !isset ( $wgParser ) ) return ; # Paranoia
 157+ if ( !isset ( $wgParser->mTagHooks[$this->extension_name] ) ) return ; # Extension has no handler
 158+
 159+ if ( $extension_text == "" ) $extension_text = "<{$this->extension_name}/>" ;
 160+ else $extension_text = "<{$this->extension_name}>{$extension_text}</{$this->extension_name}>" ;
 161+ $options = new ParserOptions ;
 162+ $s = $wgParser->parse ( $extension_text , $wgTitle , $options , false ) ;
 163+ $this->add ( $s->getText() ) ;
 164+ }
 165+ }
 166+
 167+
140168 function tag_paragraph ( $open , &$attrs ) {
141169 if ( !isset ( $attrs['align'] ) ) $attrs['align'] = 'justify' ;
142170 if ( $open ) $this->add_tag ( "p" , $attrs ) ;

Status & tagging log