Last update: 31.03.2008 | © 2024 Julian von Mendel | Datenschutz
<?php
/* xml_extension class
* (C) 2006 Julian von Mendel (http://derjulian.net)
* License: LGPL
*/
class xml_h implements xml_widget
{
public $node;
public $xml ;
function __construct($node, $xml)
{
$this->node = $node;
$this->xml = $xml ;
}
public static function dtd()
{
return <<<DTD
DTD;
}
public function output($returntype = "xhtml")
{
$parse = $this->xml->parseNode($this->node, True, True, True, array("toc", "id", "href"));
$attributes = $parse["attributes_string"];
$anchor = $parse["attributes_array"]["id"];
$content = $parse["content_string"];
$data = $this->xml->getDataItem("headlines");
if (!is_array($data))
{
$data = array
(
"level" => 1,
"anchor" => 0,
"anchor-title" => array()
);
}
$nr = $data["level"];
if ($anchor == "" || isset($data[1][$anchor]))
{
$anchor = "headline_".++$data["anchor"];
}
if ($parse["attributes_array"]["toc"] != "no")
{
$data["anchor-title"][] = array
(
"level" => $nr ,
"content" => $content,
"anchor" => $anchor
);
}
$content = $this->xml->href($content, "", $parse["attributes_array"], True);
$this->xml->setDataItem("headlines", $data);
if (method_exists($this, $returntype))
{
return call_user_func(array($this, $returntype), $nr, $anchor, $attributes, $content);
}
return False;
}
private function xhtml($nr, $anchor, $attributes, $content)
{
if ($anchor)
{
$anchor = " id=\"".$anchor."\"";
}
return "<h".$nr.$attributes.$anchor.">".$content."</h".$nr.">";
}
}
?>
© 2009 Julian von Mendel (http://derjulian.net) | Datum: 09.09.2024