All pastes #506906 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-05-24 08:37 UTC
rendered paste body
class YahooJavascriptLoaderFilter extends AgaviFilter implements AgaviIFilter, AgaviIGlobalFilter
{
    function executeOnce(AgaviFilterChain $fc, AgaviExecutionContainer $cont)
    {
        $fc->execute($cont);

        $html = $cont->getResponse()->getContent();
        $req = $this->context->getRequest();

        $deps = $req->getAttribute('deps', 'xxx.layout.yahoo');

        $js_dependencies = @array_unique($deps);

        if ($js_dependencies && is_array($js_dependencies))
        {
            $r = $this->getContext()->getRouting();
            $include = '';
            foreach($js_dependencies as $dep)
                $include .= '<script src="js/yui/' . $dep . '.js" type="text/javascript"></script>
' . "\n";
            $html = str_replace('%%JS_INCLUDE%%', $include, $html);
        }
        else
            $include = '';

        $html = str_replace('%%JS_INCLUDE%%', $include, $html);
        $cont->getResponse()->setContent($html);
    }
}