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_lang 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")
{
if (!$this->xml->getDataItem("lang") || !$this->xml->getDataItem("lang_var"))
{
return "[no language variables set.]";
}
$parse = $this->xml->parseNode($this->node, True, True, True, array("if", "replace", "key", "lang"));
$attributes = $parse["attributes_array"];
$lang = $this->xml->getDataItem("lang");
if ($attributes["if"] != "")
{
if ($attributes["if"] == $lang)
{
return $parse["content_string"];
}
return "";
}
$lang_var = $this->xml->getDataItem("lang_var");
if ($attributes["lang"] != "")
{
$lang = $attributes["lang"];
}
if (!isset($lang_var[$attributes["key"]][$lang]))
{
return "[no translation found for given key.]";
}
$val = $lang_var[$attributes["key"]][$lang];
$val = str_replace("%s", $attributes["replace"], $val);
return xml::mask_xml($val);
}
}
?>
© 2009 Julian von Mendel (http://derjulian.net) | Datum: 10.09.2024