Hooks for Erik Zachte's EasyTimeline extension.
authorJens Frank <jeluf@users.mediawiki.org>
Mon, 26 Apr 2004 10:20:54 +0000 (10:20 +0000)
committerJens Frank <jeluf@users.mediawiki.org>
Mon, 26 Apr 2004 10:20:54 +0000 (10:20 +0000)
Plus one one-line patch by Dori.

includes/DefaultSettings.php
includes/Parser.php
includes/Tokenizer.php

index 59fb115..135ef64 100644 (file)
@@ -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
index 0a6c347..5f1043a 100644 (file)
@@ -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 "<timeline>":
+                                       if ( $wgUseTimeline && 
+                                            "" != ( $timelinesrc = $tokenizer->readAllUntil("&lt;/timeline&gt;") ) )
+                                       {
+                                               $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:
index f23df7f..2c61c65 100644 (file)
@@ -217,6 +217,17 @@ class Tokenizer {
                                                        break 2; // switch + while
                                                }
                                                break;
+                                       case "&": //extensions like <timeline>, since HTML stripping has already been done, 
+                                                 //those look like &lt;timeline&gt;
+                                               if ( $this->continues( "lt;timeline&gt;" ) )
+                                               {
+                                                       $queueToken["type"] = "<timeline>";
+                                                       $queueToken["text"] = "&lt;timeline&gt;";
+                                                       $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;
+       }
+
 }