protected function _tagBuilder($tagType, $args = array())
{
$arg = current($args);
if (empty($arg) || $arg === '') {
$errorMsg = 'Missing argument for ' . __CLASS__ . '::' . $tagType . '()';
trigger_error($errorMsg, E_USER_WARNING);
}
if (is_array($arg)) {
foreach ($arg as $thisArg) {
$return[] = $this->_tagBuilder($tagType, array($thisArg));
}
$return = implode(PHP_EOL, $return);
} else {
switch ($tagType) {
case 'js':
case 'jsSingleton':
case 'css':
//Optional extra argument to define CSS media type
//Optional extra argument to define CSS media type
case 'cssSingleton':
case 'jqueryTheme':
if ($tagType == 'jqueryTheme') {
$arg = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/' . str_replace(' ', '-', strtolower($arg)) . '/jquery-ui.css';
$tagType = 'css';
}
if (!isset($this->_includedFiles[$tagType][$arg])) {
if ($tagType == 'css' || $tagType == 'cssSingleton') {
$return = '<link rel="stylesheet" type="text/css" href="' . $arg . '"' . ' media="' . (isset($args[1]) ? $args[1] : 'all') . '" />';
} else {
$return = '<script type="text/javascript" src="' . $arg . '"></script>';
}
$this->_includedFiles[$tagType][$arg] = true;
} else {
$return = null;
if (DEBUG_MODE && ($tagType == 'js' || $tagType == 'css')) {
debug::log($arg . $tagType . ' file has already been included', 'warn');
}
}
break;
case 'cssInline':
//Optional extra argument to define CSS media type
$return = '<style type="text/css" media="' . (isset($args[1]) ? $args[1] : 'all') . '">' . PHP_EOL . '/*<![CDATA[*/' . PHP_EOL . '<!--' . PHP_EOL . $arg . PHP_EOL . '//-->' . PHP_EOL . '/*]]>*/' . PHP_EOL . '</style>';
break;
case 'jsInline':
$return = '<script type="text/javascript">' . PHP_EOL . '//<![CDATA[' . PHP_EOL . '<!--' . PHP_EOL . $arg . PHP_EOL . '//-->' . PHP_EOL . '//]]>' . PHP_EOL . '</script>';
break;
case 'jsInlineSingleton':
//Optional extra argument to supress adding of inline JS/CSS wrapper
//Optional extra argument to supress adding of inline JS/CSS wrapper
case 'cssInlineSingleton':
$tagTypeBase = substr($tagType, 0, -15);
$return = null;
$md5 = md5($arg);
if (!isset($this->{'_' . $tagTypeBase . 'Singleton'}[$md5])) {
$this->{'_' . $tagTypeBase . 'Singleton'}[$md5] = true;
if (!$this->_bodyOpen) {
$this->vorkHead[$tagTypeBase . 'Inline'][] = $arg;
} else {
$return = !isset($args[1]) || !$args[1] ? $this->{$tagTypeBase . 'Inline'}($arg) : $arg . PHP_EOL;
}
}
break;
case 'div':
case 'li':
case 'p':
case 'h1':
case 'h2':
case 'h3':
case 'h4':
$return = '<' . $tagType . '>' . $arg . '</' . $tagType . '>';
break;
default:
$errorMsg = 'TagType ' . $tagType . ' not valid in ' . __CLASS__ . '::' . __METHOD__;
throw new Exception($errorMsg);
break;
}
}
return $return;
}