Created
April 28, 2009 18:11
-
-
Save BRMatt/103298 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class page_Core | |
{ | |
static $title = ''; | |
static $heading = ''; | |
static $stylesheets = array(); | |
static $scripts = array(); | |
static $inline_scripts = array(); | |
static function inline_script($script = '') | |
{ | |
if ($script === '') | |
return implode("\n", self::$inline_scripts); | |
$script = '<script>'.$script.'</script>'; | |
self::$inline_scripts[] = $script; | |
} | |
static function title($title = '', $set_heading = FALSE) | |
{ | |
if($title === '') | |
return self::$title; | |
// We want to set the title from a language var with params | |
if(is_array($title)) | |
$title = kohana::lang($title[0], array_slice($title, 1)); | |
// This is is a plain lang string... possibly | |
// if it's not kohana::lang() returns original string | |
elseif(strrpos($title, ' ') === FALSE AND strrpos($title, '.') === TRUE) | |
$title = kohana::lang($title); | |
kohana::log('debug', 'Setting page title to "'.$title.'"'); | |
self::$title = $title; | |
if($set_heading) | |
self::heading($title); | |
} | |
static function heading($heading = '') | |
{ | |
if($heading === '') | |
return self::$heading; | |
kohana::log('debug', 'Setting page heading to "'.$heading.'"'); | |
self::$heading = $heading; | |
} | |
/** | |
* Add a stylesheet to the page / Fetch all stylesheets | |
* To add a stylesheet pass the path to the stylesheet as the first | |
* paramater, with an optional second argument as the media type. | |
* | |
* To fetch all stylesheets as a concacted string, simply call | |
* the function with no parameters | |
* | |
* @return | |
* @param string $stylesheet[optional] | |
* @param string $media[optional] | |
*/ | |
static function stylesheet($stylesheet = '', $media = 'screen') | |
{ | |
if($stylesheet === '') | |
return implode("\n", self::$stylesheets); | |
self::$stylesheets[] = html::stylesheet($stylesheet, $media, FALSE); | |
} | |
/** | |
* Add a script to the page / Fetch all scripts | |
* To add a script to the page, pass the path as the first | |
* paramater | |
* | |
* To fetch all scripts as a string, call the | |
* function without a paramater | |
* | |
* @return | |
* @param string $script[optional] | |
*/ | |
static function script($script = '', $index = FALSE, $append_js = TRUE) | |
{ | |
if($script === '') | |
return implode ("\n", self::$scripts); | |
self::$scripts[] = html::script($script, $index, $append_js); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment