Changeset 851

Show
Ignore:
Timestamp:
2007-09-17 21:00:18 (12 months ago)
Author:
freakerz
Message:

First pass at implementing header and footer aggregation functions.

Theme::header() and Theme::footer() are the new functions.

They call THEME_CLASS::header() and THEME_CLASS::footer, plus:

New plugin hooks: template_header, template_footer.

New Stack names: template_stylesheet, template_header_javascript and template_footer_javascript.

-

Moved the K2 header verification for jQuery to the K2 theme.php file.

Comment/Suggestions?

Location:
trunk/htdocs
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/htdocs/system/classes/theme.php

    r849 r851  
    357357    } 
    358358     
     359     
     360    /** 
     361     * Aggregates and echos the additional header code by combining Plugins and Stack calls. 
     362     */ 
     363    public function header() { 
     364        Plugins::act( 'template_header' ); 
     365        if ( is_callable( array( THEME_CLASS, 'header' ) ) ) { 
     366            call_user_func( array( THEME_CLASS, 'header' ) ); 
     367        } 
     368        $header= Stack::get( 'template_stylesheet', ' <link rel="stylesheet" type="text/css"  href="%s" media="%s">'."\r\n" ); 
     369        $header.= Stack::get( 'template_header_javascript', ' <script src="%s" type="text/javascript"></script>'."\r\n" ); 
     370        if ( $header != '' ) { 
     371            echo $header; 
     372        } 
     373    } 
     374     
     375    /** 
     376     * Aggregates and echos the additional footer code by combining Plugins and Stack calls. 
     377     */ 
     378    public function footer() { 
     379        Plugins::act( 'template_footer' ); 
     380        if ( is_callable( array( THEME_CLASS, 'footer' ) ) ) { 
     381            call_user_func( array( THEME_CLASS, 'footer' ) ); 
     382        } 
     383        $footer= Stack::get( 'template_footer_javascript', ' <script src="%s" type="text/javascript"></script>'."\r\n" ); 
     384        if ( $footer != '' ) { 
     385            echo $footer; 
     386        } 
     387    } 
     388     
    359389    /**  
    360390     * Detects if a variable is assigned to the template engine for use in  
  • trunk/htdocs/user/themes/k2/footer.php

    r839 r851  
    1111</p> 
    1212 
     13<?php Theme::footer(); ?> 
     14 
    1315<?php 
    1416// Uncomment this to view your DB profiling info 
  • trunk/htdocs/user/themes/k2/header.php

    r814 r851  
    1313 <link rel="stylesheet" type="text/css" media="screen" href="<?php Site::out_url( 'theme' ); ?>/style.css"> 
    1414 
    15 <?php if ( $user ) { // Still needs to check for edit permissions ?> 
    16  <script type="text/javascript" src="<?php Site::out_url( 'habari' ); ?>/scripts/jquery.js"></script> 
    17 <?php } ?> 
     15<?php Theme::header() ?> 
    1816</head> 
    1917 
  • trunk/htdocs/user/themes/k2/theme.php

    r808 r851  
    6363    } 
    6464     
     65    public function header() 
     66    { 
     67        if ( $this->user instanceof User ) { 
     68            Stack::add( 'template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery' ); 
     69        } 
     70    } 
     71     
    6572} 
    6673