Changeset 1323
- Timestamp:
- 02/03/08 21:29:43 (7 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubAbstractFilterAnnotation.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubAbstractStringFilterAnnotation.php (added)
- trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubStringFilterAnnotation.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubTextFilterAnnotation.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/broker/stubRequestBroker.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubAbstractFilter.php (deleted)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubAbstractFilterDecorator.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubAbstractStringFilter.php (deleted)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubDefaultValueFilterDecorator.php (added)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubEncodingFilterDecorator.php (added)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubFilter.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubFloatFilter.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubHTTPURLFilter.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubHtmlOutputFilter.php (deleted)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubIntegerFilter.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubLengthFilterDecorator.php (added)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubMD5Filter.php (deleted)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubMailFilter.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubNumberFilter.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubPassThruFilter.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubPasswordFilter.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubRegexChangeFilterDecorator.php (moved) (moved from trunk/src/main/php/net/stubbles/ipo/request/filters/stubRegexFilterDecorator.php) (2 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubRegexCheckFilterDecorator.php (added)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubRequiredFilterDecorator.php (added)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubSimpleStringFilter.php (deleted)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubStrategyFilterDecorator.php (added)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubStringFilter.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/request/filters/stubTextFilter.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/stubAbstractRequest.php (modified) (5 diffs)
- trunk/src/main/php/net/stubbles/ipo/request/stubRequest.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisProcessor.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/ipo/IPOTestSuite.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubAbstractFilterAnnotationTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubAbstractStringFilterAnnotationTestCase.php (added)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubFloatFilterAnnotationTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubHTTPURLFilterAnnotationTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubIntegerFilterAnnotationTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubMailFilterAnnotationTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubPasswordFilterAnnotationTestCase.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubStringFilterAnnotationTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/broker/annotations/stubTextFilterAnnotationTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubAbstractFilterDecoratorTestCase.php (added)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubDefaultValueFilterDecoratorTestCase.php (added)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubEncodingFilterDecoratorTestCase.php (added)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubFloatFilterTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubHTTPURLFilterTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubIntegerFilterTestCase.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubLengthFilterDecoratorTestCase.php (added)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubMD5FilterTestCase.php (deleted)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubNumberFilterTestCase.php (added)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubPassThruFilterTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubPasswordFilterTestCase.php (modified) (7 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubRegexChangeFilterDecoratorTestCase.php (moved) (moved from trunk/src/test/php/net/stubbles/ipo/request/filters/stubRegexFilterDecoratorTestCase.php) (5 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubRegexCheckFilterDecoratorTestCase.php (added)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubRequiredFilterDecoratorTestCase.php (added)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubStrategyFilterDecoratorTestCase.php (added)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubStringFilterTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/filters/stubTextFilterTestCase.php (modified) (6 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/stubAbstractRequestTestCase.php (modified) (8 diffs)
- trunk/src/test/php/net/stubbles/ipo/request/stubRequestPrefixDecoratorTestCase.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubAbstractFilterAnnotation.php
r1307 r1323 33 33 */ 34 34 protected $rveFactoryClass; 35 /** 36 * the created rve factory 37 * 38 * @var stubRequestValueErrorFactory 39 */ 40 protected $rveFactory = null; 35 41 /** 36 42 * switch whether the value is required or not … … 125 131 { 126 132 $filter = $this->doGetFilter(); 127 $filter->setRequired($this->isRequired); 128 $filter->setDefaultValue($this->defaultValue); 133 if (true === $this->isRequired) { 134 $filter = new stubRequiredFilterDecorator($filter, $this->createRVEFactory()); 135 } 136 137 if (null !== $this->defaultValue) { 138 $filter = new stubDefaultValueFilterDecorator($filter, $this->defaultValue); 139 } 140 129 141 return $filter; 130 142 } … … 146 158 protected function createRVEFactory() 147 159 { 160 if (null !== $this->rveFactory) { 161 return $this->rveFactory; 162 } 163 148 164 if (null != $this->rveFactoryClass) { 149 165 $rveFactory = $this->rveFactoryClass->newInstance(); … … 151 167 throw new stubRequestBrokerException('Created request value error factory is not an instance of stubRequestValueErrorFactory'); 152 168 } 169 170 $this->rveFactory = $rveFactory; 153 171 } else { 154 172 stubClassLoader::load('net::stubbles::ipo::request::stubRequestValueErrorXJConfFactory'); 155 $ rveFactory = new stubRequestValueErrorXJConfFactory();173 $this->rveFactory = new stubRequestValueErrorXJConfFactory(); 156 174 } 157 175 158 176 if (count($this->mappings) === 0) { 159 return $ rveFactory;177 return $this->rveFactory; 160 178 } 161 179 162 180 stubClassLoader::load('net::stubbles::ipo::request::stubRequestValueErrorFactoryMappingDecorator'); 163 $ rveMappingDecorator = new stubRequestValueErrorFactoryMappingDecorator($rveFactory);181 $this->rveFactory = new stubRequestValueErrorFactoryMappingDecorator($this->rveFactory); 164 182 foreach ($this->mappings as $oldErrorId => $newErrorId) { 165 $ rveMappingDecorator->addMapping($oldErrorId, $newErrorId);183 $this->rveFactory->addMapping($oldErrorId, $newErrorId); 166 184 } 167 185 168 return $ rveMappingDecorator;186 return $this->rveFactory; 169 187 } 170 188 trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubStringFilterAnnotation.php
r1301 r1323 7 7 * @subpackage ipo_request_broker_annotations 8 8 */ 9 stubClassLoader::load('net::stubbles::reflection::annotations::stubAnnotation', 9 stubClassLoader::load('net::stubbles::ipo::request::broker::annotations::stubAbstractStringFilterAnnotation', 10 'net::stubbles::ipo::request::filters::stubRegexCheckFilterDecorator', 10 11 'net::stubbles::ipo::request::filters::stubStringFilter', 11 'net::stubbles::ipo::request::broker::annotations::stubAbstractFilterAnnotation',12 'net::stubbles::php::string::stubStringEncoder',13 'net::stubbles::util::validators::stubMaxLengthValidator',14 'net::stubbles::util::validators::stubMinLengthValidator',15 12 'net::stubbles::util::validators::stubRegexValidator' 16 13 ); … … 21 18 * @subpackage ipo_request_broker_annotations 22 19 */ 23 class stubStringFilterAnnotation extends stubAbstract FilterAnnotation implements stubAnnotation20 class stubStringFilterAnnotation extends stubAbstractStringFilterAnnotation 24 21 { 25 /**26 * minimum length of the string27 *28 * @var int29 */30 protected $minLength;31 /**32 * maximum length of the string33 *34 * @var int35 */36 protected $maxLength;37 22 /** 38 23 * regular expression to filter the string … … 40 25 * @var string 41 26 */ 42 protected $regex = null; 43 /** 44 * the encoder class to be used 45 * 46 * @var stubReflectionClass 47 */ 48 protected $encoderClass = null; 49 /** 50 * the encoding mode to be applied 51 * 52 * @var int 53 */ 54 protected $encoderMode = stubStringEncoder::MODE_DECODE; 55 56 /** 57 * checks if the regex property is set and if the encoder mode is correct 58 * 59 * @throws ReflectionException 60 */ 61 public function finish() 62 { 63 if (null == $this->regex) { 64 throw new ReflectionException('Can not use ' . $this->getClassName() . ' without setting the regular expression via regex property.'); 65 } 66 67 if (null !== $this->encoderClass && in_array($this->encoderMode, array(stubStringEncoder::MODE_DECODE, stubStringEncoder::MODE_ENCODE)) === false) { 68 throw new ReflectionException('Can not use ' . $this->getClassName() . ' with wrong encoder mode ' . $this->encoderMode); 69 } 70 } 71 72 /** 73 * sets the minimum length of the string 74 * 75 * @param int $minLength 76 */ 77 public function setMinLength($minLength) 78 { 79 $this->minLength = $minLength; 80 } 81 82 /** 83 * sets the maximum length of the string 84 * 85 * @param int $maxLength 86 */ 87 public function setMaxLength($maxLength) 88 { 89 $this->maxLength = $maxLength; 90 } 27 protected $regex = null; 91 28 92 29 /** … … 101 38 102 39 /** 103 * sets the encoder class to be used104 *105 * @param stubReflectionClass $encoderClass106 */107 public function setEncoder(stubReflectionClass $encoderClass)108 {109 $this->encoderClass = $encoderClass;110 }111 112 /**113 * sets the encoder mode to be used114 *115 * @param int $mode116 */117 public function setEncoderMode($mode)118 {119 $this->encoderMode = $mode;120 }121 122 /**123 40 * returns the filter defined by the annotation 124 41 * 125 * @return stubStringFilter 126 * @throws stubRequestBrokerException 42 * @return stubFilter 127 43 */ 128 protected function do GetFilter()44 protected function doDoGetFilter() 129 45 { 130 $stringFilter = new stubStringFilter($this->createRVEFactory(), new stubRegexValidator($this->regex)); 131 if (null !== $this->minLength) { 132 $stringFilter->setMinLengthValidator(new stubMinLengthValidator($this->minLength)); 133 } 134 135 if (null !== $this->maxLength) { 136 $stringFilter->setMaxLengthValidator(new stubMaxLengthValidator($this->maxLength)); 137 } 138 139 if (null !== $this->encoderClass) { 140 $stringFilter->setEncoder($this->encoderClass->newInstance(), $this->encoderMode); 46 $stringFilter = new stubStringFilter(); 47 if (null !== $this->regex) { 48 $stringFilter = new stubRegexCheckFilterDecorator($stringFilter, $this->createRVEFactory(), new stubRegexValidator($this->regex)); 141 49 } 142 50 trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubTextFilterAnnotation.php
r1301 r1323 1 1 <?php 2 2 /** 3 * Filter annotation for strings.3 * Filter annotation for texts. 4 4 * 5 5 * @author Frank Kleine <mikey@stubbles.net> … … 7 7 * @subpackage ipo_request_broker_annotations 8 8 */ 9 stubClassLoader::load('net::stubbles::reflection::annotations::stubAnnotation', 10 'net::stubbles::ipo::request::filters::stubTextFilter', 11 'net::stubbles::ipo::request::broker::annotations::stubAbstractFilterAnnotation', 12 'net::stubbles::php::string::stubStringEncoder', 13 'net::stubbles::util::validators::stubMaxLengthValidator', 14 'net::stubbles::util::validators::stubMinLengthValidator', 15 'net::stubbles::util::validators::stubRegexValidator' 9 stubClassLoader::load('net::stubbles::ipo::request::filters::stubTextFilter', 10 'net::stubbles::ipo::request::broker::annotations::stubAbstractStringFilterAnnotation' 16 11 ); 17 12 /** 18 * Filter annotation for strings.13 * Filter annotation for texts. 19 14 * 20 15 * @package stubbles 21 16 * @subpackage ipo_request_broker_annotations 22 17 */ 23 class stubTextFilterAnnotation extends stubAbstract FilterAnnotation implements stubAnnotation18 class stubTextFilterAnnotation extends stubAbstractStringFilterAnnotation 24 19 { 25 /**26 * minimum length of the string27 *28 * @var int29 */30 protected $minLength;31 /**32 * maximum length of the string33 *34 * @var int35 */36 protected $maxLength;37 20 /** 38 21 * list of allowed tags … … 41 24 */ 42 25 protected $allowedTags = array(); 43 /**44 * the encoder class to be used45 *46 * @var stubReflectionClass47 */48 protected $encoderClass = null;49 /**50 * the encoding mode to be applied51 *52 * @var int53 */54 protected $encoderMode = stubStringEncoder::MODE_DECODE;55 56 /**57 * checks if the encoder mode is correct58 *59 * @throws ReflectionException60 */61 public function finish()62 {63 if (null !== $this->encoderClass && in_array($this->encoderMode, array(stubStringEncoder::MODE_DECODE, stubStringEncoder::MODE_ENCODE)) === false) {64 throw new ReflectionException('Can not use ' . $this->getClassName() . ' with wrong encoder mode ' . $this->encoderMode);65 }66 }67 68 /**69 * sets the minimum length of the string70 *71 * @param int $minLength72 */73 public function setMinLength($minLength)74 {75 $this->minLength = $minLength;76 }77 78 /**79 * sets the maximum length of the string80 *81 * @param int $maxLength82 */83 public function setMaxLength($maxLength)84 {85 $this->maxLength = $maxLength;86 }87 26 88 27 /** … … 100 39 101 40 /** 102 * sets the encoder class to be used103 *104 * @param stubReflectionClass $encoderClass105 */106 public function setEncoder(stubReflectionClass $encoderClass)107 {108 $this->encoderClass = $encoderClass;109 }110 111 /**112 * sets the encoder mode to be used113 *114 * @param int $mode115 */116 public function setEncoderMode($mode)117 {118 $this->encoderMode = $mode;119 }120 121 /**122 41 * returns the filter defined by the annotation 123 42 * 124 * @return stubTextFilter 125 * @throws stubRequestBrokerException 43 * @return stubFilter 126 44 */ 127 protected function do GetFilter()45 protected function doDoGetFilter() 128 46 { 129 $textFilter = new stubTextFilter($this->createRVEFactory()); 130 if (null !== $this->minLength) { 131 $textFilter->setMinLengthValidator(new stubMinLengthValidator($this->minLength)); 132 } 133 134 if (null !== $this->maxLength) { 135 $textFilter->setMaxLengthValidator(new stubMaxLengthValidator($this->maxLength)); 136 } 137 138 if (null !== $this->encoderClass) { 139 $textFilter->setEncoder($this->encoderClass->newInstance(), $this->encoderMode); 140 } 141 47 $textFilter = new stubTextFilter(); 142 48 $textFilter->setAllowedTags($this->allowedTags); 143 49 return $textFilter; trunk/src/main/php/net/stubbles/ipo/request/broker/stubRequestBroker.php
r1232 r1323 42 42 $refClass = new stubReflectionClass(get_class($object)); 43 43 } else { 44 throw new stubIllegalArgumentException('Parameter object must be a classname ora concrete object instance.');44 throw new stubIllegalArgumentException('Parameter object must a concrete object instance.'); 45 45 } 46 46 47 47 foreach ($refClass->getProperties() as $refProperty) { 48 if ($this->isAvailable($refProperty) === false) { 49 continue; 50 } 51 52 $filterAnnotation = $refProperty->getAnnotation('Filter'); 53 $value = $request->getFilteredValue($filterAnnotation->getFilter(), $prefix . $filterAnnotation->getFieldName()); 54 if ($request->hasValueError($prefix . $filterAnnotation->getFieldName()) === false) { 55 $refProperty->setValue($object, $value); 48 if ($this->isAvailable($refProperty) === true) { 49 $filterAnnotation = $refProperty->getAnnotation('Filter'); 50 $value = $request->getFilteredValue($filterAnnotation->getFilter(), $prefix . $filterAnnotation->getFieldName()); 51 if ($request->hasValueError($prefix . $filterAnnotation->getFieldName()) === false) { 52 $refProperty->setValue($object, $value); 53 } 56 54 } 57 55 } 58 56 59 57 foreach ($refClass->getMethods() as $refMethod) { 60 if ($this->isAvailable($refMethod) === false) { 61 continue; 62 } 63 64 $filterAnnotation = $refMethod->getAnnotation('Filter'); 65 $value = $request->getFilteredValue($filterAnnotation->getFilter(), $prefix . $filterAnnotation->getFieldName()); 66 if ($request->hasValueError($prefix . $filterAnnotation->getFieldName()) === false) { 67 $refMethod->invoke($object, $value); 58 if ($this->isAvailable($refMethod) === true) { 59 $filterAnnotation = $refMethod->getAnnotation('Filter'); 60 $value = $request->getFilteredValue($filterAnnotation->getFilter(), $prefix . $filterAnnotation->getFieldName()); 61 if ($request->hasValueError($prefix . $filterAnnotation->getFieldName()) === false) { 62 $refMethod->invoke($object, $value); 63 } 68 64 } 69 65 } trunk/src/main/php/net/stubbles/ipo/request/filters/stubAbstractFilterDecorator.php
r1301 r1323 5 5 * 6 6 * @author Richard Sternagel <richard.sternagel@1und1.de> 7 * @author Frank Kleine <mikey@stubbles.net> 7 8 * @package stubbles 8 9 * @subpackage ipo_request_filters … … 44 45 return $this->decoratedFilter; 45 46 } 46 47 /**48 * switch whether a value is required or not49 *50 * @param bool $required51 */52 public function setRequired($required)53 {54 $this->decoratedFilter->setRequired($required);55 }56 57 /**58 * set a default value in case the value to filter is not set59 *60 * @param mixed $defaultValue61 */62 public function setDefaultValue($defaultValue)63 {64 $this->decoratedFilter->setDefaultValue($defaultValue);65 }66 67 /**68 * returns true if the filter has a default value in case the value to filter is not set69 *70 * @return bool71 */72 public function hasDefaultValue()73 {74 return null != $this->decoratedFilter->defaultValue;75 }76 77 /**78 * returns a default value in case the value to filter is not set79 *80 * @return mixed81 */82 public function getDefaultValue()83 {84 return $this->decoratedFilter->defaultValue;85 }86 47 } 87 48 ?> trunk/src/main/php/net/stubbles/ipo/request/filters/stubFilter.php
r1223 r1323 20 20 { 21 21 /** 22 * switch whether a value is required or not23 *24 * @param bool $required25 */26 public function setRequired($required);27 28 /**29 22 * execute the filter 30 23 * … … 34 27 */ 35 28 public function execute($value); 36 37 /**38 * set a default value in case the value to filter is not set39 *40 * @param mixed $defaultValue41 */42 public function setDefaultValue($defaultValue);43 44 /**45 * returns true if the filter has a default value in case the value to filter is not set46 *47 * @return bool48 */49 public function hasDefaultValue();50 51 /**52 * returns a default value in case the value to filter is not set53 *54 * @return mixed55 */56 public function getDefaultValue();57 29 } 58 30 ?> trunk/src/main/php/net/stubbles/ipo/request/filters/stubFloatFilter.php
r1281 r1323 50 50 function execute($value) 51 51 { 52 if ((strlen($value) > 0 && true == $this->isRequired) || false == $this->isRequired || false === $value) { 53 settype($value, 'float'); 54 } 55 52 settype($value, 'float'); 56 53 $value = parent::doExecute($value); 57 54 $decimals = stubRegistry::getConfig(self::DECIMALS_REGISTRY_KEY); trunk/src/main/php/net/stubbles/ipo/request/filters/stubHTTPURLFilter.php
r1223 r1323 7 7 * @subpackage ipo_request_filters 8 8 */ 9 stubClassLoader::load('net::stubbles::ipo::request::filters::stub AbstractFilter',9 stubClassLoader::load('net::stubbles::ipo::request::filters::stubFilter', 10 10 'net::stubbles::util::net::http::stubHTTPURL' 11 11 ); … … 16 16 * @subpackage ipo_request_filters 17 17 */ 18 class stubHTTPURLFilter extends stub AbstractFilter18 class stubHTTPURLFilter extends stubBaseObject implements stubFilter 19 19 { 20 /** 21 * request value error factory 22 * 23 * @var stubRequestValueErrorFactory 24 */ 25 protected $rveFactory; 20 26 /** 21 27 * switch whether DNS should be checked or not … … 23 29 * @var bool 24 30 */ 25 protected $checkDNS = false;31 protected $checkDNS = false; 26 32 27 33 /** … … 71 77 72 78 if (null === $http) { 73 if (true === $this->isRequired) {74 throw new stubFilterException($this->rveFactory->create('URL_INCORRECT'));75 }76 77 79 return null; 78 80 } 79 81 80 if (true === $this->checkDNS && $http->checkDNS() == false) {82 if (true === $this->checkDNS && $http->checkDNS() === false) { 81 83 throw new stubFilterException($this->rveFactory->create('URL_NOT_AVAILABLE')); 82 84 } trunk/src/main/php/net/stubbles/ipo/request/filters/stubIntegerFilter.php
r1301 r1323 41 41 function execute($value) 42 42 { 43 if ((strlen($value) > 0 && true == $this->isRequired) || false == $this->isRequired || false === $value) { 44 settype($value, 'integer'); 45 } 46 43 settype($value, 'integer'); 47 44 return parent::doExecute($value); 48 45 } trunk/src/main/php/net/stubbles/ipo/request/filters/stubMailFilter.php
r1307 r1323 7 7 * @subpackage ipo_request_filters 8 8 */ 9 stubClassLoader::load('net::stubbles::ipo::request::filters::stub AbstractFilter',9 stubClassLoader::load('net::stubbles::ipo::request::filters::stubFilter', 10 10 'net::stubbles::util::validators::stubValidator' 11 11 ); … … 17 17 * @uses net::stubbles::util::validators 18 18 */ 19 class stubMailFilter extends stub AbstractFilter19 class stubMailFilter extends stubBaseObject implements stubFilter 20 20 { 21 /** 22 * request value error factory 23 * 24 * @var stubRequestValueErrorFactory 25 */ 26 protected $rveFactory; 21 27 /** 22 28 * validator to use for checking the mail address trunk/src/main/php/net/stubbles/ipo/request/filters/stubNumberFilter.php
r1301 r1323 7 7 * @subpackage ipo_request_filters 8 8 */ 9 stubClassLoader::load('net::stubbles::ipo::request:: filters::stubAbstractFilter',10 'net::stubbles::ipo::request:: stubRequestValueErrorFactory',9 stubClassLoader::load('net::stubbles::ipo::request::stubRequestValueErrorFactory', 10 'net::stubbles::ipo::request::filters::stubFilter', 11 11 'net::stubbles::util::validators::stubValidator' 12 12 ); … … 19 19 * @package stubbles 20 20 * @subpackage ipo_request_filters 21 * @uses net::stubbles::util::validators22 21 */ 23 class stubNumberFilter extends stub AbstractFilter22 class stubNumberFilter extends stubBaseObject implements stubFilter 24 23 { 24 /** 25 * request value error factory 26 * 27 * @var stubRequestValueErrorFactory 28 */ 29 protected $rveFactory; 25 30 /** 26 31 * validator for minimum values … … 92 97 protected function doExecute($value) 93 98 { 94 if ((null === $value || strlen($value) === 0) && true === $this->isRequired) { 95 // add error message if there is no input and input is needed 96 throw new stubFilterException($this->rveFactory->create('FIELD_EMPTY')); 97 } elseif (null !== $value && null !== $this->minValidator && $this->minValidator->validate($value) !== true) { 99 if (null !== $value && null !== $this->minValidator && $this->minValidator->validate($value) !== true) { 98 100 // add error message if input is smaller than minimum value 99 101 throw new stubFilterException($this->rveFactory->create('VALUE_TOO_SMALL')->setValues($this->minValidator->getCriteria())); trunk/src/main/php/net/stubbles/ipo/request/filters/stubPassThruFilter.php
r1223 r1323 2 2 /** 3 3 * Filter that filters nothing. 4 *5 * Use this filter only when you know what you are doing.6 4 * 7 5 * @author Frank Kleine <mikey@stubbles.net> … … 9 7 * @subpackage ipo_request_filters 10 8 */ 11 stubClassLoader::load('net::stubbles::ipo::request::filters::stub AbstractFilter');9 stubClassLoader::load('net::stubbles::ipo::request::filters::stubFilter'); 12 10 /** 13 11 * Filter that filters nothing. … … 18 16 * @subpackage ipo_request_filters 19 17 */ 20 class stubPassThruFilter extends stub AbstractFilter18 class stubPassThruFilter extends stubBaseObject implements stubFilter 21 19 { 22 /**23 * constructor24 *25 * @param stubRequestValueErrorFactory $rveFactory factory to create stubRequestValueErrors26 */27 public function __construct(stubRequestValueErrorFactory $rveFactory)28 {29 $this->rveFactory = $rveFactory;30 }31 32 20 /** 33 21 * execute the filter … … 39 27 public function execute($value) 40 28 { 41 if (null === $value && true == $this->isRequired) {42 throw new stubFilterException($this->rveFactory->create('FIELD_EMPTY'));43 }44 45 29 return $value; 46 30 } trunk/src/main/php/net/stubbles/ipo/request/filters/stubPasswordFilter.php
r1307 r1323 7 7 * @subpackage ipo_request_filters 8 8 */ 9 stubClassLoader::load('net::stubbles::ipo::request::filters::stub AbstractFilter',9 stubClassLoader::load('net::stubbles::ipo::request::filters::stubFilter', 10 10 'net::stubbles::php::string::stubStringEncoder', 11 11 'net::stubbles::util::validators::stubValidator' … … 29 29 * @uses net::stubbles::util::validators 30 30 */ 31 class stubPasswordFilter extends stub AbstractFilter31 class stubPasswordFilter extends stubBaseObject implements stubFilter 32 32 { 33 /** 34 * request value error factory 35 * 36 * @var stubRequestValueErrorFactory 37 */ 38 protected $rveFactory; 33 39 /** 34 40 * validator to use for checking the minimum length of the password … … 147 153 } 148 154 149 if (false === $this->isRequired && strlen($value) === 0) {150 return null;151 }152 153 155 if ($this->minLength->validate($value) === false) { 154 156 throw new stubFilterException($this->rveFactory->create('STRING_TOO_SHORT')->setValues($this->minLength->getCriteria())); … … 165 167 } 166 168 167 return $this->secure($value); 169 if (strlen($value) > 0) { 170 return $this->secure($value); 171 } 172 173 return null; 168 174 } 169 175 trunk/src/main/php/net/stubbles/ipo/request/filters/stubRegexChangeFilterDecorator.php
r1301 r1323 1 1 <?php 2 2 /** 3 * Decorator which adds regex filtering (input value may be changed due to regex) 4 * and can therefore be used in conjunction with other filters. 3 * Class for changing values with a regular expression. 5 4 * 6 5 * @author Richard Sternagel <richard.sternagel@1und1.de> 6 * @author Frank Kleine <mikey@stubbles.net> 7 7 * @package stubbles 8 8 * @subpackage ipo_request_filters 9 9 */ 10 stubClassLoader::load('net::stubbles::ipo::request::filters::stubAbstractFilterDecorator', 11 'net::stubbles::lang::exceptions::stubIllegalArgumentException', 12 'net::stubbles::lang::exceptions::stubIllegalStateException' 10 stubClassLoader::load('net::stubbles::ipo::request::stubRequestValueErrorFactory', 11 'net::stubbles::ipo::request::filters::stubStrategyFilterDecorator' 13 12 ); 14 13 /** 15 * Decorator which adds regex filtering (input value may be changed due to regex) 16 * and can therefore be used in conjunction with other filters. 14 * Class for changing values with a regular expression. 15 * 16 * This filter does a check against a regular expression and returns the 17 * requested match. If no match is found the returned value will be null. 17 18 * 18 19 * @package stubbles 19 20 * @subpackage ipo_request_filters 20 21 */ 21 class stubRegex FilterDecorator extends stubAbstractFilterDecorator22 class stubRegexChangeFilterDecorator extends stubStrategyFilterDecorator 22 23 { 23 /**24 * indicates the decorator behavior:25 *26 * decorate the filter (apply regex) *before* the27 * actual method call.28 */29 const STRATEGY_BEFORE = -1;30 /**31 * indicates the decorator behavior:32 *33 * decorate the filter (apply regex) *after* the34 * actual method call.35 */36 const STRATEGY_AFTER = 1;37 /**38 * Decorator Strategy:39 *40 * <ul>41 * <li>self::BEFORE_STRAGTEGY</li>42 * <li>self::AFTER_STRATEGY</li>43 * </ul>44 *45 * @var int46 */47 protecte
