本文整理汇总了PHP中Zend_Validate_Int类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_Int类的具体用法?PHP Zend_Validate_Int怎么用?PHP Zend_Validate_Int使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Validate_Int类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getTennisTableRanking
/**
* 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;
}
开发者ID:Nhan-Huynh-FO,项目名称:nhan-repo,代码行数:41,代码来源:Mysql.php
示例2: _getValidator
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));
}
}
}
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:34,代码来源:ArrayConfigValidate.php
示例3: romanNumerals
/**
* 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;
}
}
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:35,代码来源:Romannumerals.php
示例4: init
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);
}
开发者ID:belapp,项目名称:opus4-application,代码行数:32,代码来源:Number.php
示例5: trainingAction
public function trainingAction()
{
$validator = new Zend_Validate_Int();
$ceId = $this->getRequest()->getParam(CalibrationExercise::COL_ID);
if ($validator->isValid($ceId)) {
$this->view->ceId = $ceId;
}
}
开发者ID:blackskaarj,项目名称:webgr,代码行数:8,代码来源:StatisticController.php
示例6: indexAction
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!');
}
}
开发者ID:blackskaarj,项目名称:webgr,代码行数:58,代码来源:MakeController.php
示例7: isValid
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;
}
}
开发者ID:racporto,项目名称:c3op,代码行数:10,代码来源:ValidId.php
示例8: init
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);
}
开发者ID:belapp,项目名称:opus4-application,代码行数:13,代码来源:SortOrder.php
示例9: init
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());
}
}
开发者ID:alexukua,项目名称:opus4,代码行数:14,代码来源:Series.php
示例10: init
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());
}
}
开发者ID:belapp,项目名称:opus4-application,代码行数:14,代码来源:Publisher.php
示例11: Pluralism
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();
}
}
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:15,代码来源:Pluralism.php
示例12: validateAttributeValue
/**
* 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;
}
开发者ID:UnicodeSystems-PrivateLimited,项目名称:Zendfox,代码行数:65,代码来源:Abstract.php
示例13: adbc
/** 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;
}
}
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:25,代码来源:Adbc.php
示例14: init
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);
}
开发者ID:belapp,项目名称:opus4-application,代码行数:20,代码来源:Year.php
示例15: certainty
/**
* 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;
}
}
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:27,代码来源:Certainty.php
示例16: completeness
/** 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;
}
}
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:29,代码来源:Completeness.php
示例17: testLocaleDetectsNoEnglishLocaleOnOtherSetLocale
/**
* @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'));
}
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:10,代码来源:IntTest.php
示例18: setRadius
/**
* 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;
}
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:19,代码来源:SearchParameters.php
示例19: setTtl
/**
* 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;
}
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:22,代码来源:Header.php
示例20: formValidator
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;
}
开发者ID:robliuning,项目名称:Luckyrabbit,代码行数:15,代码来源:DrirecordMapper.php
注:本文中的Zend_Validate_Int类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论