[ Index ]
 

Code source de Symfony 1.0.0

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

title

Body

[fermer]

/lib/filter/ -> sfFillInFormFilter.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   * sfFillInFormFilter fills in forms.
  13   *
  14   * @package    symfony
  15   * @subpackage filter
  16   * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
  17   * @version    SVN: $Id: sfFillInFormFilter.class.php 3244 2007-01-12 14:46:11Z fabien $
  18   */
  19  class sfFillInFormFilter 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      $context  = $this->getContext();
  32      $response = $context->getResponse();
  33      $request  = $context->getRequest();
  34  
  35      $fillInForm = new sfFillInForm();
  36  
  37      // converters
  38      foreach ($this->getParameter('converters', array()) as $functionName => $fields)
  39      {
  40        $fillInForm->addConverter($functionName, $fields);
  41      }
  42  
  43      // skip fields
  44      $fillInForm->setSkipFields((array) $this->getParameter('skip_fields', array()));
  45  
  46      // types
  47      $excludeTypes = (array) $this->getParameter('exclude_types', array('hidden', 'password'));
  48      $checkTypes   = (array) $this->getParameter('check_types',   array('text', 'checkbox', 'radio', 'password', 'hidden'));
  49      $fillInForm->setTypes(array_diff($checkTypes, $excludeTypes));
  50  
  51      // fill in
  52      $method  = 'fillIn'.ucfirst(strtolower($this->getParameter('content_type', 'Html')));
  53  
  54      try
  55      {
  56        $content = $fillInForm->$method($response->getContent(), $this->getParameter('name'), $this->getParameter('id'), $request->getParameterHolder()->getAll());
  57        $response->setContent($content);
  58      }
  59      catch (sfException $e)
  60      {
  61        if (sfConfig::get('sf_logging_enabled'))
  62        {
  63          $this->getContext()->getLogger()->err(sprintf('{sfFilter} %s', $e->getMessage()));
  64        }
  65      }
  66    }
  67  }


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