Index: /de-v6/navigation.xml
===================================================================
--- /de-v6/navigation.xml (revision 259)
+++ /de-v6/navigation.xml (revision 259)
@@ -0,0 +1,125 @@
+
+
+
+
+
+
Index: -v6/sidebar.xml
===================================================================
--- /de-v6/sidebar.xml (revision 258)
+++ (revision )
@@ -1,81 +1,0 @@
-
-
-
-
-
Index: /lib/menu.php
===================================================================
--- /lib/menu.php (revision 258)
+++ /lib/menu.php (revision 259)
@@ -1,15 +1,28 @@
conf = $conf_array;
+
+ // load xml file
+ $this->xml = simplexml_load_file($this->conf['webroot'].$this->conf['lang_path'] . '/' . self::navigation_file);
}
-
+
+ ///////////////////// NEWS EXTRACTION
function load_news_data() {
$newsfile = $this->conf['webroot'].$this->conf['lang_path']."/".self::news_file;
@@ -43,16 +56,66 @@
return $news_ul_content;
}
+
+ ///////////////////// RETURN INFOS ABOUT SEITEN_ID LINK
+ function get_link_infos($seiten_id=false) {
+ if(!$seiten_id) $seiten_id = $this->conf['seiten_id'];
+
+ $matches = $this->xml->xpath("//a[@seiten_id='$seiten_id']");
+ if($matches && count($matches)) {
+ // strip the first one
+ return $matches[0];
+ }
+ }
+
+ ///////////////////// INTER LANGUAGE DETECTION
+ /**
+ * @param seiten_id Get interlanguage link for that seiten_id or default.
+ **/
+ function get_interlanguage_link($seiten_id=false) {
+ if(!$seiten_id) $seiten_id = $this->conf['seiten_id'];
+
+ $interlinks = array(); // using a loop instead of mappings since php is stupid
+ foreach($this->conf['languages'] as $lang => $lconf) {
+ $foreign_menu = new t29Menu(array(
+ 'webroot' => $this->conf['webroot'],
+ 'seiten_id' => $this->conf['seiten_id'],
+ 'languages' => $this->conf['languages'],
+ 'lang' => $lang,
+ 'lang_path' => $lconf[1],
+ ));
+
+ $link = $foreign_menu->get_link_infos($seiten_id);
+ $interlinks[$lang] = $link;
+ }
+
+ return $interlinks;
+ }
// helper method
public static function dom_add_class($simplexml_element, $value) {
- $dom = dom_import_simplexml($simplexml_element);
+ $dom = dom_import_simplexml($simplexml_element); // is a fast operation
$simplexml_element['class'] =
($dom->hasAttribute("class") ? ($simplexml_element['class'].' '):'').$value;
}
+
+ public static function dom_new_link($href, $label) {
+ return new SimpleXMLElement(sprintf('%s', $href, $label));
+ }
- function print_menu($file) {
+ ///////////////////// MENU ACTIVE LINK DETECTION
+ /**
+ * @arg $xpath_menu_selection one of the horizontal_menu / sidebar_menu consts.
+ **/
+ function print_menu($xpath_menu_selection) {
$seiten_id = $this->conf['seiten_id'];
- $xml = simplexml_load_file($this->conf['webroot'].$this->conf['lang_path'] . '/' . $file);
-
+
+ // find wanted menu
+ $xml = $this->xml->xpath($xpath_menu_selection);
+ if(!$xml) {
+ print "Menu $xpath_menu_selection not found!";
+ return false;
+ }
+ $xml = $xml[0]; // just take the first result (should only one result be present)
+
// aktuelle Seite anmarkern und Hierarchie hochgehen
// (- bla
- bla
- hierbin ich <- hochgehen.)
@@ -74,5 +137,5 @@
}
- if($file == self::horizontal_menu) {
+ if($xpath_menu_selection == self::horizontal_menu) {
# inject news
$news_ul_content = $this->convert_news_data();
@@ -85,23 +148,37 @@
}
- function print_relations() {
- $seiten_id = $this->conf['seiten_id'];
-
- $sidebar = simplexml_load_file($this->conf['webroot'] . $this->conf['lang_path'] . '/' . self::sidebar_menu);
+ ///////////////////// PAGE RELATIONS
+ /**
+ * Usage:
+ * foreach(get_page_relations() as $a) {
+ * echo "Link $a going to $a[href]";
+ * }
+ * @param $seiten_id A seiten_id string or nothing for taking the current active string
+ * @returns an array(prev=>..., next=>...) or empty array, elements are SimpleXML a links
+ **/
+ function get_page_relations($seiten_id=false) {
+ if(!$seiten_id) $seiten_id = $this->conf['seiten_id'];
+
+ $xml = $this->xml->xpath(self::sidebar_menu);
+ if(!$xml) { print "Sidebar not found"; return; }
+ $sidebar = $xml[0];
+
+ $return = array();
$current_a = $sidebar->xpath("//a[@seiten_id='$seiten_id']");
if(count($current_a)) {
- $prev = $current_a[0]->xpath("preceding::a[@seiten_id][1]");
- if(count($prev)) {
- $a = $prev[0];
- print "
- vorherige Seite $a
";
- }
- $next = $current_a[0]->xpath("following::a[@seiten_id][1]");
- if(count($next)) {
- $a = $next[0];
- print "- nächste Seite $a
";
+ foreach(array(
+ "prev" => "preceding::a[@seiten_id][1]",
+ "next" => "following::a[@seiten_id][1]") as $rel => $xpath) {
+ $node = $current_a[0]->xpath($xpath);
+ if(count($node))
+ $return[$rel] = $node[0]; # $node[0] = tag
}
} else {
- print '- Starte Führung Blabla';
+ // TODO PENDING: Der Fall tritt derzeit niemals ein, da das XML
+ // sich dann doch irgendwie auf alles bezieht ($sidebar = alles) und
+ // ueberall gesucht wird. Ist aber okay. oder?
+ $return['start'] = t29Menu::dom_new_link('#', 'bla');
}
+ return $return;
}
Index: /lib/messages.php
===================================================================
--- /lib/messages.php (revision 258)
+++ /lib/messages.php (revision 259)
@@ -62,5 +62,7 @@
'sidebar-h2-mainnav' => array('Hauptnavigation', 'Main Navigation'),
'sidebar-h2-lang' => array('Sprachauswahl', 'Language'),
- 'sidebar-search-label' => array('Suchen', 'Search'),
+
+ 'topnav-interlang-title' => array('Read this page (%s) in English', 'Diese Seite (%s) auf Deutsch lesen'),
+ 'topnav-search-label' => array('Suchen', 'Search'),
'js-menu-collapse-out' => array('Menü ausklappen', 'Expand menu'),
@@ -71,4 +73,14 @@
'footer-copyright-tag' => '© 2003-2012 technikum29.',
'footer-legal-link' => array('Impressum und Kontakt', 'Legal notices'),
+ 'footer-legal-file' => array('/impressum.php', '/contact.php'),
+
+ 'nav-rel-prev' => array('vorherige Seite', 'previous page'),
+ 'nav-rel-next' => array('nächste Seite', 'next page'),
+ 'nav-rel-start' => array('Starte Führrung', 'Start guided tour'),
+
+ 'head-rel-first' => array('Deutscher Start', 'English start'),
+ 'head-rel-prev' => array('Zur vorherigen Seite (%s)', 'Previous Page (%s)'),
+ 'head-rel-next' => array('Zur folgenden Seite (%s)', 'Next Page (%s)'),
+ 'head-rel-interlang' => array('Englische Version dieser Seite (%s)', 'Deutsche Version dieser Seite (%s)'),
);
}
Index: /lib/technikum29.php
===================================================================
--- /lib/technikum29.php (revision 258)
+++ /lib/technikum29.php (revision 259)
@@ -21,5 +21,7 @@
);
-$lang = "de"; # must be index in $languages
+// try to determine the language from the file path
+$lang = substr($file, 1, 2);
+if(!in_array($lang, array_keys($languages))) $lang = "de"; # check if language exists
$lang_path = $languages[$lang][1]; # shorthand, relative to webroot. use "$webroot$lang_path" for local.
@@ -35,7 +37,6 @@
"$lib/menu.php",
"$lib/messages.php",
- "$lib/../de-v6/hauptnavigation.xml",
- "$lib/../de-v6/sidebar.xml",
- "$lib/../de-v6/news.php",
+ "$lib$lang_path/navigation.xml",
+ "$lib$lang_path/news.php",
);
Index: /lib/template.php
===================================================================
--- /lib/template.php (revision 258)
+++ /lib/template.php (revision 259)
@@ -12,19 +12,11 @@
class t29Template {
- private static $legal_pagenames = array( // should be const
- # lang => file relative to $lang_path, with starting "/".
- "de" => "/impressum.php",
- "en" => "/contact.php",
- );
-
public $conf, $menu, $msg;
public $body_classes = array();
public $javascript_config = array();
+ public $page_relations, $interlang_links;
function __construct($conf_array) {
$this->conf = $conf_array;
-
- // fill up configuration
- $this->conf['legal_pagename'] = $this->conf['lang_path'] . self::$legal_pagenames[$this->conf['lang']];
// create a menu:
@@ -35,4 +27,7 @@
require_once $this->conf['lib'].'/messages.php';
$this->msg = new t29Messages($this->conf['lang']);
+
+ // fill up configuration
+ $this->conf['legal_pagename'] = $this->conf['lang_path'] . $this->msg->_('footer-legal-file');
// setup body classes:
@@ -43,4 +38,8 @@
$this->javascript_config['lang'] = $this->conf['lang'];
$this->javascript_config['seiten_id'] = $this->conf['seiten_id'];
+
+ // get all kind of relations
+ $this->page_relations = $this->menu->get_page_relations();
+ $this->interlang_links = $this->menu->get_interlanguage_link();
}
@@ -79,5 +78,6 @@
function print_header() {
- $_ = $this->msg->get_shorthand_printer();
+ $p = $this->msg->get_shorthand_printer();
+ $_ = $this->msg->get_shorthand_returner();
?>
@@ -85,9 +85,32 @@
- conf['titel']) ? $this->conf['titel'].' - ' : ''; $_('html-title'); ?>
+ conf['titel']) ? $this->conf['titel'].' - ' : ''; $p('html-title'); ?>
+
+ t29Menu::dom_new_link($this->conf['lang_path'], $_('head-rel-first'))),
+ $this->page_relations) as $rel => $a) {
+ if($rel == 'start') continue; // not in standard
+ printf("\n ",
+ $rel, $a['href'], sprintf($_('head-rel-'.$rel), $a)
+ );
+ }
+ ?>
+
+
+ interlang_links as $lang => $a) {
+ if($lang != $this->conf['lang']) {
+ printf('',
+ $a['href'], $lang, sprintf($_('head-rel-interlang'), $a)
+ );
+ }
+ }
+ ?>
+
@@ -101,5 +124,5 @@