From c37ee075be62597268b5c8ddf575ba84369cb4d8 Mon Sep 17 00:00:00 2001 From: Jens Frank Date: Mon, 26 Apr 2004 10:20:54 +0000 Subject: [PATCH] Hooks for Erik Zachte's EasyTimeline extension. Plus one one-line patch by Dori. --- includes/DefaultSettings.php | 5 +++++ includes/Parser.php | 16 +++++++++++++++- includes/Tokenizer.php | 22 ++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 59fb115699..135ef6472f 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -221,6 +221,11 @@ $wgTexvc = "./math/texvc"; # Location of the texvc binary # 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 diff --git a/includes/Parser.php b/includes/Parser.php index 0a6c3477ef..5f1043a007 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -5,6 +5,9 @@ include_once('Tokenizer.php'); if( $GLOBALS['wgUseWikiHiero'] ){ include_once('wikihiero.php'); } +if( $GLOBALS['wgUseTimeline'] ){ + include_once('extensions/timeline/Timeline.php'); +} # PHP Parser # @@ -658,6 +661,7 @@ class Parser /* private */ function doTokenizedParser( $str ) { global $wgLang; # for language specific parser hook + global $wgUploadDirectory, $wgUseTimeline; $tokenizer=Tokenizer::newFromString( $str ); $tokenStack = array(); @@ -774,6 +778,15 @@ class Parser $txt = $this->doMagicISBN( $tokenizer ); } break; + case "": + if ( $wgUseTimeline && + "" != ( $timelinesrc = $tokenizer->readAllUntil("</timeline>") ) ) + { + $txt = renderTimeline( $timelinesrc ); + } else { + $txt=$token["text"]; + } + break; default: # Call language specific Hook. $txt = $wgLang->processToken( $token, $tokenStack ); @@ -1174,7 +1187,8 @@ class Parser case MAG_PAGENAME: return $this->mTitle->getText(); case MAG_NAMESPACE: - return Namespace::getCanonicalName($this->mTitle->getNamespace()); + # return Namespace::getCanonicalName($this->mTitle->getNamespace()); + return $wgLang->getNsText($this->mTitle->getNamespace()); // Patch by Dori case MAG_CURRENTDAYNAME: return $wgLang->getWeekdayName( date("w")+1 ); case MAG_CURRENTYEAR: diff --git a/includes/Tokenizer.php b/includes/Tokenizer.php index f23df7fb01..2c61c6574c 100644 --- a/includes/Tokenizer.php +++ b/includes/Tokenizer.php @@ -217,6 +217,17 @@ class Tokenizer { break 2; // switch + while } break; + case "&": //extensions like , since HTML stripping has already been done, + //those look like <timeline> + if ( $this->continues( "lt;timeline>" ) ) + { + $queueToken["type"] = ""; + $queueToken["text"] = "<timeline>"; + $this->mQueuedToken[] = $queueToken; + $this->mPos += 16; + break 2; // switch + while + } + break; } /* switch */ $token["text"].=$ch; @@ -254,5 +265,16 @@ class Tokenizer { return false; return ( 0 == strcmp( $prec, substr($this->mText, $this->mPos-$len, $len) ) ); } + + function readAllUntil( $border ) + { + $n = strpos( $this->mText, $border, $this->mPos ); + if ( $n === false ) + return ""; + $ret = substr( $this->mText, $this->mPos, $n - $this->mPos ); + $this->mPos = $n + strlen( $border ) + 1; + return $ret; + } + } -- 2.20.1