Changeset 560 in t29-www


Ignore:
Timestamp:
May 30, 2014, 2:35:27 AM (9 years ago)
Author:
sven
Message:

Unterstützung von externen Einbindungen, also Einbindungen
des Homepage-Layouts von Seiten außerhalb der Homepage.

  • Cache: Skip-Cache-Unterstüztung verbessert, Bugfix
  • Template: Short Open Tags vermieden, mehr Hooks (zwecks externer Einbindung)
  • WebStart: Unterstützung für external-Keyword, bei Anwesenheit wird Caching komplett unterdrückt (noch extremere Form wie bei dynamischen Seiten).
Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/cache.php

    r516 r560  
    3939        private $is_valid = null; // cache output value
    4040
    41         function __construct($debug=false, $verbose=false) {
     41        function __construct($debug=false, $verbose=false, $skip=false) {
    4242                // default values
    43                 $this->skip = isset($_GET['skip_cache']);
     43                $this->skip = isset($_GET['skip_cache']) || $skip;
    4444                $this->purge = isset($_GET['purge_cache']);
    4545                $this->debug = isset($_GET['debug_cache']) || $debug;
     
    274274                if($this->skip) {
    275275                        $this->print_info('skipped cache and cache saving.');
    276                         return; // do not save anything.
    277                 }
    278                
    279                 if(!file_exists($this->cache_file)) {
    280                         if(!self::mkdir_recursive(dirname($this->cache_file)))
    281                                 $this->print_error('Could not create recursive caching directories');
    282                 }
    283                
    284                 if(@file_put_contents($this->cache_file, $content))
    285                         $this->print_info('Wrote output cache successfully');
    286                 else
    287                         $this->print_error('Could not write page output cache to '.$this->cache_file);
     276                        //return; // do not save anything.
     277                } else {
     278                        if(!file_exists($this->cache_file)) {
     279                                if(!self::mkdir_recursive(dirname($this->cache_file)))
     280                                        $this->print_error('Could not create recursive caching directories');
     281                        }
     282                       
     283                        if(@file_put_contents($this->cache_file, $content))
     284                                $this->print_info('Wrote output cache successfully');
     285                        else
     286                                $this->print_error('Could not write page output cache to '.$this->cache_file);
     287                }
    288288
    289289                if($clear_ob_cache)
  • lib/technikum29.php

    r516 r560  
    99if(defined('T29')) return false; // no nesting
    1010define('T29', true);
     11
     12// is it an external call?
     13$external = isset($external);
    1114
    1215// at least the $seiten_id must be defined
     
    3538}
    3639
    37 // check for url rewriting neccessarity
     40// check for url rewriting neccessarity (skip at external calls)
    3841if($host->check_url_rewrite()) exit;
    3942
     
    5154
    5255// try to determine the language from the file path
    53 $lang = substr($file, 1, 2);
     56if(!isset($lang)) $lang = substr($file, 1, 2);
    5457if(!in_array($lang, array_keys($languages))) $lang = "de"; # check if language exists
    5558$lang_path = $languages[$lang][1]; # shorthand, relative to webroot. use "$webroot$lang_path" for local.
     
    5760// "AJAX" calls are our meaning for pages without chrome
    5861$ajax = isset($_GET['ajax']);
    59 if($ajax) {
     62if(!$external && $ajax) {
    6063        // print only a minimal chrome, no caching.
    6164        require "$lib/ajax-template.php";
    6265        $ajax_tmpl = new t29AJAXTemplate($GLOBALS);
    6366        $ajax_tmpl->print_page();
    64         // important: do not execute bottom code
     67        // important: do not execute code further down (Templating stuff)
    6568        return true;
    6669}
    6770
    6871require "$lib/cache.php";
     72
     73// "External" pages which are not part of the t29 website
     74if($external) {
     75        // skip caching stuff. External pages don't get in touch with
     76        // any navigation.xml or news.php etc.
     77        require "$lib/template.php";
     78        $header_cache = new t29Cache(/*debug*/false, /*verbose*/true, /*skip=memory only*/true);
     79        $footer_cache = new t29Cache(/*debug*/false, /*verbose*/true, /*skip=memory only*/true);
     80        $tmpl = new t29Template($GLOBALS);
     81        $tmpl->create_separate_caches($header_cache, $footer_cache);
     82        // important: do not execute caching stuff below
     83        return true;
     84}
    6985
    7086$page_cache = new t29Cache(false, true); // debug, verbose
  • lib/template.php

    r541 r560  
    5252                $this->log = t29Log::get();
    5353               
    54                 // create a menu:
     54                // create a menu, if not given:
    5555                require_once $this->conf['lib'].'/menu.php';
    56                 $this->menu = new t29Menu($this->conf);
     56                $this->menu = isset($this->conf['menu']) ? $this->conf['menu'] : new t29Menu($this->conf);
    5757
    5858                // create localisation class:
     
    7171                if(!isset($this->conf['header_prepend']))
    7272                        $this->conf['header_prepend'] = array(); // list
     73                elseif(is_string($this->conf['header_prepend']))
     74                        $this->conf['header_prepend'] = array($this->conf['header_prepend']); // string to list
    7375
    7476                // ask t29Host for configuration fillup
     
    229231        foreach($this->conf['header_prepend'] as $h) print $h."\n  ";
    230232       
    231         if($this->conf['ajax']) print "\n  <meta name='t29.ajax' content='true'>";
     233        $indicators = array('ajax', 'external');
     234        foreach($indicators as $key)
     235                if($this->conf[$key]) print "\n  <meta name='t29.$key' content='true'>";
    232236 
    233237        if(isset($this->conf['version'])) printf('<meta name="t29.version" content="%s">', $this->conf['version']);
     
    311315                       
    312316                        <h2 class="visuallyhidden"><?php $p("sidebar-h2-tour"); ?></h2>
    313                         <nav class="side">
    314                                 <?php $this->menu->print_menu(t29Menu::sidebar_menu, $this->conf['host']); ?>
     317                        <?php
     318                                $sidebar_contains_menu  = !isset($this->conf['sidebar_content']);
     319                        ?>
     320                        <nav class="side <?php print $sidebar_contains_menu ? 'contains-menu' : 'contains-custom'; ?>">
     321                                <?php
     322                                        if(!$sidebar_contains_menu)
     323                                                // used in external page calls
     324                                                print $this->conf['sidebar_content'];
     325                                        else
     326                                                $this->menu->print_menu(t29Menu::sidebar_menu, $this->conf['host']);
     327                                ?>
    315328                        </nav>
    316                         <!-- menu changing buttons are made with javascript -->
     329                        <!-- menu changing buttons are made with javascript, but -->
    317330        </section>
    318331        <section class="sidebar bottom">
     
    324337                <h2 class="visuallyhidden"><?php $p("sidebar-h2-mainnav"); ?></h2>
    325338                <nav class="horizontal">
    326                         <?php $this->menu->print_menu(t29Menu::horizontal_menu, $this->conf['host']); ?>
     339                        <?php
     340                                if(isset($this->conf['mainnav_content']))
     341                                        // used in external page calls
     342                                        print $this->conf['mainnav_content'];
     343                                else
     344                                        $this->menu->print_menu(t29Menu::horizontal_menu, $this->conf['host']);
     345                        ?>
    327346                </nav>
    328347                <nav class="top">
     
    365384                                <span class="no-js"><?php $p('topnav-search-label'); ?>:</span>
    366385                                <input type="text" value="" data-defaultvalue="<?php $p('topnav-search-label'); ?>" name="q" class="text">
    367                                 <input type="submit" value="<? $p('topnav-search-label'); ?>" class="button">
     386                                <input type="submit" value="<?php $p('topnav-search-label'); ?>" class="button">
    368387                        </form>
    369388                </nav>
     
    381400               
    382401        ?>
    383     <footer class="in-sheet <? if(!$print_footer_menu) print "empty-footer"; ?>">
     402    <footer class="in-sheet <?php if(!$print_footer_menu) print "empty-footer"; ?>">
    384403                <nav class="guide">
    385404                        <!-- hier wird nav.side die Liste per JS reinkopiert -->
     
    438457</div><!-- end of div id="footer-background-container" helper -->
    439458
    440   <? /* JavaScript at the bottom for fast page loading */ ?>
     459  <?php /* JavaScript at the bottom for fast page loading */ ?>
    441460  <script src="/shared/js-v6/libs/jquery-1.7.2.min.js"></script>
    442461  <script>window.t29={'conf': <?php print json_encode($this->javascript_config); ?>};</script>
     
    444463        $this->print_ressourceloader_links('js', '  <script src="%s"></script>'.PHP_EOL);
    445464  ?>
    446   <? /* Piwik Noscript, Script selbst wird asynchron im JS-Bereich aufgerufen */ ?>
    447   <noscript><img src="<? $p("js-piwik-noscript-imgsrc"); ?>" alt="" /></noscript>
     465  <?php /* Piwik Noscript, Script selbst wird asynchron im JS-Bereich aufgerufen */ ?>
     466  <noscript><img src="<?php $p("js-piwik-noscript-imgsrc"); ?>" alt="" /></noscript>
     467  <?php
     468        if(isset($this->conf['body_append']))
     469                print $this->conf['body_append'];
     470  ?>
    448471</body>
    449472</html>
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