- Timestamp:
- Jul 19, 2012, 7:10:15 AM (12 years ago)
- Location:
- lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/menu.php
r278 r279 71 71 72 72 ///////////////////// RETURN INFOS ABOUT SEITEN_ID LINK 73 function find_link($seiten_id=false) { 73 74 /** 75 * Find the corresponding XML node in the navigation tree for the link 76 * with given $seiten_id or the current given seiten_id in the configuration 77 * array. 78 * This method is used in get_link_navigation_class, etc. for resolving 79 * the XML element from the string. They can be used with the XML node, too, 80 * and this behaviour is passed throught by this method, so if you call 81 * this with an SimpleXMLElement as argument, it behaves like an identity 82 * function and just does nothing. 83 * (This is used in template.php for caching the found xml element and saving 84 * several xpath querys on get_* calls) 85 * 86 * @param $seiten_id Either a string, or nothing (defaults to conf) or SimpleXMLElement 87 * @returns SimpleXMLElement or null if link not found 88 **/ 89 function get_link($seiten_id=false) { 74 90 if($this->xml_is_defective()) { 75 91 return null; 76 92 } 77 93 if(!$seiten_id) $seiten_id = $this->conf['seiten_id']; 94 // convenience: If you found your link already. 95 if($seiten_id instanceof SimpleXMLElement) return $seiten_id; 78 96 79 97 $matches = $this->xml->xpath("//a[@seiten_id='$seiten_id']"); … … 82 100 return $matches[0]; 83 101 } 84 } 102 return null; 103 } 104 105 /** 106 * Get navigation list membership (horizontal or side) of a link 107 * @see get_link for parameters 108 * @returns String of <nav> class where this link is affiliated to 109 **/ 110 function get_link_navigation_class($seiten_id=false) { 111 $link = $this->get_link($seiten_id); 112 if(!$link) return null; 113 114 // navigation list membership 115 $nav = $link->xpath("ancestor::nav"); 116 return strval($nav[0]['class']); // cast SimpleXMLElement 117 } 118 119 /** 120 * Get list of parental ul classes (u2, u3, geraete, ...) 121 * @see get_link for parameters 122 * @returns array with individual class names as strings 123 **/ 124 function get_link_ul_classes($seiten_id=false) { 125 $link = $this->get_link($seiten_id); 126 if(!$link) return array(); 127 128 // direct parental ul classes 129 $ul = $link->xpath("ancestor::ul"); 130 $parent_ul = array_pop($ul); 131 return explode(' ',$parent_ul['class']); 132 } 133 85 134 86 135 ///////////////////// INTER LANGUAGE DETECTION … … 101 150 )); 102 151 103 $link = $foreign_menu-> find_link($seiten_id);152 $link = $foreign_menu->get_link($seiten_id); 104 153 $interlinks[$lang] = $link; 105 154 } … … 217 266 return $return; 218 267 } 219 220 /**221 * Construct link class information as an array, containing:222 * - navigation list membership (in-nav-horizontal, in-nav-side)223 * - parental ul classes (in-u2, in-u3, in-geraete, ...)224 * @returns array with individual class names as strings225 **/226 function get_link_classes($seiten_id=false) {227 if($this->xml_is_defective())228 return array();229 if(!$seiten_id) $seiten_id = $this->conf['seiten_id'];230 231 $link = $this->find_link($seiten_id);232 if(!$link) return array(); // if not found233 $classes = array();234 235 // navigation list membership236 $nav = $link->xpath("ancestor::nav");237 $nav_type = $nav[0]['class'];238 $classes[] = "in-nav-$nav_type";239 240 // direct parental ul classes241 $ul = $link->xpath("ancestor::ul");242 $parent_ul = array_pop($ul);243 foreach(explode(' ',$parent_ul['class']) as $c)244 $classes[] = "in-$c";245 246 return $classes;247 }248 268 249 269 } // class -
lib/messages.php
r278 r279 91 91 'head-h1-title' => array('Zur technikum29 Startseite', 'Go to technikum29 homepage'), 92 92 'head-h1' => 'technikum29', 93 'homepage-pagename' => 'startseite', # seiten_id der startseite 93 94 94 95 'sidebar-h2-tour' => array('Museumstour', 'Museum Tour'), -
lib/template.php
r278 r279 40 40 $this->conf[$msg] = $this->conf['lang_path'] . $this->msg->_($msg); 41 41 42 // store informations about the current page 43 $this->conf['seiten_link'] = $this->menu->get_link(); 44 $this->conf['seite_in_nav'] = $this->menu->get_link_navigation_class($this->conf['seiten_link']); 45 $this->conf['seite_in_ul'] = $this->menu->get_link_ul_classes($this->conf['seiten_link']); 46 42 47 // setup body classes: 43 $this->body_classes[] = "lang-" . $this->conf['lang']; 44 $this->body_classes[] = "page-" . $this->conf['seiten_id']; 45 $this->body_classes = array_merge($this->body_classes, $this->menu->get_link_classes()); 48 $body_classprefixes = array( 49 // css prefix => configuration array value 50 'lang-' => 'lang', 51 'page-' => 'seiten_id', 52 'in-nav-' => 'seite_in_nav', 53 'in-' => 'seite_in_ul', 54 ); 55 foreach($body_classprefixes as $prefix => $key) { 56 if(is_array($this->conf[$key])) 57 // append each element of array conf values 58 foreach($this->conf[$key] as $x) 59 $this->body_classes[] = $prefix . $x; 60 elseif($this->conf[$key]) // skip null/false/empty conf values 61 $this->body_classes[] = $prefix . $this->conf[$key]; 62 } 46 63 47 64 // setup javascript configuration 48 $this->javascript_config['lang'] = $this->conf['lang']; 49 $this->javascript_config['seiten_id'] = $this->conf['seiten_id']; 65 $javascript_transfer = array('lang', 'seiten_id', 'seite_in_nav', 'seite_in_ul'); 66 foreach($javascript_transfer as $key) 67 $this->javascript_config[$key] = $this->conf[$key]; 50 68 51 69 // get all kind of relations … … 58 76 // FIXME: There is no caching check yet for this setting 59 77 // (new pagecss file won't be detected and wont purge the tmpl cache) 78 79 // setup html title 80 $this->conf['html_title'] = ''; 81 if(isset($this->conf['titel']) && !empty($this->conf['titel'])) 82 $this->conf['html_title'] = $this->conf['titel'] . ' - '; 83 elseif($this->conf['seiten_id'] == $this->msg->_('homepage-pagename')) 84 {} // nop: Startseitentitel soll nur sein "technikum29" 85 elseif($this->conf['seiten_link']) 86 // Titel vom Menu nehmen 87 $this->conf['html_title'] = $this->conf['seiten_link'] . ' - '; 88 $this->conf['html_title'] .= $this->msg->_('html-title'); 60 89 } 61 90 … … 98 127 <head> 99 128 <meta charset="utf-8"> 100 <title><?php echo isset($this->conf['titel']) ? $this->conf['titel'].' - ' : ''; $p('html-title'); ?></title>129 <title><?php echo $this->conf['html_title']; ?></title> 101 130 <meta name="description" content="Produziert am 08.01.2012"> 102 131 <meta name="author" content="Sven"> … … 233 262 <ul> 234 263 <?php 264 // only print menu when in sidebar where it applies 265 if($this->conf['seite_in_nav'] == 'side') 235 266 foreach($this->page_relations as $rel => $a) { 236 267 printf("\t<li class='%s'><a href='%s' title='%s'>%s <strong>%s</strong></a>\n",
Note: See TracChangeset
for help on using the changeset viewer.