Development

/branches/1.2/lib/plugins/sfCompat10Plugin/lib/filter/sfFillInFormFilter.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/plugins/sfCompat10Plugin/lib/filter/sfFillInFormFilter.class.php

Revision 5320, 1.9 kB (checked in by fabien, 7 years ago)

moved validators and fill-in classes to sfCompat10Plugin

  • 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  * sfFillInFormFilter fills in forms.
13  *
14  * @package    symfony
15  * @subpackage filter
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
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     $response = $this->context->getResponse();
32     $request  = $this->context->getRequest();
33
34     $fillInForm = new sfFillInForm();
35
36     // converters
37     foreach ($this->getParameter('converters', array()) as $functionName => $fields)
38     {
39       $fillInForm->addConverter($functionName, $fields);
40     }
41
42     // skip fields
43     $fillInForm->setSkipFields((array) $this->getParameter('skip_fields', array()));
44
45     // types
46     $excludeTypes = (array) $this->getParameter('exclude_types', array('hidden', 'password'));
47     $checkTypes   = (array) $this->getParameter('check_types',   array('text', 'checkbox', 'radio', 'password', 'hidden'));
48     $fillInForm->setTypes(array_diff($checkTypes, $excludeTypes));
49
50     // fill in
51     $method = 'fillIn'.ucfirst(strtolower($this->getParameter('content_type', 'Html')));
52
53     try
54     {
55       $content = $fillInForm->$method($response->getContent(), $this->getParameter('name'), $this->getParameter('id'), $request->getParameterHolder()->getAll());
56       $response->setContent($content);
57     }
58     catch (sfException $e)
59     {
60       if (sfConfig::get('sf_logging_enabled'))
61       {
62         $this->context->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array($e->getMessage(), 'priority' => sfLogger::ERR)));
63       }
64     }
65   }
66 }
67
Note: See TracBrowser for help on using the browser.