errant

tom morton

Kohana Page Helper (early example)

Back to Pastebin
<?php defined('SYSPATH') or die('No direct script access.');
 
/**
 * Page helper class
 */
class page_Core {
 
    public static $a_css = array();
    public static $s_cssDir = 'content/css/';
    public static $s_title = '';
    public static $s_head = '_layout/head';
    public static $s_template = '_layout/wrapper';
    public static $s_footer = '_layout/footer';
    public static $s_theme = 'default';
 
    public static function set_theme($theme)
    {
        self::$s_theme = $theme;
    }
 
    public static function get_theme()
    {
        return self::$s_theme;
    }
 
    public static function set_title($title)
    {
        self::$s_title = $title;
    }
 
    public static function get_title()
    {
        return self::$s_title;
    }
 
    public static function add_css($css)
    {
        // normalize to an array
        if ( ! is_array($css) )
        {
            $css = array($css);
        }
 
        foreach($css as $fp)
        {
            self::$a_css[] = $fp;
        }
 
    }
 
    public static function get_css()
    {
        $s_css = '';
        foreach(self::$a_css as $css)
        {
            $s_css .= '<link rel="stylesheet" href="'.url::base().self::$s_cssDir.$css.'.css" type="text/css" media="screen" />';
        }
 
        return $s_css;
    }
 
    public static function get($view=FALSE)
    {
        if(IN_PRODUCTION == FALSE)
        {
            page::add_css('toolbar');
        }
        $template = new View(self::$s_template);
        $template->head = new View(self::$s_head);
        $template->footer = new View(self::$s_footer);
        if($view != FALSE)
        {
            $template->content = new View($view);
        }
        return $template;
    }
 
}