-<?
+<?php
require_once ( "Parser.php" ) ;
/**
$ret .= "</" . $tag . ">\n" ;
return $ret ;
}
+
+ function createInternalLink ( &$parser , $target , $display_title , $options )
+ {
+ $tp = explode ( ":" , $target ) ; # tp = target parts
+ $title = "" ; # The plain title
+ $language = "" ; # The language/meta/etc. part
+ $namespace = "" ; # The namespace, if any
+ $subtarget = "" ; # The '#' thingy
+ if ( count ( $tp ) == 1 ) $title = $target ; # Plain and simple case
+ else
+ {
+ # To be implemented
+ }
+
+ if ( $language != "" ) # External link within the WikiMedia project
+ {
+ return "{language link}" ;
+ }
+ else if ( $namespace != "" ) # Link to another namespace, check for image/media stuff
+ {
+ return "{namespace link}" ;
+ }
+ else
+ {
+ return "{internal link}" ;
+ }
+ }
+ function makeInternalLink ( &$parser )
+ {
+ $target = "" ;
+ $option = array () ;
+ foreach ($this->children as $child) {
+ if ( is_string($child) ) {
+ # This shouldn't be the case!
+ } else {
+ if ( $child->name == "LINKTARGET" )
+ $target = trim ( $child->makeXHTML ( $parser ) ) ;
+ else
+ $option[] = trim ( $child->makeXHTML ( $parser ) ) ;
+ }
+ }
+
+ if ( count ( $option ) == 0 ) $option[] = $target ; # Create dummy display title
+ $display_title = array_pop ( $option ) ;
+ return $this->createInternalLink ( $parser , $target , $display_title , $option ) ;
+ }
+
function makeXHTML ( &$parser )
{
$ret = "" ;
else if ( $n == "ITALICS" )
$ret .= $this->sub_makeXHTML ( $parser , "em" ) ;
- else if ( $n == "EXTENSION" )
+ else if ( $n == "LINK" )
+ $ret .= $this->makeInternalLink ( $parser ) ;
+ else if ( $n == "LINKTARGET" )
+ $ret .= $this->sub_makeXHTML ( $parser ) ;
+ else if ( $n == "LINKOPTION" )
+ $ret .= $this->sub_makeXHTML ( $parser ) ;
+
+ else if ( $n == "EXTENSION" ) # This is currently a dummy!!!
{
$ext = $this->attrs["NAME"] ;
-# $ret .= $this->sub_makeXHTML ( $parser , "em" ) ;
+ $ret .= "<" . $ext . ">" ;
+ $ret .= $this->sub_makeXHTML ( $parser ) ;
+ $ret .= "</" . $ext . "> " ;
}
else if ( $n == "TABLE" )
{
$ret .= "<" . $n . ">" ;
$ret .= $this->sub_makeXHTML ( $parser ) ;
- $ret .= "</" . $n . ">" ;
+ $ret .= "</" . $n . "> " ;
}
+ $ret = "\n{$ret}\n" ;
+ $ret = str_replace ( "\n\n" , "\n" , $ret ) ;
return $ret ;
}