Source for file Header.class.php
Documentation is available at Header.class.php
* Gumbo Library Framework
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* Special Template Header Class
* This class will represent the Header. If using HTML, it provides methods for
* adding Stylesheets and JavaScript dynamically. This will format two Template
* variables 'header_styles' and 'header_javascript'.
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* @desc Special Template Header Class
gumbo_load ("Interface_Singleton");
gumbo_load ("Template_Special");
/** @var Gumbo_Template_Header $_instance */
private static $_instance =
null;
/** @var Gumbo_Interface_List $_styles list of extra stylesheets */
/** @var Gumbo_Interface_List $_javascript list of javascript files */
* @return Gumbo_Interface_Special_Header
if (self::$_instance ==
null) {
self::$_instance =
new Gumbo_Template_Header ();
* Returns the formatted text to the browser
* @param bool $reload reloads the output
public function fetch ($reload=
false) {
$txt .=
"\t<link href=\"" .
gumbo_appendLocation ($style ['url']) .
$style ['file'] .
"\" rel=\"stylesheet\" type=\"text/css\" media=\"" .
$style ['media'] .
"\" />\n";
$this->assign ("header_styles", $txt);
$txt .=
"\t<script type=\"text/javascript\" ";
$txt .=
"src=\"{$js ['js']}\" />";
$txt .=
">{$js ['js']}</style>";
$this->assign ("header_javascript", $txt);
* Adds a style sheet (path not necessary)
* @param string $file file name of the style sheet
* @param string $media media type (screen|print|etc.)
* @param string $url URL to style sheet
* @throws Gumbo_Exception
public function addStyle ($file, $media=
null, $url=
null) {
$e->setFunction (__METHOD__
);
if (is_null ($media)) { $media =
"screen"; }
case "projection" :
break;
default : throw
new Gumbo_Exception ("Invalid Media Value [all|screen|print|handheld|projection|tty|tv|braille|aural]: {$media}");
$this->getStyles ()->add (array ("file"=>
$file, "media"=>
$media, "url"=>
$url));
$e->setFunction (__METHOD__
);
* Adds Javascript to the Header
* @param string $js file name or javascript text
$e->setFunction (__METHOD__
);
$this->getJavascript ()->add (array ("js"=>
$js, "file"=>
$as_string));
$e->setFunction (__METHOD__
);
* Returns the extra style sheets to include in the template file
* @return Gumbo_Interface_List
* Returns any Javascript Files
* @return Gumbo_Interface_List