Development

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

You must first sign up to be able to contribute.

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

Revision 3244, 1.6 kB (checked in by fabien, 7 years ago)

updated lib/filter/ directory phpdoc

  • 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 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->getContext()->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 (!$response->getParameter('javascripts_included', false, 'symfony/view/asset'))
41       {
42         $html .= get_javascripts($response);
43       }
44       if (!$response->getParameter('stylesheets_included', false, 'symfony/view/asset'))
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     $response->setParameter('javascripts_included', false, 'symfony/view/asset');
56     $response->setParameter('stylesheets_included', false, 'symfony/view/asset');
57   }
58 }
59
Note: See TracBrowser for help on using the browser.