| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
class sfFillInFormFilter extends sfFilter |
|---|
| 23 |
{ |
|---|
| 24 |
|
|---|
| 25 |
* Executes this filter. |
|---|
| 26 |
* |
|---|
| 27 |
* @param sfFilterChain A sfFilterChain instance |
|---|
| 28 |
*/ |
|---|
| 29 |
public function execute($filterChain) |
|---|
| 30 |
{ |
|---|
| 31 |
|
|---|
| 32 |
$filterChain->execute(); |
|---|
| 33 |
|
|---|
| 34 |
$response = $this->context->getResponse(); |
|---|
| 35 |
$request = $this->context->getRequest(); |
|---|
| 36 |
|
|---|
| 37 |
$fillInForm = new sfFillInForm(); |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
foreach ($this->getParameter('converters', array()) as $functionName => $fields) |
|---|
| 41 |
{ |
|---|
| 42 |
$fillInForm->addConverter($functionName, $fields); |
|---|
| 43 |
} |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
$fillInForm->setSkipFields((array) $this->getParameter('skip_fields', array())); |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
$excludeTypes = (array) $this->getParameter('exclude_types', array('hidden', 'password')); |
|---|
| 50 |
$checkTypes = (array) $this->getParameter('check_types', array('text', 'checkbox', 'radio', 'password', 'hidden')); |
|---|
| 51 |
$fillInForm->setTypes(array_diff($checkTypes, $excludeTypes)); |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
$method = 'fillIn'.ucfirst(strtolower($this->getParameter('content_type', 'Html'))); |
|---|
| 55 |
|
|---|
| 56 |
try |
|---|
| 57 |
{ |
|---|
| 58 |
$content = $fillInForm->$method($response->getContent(), $this->getParameter('name'), $this->getParameter('id'), $request->getParameterHolder()->getAll()); |
|---|
| 59 |
$response->setContent($content); |
|---|
| 60 |
} |
|---|
| 61 |
catch (sfException $e) |
|---|
| 62 |
{ |
|---|
| 63 |
if (sfConfig::get('sf_logging_enabled')) |
|---|
| 64 |
{ |
|---|
| 65 |
$this->context->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array($e->getMessage(), 'priority' => sfLogger::ERR))); |
|---|
| 66 |
} |
|---|
| 67 |
} |
|---|
| 68 |
} |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|