本文整理汇总了PHP中Validate::isInt方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isInt方法的具体用法?PHP Validate::isInt怎么用?PHP Validate::isInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::isInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setStatus
public function setStatus($status)
{
if (Validate::isInt($status)) {
$this->status = $status;
}
return $this;
}
示例2: getContent
public function getContent()
{
$this->_html = '<h2>' . $this->displayName . '</h2>';
if (Tools::isSubmit('submitUpdate')) {
if (Tools::getValue('STORE_DELIVERY_SEND_MAIL') !== false && Validate::isBool(Tools::getValue('STORE_DELIVERY_SEND_MAIL'))) {
Configuration::updateValue('STORE_DELIVERY_SEND_MAIL', Tools::getValue('STORE_DELIVERY_SEND_MAIL'));
}
if (Tools::getValue('STORE_DELIVERY_CARRIER') != false && Validate::isInt(Tools::getValue('STORE_DELIVERY_CARRIER'))) {
Configuration::updateValue('STORE_DELIVERY_CARRIER', Tools::getValue('STORE_DELIVERY_CARRIER'));
$carrierObj = new Carrier((int) Tools::getValue('STORE_DELIVERY_CARRIER'));
Configuration::updateValue('STORE_DELIVERY_CARRIER_REFERENCE', $carrierObj->id_reference);
}
if (Tools::getValue('STORE_DELIVERY_DISPLAY_MAP') !== false && Validate::isBool(Tools::getValue('STORE_DELIVERY_DISPLAY_MAP'))) {
Configuration::updateValue('STORE_DELIVERY_DISPLAY_MAP', Tools::getValue('STORE_DELIVERY_DISPLAY_MAP'));
}
if (Tools::getValue('STORE_DELIVERY_HEIGHT_MAP') !== false && Validate::isString(Tools::getValue('STORE_DELIVERY_HEIGHT_MAP'))) {
Configuration::updateValue('STORE_DELIVERY_HEIGHT_MAP', Tools::getValue('STORE_DELIVERY_HEIGHT_MAP'));
}
if (Tools::getValue('STORE_DELIVERY_WIDTH_MAP') !== false && Validate::isString(Tools::getValue('STORE_DELIVERY_WIDTH_MAP'))) {
Configuration::updateValue('STORE_DELIVERY_WIDTH_MAP', Tools::getValue('STORE_DELIVERY_WIDTH_MAP'));
}
if (!Validate::isBool(Tools::getValue('STORE_DELIVERY_SEND_MAIL')) || !Validate::isInt(Tools::getValue('STORE_DELIVERY_CARRIER')) || !Validate::isBool(Tools::getValue('STORE_DELIVERY_DISPLAY_MAP')) || !Validate::isString(Tools::getValue('STORE_DELIVERY_HEIGHT_MAP')) || !Validate::isString(Tools::getValue('STORE_DELIVERY_WIDTH_MAP'))) {
$this->_html .= '<div class="alert">' . $this->l('Error! An information is invalid') . '</div>';
}
}
return $this->_displayForm();
}
示例3: loadData
public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
{
$where = '';
if (!empty($filter['id_currency']) && Validate::isInt($filter['id_currency'])) {
$where .= ' AND a.`id_currency`=' . intval($filter['id_currency']);
}
if (!empty($filter['name']) && Validate::isCatalogName($filter['name'])) {
$where .= ' AND a.`name` LIKE "%' . pSQL($filter['name']) . '%"';
}
if (!empty($filter['active']) && Validate::isInt($filter['active'])) {
$where .= ' AND a.`active`=' . ((int) $filter['active'] == 1 ? '1' : '0');
}
if (!is_null($orderBy) and !is_null($orderWay)) {
$postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
} else {
$postion = 'ORDER BY `id_currency` DESC';
}
$total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'currency` a
WHERE 1
' . $where);
if ($total == 0) {
return false;
}
$result = Db::getInstance()->getAll('SELECT a.* FROM `' . DB_PREFIX . 'currency` a
WHERE 1
' . $where . '
' . $postion . '
LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
$rows = array('total' => $total['total'], 'items' => $result);
return $rows;
}
示例4: getRule
public static function getRule($active = true, $p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
{
if (!Validate::isBool($active)) {
die(Tools::displayError());
}
$where = '';
if (!empty($filter['id_rule']) && Validate::isInt($filter['id_rule'])) {
$where .= ' AND a.`id_rule`=' . intval($filter['id_rule']);
}
if (!empty($filter['entity']) && Validate::isCatalogName($filter['entity'])) {
$where .= ' AND a.`entity` LIKE "%' . pSQL($filter['entity']) . '%"';
}
if (!empty($filter['rule_link']) && Validate::isCatalogName($filter['rule_link'])) {
$where .= ' AND a.`rule_link` LIKE "%' . pSQL($filter['rule_link']) . '%"';
}
if (!empty($filter['id_entity']) && Validate::isInt($filter['id_entity'])) {
$where .= ' AND a.`id_entity`=' . (int) $filter['id_entity'];
}
if (!is_null($orderBy) and !is_null($orderWay)) {
$postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
} else {
$postion = 'ORDER BY `position` ASC';
}
$total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'rule` a
WHERE 1 ' . $where);
$result = Db::getInstance()->getAll('SELECT * FROM `' . DB_PREFIX . 'rule` a
WHERE 1 ' . $where . '
' . $postion . '
LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
$rows = array('total' => $total['total'], 'rules' => $result);
return $rows;
}
示例5: getContent
public function getContent()
{
$output = '<h2>' . $this->displayName . '</h2>';
if (Tools::isSubmit('submitBlockRss')) {
$urlfeed = strval(Tools::getValue('urlfeed'));
$title = strval(Tools::getValue('title'));
$nbr = intval(Tools::getValue('nbr'));
if ($urlfeed and !Validate::isUrl($urlfeed)) {
$errors[] = $this->l('Invalid feed URL');
} elseif (!$title or empty($title) or !Validate::isGenericName($title)) {
$errors[] = $this->l('Invalid title');
} elseif (!$nbr or $nbr <= 0 or !Validate::isInt($nbr)) {
$errors[] = $this->l('Invalid number of feeds');
} else {
Configuration::updateValue('RSS_FEED_URL', $urlfeed);
Configuration::updateValue('RSS_FEED_TITLE', $title);
Configuration::updateValue('RSS_FEED_NBR', $nbr);
}
if (isset($errors) and sizeof($errors)) {
$output .= $this->displayError(implode('<br />', $errors));
} else {
$output .= $this->displayConfirmation($this->l('Settings updated'));
}
}
return $output . $this->displayForm();
}
示例6: isItemsOrder
public static function isItemsOrder($value)
{
$str_error = Tools::displayError('For the items');
foreach ($value as $key => $item) {
$str_error .= ' ' . $key . ' ';
$str_error .= isset($item['name']) ? $item['name'] . ' ' : '';
$str_error .= ' :';
if (isset($item['total_ht']) && !Validate::isFloat($item['total_ht'])) {
throw new TwengaFieldsException($str_error . Tools::displayError('The total HT must be a float value.'));
}
if (isset($item['quantity']) && !Validate::isInt($item['quantity'])) {
throw new TwengaFieldsException($str_error . Tools::displayError('The quantity must be a integer value.'));
}
if (isset($item['sku']) && !is_string($item['sku']) && strlen($item['sku']) > 40) {
throw new TwengaFieldsException($str_error . Tools::displayError('The sku must be a string with length less than 40 chars.'));
}
if (isset($item['name']) && !is_string($item['name'])) {
throw new TwengaFieldsException($str_error . Tools::displayError('The name must be a string with length less than 100 chars.'));
}
if (isset($item['category_name']) && !is_string($item['category_name'])) {
throw new TwengaFieldsException($str_error . Tools::displayError('The category name must be a string with length less than 100 chars.'));
}
}
return true;
}
示例7: getContent
public function getContent()
{
$output = '';
$errors = array();
if (Tools::isSubmit('submitHomeFeatured')) {
$nbr = Tools::getValue('HOME_FEATURED_NBR');
if (!Validate::isInt($nbr) || $nbr <= 0) {
$errors[] = $this->l('The number of products is invalid. Please enter a positive number.');
}
$cat = Tools::getValue('HOME_FEATURED_CAT');
if (!Validate::isInt($cat) || $cat <= 0) {
$errors[] = $this->l('The category ID is invalid. Please choose an existing category ID.');
}
$rand = Tools::getValue('HOME_FEATURED_RANDOMIZE');
if (!Validate::isBool($rand)) {
$errors[] = $this->l('Invalid value for the "randomize" flag.');
}
if (isset($errors) && count($errors)) {
$output = $this->displayError(implode('<br />', $errors));
} else {
Configuration::updateValue('HOME_FEATURED_NBR', (int) $nbr);
Configuration::updateValue('HOME_FEATURED_CAT', (int) $cat);
Configuration::updateValue('HOME_FEATURED_RANDOMIZE', (bool) $rand);
Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath('homefeatured.tpl'));
$output = $this->displayConfirmation($this->l('Your settings have been updated.'));
}
}
return $output . $this->renderForm();
}
示例8: processOrderStep
function processOrderStep($params)
{
global $cart, $smarty, $errors, $isVirtualCart, $orderTotal;
$cart->recyclable = (isset($_POST['recyclable']) and !empty($_POST['recyclable'])) ? 1 : 0;
if (isset($_POST['gift']) and !empty($_POST['gift'])) {
if (!Validate::isMessage($_POST['gift_message'])) {
$errors[] = Tools::displayError('invalid gift message');
} else {
$cart->gift = 1;
$cart->gift_message = strip_tags($_POST['gift_message']);
}
} else {
$cart->gift = 0;
}
$address = new Address(intval($cart->id_address_delivery));
if (!Validate::isLoadedObject($address)) {
die(Tools::displayError());
}
if (!($id_zone = Address::getZoneById($address->id))) {
$errors[] = Tools::displayError('no zone match with your address');
}
if (isset($_POST['id_carrier']) and Validate::isInt($_POST['id_carrier']) and sizeof(Carrier::checkCarrierZone(intval($_POST['id_carrier']), intval($id_zone)))) {
$cart->id_carrier = intval($_POST['id_carrier']);
} elseif (!$isVirtualCart) {
$errors[] = Tools::displayError('invalid carrier or no carrier selected');
}
Module::hookExec('extraCarrierDetailsProcess', array('carrier' => new Carrier($cart->id_carrier)));
$cart->update();
}
示例9: postProcess
public function postProcess()
{
if (Tools::isSubmit('submitAddconfiguration')) {
$themeName = $this->_getThemeName();
$modes = getSliderModes();
$sliders = getSliders();
foreach ($sliders as $sliderName => $sliderCaption) {
foreach ($modes as $modeName => $modeCaption) {
$name = getSliderSettingsName($themeName, $sliderName, $modeName);
$value = Tools::getValue($name, '');
if (Validate::isInt($value) || empty($value)) {
$value = empty($value) ? '' : $value;
Configuration::updateValue($name, $value);
} else {
$this->errors[] = $this->l('Invalid value for slider "' . $sliderCaption . '" in "' . $modeCaption . '" mode');
}
}
}
$sourceTemplates = getTemplates();
foreach ($sourceTemplates as $type => $caption) {
$name = getTemplateName($themeName, $type);
$value = Tools::getValue($name, '');
Configuration::updateValue($name, $value);
}
if (!count($this->errors)) {
$this->confirmations[] = $this->l('The settings have been updated.');
}
}
return parent::postProcess();
}
示例10: getContent
public function getContent()
{
$output = '';
$errors = array();
if (Tools::isSubmit('submitBlockTags')) {
$tagsNbr = Tools::getValue('BLOCKTAGS_NBR');
if (!strlen($tagsNbr)) {
$errors[] = $this->l('Please complete the "Displayed tags" field.');
} elseif (!Validate::isInt($tagsNbr) || (int) $tagsNbr <= 0) {
$errors[] = $this->l('Invalid number.');
}
$tagsLevels = Tools::getValue('BLOCKTAGS_MAX_LEVEL');
if (!strlen($tagsLevels)) {
$errors[] = $this->l('Please complete the "Tag levels" field.');
} elseif (!Validate::isInt($tagsLevels) || (int) $tagsLevels <= 0) {
$errors[] = $this->l('Invalid value for "Tag levels". Choose a positive integer number.');
}
$randomize = Tools::getValue('BLOCKTAGS_RANDOMIZE');
if (!strlen($randomize)) {
$errors[] = $this->l('Please complete the "Randomize" field.');
} elseif (!Validate::isBool($randomize)) {
$errors[] = $this->l('Invalid value for "Randomize". It has to be a boolean.');
}
if (count($errors)) {
$output = $this->displayError(implode('<br />', $errors));
} else {
Configuration::updateValue('BLOCKTAGS_NBR', (int) $tagsNbr);
Configuration::updateValue('BLOCKTAGS_MAX_LEVEL', (int) $tagsLevels);
Configuration::updateValue('BLOCKTAGS_RANDOMIZE', (bool) $randomize);
$output = $this->displayConfirmation($this->l('Settings updated'));
}
}
return $output . $this->renderForm();
}
示例11: loadData
public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
{
$where = '';
if (!empty($filter['id_onepage']) && Validate::isInt($filter['id_onepage'])) {
$where .= ' AND a.`id_onepage`=' . intval($filter['id_onepage']);
}
if (!empty($filter['view_name']) && Validate::isEntityName($filter['view_name'])) {
$where .= ' AND a.`view_name` LIKE "%' . pSQL($filter['view_name']) . '%"';
}
if (!empty($filter['meta_title']) && Validate::isGenericName($filter['meta_title'])) {
$where .= ' AND a.`meta_title` LIKE "%' . pSQL($filter['meta_title']) . '%"';
}
if (!empty($filter['rewrite']) && Validate::isLinkRewrite($filter['rewrite'])) {
$where .= ' AND a.`rewrite` LIKE "%' . pSQL($filter['rewrite']) . '%"';
}
if (!is_null($orderBy) and !is_null($orderWay)) {
$postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
} else {
$postion = 'ORDER BY `id_onepage` DESC';
}
$total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'onepage` a
WHERE 1 ' . $where);
if ($total == 0) {
return false;
}
$result = Db::getInstance()->getAll('SELECT a.* FROM `' . DB_PREFIX . 'onepage` a
WHERE 1 ' . $where . '
' . $postion . '
LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
$rows = array('total' => $total['total'], 'items' => $result);
return $rows;
}
示例12: setRootCategory
public function setRootCategory($value)
{
if (!Validate::isInt($value)) {
throw new PrestaShopException('Root category must be an integer value');
}
$this->_root_category = $value;
return $this;
}
示例13: setLanguage
private function setLanguage()
{
if (isset($_GET['language']) and Validate::isInt($_GET['language'])) {
$id_lang = intval($_GET['language']);
}
if (!isset($id_lang)) {
$id_lang = $this->getIdByHAL();
}
$this->lang = $this->xml_file->lang[intval($id_lang)];
}
示例14: updateCalculateExamResultStatus
/**
* 更新考试结果计算的状态
* @param int|array $id 需要更新的考试记录
* @param int $status 更新的状态
* @return boolean
*/
public static function updateCalculateExamResultStatus($id, $status)
{
if (!$id || !is_array($id) && !Validate::isInt($id)) {
return false;
}
if (is_array($id)) {
$where = "id IN (" . implode(',', $id) . ")";
} else {
$where = "id = {$id}";
}
return Fn::db()->update("rd_cron_task_exam_result", array('status' => intval($status)), $where);
}
示例15: loadData
public static function loadData($p = 1, $limit = 50, $orderBy = NULL, $orderWay = NULL, $filter = array())
{
$where = '';
if (!empty($filter['id_order']) && Validate::isInt($filter['id_order'])) {
$where .= ' AND a.`id_order`=' . intval($filter['id_order']);
}
if (!empty($filter['reference']) && Validate::isInt($filter['reference'])) {
$where .= ' AND a.`reference`=' . intval($filter['reference']);
}
if (!empty($filter['payment'])) {
$where .= ' AND a.`payment` LIKE "%' . pSQL($filter['payment']) . '%"';
}
if (!empty($filter['id_cart']) && Validate::isCatalogName($filter['id_cart'])) {
$where .= ' AND a.`id_cart` = ' . intval($filter['id_cart']);
}
if (!empty($filter['name']) && Validate::isCatalogName($filter['name'])) {
$where .= ' AND u.`name` LIKE "%' . pSQL($filter['name']) . '%"';
}
if (!empty($filter['email']) && Validate::isInt($filter['email'])) {
$where .= ' AND a.`email` LIKE "%' . pSQL($filter['email']) . '%"';
}
if (!is_null($orderBy) and !is_null($orderWay)) {
$postion = 'ORDER BY ' . pSQL($orderBy) . ' ' . pSQL($orderWay);
} else {
$postion = 'ORDER BY `id_order` DESC';
}
$total = Db::getInstance()->getRow('SELECT count(*) AS total FROM `' . DB_PREFIX . 'order` a
LEFT JOIN `' . DB_PREFIX . 'user` u ON (a.id_user = u.id_user)
LEFT JOIN `' . DB_PREFIX . 'carrier` c ON (a.id_carrier = c.id_carrier)
LEFT JOIN `' . DB_PREFIX . 'order_status` os ON (os.id_order_status = a.id_order_status)
WHERE 1
' . $where);
if ($total == 0) {
return false;
}
$result = Db::getInstance()->getAll('SELECT a.*, m.name AS `payment`, u.name, c.name as carrier, os.name as status, os.color
FROM `' . DB_PREFIX . 'order` a
LEFT JOIN `' . DB_PREFIX . 'user` u ON (a.id_user = u.id_user)
LEFT JOIN `' . DB_PREFIX . 'module` m ON (a.id_module = m.id_module)
LEFT JOIN `' . DB_PREFIX . 'carrier` c ON (a.id_carrier = c.id_carrier)
LEFT JOIN `' . DB_PREFIX . 'order_status` os ON (os.id_order_status = a.id_order_status)
WHERE 1
' . $where . '
' . $postion . '
LIMIT ' . ($p - 1) * $limit . ',' . (int) $limit);
$rows = array('total' => $total['total'], 'items' => $result);
return $rows;
}