Exemple #1
0
 public function __construct($inputSource, $definition, $characterEncoding = null, $inputData = null, $useOverride = false)
 {
     if (($returnValue = ezcInputForm::validateDefinition($definition)) !== true) {
         throw new ezcInputFormInvalidDefinitionException($returnValue[1]);
     }
     $this->definition = $definition;
     $this->inputSource = $inputSource;
     $this->inputData = $inputData;
     if ($inputData === null || count($inputData) == 0) {
         $this->parseInput();
     } else {
         $this->parseInputFromData($useOverride);
     }
 }
Exemple #2
0
 /**
  * Constructs a new ezcInputForm for $inputSource with $definition.
  *
  * This method constructs a new ezcInputForm with three parameters. The
  * $inputSource parameter selects the input source and should be one of the
  * constants INPUT_GET, INPUT_POST or INPUT_COOKIE. The $definition
  * parameter is an array of ezcInputFormDefinitionElement items and
  * determines which input variables make up this form (see the example at
  * the top of this class). The last parameter, $characterEncoding is the
  * character encoding to use while retrieving input variable data. This
  * parameter has currently no function as it will depend on PHP 6
  * functionality which does not exist yet in the input filter extension.
  *
  * @throws ezcInputFormVariableMissingException when one of the required
  *         input variables is missing.
  * @throws ezcInputFormInvalidDefinitionException when the definition array
  *         is invalid or when the input source was invalid.
  *
  * @param int $inputSource
  * @param array(ezcInputFormDefinitionElement) $definition
  * @param string $characterEncoding
  */
 public function __construct($inputSource, $definition, $characterEncoding = null)
 {
     if (($returnValue = ezcInputForm::validateDefinition($definition)) !== true) {
         throw new ezcInputFormInvalidDefinitionException($returnValue[1]);
     }
     $this->definition = $definition;
     $this->inputSource = $inputSource;
     $this->parseInput();
 }
Exemple #3
0
 public function testValidateDefinitionFieldName()
 {
     // The input field name should have a sane format
     $def = array('test' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'int'));
     self::assertEquals(true, ezcInputForm::validateDefinition($def));
     $def = array('' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'int'));
     self::assertEquals(array(ezcInputForm::DEF_FIELD_NAME_BROKEN, "The element name '' has an unsupported format. It should start with an a-z and followed by a-z0-9_"), ezcInputForm::validateDefinition($def));
     $def = array('^*(68769' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'int'));
     self::assertEquals(array(ezcInputForm::DEF_FIELD_NAME_BROKEN, "The element name '^*(68769' has an unsupported format. It should start with an a-z and followed by a-z0-9_"), ezcInputForm::validateDefinition($def));
     $def = array('foobar_42' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'int'));
     self::assertEquals(true, ezcInputForm::validateDefinition($def));
 }