本文整理汇总了PHP中Validate::isBool方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isBool方法的具体用法?PHP Validate::isBool怎么用?PHP Validate::isBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::isBool方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: _update_value
private function _update_value($key, $value)
{
$interface = PS_CLI_Interface::getInterface();
$validValue = true;
switch ($key) {
case 'PS_ONE_PHONE_AT_LEAST':
case 'PS_REGISTRATION_PROCESS_TYPE':
case 'PS_CART_FOLLOWING':
case 'PS_CUSTOMER_CREATION_EMAIL':
case 'PS_B2B_ENABLE':
$validValue = Validate::isBool($value);
break;
case 'PS_PASSWD_TIME_FRONT':
$validValue = Validate::isUnsignedInt($value);
break;
default:
$interface->error("The configuration key {$key} is not handled by this plugin !");
break;
}
if (!$validValue) {
$interface->error("Invalid value '{$value}' for configuration key '{$key}'");
}
if (PS_CLI_Utils::update_configuration_value($key, $value)) {
$interface->success("Successfully updated configuration key '{$key}'");
} else {
$interface->error("Could not update configuration key '{$key}'");
}
}
示例3: getProductsCollection
/**
* Lists of items
* @param int $iIdLang
* @param bool $active
* @return array
*/
public static function getProductsCollection($iIdLang = null, $bActive = true)
{
if (!Validate::isBool($bActive)) {
die(Tools::displayError());
}
if (is_null($iIdLang)) {
$iIdLang = (int) Context::getContext()->language->id;
}
$sSQL = '
SELECT r.`id_product`
FROM `' . _DB_PREFIX_ . 'now_mea_home` r
' . Shop::addSqlAssociation('now_mea_home', 'r') . '
LEFT JOIN `' . _DB_PREFIX_ . 'now_product_type_product` pt ON (pt.`id_product` = r.`id_product`)
WHERE 1 ' . ($bActive ? ' AND r.`active` = 1 ' : '') . '
AND pt.`id_now_product_type_product` IS NULL
ORDER BY RAND() LIMIT 0 , ' . Configuration::get('NOW_MEA_HOME_NB_PRODUCT');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sSQL);
$aProducts = array();
foreach ($result as $row) {
$oProduct = new Product($row['id_product'], false, $iIdLang);
$oProduct->loadStockData();
$aProducts[] = $oProduct;
}
return $aProducts;
}
示例4: getByIdProductTypes
/**
* @param array $aIdProductType
* @param null $iIdLang
* @param bool $bActive
* @return mixed
* @throws PrestaShopDatabaseException
*/
public static function getByIdProductTypes($aIdProductType = array(), $iIdLang = null, $bActive = true)
{
if (!Validate::isBool($bActive)) {
die(Tools::displayError());
}
if (empty($aIdProductType)) {
return array();
}
if (is_null($iIdLang)) {
$iIdLang = (int) Context::getContext()->language->id;
}
$sSQL = '
SELECT *
FROM `' . _DB_PREFIX_ . 'now_product_type` pt
INNER JOIN `' . _DB_PREFIX_ . 'now_product_type_lang` ptl ON (pt.`id_now_product_type` = ptl.`id_now_product_type` AND ptl.`id_lang` = ' . (int) $iIdLang . ')
WHERE 1 ' . ($bActive ? 'AND pt.`active` = 1' : '') . '
AND pt.`id_now_product_type` IN (' . implode(',', $aIdProductType) . ')
';
$aResult = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sSQL);
$aProductTypes = array();
foreach ($aResult as $aRow) {
$aProductTypes[$aRow['id_now_product_type']] = $aRow;
}
return $aProductTypes;
}
示例5: 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();
}
示例6: 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();
}
示例7: 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;
}
示例8: getCountries
/**
* Return available countries
*
* @param integer $id_lang Language ID
* @param boolean $active return only active coutries
* @return array Countries and corresponding zones
*/
public static function getCountries($id_lang, $active = false, $containStates = NULL)
{
if (!Validate::isBool($active)) {
die(Tools::displayError());
}
$states = Db::getInstance()->ExecuteS('
SELECT s.*
FROM `' . _DB_PREFIX_ . 'state` s
');
$result = Db::getInstance()->ExecuteS('
SELECT cl.*,c.*, cl.`name` AS country, z.`name` AS zone
FROM `' . _DB_PREFIX_ . 'country` c
LEFT JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = ' . intval($id_lang) . ')
LEFT JOIN `' . _DB_PREFIX_ . 'zone` z ON z.`id_zone` = c.`id_zone`
WHERE 1
' . ($active ? 'AND c.active = 1' : '') . '
' . (!is_null($containStates) ? 'AND c.`contains_states` = ' . intval($containStates) : '') . '
ORDER BY cl.name ASC');
$countries = array();
foreach ($result as &$country) {
$countries[$country['id_country']] = $country;
}
foreach ($states as &$state) {
if (isset($countries[$state['id_country']])) {
/* Does not keep the state if its country has been disabled and not selected */
$countries[$state['id_country']]['states'][] = $state;
}
}
return $countries;
}
示例9: _update_configuration
protected function _update_configuration($key, $value)
{
$interface = PS_CLI_Interface::getInterface();
$validValue = false;
switch ($key) {
case 'PS_STORE_DISPLAY_FOOTER':
case 'PS_STORE_DISPLAY_SITEMAP':
case 'PS_STORE_SIMPLIFIED':
$validValue = Validate::isBool($value);
break;
case 'PS_STORES_CENTER_LAT':
case 'PS_STORES_CENTER_LONG':
$validValue = Validate::isCoordinate($value);
break;
case 'PS_SHOP_NAME':
$validValue = Validate::isName($value);
break;
case 'PS_SHOP_EMAIL':
$validValue = Validate::isEmail($value);
break;
case 'PS_SHOP_DETAILS':
$validValue = Validate::isString($value);
break;
case 'PS_SHOP_ADDR1':
case 'PS_SHOP_ADDR2':
$validValue = Validate::isAddress($value);
break;
case 'PS_SHOP_CODE':
$validValue = Validate::isPostCode($value);
break;
case 'PS_SHOP_CITY':
$validValue = Validate::isCityName($value);
break;
case 'PS_SHOP_COUNTRY_ID':
if (Validate::isUnsignedId($value)) {
$obj = new Country((int) $value);
$validValue = Validate::isLoadedObject($obj);
}
break;
case 'PS_SHOP_STATE_ID':
$validValue = Validate::isUnsignedId($value);
break;
case 'PS_SHOP_PHONE':
case 'PS_SHOP_FAX':
$validValue = Validate::isPhoneNumber($value);
break;
default:
$interface->error("Configuration key '{$key}' is not handled by this command");
break;
}
if (!$validValue) {
$interface->error("value '{$value}' is not a valid value for configuration key '{$key}'");
}
if (PS_CLI_Utils::update_configuration_value($key, $value)) {
$interface->success("Successfully updated '{$key}' configuration");
} else {
$interface->error("Could not update configuration key '{$key}'");
}
}
示例10: getCategories
public function getCategories($id_categories, $id_lang = false, $active = true, $sql_filter = '', $sql_sort = '', $sql_limit = '')
{
if (!Validate::isBool($active)) {
die(Tools::displayError());
}
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT *
FROM `' . _DB_PREFIX_ . 'category` c
' . Shop::addSqlAssociation('category', 'c') . '
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON c.`id_category` = cl.`id_category`' . Shop::addSqlRestrictionOnLang('cl') . '
WHERE 1 ' . pSQL($sql_filter) . ' ' . ($id_lang ? 'AND `id_lang` = ' . (int) $id_lang : '') . ($id_categories ? ' AND c.id_category IN (' . pSQL($id_categories) . ')' : '') . ($active ? ' AND `active` = 1' : '') . (!$id_lang ? ' GROUP BY c.id_category' : '') . ($sql_sort != '' ? $sql_sort : ' ORDER BY c.`level_depth` ASC, category_shop.`position` ASC ') . ($sql_limit != '' ? $sql_limit : ''));
return $result;
}
示例11: getPaySystems
public static function getPaySystems($id_lang, $active = true, $id_carrier = false, $groups = array())
{
if (!Validate::isBool($active)) {
die(Tools::displayError());
}
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT *
FROM `' . _DB_PREFIX_ . 'universalpay_system` us
LEFT JOIN `' . _DB_PREFIX_ . 'universalpay_system_lang` usl ON us.`id_universalpay_system` = usl.`id_universalpay_system`
' . ($id_carrier ? 'JOIN `' . _DB_PREFIX_ . 'universalpay_system_carrier` usc
ON (us.`id_universalpay_system` = usc.`id_universalpay_system` AND usc.`id_carrier`=' . (int) $id_carrier . ')' : '') . '
' . (!empty($groups) ? 'JOIN `' . _DB_PREFIX_ . 'universalpay_system_group` usg
ON (us.`id_universalpay_system` = usg.`id_universalpay_system` AND usg.`id_group` IN (' . implode(',', array_map('intval', $groups)) . '))' : '') . 'WHERE `id_lang` = ' . (int) $id_lang . ($active ? ' AND `active` = 1' : '') . '
GROUP BY us.`id_universalpay_system`
ORDER BY us.`position` ASC');
return $result;
}
示例12: getProductsById
/**
* Permet de récupèrer tous les produits qui sont "typer"
* @return array
*/
public static function getProductsById($bActive = true)
{
if (!Validate::isBool($bActive)) {
die(Tools::displayError());
}
$sSQL = '
SELECT *
FROM `' . _DB_PREFIX_ . 'now_product_type_product` pt
' . Shop::addSqlAssociation('now_product_type_product', 'pt') . '
WHERE 1 ' . ($bActive ? 'AND pt.`active` = 1' : '');
$aResults = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sSQL);
$aProductsTypes = array();
foreach ($aResults as $aRow) {
$aProductsTypes[$aRow['id_product']] = $aRow['id_now_product_type'];
}
return $aProductsTypes;
}
示例13: getMessagesByOrderId
/**
* Return name from Order ID
*
* @param integer $id_order Order ID
* @param boolean $private return WITH private messages
* @return array Messages
*/
public static function getMessagesByOrderId($id_order, $private = false)
{
if (!Validate::isBool($private)) {
die(Tools::displayError());
}
global $cookie;
$result = Db::getInstance()->ExecuteS('
SELECT m.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname, (COUNT(mr.id_message) = 0 AND m.id_customer != 0) AS is_new_for_me
FROM `' . _DB_PREFIX_ . 'message` m
LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON m.`id_customer` = c.`id_customer`
LEFT JOIN `' . _DB_PREFIX_ . 'message_readed` mr ON (mr.id_message = m.id_message AND mr.id_employee = ' . intval($cookie->id_employee) . ')
LEFT OUTER JOIN `' . _DB_PREFIX_ . 'employee` e ON e.`id_employee` = m.`id_employee`
WHERE id_order = ' . intval($id_order) . '
' . (!$private ? ' AND m.`private` = 0' : '') . '
GROUP BY m.id_message
ORDER BY m.date_add DESC
');
return $result;
}
示例14: getContent
public function getContent()
{
$this->_html = '<h2>' . $this->displayName . '</h2>';
if (Tools::isSubmit('submitUpdate')) {
if (isset($_POST['new_page']) and Validate::isBool((int) $_POST['new_page'])) {
Configuration::updateValue('NW_CONFIRMATION_NEW_PAGE', $_POST['new_page']);
}
if (isset($_POST['conf_email']) and VAlidate::isBool((int) $_POST['conf_email'])) {
Configuration::updateValue('NW_CONFIRMATION_EMAIL', pSQL($_POST['conf_email']));
}
if (!empty($_POST['voucher']) and !Validate::isDiscountName($_POST['voucher'])) {
$this->_html .= '<div class="alert">' . $this->l('Voucher code is invalid') . '</div>';
} else {
Configuration::updateValue('NW_VOUCHER_CODE', pSQL($_POST['voucher']));
$this->_html .= '<div class="conf ok">' . $this->l('Updated') . '</div>';
}
}
return $this->_displayForm();
}
示例15: getCMSCategories
public function getCMSCategories($active = true, $order = true, $sql_filter = '', $sql_sort = '', $sql_limit = '')
{
if (!Validate::isBool($active)) {
die(Tools::displayError());
}
$result = Db::getInstance()->getAll('
SELECT *
FROM `' . DB_PREFIX . 'cms_category` c
WHERE 1 ' . $sql_filter . '
' . ($active ? 'AND `active` = 1' : '') . '
' . ($sql_sort != '' ? $sql_sort : 'ORDER BY c.`position` ASC') . '
' . ($sql_limit != '' ? $sql_limit : ''));
if (!$order) {
return $result;
}
$categories = array();
foreach ($result as $row) {
$categories[$row['id_parent']][$row['id_cms_category']]['infos'] = $row;
}
return $categories;
}