*/
function script($src, $type='text/javascript')
{
- $url = parse_url($src);
- if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment))
- {
- $src = common_path($src) . '?version=' . STATUSNET_VERSION;
+ if(Event::handle('StartScriptElement', array($this,&$src,&$type))) {
+ $url = parse_url($src);
+ if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment))
+ {
+ $src = common_path($src) . '?version=' . STATUSNET_VERSION;
+ }
+ $this->element('script', array('type' => $type,
+ 'src' => $src),
+ ' ');
+ Event::handle('EndScriptElement', array($this,$src,$type));
}
- $this->element('script', array('type' => $type,
- 'src' => $src),
- ' ');
}
+ /**
+ * output a script (almost always javascript) tag with inline
+ * code.
+ *
+ * @param string $code relative or absolute script path
+ * @param string $type 'type' attribute value of the tag
+ *
+ * @return void
+ */
+
+ function inlineScript($code, $type='text/javascript')
+ {
+ $this->elementStart('script', array('type' => $type));
+ $this->raw('/*<![CDATA[*/ '); // XHTML compat for Safari
+ $this->raw($code);
+ $this->raw(' /*]]>*/'); // XHTML compat for Safari
+ $this->elementEnd('script');
+ }
+
/**
* output a css link
*