*/ WBClass::load('WBHtml_JS'); /** * Add JavaScript * * This is a simple interface to WBHTML_JS * * @version 0.2.1 * @package Wombat * @subpackage patTemplate */ class patTemplate_Function_Script extends patTemplate_Function { /** * name of the function * @access private * @var string */ public $_name = 'Script'; /** * tell that this function has to be executed during runtime * @var string */ public $_type = PATTEMPLATE_FUNCTION_RUNTIME; /** * call the function * * @access public * @param array $params parameters of the function (= attributes of the tag) * @param string $content inside tag * @return string content to insert into the template */ public function call( $params, $content ) { // nothing to do if (empty($content)) { return ''; } if (!isset ($params['area'])){ $params['area'] = 'include'; } switch (strtolower($params['area'])) { case 'onload': WBHtml_JS::add($content, WBHtml_JS::AREA_ONLOAD); break; case 'code': return sprintf(WBHtml_JS::FMT_CODE, $content); break; case 'foot': WBHtml_JS::add($content, WBHtml_JS::AREA_FOOT); break; case 'include': default: $content = str_replace('.', '/', $content); $content = trim($content, '/'); WBHtml_JS::add($content, WBHtml_JS::AREA_INCLUDE); return ''; break; } return ''; } }