1. sfCommonFilter.class.php
  2. /** * sfCommonFilter automatically adds javascripts and stylesheets information in the sfResponse content. * * @package symfony * @subpackage filter * @author Fabien Potencier * @version SVN: $Id$ */
  3. class sfCommonFilter extends sfFilter
  4. {
  5. /**
  6. * Executes this filter.
  7. *
  8. * @param sfFilterChain $filterChain A sfFilterChain instance
  9. */
  10. public function execute($filterChain)
  11. {
  12. // execute next filter
  13. $filterChain->execute();
  14. // execute this filter only once
  15. $response = $this->context->getResponse();
  16. // include javascripts and stylesheets
  17. $content = $response->getContent();
  18. if (false !== ($pos = strpos($content, '</head>')))
  19. {
  20. $this->context->getConfiguration()->loadHelpers(array('Tag', 'Asset'));
  21. $html = '';
  22. if (!sfConfig::get('symfony.asset.javascripts_included', false))
  23. {
  24. $html .= get_javascripts($response);
  25. }
  26. if (!sfConfig::get('symfony.asset.stylesheets_included', false))
  27. {
  28. $html .= get_stylesheets($response);
  29. }
  30. if ($html)
  31. {
  32. $response->setContent(substr($content, 0, $pos).$html.substr($content, $pos));
  33. }
  34. }
  35. sfConfig::set('symfony.asset.javascripts_included', false);
  36. sfConfig::set('symfony.asset.stylesheets_included', false);
  37. }
  38. }

Debug toolbar