Development

/branches/1.1/lib/filter/sfCommonFilter.class.php

You must first sign up to be able to contribute.

root/branches/1.1/lib/filter/sfCommonFilter.class.php

Revision 9087, 1.6 kB (checked in by Carl.Vondrick, 6 years ago)

1.1: fixed phpdoc to fit specs in filter (refs #2991)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * sfCommonFilter automatically adds javascripts and stylesheets information in the sfResponse content.
13  *
14  * @package    symfony
15  * @subpackage filter
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
18  */
19 class sfCommonFilter extends sfFilter
20 {
21   /**
22    * Executes this filter.
23    *
24    * @param sfFilterChain $filterChain A sfFilterChain instance
25    */
26   public function execute($filterChain)
27   {
28     // execute next filter
29     $filterChain->execute();
30
31     // execute this filter only once
32     $response = $this->context->getResponse();
33
34     // include javascripts and stylesheets
35     $content = $response->getContent();
36     if (false !== ($pos = strpos($content, '</head>')))
37     {
38       sfLoader::loadHelpers(array('Tag', 'Asset'));
39       $html = '';
40       if (!sfConfig::get('symfony.asset.javascripts_included', false))
41       {
42         $html .= get_javascripts($response);
43       }
44       if (!sfConfig::get('symfony.asset.stylesheets_included', false))
45       {
46         $html .= get_stylesheets($response);
47       }
48
49       if ($html)
50       {
51         $response->setContent(substr($content, 0, $pos).$html.substr($content, $pos));
52       }
53     }
54
55     sfConfig::set('symfony.asset.javascripts_included', false);
56     sfConfig::set('symfony.asset.stylesheets_included', false);
57   }
58 }
59
Note: See TracBrowser for help on using the browser.