예제 #1
0
 /**
  * Get tennis table ranking by year and gender
  * @param int $year
  * @param int $gender Only 0 or 1. 0 => woman (WTA), 1 => man (ATP)
  * @return array|boolean
  * @author QuangTM
  */
 public function getTennisTableRanking($year, $gender)
 {
     // Get result
     $result = array();
     try {
         // Validate int
         $validInt = new Zend_Validate_Int();
         // Validate input
         if (!$validInt->isValid($year) || !$validInt->isValid($gender)) {
             return FALSE;
         }
         // Get DB Obj
         $dbObj = Thethao_Global::getDB('sport', 'slave');
         // Prepare SQL
         $stmt = $dbObj->prepare('CALL sp_tennis_getTennisRanking(:p_gender, :p_year);');
         // Bind param
         $stmt->bindParam('p_gender', $gender, PDO::PARAM_INT);
         $stmt->bindParam('p_year', $year, PDO::PARAM_INT);
         // Execute
         $stmt->execute();
         // Get format data
         $formatInstance = new Thethao_Business_Tennis_Metadata_Ranking();
         while ($row = $stmt->fetch()) {
             $result[$row['player_id']] = $formatInstance->init($row)->getFormatedData();
         }
         // Close
         $stmt->closeCursor();
         // Release variables
         unset($stmt);
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex, 1);
     }
     return $result;
 }
 protected function _getValidator($value)
 {
     $validator = new \App_Validate_IsBoolean();
     if ($validator->isValid($value)) {
         return $validator;
     }
     $validator = new \Zend_Validate_Int();
     if ($validator->isValid($value)) {
         return $validator;
     }
     if (is_string($value)) {
         $validator = new \Zend_Validate_StringLength(array('max' => 2047));
         return $validator;
     }
     if ($value instanceof StructConfigModel) {
         return new StructConfigValidate(array('acceptArrayAsModel' => true));
     }
     if ($value instanceof ArrayConfigModel) {
         return new ArrayConfigValidate(array('acceptArrayAsModel' => true));
     }
     if (is_array($value)) {
         if (!empty($value)) {
             $keys = array_keys($value);
             $key = array_shift($keys);
             if (!is_int($key)) {
                 return new StructConfigValidate(array('acceptArrayAsModel' => true));
             } else {
                 return new ArrayConfigValidate(array('acceptArrayAsModel' => true));
             }
         } else {
             return new ArrayConfigValidate(array('acceptArrayAsModel' => true));
         }
     }
 }
