[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/filter/ -> sfCommonFilter.class.php (source)

   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: sfCommonFilter.class.php 3244 2007-01-12 14:46:11Z fabien $
  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  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7