Changeset 279 in t29-www for lib


Ignore:
Timestamp:
Jul 19, 2012, 7:10:15 AM (12 years ago)
Author:
sven
Message:

Design: Linkfarben, Footerrelationslinks, Einblendlogik von Relationen.

  • menu.php: Linkdetail-Getter umgeformt
  • template.php: Mehr Daten in bodyclasses und javascriptconfig durchgeben
  • a.go-Doppelfeile, mal testweise per content-before umgesetzt
  • Relationale Navigation huebscher Formatiert, nach dem Vorschlag von Intsar vom 23.04.2012
  • Inhalts-Linkfarben mit dunkler Linkfarbe
  • menu.js: Beam nur anzeigen wenn im Inhalt, ebenso mit Relationslinks (template.php)
Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/menu.php

    r278 r279  
    7171       
    7272        ///////////////////// 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) {
    7490                if($this->xml_is_defective()) {
    7591                        return null;
    7692                }
    7793                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;
    7896
    7997                $matches = $this->xml->xpath("//a[@seiten_id='$seiten_id']");
     
    82100                        return $matches[0];
    83101                }
    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
    85134
    86135        ///////////////////// INTER LANGUAGE DETECTION
     
    101150                        ));
    102151
    103                         $link = $foreign_menu->find_link($seiten_id);
     152                        $link = $foreign_menu->get_link($seiten_id);
    104153                        $interlinks[$lang] = $link;
    105154                }
     
    217266                return $return;
    218267        }
    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 strings
    225          **/
    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 found
    233                 $classes = array();
    234                
    235                 // navigation list membership
    236                 $nav = $link->xpath("ancestor::nav");
    237                 $nav_type = $nav[0]['class'];
    238                 $classes[] = "in-nav-$nav_type";
    239                
    240                 // direct parental ul classes
    241                 $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         }
    248268
    249269} // class
  • lib/messages.php

    r278 r279  
    9191                'head-h1-title'          => array('Zur technikum29 Startseite', 'Go to technikum29 homepage'),
    9292                'head-h1'                => 'technikum29',
     93                'homepage-pagename'      => 'startseite', # seiten_id der startseite
    9394
    9495                'sidebar-h2-tour'        => array('Museumstour', 'Museum Tour'),
  • lib/template.php

    r278 r279  
    4040                        $this->conf[$msg] = $this->conf['lang_path'] . $this->msg->_($msg);
    4141
     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
    4247                // 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                }
    4663               
    4764                // 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];
    5068               
    5169                // get all kind of relations
     
    5876                // FIXME: There is no caching check yet for this setting
    5977                //        (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');
    6089        }
    6190       
     
    98127<head>
    99128  <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>
    101130  <meta name="description" content="Produziert am 08.01.2012">
    102131  <meta name="author" content="Sven">
     
    233262                <ul>
    234263                        <?php
     264                          // only print menu when in sidebar where it applies
     265                          if($this->conf['seite_in_nav'] == 'side')
    235266                                foreach($this->page_relations as $rel => $a) {
    236267                                        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.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License