- Timestamp:
- Sep 20, 2012, 12:18:45 AM (12 years ago)
- Location:
- lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/loader.php
r277 r301 23 23 'cache_file' => array('compressed.js', 'style.css'), 24 24 'module_dir' => array("$webroot/shared/js-v6/modules", "$webroot/shared/css-v6/modules"), 25 'page_dir' => array("$webroot/shared/js-v6/pagescripts", "$webroot/shared/css-v6/pagestyles"), 25 26 'glob_pattern' => array('*.js', '*.css'), 26 27 'content_types' => array('application/javascript', 'text/css'), -
lib/menu.php
r299 r301 5 5 * 6 6 **/ 7 8 require_once dirname(__FILE__).'/messages.php'; 9 7 10 class t29Menu { 8 11 public $conf; 9 12 public $xml; 10 13 14 // Bevor es eine ordentliche Dev-Moeglichkeit gibt: Der magische 15 // Schalter zum Ausblenden der Geraeteseiten im Menue 16 const hide_geraete_seiten = true; 17 11 18 // jeweils relativ zum lang_path 12 19 const navigation_file = 'navigation.xml'; … … 19 26 function __construct($conf_array) { 20 27 $this->conf = $conf_array; 28 29 // create a message object if not given 30 if(!isset($this->conf['msg'])) 31 $this->conf['msg'] = new t29Messages($this->conf['lang']); 21 32 22 33 // libxml: don't raise errors while parsing. … … 201 212 } 202 213 $seiten_id = $this->conf['seiten_id']; 203 214 $_ = $this->conf['msg']->get_shorthand_returner(); 215 204 216 // find wanted menu 205 217 $xml = $this->xml->xpath($xpath_menu_selection); … … 216 228 $current_li = $current_a[0]->xpath("parent::li"); 217 229 self::dom_add_class($current_li[0], 'current'); 218 self::dom_prepend_attribute($current_a, 'title', 'Aktuelle Seite', ': ');230 self::dom_prepend_attribute($current_a, 'title', $_('nav-hierarchy-current'), ': '); 219 231 220 232 $actives = $current_li[0]->xpath("ancestor-or-self::li"); … … 222 234 223 235 $ancestors = $current_li[0]->xpath("ancestor::li"); 224 array_walk($ancestors, function($i) { 225 t29Menu::dom_prepend_attribute($i->xpath("./a[1]"), 'title', 'Übergeordnete Kategorie der aktuellen Seite' , ': '); 226 }); 236 foreach($ancestors as $i) 237 t29Menu::dom_prepend_attribute($i->xpath("./a[1]"), 'title', $_('nav-hierarchy-ancestor'), ': '); 227 238 } 228 239 … … 237 248 238 249 // Geraete-Seiten entfernen 239 $geraete_uls = $xml->xpath("//ul[contains(@class, 'geraete')]"); 240 foreach($geraete_uls as $ul) { 241 $uld = dom_import_simplexml($ul); 242 $uld->parentNode->removeChild($uld); 243 } 244 250 if(self::hide_geraete_seiten) { 251 $geraete_uls = $xml->xpath("//ul[contains(@class, 'geraete')]"); 252 foreach($geraete_uls as $ul) { 253 $uld = dom_import_simplexml($ul); 254 $uld->parentNode->removeChild($uld); 255 } 256 } 245 257 246 258 if($xpath_menu_selection == self::horizontal_menu) { … … 283 295 // wenn aktuelle seite eine geraeteseite ist 284 296 if(in_array('geraete', $this->get_link_ul_classes($seiten_id))) { 285 //$return['next'] = null; // kein Link nach vorne 286 //$return['prev'] = null; // TODO: Da muss der richtige Link auf die Seite, die auf diese Extraseite verweist. 297 // pfad: a ->li->ul.geraete->li->li/a 298 $geraetelink = $current_a[0]->xpath("../../../a"); 299 if(count($geraetelink)) 300 $return['prev'] = $geraetelink[0]; 301 $return['next'] = null; // kein Link nach vorne 287 302 } else { 288 303 foreach(array( … … 304 319 $return['start'] = t29Menu::dom_new_link('#', 'bla'); 305 320 } 321 322 // Linkliste aufarbeiten: Nullen rausschmeissen (nur deko) und 323 // Links *klonen*, denn sie werden durch print_menu sonst veraendert 324 // ("Übergeordnete Kategorie der aktuellen Seite" steht dann drin) 325 // und wir wollen sie unveraendert haben. 326 foreach($return as $key => $node) { 327 if(!$node) { 328 unset($return[$key]); 329 continue; 330 } 331 $dn = dom_import_simplexml($node); 332 $dnc = simplexml_import_dom($dn->cloneNode(true)); 333 $return[$key] = $dnc; 334 } 335 306 336 return $return; 307 337 } -
lib/messages.php
r299 r301 137 137 '© 2003-2012 technikum29. You must not use contents and photographies without the permission of the owner. <a href="/en/contact.php" class="go">Legal Information</a>.'), 138 138 139 'nav-hierarchy-current' => array('Aktuelle Seite', 'Current page'), 140 'nav-hierarchy-ancestor' => array('Übergeordnete Kategorie der aktuellen Seite', 'Parental category of current page'), 139 141 'nav-rel-prev' => array('vorherige Seite', 'previous page'), 140 142 'nav-rel-next' => array('nächste Seite', 'next page'), -
lib/ressourceloader.php
r285 r301 32 32 class t29RessourceLoader { 33 33 /** 34 * expects: type, cache_file, module_dir, glob_pattern, content_types, class, modules, debug34 * expects: type, cache_file, module_dir, page_dir, glob_pattern, content_types, class, modules, debug 35 35 **/ 36 36 public $conf; … … 61 61 62 62 return new $conf['class']($conf); 63 } 64 65 function get_page_specific_urls($seiten_id) { 66 global $webroot; 67 $file = sprintf("%s/%s.%s", $this->conf['page_dir'], $seiten_id, $this->conf['type']); 68 // TODO: This is hacky. Same in get_urls. 69 $file_rel2webroot = str_replace($webroot, '', $file); 70 return file_exists($file) ? array($file_rel2webroot) : array(); 63 71 } 64 72 … … 187 195 } 188 196 } 197 198 function get_page_specific_urls($seiten_id) { 199 $urls = parent::get_page_specific_urls($seiten_id); 200 switch($seiten_id) { 201 case 'impressum': 202 $urls[] = 'http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAAraTKZ5cINardZ8ITNVssKhRcOoEBtCgYLJRQznXYEV8m1M3fRRRT9wMSvFwhyo62fD3KyiwQxe5ruw'; 203 break; 204 } 205 return $urls; 206 } 189 207 190 208 function print_header($title=null) { -
lib/template.php
r299 r301 11 11 **/ 12 12 13 require dirname(__FILE__) . "/ressourceloader.php";14 15 13 class t29Template { 16 14 public $conf, $menu, $msg; … … 34 32 require_once $this->conf['lib'].'/messages.php'; 35 33 $this->msg = new t29Messages($this->conf['lang']); 34 35 // create the ressourceloaders: 36 require_once $this->conf['lib'].'/ressourceloader.php'; 37 $this->rl = array(); 38 foreach(array('js','css') as $type) 39 $this->rl[$type] = t29RessourceLoader::create_from_type($type, $this->conf); 36 40 37 41 // fill up configuration … … 175 179 <meta name="viewport" content="width=device-width,initial-scale=1"> 176 180 <?php 177 $csslinktmpl = PHP_EOL.' <link rel="stylesheet" href="%s">'; 178 foreach($this->get_ressourceloader_links('css') as $css) 179 printf($csslinktmpl, $css); 180 181 if($this->conf['has_pagecss']) 182 printf($csslinktmpl, $this->conf['pagecss']); 181 $this->print_ressourceloader_links('css', PHP_EOL . ' <link rel="stylesheet" href="%s">'); 183 182 ?> 184 183 … … 309 308 310 309 <!-- JavaScript at the bottom for fast page loading --> 311 312 <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline --> 313 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 314 <script>window.jQuery || document.write('<script src="/shared/js-v6/libs/jquery-1.7.2.min.js"><\/script>')</script> 315 310 <script src="/shared/js-v6/libs/jquery-1.7.2.min.js"></script> 316 311 <script>window.t29={'conf': <?php print json_encode($this->javascript_config); ?>};</script> 317 312 <?php 318 foreach($this->get_ressourceloader_links('js') as $js) 319 printf(' <script src="%s"></script>'.PHP_EOL, $js); 313 $this->print_ressourceloader_links('js', ' <script src="%s"></script>'.PHP_EOL); 320 314 ?> 321 315 </body> … … 331 325 } 332 326 333 function get_ressourceloader_links($type) { 334 $rl = t29RessourceLoader::create_from_type($type, $this->conf); 335 return $rl->get_urls( isset($_GET['rl_debug']) ); 336 } 327 function print_ressourceloader_links($type, $template='<!-- RL: %s -->') { 328 $rl = $this->rl[$type]; 329 $rl_links = $rl->get_urls( isset($_GET['rl_debug']) ); 330 $rl_pagespecific_links = $rl->get_page_specific_urls($this->conf['seiten_id']); 331 332 foreach(array($rl_links, $rl_pagespecific_links) as $rls) 333 foreach($rls as $link) 334 printf($template, $link); 335 } 336 337 337 338 338 } // class t29Template
Note: See TracChangeset
for help on using the changeset viewer.