-
log->print_all();
// All log entries generated until final processing will be flushed out at the
// end; a userspace javascript helper will then move them here.
?>
conf will be set up from the * former global namespace. For correct working, at least some global vars * like * $lib * $lang * $host * ... * are considered as present (see above for a list). * **/ function __construct($conf_array) { $this->conf = $conf_array; // fetch the lightweight logging object: require_once $this->conf['lib'].'/logging.php'; $this->log = t29Log::get(); // create a menu, if not given: require_once $this->conf['lib'].'/menu.php'; $this->menu = isset($this->conf['menu']) ? $this->conf['menu'] : new t29Menu($this->conf); // create localisation class: require_once $this->conf['lib'].'/messages.php'; $this->msg = new t29Messages($this->conf['lang']); // create the ressourceloaders: require_once $this->conf['lib'].'/ressourceloader.php'; $this->rl = array(); foreach(array('js','css') as $type) $this->rl[$type] = t29RessourceLoader::create_from_type($type, $this->conf); // fill up configuration // optional html headers which can be filled by hooks or parts if(!isset($this->conf['header_prepend'])) $this->conf['header_prepend'] = array(); // list elseif(is_string($this->conf['header_prepend'])) $this->conf['header_prepend'] = array($this->conf['header_prepend']); // string to list // optional body css classes which can be filled by hooks or parts if(!isset($this->conf['body_classes_append'])) $this->conf['body_classes_append'] = array(); // ask t29Host for configuration fillup $this->conf['host']->fillup_template_conf($this->conf); $this->body_classes += $this->conf['body_classes_append']; // Path names in messages foreach(array('footer-legal-file', 'topnav-search-page') as $msg_id) $this->msg->set($msg_id, $this->conf['lang_path'].$this->msg->_($msg_id)); // store informations about the current page $this->conf['seiten_link'] = $this->menu->get_link(); $this->conf['seite_in_nav'] = $this->menu->get_link_navigation_class($this->conf['seiten_link']); $this->conf['seite_in_ul'] = $this->menu->get_link_ul_classes($this->conf['seiten_link']); // setup body classes: $body_classprefixes = array( // css prefix => configuration array value 'lang-' => 'lang', 'page-' => 'seiten_id', 'in-nav-' => 'seite_in_nav', 'in-' => 'seite_in_ul', ); foreach($body_classprefixes as $prefix => $key) { if(is_array($this->conf[$key])) // append each element of array conf values foreach($this->conf[$key] as $x) $this->body_classes[] = $prefix . $x; elseif($this->conf[$key]) // skip null/false/empty conf values $this->body_classes[] = $prefix . $this->conf[$key]; } // setup javascript configuration $javascript_transfer = array('lang', 'seiten_id', 'seite_in_nav', 'seite_in_ul'); foreach($javascript_transfer as $key) $this->javascript_config[$key] = $this->conf[$key]; // also collect data from other classes, e.g. t29Host: $this->javascript_config['web_prefix'] = $this->conf['host']->web_prefix; // get all kind of relations. Pages can afterwards be overwritten with t29Template // methods (see below). $this->page_relations = $this->menu->get_page_relations(); $this->interlang_links = $this->menu->get_interlanguage_link(); $this->current_link_classes = $this->menu->get_link_classes(); // as a service for CSS, show all link classes in the body // (added quite lately in dec 2016 as a patchy way to tag pages) $this->body_classes = array_merge($this->current_link_classes, $this->body_classes); // 2017-06-26: Another design review, this time by switching between CSS classes. $this->body_classes[] = "design-2017-06-26"; // check and load additional css. // #51: This is now checked by the site caching in technikum29.php. $this->conf['pagecss'] = $this->conf['host']->ressources_get_pagestyle($this->conf['seiten_id']); $this->conf['has_pagecss'] = file_exists($this->conf['webroot'].$this->conf['pagecss']); // setup html title $this->conf['html_title'] = ''; if(isset($this->conf['titel']) && !empty($this->conf['titel'])) $this->conf['html_title'] = $this->conf['titel'] . ' - '; // Startseite macht ihren Titel jetzt selbst (SEO): //elseif($this->conf['seiten_id'] == $this->msg->_('homepage-pagename')) // {} // nop: Startseitentitel soll nur sein "technikum29" elseif($this->conf['seiten_link']) // Titel vom Menu nehmen $this->conf['html_title'] = $this->conf['seiten_link'] . ' - '; $this->conf['html_title'] .= $this->msg->_('html-title'); // Unfortunately mostly a t29Template instance won't be visible to a page // handled by technikum29.php. Therefore there is this small "future" trick: if(isset($this->conf['template_callback'])) $this->conf['template_callback']($this); // Now you can use code like // $template_callback = function($template) { // $template->set_page_relation("next", "/de/example", "foo"); // $template->menu->... read and modify anything ... etc // } // so the callback function is called at the end of the template constructor. // This can be considered whenever giving a static configuration variables // is not enough. } /** * Overwrite the page relations given by the t29Menu. * By setting $relation to "prev" or "next", you can overwrite the * relations which has been set up by construction by $this->menu->get_page_relations(). * Thus any page can state any relations. For sure they are only one-directional, * the other pages don't know anything about such relations because no vice-versa * introspection can be done. **/ function set_page_relation($relation, $href, $label) { // good values for $relation are: "prev", "next". // Link is composed as $label. $this->page_relations[$relation] = t29Menu::dom_new_link($href, $label); //print_r($this->page_relations); } /** * Overwrite the interlanguage link list given by the t29Menu. * This does the same as set_page_relation() only for interlanguage links. **/ function set_interlang_link($lang, $href, $label) { // good values for $lang are: "de", "en". // Link is composed as $label. $this->interlang_links[$lang] = t29Menu::dom_new_link($href, $label); } /** * Main caching and output system. * Parameters (global configuration): * skip_cache - if true, skips writing output to cache file * purge_cache - if true, forces creation of new cache file * (does not change behaviour of this file's code) **/ function create_cache($cache_object) { $cache_object->start_cache(array( 'shutdown_func' => array($this, 'print_footer'), // print the footer with it 'filter_func' => $this->conf['host']->has_web_prefix ? array($this, 'rewrite_page_prefix_links') : null, // Entrypoint for URL and content rewriting! )); // directly start header printing $this->print_header(); } /** * Write header and footer in separate cache files. **/ function create_separate_caches($header_cache, $footer_cache) { $header_cache->start_cache(array( // start with no shutdown, filter, nor writing 'filter_func' => $this->conf['host']->has_web_prefix ? array($this, 'rewrite_page_prefix_links') : null, 'write_cache' => false, )); $this->print_header(); $header_cache->write_cache(); // will also print out header immediately. $footer_cache->start_cache(array( // start with no shutdown, filter, nor writing 'filter_func' => $this->conf['host']->has_web_prefix ? array($this, 'rewrite_page_prefix_links') : null, 'write_cache' => false, )); $this->print_footer(); $footer_content = $footer_cache->write_cache(null, true); // don't print footer immediately. // print footer on exit. register_shutdown_function(function() use ($footer_content) { print $footer_content; }); } function print_header() { $p = $this->msg->get_shorthand_printer(); // t29Messages gettext printer $_ = $this->msg->get_shorthand_returner(); // t29Messages gettext $href = $this->conf['host']->get_shorthand_link_returner(); // t29Host link rewriter ?>