conf = $conf_array;
// libxml: don't raise errors while parsing.
// will fetch them with libxml_get_errors later.
//libxml_use_internal_errors(true);
// load xml file
$this->xml = simplexml_load_file($this->conf['webroot'].$this->conf['lang_path'] . '/' . self::navigation_file);
if($this->xml_is_defective()) {
trigger_error("Kann Navigationsdatei nicht verwenden, da das XML nicht sauber ist. Bitte reparieren!");
}
}
function xml_is_defective() {
// check if return value of simplexml_load_file was false,
// which means parse error.
return $this->xml === FALSE;
}
///////////////////// NEWS EXTRACTION
function load_news_data() {
$newsfile = $this->conf['webroot'].$this->conf['lang_path']."/".self::news_file;
$newsdir = dirname(realpath($newsfile));
// include path wird ignoriert wenn include relativ ist, was in der
// eingebundenen Datei der Fall ist
// set_include_path( get_include_path(). PATH_SEPARATOR . dirname($newsfile));
$pwd = getcwd(); chdir($newsdir);
include(self::news_file);
chdir($pwd);
return $neues_menu;
}
function convert_news_data() {
require $this->conf['lib'].'/spyc.php';
$data = Spyc::YAMLLoad($this->load_news_data());
$fields = array('titel', 'text', 'link', 'bild');
$news_ul_content = '';
foreach($data as $e) {
if(!array_reduce(array_map(function($x) use ($fields,$e){ return isset($e[$x]); }, $fields),
function($a,$b){ return $a && $b;}, true)) {
$li = "
";
}
$news_ul_content .= "\t".$li."\n";
}
return $news_ul_content;
}
///////////////////// RETURN INFOS ABOUT SEITEN_ID LINK
/**
* Find the corresponding XML node in the navigation tree for the link
* with given $seiten_id or the current given seiten_id in the configuration
* array.
* This method is used in get_link_navigation_class, etc. for resolving
* the XML element from the string. They can be used with the XML node, too,
* and this behaviour is passed throught by this method, so if you call
* this with an SimpleXMLElement as argument, it behaves like an identity
* function and just does nothing.
* (This is used in template.php for caching the found xml element and saving
* several xpath querys on get_* calls)
*
* @param $seiten_id Either a string, or nothing (defaults to conf) or SimpleXMLElement
* @returns SimpleXMLElement or null if link not found
**/
function get_link($seiten_id=false) {
if($this->xml_is_defective()) {
return null;
}
if(!$seiten_id) $seiten_id = $this->conf['seiten_id'];
// convenience: If you found your link already.
if($seiten_id instanceof SimpleXMLElement) return $seiten_id;
$matches = $this->xml->xpath("//a[@seiten_id='$seiten_id']");
if($matches && count($matches)) {
// strip the first one
return $matches[0];
}
return null;
}
/**
* Get navigation list membership (horizontal or side) of a link
* @see get_link for parameters
* @returns String of