本文整理汇总了PHP中Validate::isUnsignedInt方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isUnsignedInt方法的具体用法?PHP Validate::isUnsignedInt怎么用?PHP Validate::isUnsignedInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::isUnsignedInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getItems
/**
* Get product accessories
*
* @param integer $id_lang Language id
* @return array Product accessories
*/
public static function getItems($iIdProduct, $id_lang, $active = true, Context $context = null)
{
if (!$context) {
$context = Context::getContext();
}
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`,
pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, pl.`available_now`, pl.`available_later`,
MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` as manufacturer_name, cl.`name` AS category_default,
DATEDIFF(
p.`date_add`,
DATE_SUB(
NOW(),
INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . ' DAY
)
) > 0 AS new
FROM `' . _DB_PREFIX_ . 'now_ideas_or_tips`
LEFT JOIN `' . _DB_PREFIX_ . 'product` p ON p.`id_product` = `id_product_2`
' . Shop::addSqlAssociation('product', 'p') . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . '
)
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (
product_shop.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('cl') . '
)
LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (p.`id_manufacturer`= m.`id_manufacturer`)
' . Product::sqlStock('p', 0) . '
WHERE `id_product_1` = ' . (int) $iIdProduct . ($active ? ' AND product_shop.`active` = 1 AND product_shop.`visibility` != \'none\'' : '') . '
GROUP BY product_shop.id_product';
if (!($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))) {
return false;
}
foreach ($result as &$row) {
$row['id_product_attribute'] = Product::getDefaultAttribute((int) $row['id_product']);
}
return Product::getProductsProperties($id_lang, $result);
}
示例2: getContent
public function getContent()
{
$html = '
<h2>' . $this->l('Payment logo.') . '</h2>
';
if (Tools::isSubmit('submitConfiguration')) {
if (Validate::isUnsignedInt(Tools::getValue('id_cms'))) {
Configuration::updateValue('PS_PAYMENT_LOGO_CMS_ID', (int) Tools::getValue('id_cms'));
$this->_clearCache('blockpaymentlogo.tpl');
$html .= $this->displayConfirmation($this->l('The settings have been updated.'));
}
}
$cmss = CMS::listCms($this->context->language->id);
if (!count($cmss)) {
$html .= $this->displayError($this->l('No CMS page is available.'));
} else {
$html .= '
<form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post">
<fieldset>
<legend><img src="' . $this->_path . '/logo.gif" alt="" /> ' . $this->l('Configure') . '</legend>
<label>' . $this->l('Page CMS for link') . ':</label>
<div class="margin-form">
<select name="id_cms"><option value="0">(' . $this->l('Select a page') . ')</option>';
foreach ($cmss as $cms) {
$html .= '<option value="' . $cms['id_cms'] . '"' . (Configuration::get('PS_PAYMENT_LOGO_CMS_ID') == $cms['id_cms'] ? ' selected="selected"' : '') . '>' . $cms['meta_title'] . '</option>';
}
$html .= '</select>
</div>
<p class="center"><input class="button" type="submit" name="submitConfiguration" value="' . $this->l('Save settings') . '" /></p>
</fieldset>
</form>
';
}
return $html;
}
示例3: cleanRelatedForPost
public static function cleanRelatedForPost($id_simpleblog_post)
{
if (!Validate::isUnsignedInt($id_simpleblog_post)) {
die(Tools::displayError());
}
return Db::getInstance()->delete('simpleblog_related_post', 'id_simpleblog_post = ' . (int) $id_simpleblog_post);
}
示例4: _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}'");
}
}
示例5: getContent
function getContent()
{
$output = '';
if (Tools::isSubmit('submitBlockSuppliers')) {
$text_list = (int) Tools::getValue('SUPPLIER_DISPLAY_TEXT');
$text_nb = (int) Tools::getValue('SUPPLIER_DISPLAY_TEXT_NB');
$form_list = (int) Tools::getValue('SUPPLIER_DISPLAY_FORM');
if ($text_list and !Validate::isUnsignedInt($text_nb)) {
$errors[] = $this->l('Invalid number of elements.');
} elseif (!$text_list and !$form_list) {
$errors[] = $this->l('Please activate at least one type of list.');
} else {
Configuration::updateValue('SUPPLIER_DISPLAY_TEXT', $text_list);
Configuration::updateValue('SUPPLIER_DISPLAY_TEXT_NB', $text_nb);
Configuration::updateValue('SUPPLIER_DISPLAY_FORM', $form_list);
$this->_clearCache('blocksupplier.tpl');
}
if (isset($errors) and sizeof($errors)) {
$output .= $this->displayError(implode('<br />', $errors));
} else {
$output .= $this->displayConfirmation($this->l('Settings updated.'));
}
}
return $output . $this->renderForm();
}
示例6: renderContent
public function renderContent($setting)
{
$t = array('product_id' => 0, 'image_height' => '320', 'image_width' => 300);
$setting = array_merge($t, $setting);
$id_lang = (int) $this->lang_id;
$id_product = $setting['product_id'];
$sql = 'SELECT p.*, product_shop.*, stock.`out_of_stock` out_of_stock, pl.`description`, pl.`description_short`,
pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
p.`ean13`, p.`upc`, MAX(image_shop.`id_image`) id_image, il.`legend`,
DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(),
INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . '
DAY)) > 0 AS new
FROM `' . _DB_PREFIX_ . 'product` p
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . '
)
' . Shop::addSqlAssociation('product', 'p') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
' . Product::sqlStock('p', 0) . '
WHERE p.id_product = ' . (int) $id_product . '
GROUP BY product_shop.id_product';
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (!$row) {
return false;
}
if (isset($row['id_product_attribute']) && $row['id_product_attribute']) {
$row['id_product_attribute'] = $row['id_product_attribute'];
}
$p = Product::getProductProperties($id_lang, $row);
$setting['product'] = $p;
$output = array('type' => 'product', 'data' => $setting);
return $output;
}
示例7: getBestSales
public static function getBestSales($id_lang, $page_number = 0, $nb_products = 10, $order_by = null, $order_way = null)
{
if ($page_number < 0) {
$page_number = 0;
}
if ($nb_products < 1) {
$nb_products = 10;
}
$final_order_by = $order_by;
if (empty($order_by) || $order_by == 'position' || ($order_by = 'price')) {
$order_by = 'sales';
}
if (empty($order_way) || $order_by == 'sales') {
$order_way = 'DESC';
}
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups = count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1';
$interval = Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20;
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity,
pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
m.`name` AS manufacturer_name, p.`id_manufacturer` as id_manufacturer,
MAX(image_shop.`id_image`) id_image, il.`legend`,
ps.`quantity` AS sales, t.`rate`, pl.`meta_keywords`, pl.`meta_title`, pl.`meta_description`,
DATEDIFF(p.`date_add`, DATE_SUB(NOW(),
INTERVAL ' . $interval . ' DAY)) > 0 AS new
FROM `' . _DB_PREFIX_ . 'product_sale` ps
LEFT JOIN `' . _DB_PREFIX_ . 'product` p ON ps.`id_product` = p.`id_product`
' . Shop::addSqlAssociation('product', 'p', false) . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
ON p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (product_shop.`id_tax_rules_group` = tr.`id_tax_rules_group`)
AND tr.`id_country` = ' . (int) Context::getContext()->country->id . '
AND tr.`id_state` = 0
LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`)
' . Product::sqlStock('p') . '
WHERE product_shop.`active` = 1
AND p.`visibility` != \'none\'
AND p.`id_product` IN (
SELECT cp.`id_product`
FROM `' . _DB_PREFIX_ . 'category_group` cg
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`)
WHERE cg.`id_group` ' . $sql_groups . '
)
GROUP BY product_shop.id_product
ORDER BY `' . pSQL($order_by) . '` ' . pSQL($order_way) . '
LIMIT ' . (int) ($page_number * $nb_products) . ', ' . (int) $nb_products;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if ($final_order_by == 'price') {
Tools::orderbyPrice($result, $order_way);
}
if (!$result) {
return false;
}
return Product::getProductsProperties($id_lang, $result);
}
示例8: getContent
public function getContent()
{
global $cookie;
$html = '
<h2>' . $this->l('Payment logo') . '</h2>
';
if (Tools::isSubmit('submitConfiguration')) {
if (Validate::isUnsignedInt(Tools::getValue('id_cms'))) {
Configuration::updateValue('PS_PAYMENT_LOGO_CMS_ID', intval(Tools::getValue('id_cms')));
$html .= $this->displayConfirmation($this->l('Settings are updated'));
}
}
$cmss = CMS::listCms(intval($cookie->id_lang));
if (!sizeof($cmss)) {
$html .= $this->displayError($this->l('No CMS page is available'));
} else {
$html .= '
<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">
<fieldset>
<legend><img src="' . $this->_path . '/logo.gif" alt="" /> ' . $this->l('Configure') . '</legend>
<label>' . $this->l('Page CMS for link') . ':</label>
<div class="margin-form">
<select name="id_cms">';
foreach ($cmss as $cms) {
$html .= '<option value="' . $cms['id_cms'] . '"' . (Configuration::get('PS_PAYMENT_LOGO_CMS_ID') == $cms['id_cms'] ? ' selected="selected"' : '') . '>' . $cms['meta_title'] . '</option>';
}
$html .= '</select>
</div>
<p class="center"><input class="button" type="submit" name="submitConfiguration" value="' . $this->l('Save settings') . '" /></p>
</fieldset>
</form>
';
}
return $html;
}
示例9: hasProductDownload
public function hasProductDownload($cart)
{
foreach ($cart->getProducts() as $product) {
$pd = ProductDownload::getIdFromIdProduct((int) $product['id_product']);
if ($pd and Validate::isUnsignedInt($pd)) {
return true;
}
}
return false;
}
示例10: getMailAlerts
public static function getMailAlerts($id_customer, $id_lang, Shop $shop = null)
{
if (!Validate::isUnsignedId($id_customer) || !Validate::isUnsignedId($id_lang)) {
die(Tools::displayError());
}
if (!$shop) {
$shop = Context::getContext()->shop;
}
$customer = new Customer($id_customer);
$products = MailAlert::getProducts($customer, $id_lang);
$products_number = count($products);
if (empty($products) === true || !$products_number) {
return array();
}
for ($i = 0; $i < $products_number; ++$i) {
$obj = new Product((int) $products[$i]['id_product'], false, (int) $id_lang);
if (!Validate::isLoadedObject($obj)) {
continue;
}
if (isset($products[$i]['id_product_attribute']) && Validate::isUnsignedInt($products[$i]['id_product_attribute'])) {
$attributes = self::getProductAttributeCombination($products[$i]['id_product_attribute'], $id_lang);
$products[$i]['attributes_small'] = '';
if ($attributes) {
foreach ($attributes as $k => $row) {
$products[$i]['attributes_small'] .= $row['attribute_name'] . ', ';
}
}
$products[$i]['attributes_small'] = rtrim($products[$i]['attributes_small'], ', ');
$products[$i]['id_shop'] = $shop->id;
/* Get cover */
$attrgrps = $obj->getAttributesGroups((int) $id_lang);
foreach ($attrgrps as $attrgrp) {
if ($attrgrp['id_product_attribute'] == (int) $products[$i]['id_product_attribute'] && ($images = Product::_getAttributeImageAssociations((int) $attrgrp['id_product_attribute']))) {
$products[$i]['cover'] = $obj->id . '-' . array_pop($images);
break;
}
}
}
if (!isset($products[$i]['cover']) || !$products[$i]['cover']) {
$images = $obj->getImages((int) $id_lang);
foreach ($images as $k => $image) {
if ($image['cover']) {
$products[$i]['cover'] = $obj->id . '-' . $image['id_image'];
break;
}
}
}
if (!isset($products[$i]['cover'])) {
$products[$i]['cover'] = Language::getIsoById($id_lang) . '-default';
}
$products[$i]['link'] = $obj->getLink();
$products[$i]['link_rewrite'] = $obj->link_rewrite;
}
return $products;
}
示例11: getSlugById
public static function getSlugById($id_simpleblog_post_type)
{
if (!Validate::isUnsignedInt($id_simpleblog_post_type)) {
return Tools::displayError('getSlugByID - invalid ID');
}
$sql = new DbQuery();
$sql->select('slug');
$sql->from('simpleblog_post_type', 'sbpt');
$sql->where('id_simpleblog_post_type = ' . (int) $id_simpleblog_post_type);
return Db::getInstance()->getValue($sql);
}
示例12: getAllById
public static function getAllById($id_simpleblog_post)
{
if (!Validate::isUnsignedInt($id_simpleblog_post)) {
return Tools::displayError('getAllById - invalid ID');
}
$sql = new DbQuery();
$sql->select('*');
$sql->from('simpleblog_post_image', 'sbpi');
$sql->where('id_simpleblog_post = ' . (int) $id_simpleblog_post);
$sql->orderBy('position ASC');
return Db::getInstance()->executeS($sql);
}
示例13: getBestSales
public static function getBestSales($id_lang, $pageNumber = 0, $nbProducts = 10, $orderBy = null, $orderWay = null)
{
if ($pageNumber < 0) {
$pageNumber = 0;
}
if ($nbProducts < 1) {
$nbProducts = 10;
}
if (empty($orderBy) || $orderBy == 'position') {
$orderBy = 'sales';
}
if (empty($orderWay)) {
$orderWay = 'DESC';
}
$groups = FrontController::getCurrentCustomerGroups();
$sqlGroups = count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT p.*,
pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, m.`name` manufacturer_name, p.`id_manufacturer` as id_manufacturer,
i.`id_image`, il.`legend`,
ps.`quantity` sales, t.`rate`, pl.`meta_keywords`, pl.`meta_title`, pl.`meta_description`,
DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . ' DAY)) > 0 new
FROM `' . _DB_PREFIX_ . 'product_sale` ps
LEFT JOIN `' . _DB_PREFIX_ . 'product` p ON ps.`id_product` = p.`id_product`
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . (int) $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
AND tr.`id_country` = ' . (int) Country::getDefaultCountryId() . '
AND tr.`id_state` = 0)
LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`)
WHERE p.`active` = 1
AND p.`id_product` IN (
SELECT cp.`id_product`
FROM `' . _DB_PREFIX_ . 'category_group` cg
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`)
WHERE cg.`id_group` ' . $sqlGroups . '
)
ORDER BY ' . (isset($orderByPrefix) ? $orderByPrefix . '.' : '') . '`' . pSQL($orderBy) . '` ' . pSQL($orderWay) . '
LIMIT ' . (int) ($pageNumber * $nbProducts) . ', ' . (int) $nbProducts);
if ($orderBy == 'price') {
Tools::orderbyPrice($result, $orderWay);
}
if (!$result) {
return false;
}
return Product::getProductsProperties($id_lang, $result);
}
示例14: addMissingProductFields
private function addMissingProductFields(array $rawProduct)
{
$id_shop = (int) $this->searchContext->getIdShop();
$id_lang = (int) $this->searchContext->getIdLang();
$id_product = (int) $rawProduct['id_product'];
$prefix = _DB_PREFIX_;
$nb_days_new_product = (int) Configuration::get('PS_NB_DAYS_NEW_PRODUCT');
if (!Validate::isUnsignedInt($nb_days_new_product)) {
$nb_days_new_product = 20;
}
$now = date('Y-m-d') . ' 00:00:00';
$sql = "SELECT\n p.*,\n pl.*,\n (DATEDIFF(\n\t\t\t\tp.`date_add`,\n\t\t\t\tDATE_SUB(\n\t\t\t\t\t'{$now}',\n\t\t\t\t\tINTERVAL {$nb_days_new_product} DAY\n\t\t\t\t)\n\t\t\t) > 0) as new\n FROM {$prefix}product p\n INNER JOIN {$prefix}product_lang pl\n ON pl.id_product = p.id_product\n AND pl.id_shop = {$id_shop}\n AND pl.id_lang = {$id_lang}\n AND p.id_product = {$id_product}";
$rows = Db::getInstance()->executeS($sql);
return array_merge($rawProduct, $rows[0]);
}
示例15: hookPayment
public function hookPayment($params)
{
if (!$this->active) {
return;
}
global $smarty;
// Check if cart has product download
foreach ($params['cart']->getProducts() as $product) {
$pd = ProductDownload::getIdFromIdProduct((int) $product['id_product']);
if ($pd and Validate::isUnsignedInt($pd)) {
return false;
}
}
$smarty->assign(array('this_path' => $this->_path, 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/'));
return $this->display(__FILE__, 'payment.tpl');
}