From: Tim Starling Date: Wed, 9 Jun 2004 12:15:42 +0000 (+0000) Subject: Hiero and timeline as fully modular extensions. To use, just include the header file... X-Git-Tag: 1.5.0alpha1~2975 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=3ac0a71c13236ec7eb192f938dd00ad485c066bb;p=lhc%2Fweb%2Fwiklou.git Hiero and timeline as fully modular extensions. To use, just include the header file from LocalSettings.php --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 6de7127cb3..f334d4f09a 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -227,17 +227,6 @@ $wgWLCacheTimeout = 3600; # The hour or so mentioned above $wgUseTeX = false; $wgTexvc = './math/texvc'; # Location of the texvc binary -# Support for inline hieroglyphs, see http://aoineko.free.fr/ The -# WikiHiero php files must be present in the same directory as the -# rest of the mediawiki code, and WikiHiero must have been configured -# with the correct image locations. -$wgUseWikiHiero = false; - -# Support for inline timelines, see http://members.chello.nl/epzachte/Wikipedia/EasyTimeline/Introduction.htm -# The Timeline php files must be present in the extension directory and you must have the -# ploticus tool available, see http://ploticus.sourceforge.net/ -$wgUseTimeline = false; - # Profiling / debugging $wgProfiling = false; # Enable for more detailed by-function times in debug log $wgProfileLimit = 0.0; # Only record profiling info for pages that took longer than this @@ -293,6 +282,9 @@ $wgCheckFileExtensions = true; # covered by $wgFileExtensions. $wgStrictFileExtensions = true; +# Warn if uploaded files are larger than this +$wgUploadSizeWarning = 150000; + $wgPasswordSalt = true; # For compatibility with old installations set to false # Which namespaces should support subpages? diff --git a/includes/Parser.php b/includes/Parser.php index 7e2c3047d5..964af1be83 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -2,13 +2,6 @@ // require_once('Tokenizer.php'); -if( $GLOBALS['wgUseWikiHiero'] ){ - require_once('extensions/wikihiero/wikihiero.php'); -} -if( $GLOBALS['wgUseTimeline'] ){ - require_once('extensions/timeline/Timeline.php'); -} - # PHP Parser # # Processes wiki markup @@ -53,6 +46,8 @@ define( "STRIP_COMMENTS", "HTMLCommentStrip" ); # prefix for escaping, used in two functions at least define( "UNIQ_PREFIX", "NaodW29"); +/* private */ $wgParserHooks = array(); + class Parser { # Cleared with clearState(): @@ -200,18 +195,21 @@ class Parser # counting the sections in the wikisource function strip( $text, &$state, $stripcomments = false ) { + global $wgParserHooks; + $render = ($this->mOutputType == OT_HTML); $nowiki_content = array(); - $hiero_content = array(); - $timeline_content = array(); $math_content = array(); $pre_content = array(); $comment_content = array(); - + $ext_content = array(); + # Replace any instances of the placeholders $uniq_prefix = UNIQ_PREFIX; #$text = str_replace( $uniq_prefix, wfHtmlEscapeFirst( $uniq_prefix ), $text ); + + # nowiki $text = Parser::extractTags('nowiki', $text, $nowiki_content, $uniq_prefix); foreach( $nowiki_content as $marker => $content ){ if( $render ){ @@ -221,24 +219,7 @@ class Parser } } - $text = Parser::extractTags('hiero', $text, $hiero_content, $uniq_prefix); - foreach( $hiero_content as $marker => $content ){ - if( $render && $GLOBALS['wgUseWikiHiero']){ - $hiero_content[$marker] = WikiHiero( $content, WH_MODE_HTML); - } else { - $hiero_content[$marker] = "$content"; - } - } - - $text = Parser::extractTags('timeline', $text, $timeline_content, $uniq_prefix); - foreach( $timeline_content as $marker => $content ){ - if( $render && $GLOBALS['wgUseTimeline']){ - $timeline_content[$marker] = renderTimeline( $content ); - } else { - $timeline_content[$marker] = "$content"; - } - } - + # math $text = Parser::extractTags('math', $text, $math_content, $uniq_prefix); foreach( $math_content as $marker => $content ){ if( $render ) { @@ -252,6 +233,7 @@ class Parser } } + # pre $text = Parser::extractTags('pre', $text, $pre_content, $uniq_prefix); foreach( $pre_content as $marker => $content ){ if( $render ){ @@ -260,6 +242,8 @@ class Parser $pre_content[$marker] = "
$content
"; } } + + # Comments if($stripcomments) { $text = Parser::extractTags(STRIP_COMMENTS, $text, $comment_content, $uniq_prefix); foreach( $comment_content as $marker => $content ){ @@ -267,23 +251,38 @@ class Parser } } + # Extensions + foreach ( $wgParserHooks as $tag => $callback ) { + $ext_contents[$tag] = array(); + $text = Parser::extractTags( $tag, $text, $ext_content[$tag], $uniq_prefix ); + foreach( $ext_content[$tag] as $marker => $content ) { + if ( $render ) { + $ext_content[$tag][$marker] = $callback( $content ); + } else { + $ext_content[$tag][$marker] = "<$tag>$content"; + } + } + } + # Merge state with the pre-existing state, if there is one if ( $state ) { $state['nowiki'] = $state['nowiki'] + $nowiki_content; - $state['hiero'] = $state['hiero'] + $hiero_content; - $state['timeline'] = $state['timeline'] + $timeline_content; $state['math'] = $state['math'] + $math_content; $state['pre'] = $state['pre'] + $pre_content; $state['comment'] = $state['comment'] + $comment_content; + + foreach( $ext_content as $tag => $array ) { + if ( array_key_exists( $tag, $state ) ) { + $state[$tag] = $state[$tag] + $array; + } + } } else { $state = array( 'nowiki' => $nowiki_content, - 'hiero' => $hiero_content, - 'timeline' => $timeline_content, 'math' => $math_content, 'pre' => $pre_content, - 'comment' => $comment_content - ); + 'comment' => $comment_content, + ) + $ext_content; } return $text; } @@ -324,7 +323,6 @@ class Parser if ( !$state ) { $state = array( 'nowiki' => array(), - 'hiero' => array(), 'math' => array(), 'pre' => array() ); @@ -2223,6 +2221,16 @@ cl_sortkey" ; $executing = false; return $text; } + + # Create an HTML-style tag, e.g. special text + # Callback will be called with the text within + # Transform and return the text within + /* static */ function setHook( $tag, $callback ) { + global $wgParserHooks; + $oldVal = @$wgParserHooks[$tag]; + $wgParserHooks[$tag] = $callback; + return $oldVal; + } } class ParserOutput