예제 #3
0
 /**
  * The function below creates a roman numeral from a number
  * @param int $num
  * @return string
  * @uses Zend_Validate_Int
  */
 public function romanNumerals($date)
 {
     //Check if the number is an integer
     $validator = new Zend_Validate_Int();
     if ($validator->isValid($date)) {
         $n = intval($date);
         $res = '';
         /** Create the array of Roman numerals based on numbers
          */
         $roman_numerals = array('M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1);
         foreach ($roman_numerals as $roman => $number) {
             /**
              * Divide number to get matches 
              */
             $matches = intval($n / $number);
             /**
              *  assign the roman char * $matches 
              */
             $res .= str_repeat($roman, $matches);
             /** 
              * subtract from the number 
              */
             $n = $n % $number;
         }
         /** return the resulting string as a roman numeral
          */
         return $res;
     }
 }
예제 #4
0
 /**
  * Ensures that the validator follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     $valuesExpected = array(array(1.0, true), array(0.0, true), array(0.01, false), array(-0.1, false), array(-1, true), array('10', true), array(1, true), array('not an int', false));
     foreach ($valuesExpected as $element) {
         $this->assertEquals($element[1], $this->_validator->isValid($element[0]));
     }
 }
예제 #5
0
 public function init()
 {
     parent::init();
     if (is_null($this->getAttrib('size'))) {
         $this->setAttrib('size', 6);
     }
     $validator = new Zend_Validate_Int();
     $validator->setMessage('validation_error_int');
     $this->addValidator($validator);
     $options = array();
     $min = $this->getAttrib('min');
     if (is_null($min)) {
         $min = 0;
     } else {
         $this->setAttrib('min', null);
         // remove from rendered attributes
     }
     $options['min'] = $min;
     $max = $this->getAttrib('max');
     if (is_null($max)) {
         $validator = new Zend_Validate_GreaterThan(array('min' => $min - 1));
         // inclusive not supported in ZF1
         $validator->setMessage('validation_error_number_tooSmall');
     } else {
         $this->setAttrib('max', null);
         // remove from rendered attributes
         $options['max'] = $max;
         $validator = new Zend_Validate_Between(array('min' => $min, 'max' => $max));
         $validator->setMessage('validation_error_number_notBetween');
     }
     $this->addValidator($validator);
 }
예제 #6
0
 public function trainingAction()
 {
     $validator = new Zend_Validate_Int();
     $ceId = $this->getRequest()->getParam(CalibrationExercise::COL_ID);
     if ($validator->isValid($ceId)) {
         $this->view->ceId = $ceId;
     }
 }
예제 #7
0
 public function indexAction()
 {
     $validator = new Zend_Validate_Int();
     $ceId = $this->getRequest()->getParam(CalibrationExercise::COL_ID);
     $error = false;
     if ($validator->isValid($ceId)) {
         $dbadapter = Zend_Registry::get('DB_CONNECTION1');
         $select = $dbadapter->select();
         if (Default_ReferenceQuery::isParticipantInCe($ceId)) {
             //set CE id
             $namespace = new Zend_Session_Namespace('default');
             $constCeId = CalibrationExercise::COL_ID;
             $namespace->{$constCeId} = $ceId;
             // Get part_id and part_role
             $auth = Zend_Auth::getInstance();
             $storage = $auth->getStorage();
             $constUserId = User::COL_ID;
             $userId = $storage->read()->{$constUserId};
             $select->from(Participant::TABLE_NAME);
             $select->where(Participant::COL_USER_ID . " =?", $userId);
             $select->where(Participant::COL_CE_ID . " =?", $ceId);
             $array = $dbadapter->fetchAll($select);
             $constPartId = Participant::COL_ID;
             $namespace->{$constPartId} = $array[0][Participant::COL_ID];
             $constPartRole = Participant::COL_ROLE;
             $namespace->{$constPartRole} = $array[0][Participant::COL_ROLE];
             //Set CE-info result Object
             $select->reset();
             $select->from(array('caex' => CalibrationExercise::TABLE_NAME));
             $select->join(array('exp' => Expertise::TABLE_NAME), 'caex.' . CalibrationExercise::COL_EXPERTISE_ID . "=" . 'exp.' . Expertise::COL_ID, array());
             $select->join(array('key' => KeyTable::TABLE_NAME), 'caex.' . CalibrationExercise::COL_KEY_TABLE_ID . "=" . 'key.' . KeyTable::COL_ID);
             $select->join(array('work' => Workshop::TABLE_NAME), 'caex.' . CalibrationExercise::COL_WORKSHOP_ID . "=" . "work." . Workshop::COL_ID, array(Workshop::COL_NAME));
             $select->join(array('vali' => ValueList::TABLE_NAME), 'exp.' . Expertise::COL_SUBJECT . '=vali.' . ValueList::COL_ID, array(Expertise::COL_SUBJECT => ValueList::COL_NAME));
             $select->where('caex.' . CalibrationExercise::COL_ID . "=?", $ceId);
             $ceArray = $dbadapter->fetchAll($select);
             $namespace->ceArray = $ceArray;
             $this->view->subject = $ceArray[0][Expertise::COL_SUBJECT];
         } else {
             $error = true;
             $this->view->message = "Your are not a participant of this CE.<br>" . "Please contact one of the coordinators:<br>";
             $select->from(array('caex' => CalibrationExercise::TABLE_NAME));
             $select->join(array('part' => Participant::TABLE_NAME), 'caex.' . CalibrationExercise::COL_ID . '=' . 'part.' . Participant::COL_CE_ID);
             $select->join(array('user' => User::TABLE_NAME), 'part.' . Participant::COL_USER_ID . '=' . 'user.' . User::COL_ID);
             $select->where('part.' . Participant::COL_CE_ID . '=?', $ceId);
             $select->where('part.' . Participant::COL_ROLE . '=?', 'Coordinator');
             $infoArray = $dbadapter->fetchAll($select);
             $this->view->error = true;
             if (count($infoArray) != 0) {
                 $this->view->coordinators = $infoArray;
             } else {
                 $this->view->message = "The CE doesn't exist.<br>";
                 $this->view->coordinators = array();
             }
         }
     } else {
         throw new Zend_Exception('The CE id was not valid!');
     }
 }
예제 #8
0
파일: ValidId.php 프로젝트: racporto/c3op
 public function isValid($value)
 {
     $intValidator = new Zend_Validate_Int(array('locale' => 'br'));
     $positiveValidator = new Zend_Validate_GreaterThan(0);
     if ($intValidator->isValid($value) && $positiveValidator->isValid($value)) {
         return true;
     } else {
         return false;
     }
 }
예제 #9
0
 public function init()
 {
     parent::init();
     if (is_null($this->getAttrib('size'))) {
         $this->setAttrib('size', 6);
     }
     $validator = new Zend_Validate_Int();
     $validator->setMessage('validation_error_int');
     $this->addValidator($validator);
     $validator = new Zend_Validate_GreaterThan(-1);
     $validator->setMessage('validation_error_negative_number');
     $this->addValidator($validator);
 }
예제 #10
0
파일: Series.php 프로젝트: alexukua/opus4
 public function init()
 {
     parent::init();
     $this->setRequired(true);
     $this->setDisableTranslator(true);
     // Schriftenreihen werden nicht übersetzt
     $validator = new Zend_Validate_Int();
     $validator->setMessage('validation_error_int');
     $this->addValidator($validator);
     $options = Opus_Series::getAll();
     foreach ($options as $option) {
         $this->addMultiOption($option->getId(), $option->getTitle());
     }
 }
예제 #11
0
 public function init()
 {
     parent::init();
     $this->setRequired(true);
     $this->setDisableTranslator(true);
     // publishing institutions are not translated
     $validator = new Zend_Validate_Int();
     $validator->setMessage('validation_error_int');
     $this->addValidator($validator);
     $options = Opus_DnbInstitute::getPublishers();
     foreach ($options as $option) {
         $this->addMultiOption($option->getId(), $option->getDisplayName());
     }
 }
예제 #12
0
 public function Pluralism($number)
 {
     $filter = new Zend_Validate_Int();
     if ($filter->isValid($number)) {
         if ($number === 0) {
             return self::NONE;
         }
         if ($number === 1) {
             return self::SINGULAR;
         }
         return $number . ' ' . self::PLURAL;
     } else {
         return $filter->getMessages();
     }
 }
예제 #13
0
 public function isValid($value)
 {
     if (!parent::isValid($value)) {
         return false;
     }
     if (!is_null($this->_min) || !is_null($this->_max)) {
         $validators = array();
         if (!is_null($this->_min)) {
             $validator = new Zend_Validate_GreaterThan($this->_min);
             $validator->setMin($this->_min);
             $validators[] = $validator;
         }
         if (!is_null($this->_max)) {
             $validator = new Zend_Validate_LessThan($this->_max);
             $validator->setMax($this->_max);
             $validators[] = $validator;
         }
         foreach ($validators as $val) {
             if (!$val->isValid($value)) {
                 $messages = $val->getMessages();
                 if (!is_array($this->_messages)) {
                     $this->_messages = array();
                 }
                 $this->_messageVariables = array('max' => '_max', 'min' => '_min');
                 foreach ($messages as $key => $message) {
                     $this->_error($key, $value);
                 }
                 return false;
             }
         }
     }
     return true;
 }
 /**
  * Validate attributes
  * 
  * @param string $validation attribute validation class name
  * @param string $value attribute value
  * @return array returns success and errors as array keys
  */
 protected function validateAttributeValue($validation, $value)
 {
     $valid = array('success' => TRUE, 'errors' => '');
     switch ($validation) {
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_DECIMAL:
             if (!$this->decimalValidation) {
                 $this->decimalValidation = new Zend_Validate_Float();
             }
             $valid['success'] = $this->decimalValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" contains invalid digits.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_EMAIL:
             if (!$this->emailValidation) {
                 $this->emailValidation = new Zend_Validate_EmailAddress();
             }
             $valid['success'] = $this->emailValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid email address.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_INT:
             if (!$this->intValidation) {
                 $this->intValidation = new Zend_Validate_Int();
             }
             $valid['success'] = $this->intValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid integer.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_LETTERS:
             if (!$this->letterValidation) {
                 $this->letterValidation = new Zend_Validate_Alpha(true);
             }
             $valid['success'] = $this->letterValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" contains invalid characters.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_DATE:
             $valid['success'] = strtotime($value) > 0;
             $valid['errors'] = '"' . $value . '" is invalid date.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_URL:
             if (!$this->urlValidation) {
                 $this->urlValidation = new Uni_Validate_Url();
             }
             $valid['success'] = $this->urlValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid url.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_IMAGE:
             if (empty($this->validExtensions)) {
                 $this->validExtensions = array('jpg', 'jpeg', 'png', 'bmp', 'gif', 'tiff');
             }
             $extPos = strrpos($value, '.');
             if (!$extPos || !empty($this->validExtensions) && !in_array(substr($value, $extPos + 1), $this->validExtensions)) {
                 $valid['success'] = FALSE;
                 $valid['errors'] = 'Invalid image was given.';
             }
             break;
         default:
             break;
     }
     return $valid;
 }
예제 #15
0
 /** A function for turning the integer into a string with AD or BC added
  * 
  * @param $date integer 
  * @param $suffix string
  * @param $prefix string
  */
 public function adbc($date = NULL, $suffix = "BC", $prefix = "AD")
 {
     $validator = new Zend_Validate_Int();
     if ($validator->isValid($date)) {
         if ($date < 0) {
             return abs($date) . ' ' . $suffix;
         } else {
             if ($date > 0) {
                 return $prefix . ' ' . abs($date);
             } else {
                 if ($date === 0) {
                     return false;
                 }
             }
         }
     } else {
         return false;
     }
 }
예제 #16
0
 public function init()
 {
     parent::init();
     $this->setLabel($this->getName());
     // TODO use prefix for translation
     $validators = array();
     $validator = new Zend_Validate_Int();
     $validator->setMessage('validation_error_year_invalid_format');
     $validators[] = $validator;
     $validator = new Zend_Validate_GreaterThan(-1);
     $validator->setMessages(array(Zend_Validate_GreaterThan::NOT_GREATER => 'validation_error_year_invalid_negative'));
     $validators[] = $validator;
     $validator = new Zend_Validate_LessThan(10000);
     $validator->setMessages(array(Zend_Validate_LessThan::NOT_LESS => 'validation_error_year_too_large'));
     $validators[] = $validator;
     $this->setAttrib('placeholder', $this->getTranslator()->translate('year_format'));
     $this->setAttrib('size', 6);
     $this->setAttrib('maxlength', 4);
     $this->setValidators($validators, true);
 }
예제 #17
0
 public function isValid($value)
 {
     if (!parent::isValid($value)) {
         return false;
     }
     if ($value % $this->_mod !== 0) {
         $this->_error(self::NOT_MODULO, $value);
         return false;
     }
     return true;
 }
예제 #18
0
 /**
  * Check for the certainty
  * @param $int The certainty lookup number 
  */
 public function certainty($int)
 {
     $validator = new Zend_Validate_Int();
     if ($validator->isValid($int)) {
         switch ($int) {
             case 1:
                 $cert = 'Certain';
                 break;
             case 2:
                 $cert = 'Probably';
                 break;
             case 3:
                 $cert = 'Possibly';
                 break;
             default:
                 return false;
                 break;
         }
         return $cert;
     } else {
         return false;
     }
 }
예제 #19
0
 /** Determine the completeness from lookup value
  * 
  * @param integer $string
  * @return string
  */
 public function completeness($string)
 {
     $validator = new Zend_Validate_Int();
     if ($validator->isValid($string)) {
         switch ($string) {
             case 1:
                 $comp = 'Fragment';
                 break;
             case 2:
                 $comp = 'Incomplete';
                 break;
             case 3:
                 $comp = 'Uncertain';
                 break;
             case 4:
                 $comp = 'Complete';
                 break;
             default:
                 return false;
                 break;
         }
         return $comp;
     }
 }
예제 #20
0
 public function __construct($locale = null)
 {
     parent::__construct($locale);
     $this->_messageTemplates[self::INVALID] = trlKwfStatic("Invalid type given, value should be string or integer");
     $this->_messageTemplates[self::NOT_INT] = trlKwfStatic("'%value%' does not appear to be an integer");
 }
예제 #21
0
 /**
  * @ZF-7703
  */
 public function testLocaleDetectsNoEnglishLocaleOnOtherSetLocale()
 {
     Zend_Registry::set('Zend_Locale', new Zend_Locale('de'));
     $valid = new Zend_Validate_Int();
     $this->assertTrue($valid->isValid(1200));
     $this->assertFalse($valid->isValid('1,200'));
 }
 /**
  * sets spatial and the given radius for a circle search
  *
  * @param integer $radius
  * @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
  */
 public function setRadius($radius)
 {
     require_once 'Zend/Validate/Int.php';
     $validator = new Zend_Validate_Int();
     if (!$validator->isValid($radius)) {
         $message = $validator->getMessages();
         require_once 'Zend/Service/DeveloperGarden/LocalSearch/Exception.php';
         throw new Zend_Service_DeveloperGarden_LocalSearch_Exception(current($message));
     }
     $this->_parameters['radius'] = $radius;
     $this->_parameters['transformgeocode'] = 'false';
     return $this;
 }
예제 #23
0
 /**
  * How long in minutes a feed can be cached before refreshing
  * Ignored if atom is used
  *
  * @param  int $ttl
  * @return Zend_Feed_Builder_Header
  * @throws Zend_Feed_Builder_Exception
  */
 public function setTtl($ttl)
 {
     Zend_Loader::loadClass('Zend_Validate_Int');
     $validate = new Zend_Validate_Int();
     if (!$validate->isValid($ttl)) {
         /**
          * @see Zend_Feed_Builder_Exception
          */
         #require_once 'Zend/Feed/Builder/Exception.php';
         throw new Zend_Feed_Builder_Exception("you have to set an integer value to the ttl property");
     }
     $this->offsetSet('ttl', $ttl);
     return $this;
 }
예제 #24
0
	public function formValidator($form,$formType)
	{
		$numberValidator = new Zend_Validate_Int();
		$numberValidator->setMessage(General_Models_Text::$text_notInt);
		$form->getElement('mileEarly')->addValidator($numberValidator);
		$form->getElement('mileEnd')->addValidator($numberValidator);
		
		$emptyValidator = new Zend_Validate_NotEmpty();
		$emptyValidator->setMessage(General_Models_Text::$text_notEmpty);
		$form->getElement('mileEarly')->setAllowEmpty(false)
								->addValidator($emptyValidator);
		$form->getElement('mileEnd')->setAllowEmpty(false)
								->addValidator($emptyValidator);
		return $form;
	}
예제 #25
0
 /**
  * Faz o parse de um elemento <int> para Zend_Form.
  * @param SimpleXMLElement $element
  */
 protected function parseInt($element)
 {
     $form_element = new Zend_Form_Element_Text((string) $element->id);
     $validate_ìnt = new Zend_Validate_Int();
     $validate_ìnt->setMessage("Somente números inteiros");
     $form_element->addValidator($validate_ìnt);
     $form_element->setLabel((string) $element->label);
     $form_element->setAttrib('size', $element->size);
     if (isset($element->unit)) {
         $form_element->setDescription($element->unit);
     }
     if (isset($element->value)) {
         $form_element->setValue($element->value);
     } else {
         if (isset($element->default)) {
             $form_element->setValue($element->default);
         }
     }
     return $form_element;
 }
예제 #26
0
 /**
  * Validate Tag Search Options
  *
  * @param  array $options
  * @throws Zend_Service_Exception
  * @return void
  */
 protected function _validateTagSearch(array $options)
 {
     $validOptions = array('method', 'api_key', 'user_id', 'tags', 'tag_mode', 'text', 'min_upload_date', 'max_upload_date', 'min_taken_date', 'max_taken_date', 'license', 'sort', 'privacy_filter', 'bbox', 'accuracy', 'machine_tags', 'machine_tag_mode', 'group_id', 'extras', 'per_page', 'page');
     $this->_compareOptions($options, $validOptions);
     /**
      * @see Zend_Validate_Between
      */
     require_once 'Zend/Validate/Between.php';
     $between = new Zend_Validate_Between(1, 500, true);
     if (!$between->isValid($options['per_page'])) {
         /**
          * @see Zend_Service_Exception
          */
         require_once 'Zend/Service/Exception.php';
         throw new Zend_Service_Exception($options['per_page'] . ' is not valid for the "per_page" option');
     }
     /**
      * @see Zend_Validate_Int
      */
     require_once 'Zend/Validate/Int.php';
     $int = new Zend_Validate_Int();
     if (!$int->isValid($options['page'])) {
         /**
          * @see Zend_Service_Exception
          */
         require_once 'Zend/Service/Exception.php';
         throw new Zend_Service_Exception($options['page'] . ' is not valid for the "page" option');
     }
     // validate extras, which are delivered in csv format
     if ($options['extras']) {
         $extras = explode(',', $options['extras']);
         $validExtras = array('license', 'date_upload', 'date_taken', 'owner_name', 'icon_server');
         foreach ($extras as $extra) {
             /**
              * @todo The following does not do anything [yet], so it is commented out.
              */
             //in_array(trim($extra), $validExtras);
         }
     }
 }
예제 #27
0
파일: Sports.php 프로젝트: anhvn/bet-script
 public function deleteSportRows($id)
 {
     if ($this->conn->checkAdmin()) {
         $int = new Zend_Validate_Int();
         if (!$int->isValid($id)) {
             return $this->test;
         }
         $query = "CALL deleteSports ('" . $id . "')";
         $result = $this->conn->insert($query);
         $query = "CALL selectSports( )";
         $result->message = $this->conn->multiresultbackArray($query);
         return $result;
     } else {
         $this->test->type = "error";
         $this->test->info = "nologin";
         return $this->test;
     }
 }
예제 #28
0
 /**
  * How long in minutes a feed can be cached before refreshing
  * Ignored if atom is used
  *
  * @param  int $ttl
  * @return Zend_Feed_Builder_Header
  * @throws Zend_Feed_Builder_Exception
  */
 public function setTtl($ttl)
 {
     /**
      * @see Zend_Validate_Int
      */
     //$1 'Zend/Validate/Int.php';
     $validate = new Zend_Validate_Int();
     if (!$validate->isValid($ttl)) {
         /**
          * @see Zend_Feed_Builder_Exception
          */
         //$1 'Zend/Feed/Builder/Exception.php';
         throw new Zend_Feed_Builder_Exception("you have to set an integer value to the ttl property");
     }
     $this->offsetSet('ttl', $ttl);
     return $this;
 }
예제 #29
0
 /**
  * Validate Group Search Options
  *
  * @param  array $options
  * @throws Zend_Service_Exception
  * @return void
  */
 protected function _validateGroupPoolGetPhotos(array $options)
 {
     $validOptions = array('api_key', 'tags', 'method', 'group_id', 'per_page', 'page', 'extras', 'user_id');
     $this->_compareOptions($options, $validOptions);
     /**
      * @see Zend_Validate_Between
      */
     //$1 'Zend/Validate/Between.php';
     $between = new Zend_Validate_Between(1, 500, true);
     if (!$between->isValid($options['per_page'])) {
         /**
          * @see Zend_Service_Exception
          */
         //$1 'Zend/Service/Exception.php';
         throw new Zend_Service_Exception($options['per_page'] . ' is not valid for the "per_page" option');
     }
     /**
      * @see Zend_Validate_Int
      */
     //$1 'Zend/Validate/Int.php';
     $int = new Zend_Validate_Int();
     if (!$int->isValid($options['page'])) {
         /**
          * @see Zend_Service_Exception
          */
         //$1 'Zend/Service/Exception.php';
         throw new Zend_Service_Exception($options['page'] . ' is not valid for the "page" option');
     }
     // validate extras, which are delivered in csv format
     if (isset($options['extras'])) {
         $extras = explode(',', $options['extras']);
         $validExtras = array('license', 'date_upload', 'date_taken', 'owner_name', 'icon_server');
         foreach ($extras as $extra) {
             /**
              * @todo The following does not do anything [yet], so it is commented out.
              */
             //in_array(trim($extra), $validExtras);
         }
     }
 }
예제 #30
0
 /**
  * Ensures that getMessages() returns expected default value
  *
  * @return void
  */
 public function testGetMessages()
 {
     $this->assertEquals(array(), $this->_validator->getMessages());
 }