本文整理汇总了PHP中Validate::isFloat方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isFloat方法的具体用法?PHP Validate::isFloat怎么用?PHP Validate::isFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::isFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContent
public function getContent()
{
$output = null;
if (Tools::isSubmit('submit' . $this->name)) {
$list_value = strval(Tools::getValue('PROFIT_MARGIN'));
if (!$list_value || empty($list_value) || !Validate::isFloat($list_value)) {
$output .= $this->displayError($this->l('Invalid Configuration value'));
} else {
$email_value = strval(Tools::getValue('ORDER_CNF_MANAGER_EMAIL'));
if (Tools::getValue('ADMIN_CONFIRM_ORDER') == '1' && (empty($email_value) || !Validate::isEmail($email_value))) {
$output .= $this->displayError($this->l('Please enter valid Email ID'));
} else {
$email_value = strval(Tools::getValue('PRODUCT_REQUEST_EMAIL'));
if (empty($email_value) || !Validate::isEmail($email_value)) {
$output .= $this->displayError($this->l('Please enter valid Email ID'));
} else {
Configuration::updateValue('PROFIT_MARGIN', $list_value);
Configuration::updateValue('PRODUCT_DYNAMIC_PRICE', Tools::getValue('PRODUCT_DYNAMIC_PRICE'));
Configuration::updateValue('ORDER_CNF_MANAGER_EMAIL', Tools::getValue('ORDER_CNF_MANAGER_EMAIL'));
Configuration::updateValue('ADMIN_CONFIRM_ORDER', Tools::getValue('ADMIN_CONFIRM_ORDER'));
Configuration::updateValue('PRODUCT_REQUEST_EMAIL', Tools::getValue('PRODUCT_REQUEST_EMAIL'));
Configuration::updateValue('PRODUCT_REQUEST_SAMPLE', Tools::getValue('PRODUCT_REQUEST_SAMPLE'));
Configuration::updateValue('PRODUCT_DOWNLOAD_BUTTON', Tools::getValue('PRODUCT_DOWNLOAD_BUTTON'));
$output .= $this->displayConfirmation($this->l('Settings updated'));
}
}
}
}
$this->context->controller->addJS($this->_path . 'websitesettings.js');
//return $this->display(__FILE__,'productupdate.tpl');
return $output . $this->displayForm();
}
示例2: 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;
}
示例3: getShippingCost
/**
* Calculate shipping costs without tax
* @return float Shipping costs
*/
protected function getShippingCost($products, Currency $currency, $country, $useTax = true)
{
$c = $country;
$id_carrier = (int) Configuration::get('POWATAG_SHIPPING');
if (!$country instanceof Country) {
if (Validate::isInt($country)) {
$country = new Country((int) $country, (int) $this->context->language->id);
} else {
$country = $this->getCountryByCode($country);
}
}
if (!PowaTagValidate::countryEnable($country)) {
$this->addError(sprintf($this->module->l('Country does not exists or is not enabled for this shop : %s'), $country->iso_code), PowaTagErrorType::$MERCHANT_WRONG_COUNTRY);
return false;
}
$shippingCost = $this->getShippingCostByCarrier($products, $currency, $id_carrier, $country, $useTax);
if (!$shippingCost) {
$shippingCost = 0.0;
}
if (Validate::isFloat($shippingCost)) {
return $shippingCost;
} else {
return false;
}
}
示例4: validateCSVCODPrice
private function validateCSVCODPrice($csv_data)
{
$wrong_price = '';
$wrong_price_method = '';
$wrong_price_country = '';
$csv_data_count = count($csv_data);
for ($i = 0; $i < $csv_data_count; $i++) {
if (!empty($csv_data[$i][DpdPolandCSV::COLUMN_COD_PRICE])) {
if (!Validate::isFloat($csv_data[$i][DpdPolandCSV::COLUMN_COD_PRICE]) || $csv_data[$i][DpdPolandCSV::COLUMN_COD_PRICE] < 0) {
$wrong_price .= $i + self::DEFAULT_FIRST_LINE_INDEX . ', ';
} else {
if ($csv_data[$i][DpdPolandCSV::COLUMN_CARRIER] != _DPDPOLAND_STANDARD_COD_ID_) {
$wrong_price_method .= $i + self::DEFAULT_FIRST_LINE_INDEX . ', ';
}
if ($csv_data[$i][DpdPolandCSV::COLUMN_COUNTRY] !== self::POLAND_ISO_CODE) {
$wrong_price_country .= $i + self::DEFAULT_FIRST_LINE_INDEX . ', ';
}
}
}
}
if (!empty($wrong_price)) {
$wrong_price = Tools::substr($wrong_price, 0, -2);
}
//remove last two symbols (comma & space)
if (!empty($wrong_price_method)) {
$wrong_price_method = Tools::substr($wrong_price_method, 0, -2);
}
//remove last two symbols (comma & space)
if (!empty($wrong_price_country)) {
$wrong_price_country = Tools::substr($wrong_price_country, 0, -2);
}
//remove last two symbols (comma & space)
return empty($wrong_price) && empty($wrong_price_method) && empty($wrong_price_country) ? true : array($wrong_price, $wrong_price_method, $wrong_price_country);
}
示例5: _postValidation
/**
* Data validation for module configuration
**/
public function _postValidation()
{
$errors = array();
$method = Tools::getValue('method');
if ($method == 'signin') {
if (empty($_POST['login'])) {
$errors[] = $this->l('login is required.');
}
if (empty($_POST['password'])) {
$errors[] = $this->l('password is required.');
}
if (empty($_POST['country'])) {
$errors[] = $this->l('country is required.');
}
} elseif ($method == 'register') {
if (empty($_POST['login'])) {
$errors[] = $this->l('login is required.');
}
if (empty($_POST['login']) or !Validate::isEmail($_POST['login'])) {
$errors[] = $this->l('login must be a valid e-mail address.');
}
if (empty($_POST['password'])) {
$errors[] = $this->l('password is required.');
}
if (empty($_POST['store_name'])) {
$errors[] = $this->l('Shop name is required.');
}
if (empty($_POST['country'])) {
$errors[] = $this->l('country is required.');
}
} elseif ($method == 'products') {
$products = array();
$djlUtil = new DejalaUtils();
$responseArray = $djlUtil->getStoreProducts($this->dejalaConfig, $products);
if ('200' != $responseArray['status']) {
$products = array();
}
foreach ($_POST as $key => $value) {
if (0 === strpos($key, 'margin_')) {
$this->mylog("key=" . substr($key, 7));
$productID = (int) substr($key, 7);
if (is_null($_POST[$key]) || 0 == strlen($_POST[$key])) {
$_POST[$key] = 0;
}
$_POST[$key] = str_replace(',', '.', $_POST[$key]);
$_POST[$key] = str_replace(' ', '', $_POST[$key]);
if (!Validate::isFloat($_POST[$key])) {
$errors[] = $value . ' ' . $this->l('is not a valid margin.');
}
$margin = (double) $_POST[$key];
foreach ($products as $l_product) {
if ((int) $l_product['id'] == (int) $productID) {
$product = (int) $l_product;
break;
}
}
if ($product) {
$vat_factor = 1 + $product['vat'] / 100;
$public_price = round($product['price'] * $vat_factor, 2);
$public_price = round($public_price + $margin, 2);
if ($public_price < 0) {
$errors[] = $value . ' ' . $this->l('is not a valid margin.');
}
}
}
}
}
return $errors;
}
示例6: hookAdminOrder
public function hookAdminOrder($params)
{
if (Tools::isSubmit('submitPayPalCapture')) {
if ($capture_amount = Tools::getValue('totalCaptureMoney')) {
if ($capture_amount = PaypalCapture::parsePrice($capture_amount)) {
if (Validate::isFloat($capture_amount)) {
$capture_amount = Tools::ps_round($capture_amount, '6');
$ord = new Order((int) $params['id_order']);
$cpt = new PaypalCapture();
if ($capture_amount > Tools::ps_round(0, '6') && Tools::ps_round($cpt->getRestToPaid($ord), '6') >= $capture_amount) {
$complete = false;
if ($capture_amount > Tools::ps_round((double) $ord->total_paid, '6')) {
$capture_amount = Tools::ps_round((double) $ord->total_paid, '6');
$complete = true;
}
if ($capture_amount == Tools::ps_round($cpt->getRestToPaid($ord), '6')) {
$complete = true;
}
$this->_doCapture($params['id_order'], $capture_amount, $complete);
}
}
}
}
} elseif (Tools::isSubmit('submitPayPalRefund')) {
$this->_doTotalRefund($params['id_order']);
}
$admin_templates = array();
if ($this->isPayPalAPIAvailable()) {
if ($this->_needValidation((int) $params['id_order'])) {
$admin_templates[] = 'validation';
}
if ($this->_needCapture((int) $params['id_order'])) {
$admin_templates[] = 'capture';
}
if ($this->_canRefund((int) $params['id_order'])) {
$admin_templates[] = 'refund';
}
}
if (count($admin_templates) > 0) {
$order = new Order((int) $params['id_order']);
$currency = new Currency($order->id_currency);
$cpt = new PaypalCapture();
$cpt->id_order = (int) $order->id;
if (version_compare(_PS_VERSION_, '1.5', '>=')) {
$order_state = $order->current_state;
} else {
$order_state = OrderHistory::getLastOrderState($order->id);
}
$this->context->smarty->assign(array('authorization' => (int) Configuration::get('PAYPAL_OS_AUTHORIZATION'), 'base_url' => _PS_BASE_URL_ . __PS_BASE_URI__, 'module_name' => $this->name, 'order_state' => $order_state, 'params' => $params, 'id_currency' => $currency->getSign(), 'rest_to_capture' => Tools::ps_round($cpt->getRestToPaid($order), '6'), 'list_captures' => $cpt->getListCaptured(), 'ps_version' => _PS_VERSION_));
foreach ($admin_templates as $admin_template) {
$this->_html .= $this->fetchTemplate('/views/templates/admin/admin_order/' . $admin_template . '.tpl');
$this->_postProcess();
$this->_html .= '</fieldset>';
}
}
return $this->_html;
}
示例7: getContent
/**
* @return string
*/
public function getContent()
{
$ok = null;
if (Tools::isSubmit('submitShipping')) {
$handle = new CSVReader(Tools::getValue("filename"), $_FILES['PINCODE_UPLOAD']['tmp_name']);
if ($handle->iscsvUpload()) {
$shipping = Tools::getValue('SHIPPING_METHOD');
if (isset($shipping) && Validate::isCarrierName((string) $shipping)) {
Configuration::updateValue('SHIPPING_METHOD', (string) $shipping);
$this->updateCODPincode($handle->getRows(), $shipping);
$ok = true;
} else {
$this->_html .= $this->displayError($this->l('Error occurred during Shipping Pincode update'));
}
} else {
$this->_html .= $this->displayError(CSVconst::UPLOAD_ERROR);
}
} else {
if (Tools::isSubmit('submitCOD')) {
$cod_min = Tools::getValue('COD_MINIMUM_AMOUNT');
$cod_fee = Tools::getValue('COD_FEE');
if (isset($cod_min) && isset($cod_fee) && Validate::isFloat((double) $cod_min) && Validate::isFloat((double) $cod_fee)) {
Configuration::updateValue('COD_MINIMUM_AMOUNT', (string) $cod_min);
Configuration::updateValue('COD_FEE', (string) $cod_fee);
$ok = true;
} else {
$this->_html .= $this->displayError($this->l('Error occurred during COD update'));
}
}
}
if ($ok) {
$this->_html .= $this->displayConfirmation($this->l('Settings updated succesfully'));
}
$this->_html .= $this->renderForm();
return $this->_html;
}
示例8: postValidation
private function postValidation()
{
if (Tools::getValue('id_user') == null) {
$this->post_errors[] = $this->l('ID SO not specified');
}
if (Tools::getValue('key') == null) {
$this->post_errors[] = $this->l('Key SO not specified');
}
if (Tools::getValue('dypreparationtime') == null) {
$this->post_errors[] = $this->l('Preparation time not specified');
} elseif (!Validate::isInt(Tools::getValue('dypreparationtime'))) {
$this->post_errors[] = $this->l('Invalid preparation time');
}
if (Tools::getValue('overcost') == null) {
$this->post_errors[] = $this->l('Additional cost not specified');
} elseif (!Validate::isFloat(Tools::getValue('overcost'))) {
$this->post_errors[] = $this->l('Invalid additional cost');
}
}
示例9: validateFields
/**
* Validate fields before exportation
*
* @return array errors
*/
public function validateFields()
{
$errors = array();
foreach ($this->fields as $key => $params) {
if ($params['mandatory'] == 1 && $params['value']) {
$errors[] = $kiala_instance->l('Field ') . $key . $kiala_instance->l(' is mandatory but was not found.');
}
switch ($params['type']) {
case 'string':
if ($params['value'] && strlen($params['value']) > $params['length']) {
$errors[] = $kiala_instance->l('Field ') . $key . $kiala_instance->l(' is too long.');
}
break;
case 'price':
if ($params['value'] && strlen($params['value']) > $params['length']) {
$errors[] = $kiala_instance->l('Field ') . $key . $kiala_instance->l(' is too long.');
}
if ($params['value'] && !Validate::isPrice($params['value'])) {
$errors[] = $kiala_instance->l('Field ') . $key . $kiala_instance->l(' has a wrong format.');
}
break;
case 'float':
if ($params['value'] && !Validate::isFloat($params['value'])) {
$errors[] = $kiala_instance->l('Field ') . $key . $kiala_instance->l(' has a wrong format.');
}
break;
default:
}
}
return $errors;
}
示例10: getContent
public function getContent()
{
$output = null;
if (Tools::isSubmit('submit' . $this->name)) {
$mappa_name = strval(Tools::getValue('MAPPA_NAME'));
$latitude_center_map = floatval(Tools::getValue('MAPPA_LATITUDE_CENTER_MAP'));
$longitude_center_map = floatval(Tools::getValue('MAPPA_LONGITUDE_CENTER_MAP'));
$zoom_map = intval(Tools::getValue('MAPPA_ZOOM_MAP'));
$basemap_name = strval(Tools::getValue('MAPPA_BASEMAP_NAME'));
if ($mappa_name != strval(Configuration::get('MAPPA_NAME'))) {
if (!$mappa_name || empty($mappa_name) || !Validate::isGenericName($mappa_name)) {
$output .= $this->displayError($this->l('Invalid Configuration value'));
} else {
Configuration::updateValue('MAPPA_NAME', $mappa_name);
$output .= $this->displayConfirmation($this->l('Settings updated'));
}
}
if ($latitude_center_map != floatval(Configuration::get('MAPPA_LATITUDE_CENTER_MAP'))) {
if (!$latitude_center_map || empty($latitude_center_map) || !Validate::isFloat($latitude_center_map) || $latitude_center_map > 90 || $latitude_center_map < -90) {
$output .= $this->displayError($this->l('Invalid Latitude value'));
} else {
Configuration::updateValue('MAPPA_LATITUDE_CENTER_MAP', $latitude_center_map);
$output .= $this->displayConfirmation($this->l('Map center latitude updated'));
}
}
if ($longitude_center_map != floatval(Configuration::get('MAPPA_LONGITUDE_CENTER_MAP'))) {
if (!$longitude_center_map || empty($longitude_center_map) || !Validate::isFloat($longitude_center_map) || $longitude_center_map > 180 || $longitude_center_map < -180) {
$output .= $this->displayError($this->l('Invalid Longitude value'));
} else {
Configuration::updateValue('MAPPA_LONGITUDE_CENTER_MAP', $longitude_center_map);
$output .= $this->displayConfirmation($this->l('Map center longitude updated'));
}
}
if ($zoom_map != intval(Configuration::get('MAPPA_ZOOM_MAP'))) {
if (!$zoom_map || empty($zoom_map) || !Validate::isInt($zoom_map) || $zoom_map < 0 || $zoom_map > 22) {
$output .= $this->displayError($this->l('Invalid Zoom value'));
} else {
Configuration::updateValue('MAPPA_ZOOM_MAP', $zoom_map);
$output .= $this->displayConfirmation($this->l('Map zoom level updated'));
}
}
if ($basemap_name != strval(Configuration::get('MAPPA_BASEMAP_NAME'))) {
Configuration::updateValue('MAPPA_BASEMAP_NAME', $basemap_name);
$output .= $this->displayConfirmation($this->l('Basemap updated'));
}
}
return $output . $this->displayForm();
}
示例11: _link_product
/**
* \brief Link a product to an attribute
* \param integer Product id
* \param array Attributes id to link
* \param integer Attributes group id
* \param string Value of the scale in config parameters
* \param string Fixed dimensions separated by a comma
* \param boolean Indicates if there are fixed values to update
* \param boolean Indicates if it's a product update
* \param integer Default value to display
* \param array Default values
* \retval boolean Result of the operation
*/
private function _link_product($product_id, $attributes_id, $group_id, $scale, $fixed_dimensions, &$fixed_update, $update, $default, &$default_values)
{
global $cookie;
$return = true;
// Get the scale default value
$scale_value = $this->_get_scale($scale);
// Get the default attribute
$attribute = Db::getInstance()->getRow('SELECT attribute.* FROM ' . _DB_PREFIX_ . 'attribute as attribute LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang as lang ON ' . 'lang.id_attribute = attribute.id_attribute WHERE attribute.id_attribute_group = ' . $group_id . ' AND lang.name = "' . $scale_value . '" AND lang.id_lang = ' . (int) $cookie->id_lang);
// Create dimensions only if not an update
if (!$update) {
// We add each attribute
foreach ($attributes_id as $attribute_id) {
if (!Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'product_attribute_combination (id_attribute, id_product_attribute) VALUES (' . $attribute['id_attribute'] . ', ' . $attribute_id['id_product_attribute'] . ')')) {
$return = false;
break;
}
}
}
// Set attribute impact for delayed combinations module
$impact = (int) Db::getInstance()->getValue('SELECT id_attribute_impact FROM ' . _DB_PREFIX_ . 'attribute_impact WHERE id_product = ' . $product_id . ' AND id_attribute = ' . $attribute['id_attribute']);
if (!$impact) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'attribute_impact (id_product, id_attribute, weight, price) VALUES (' . $product_id . ', ' . $attribute['id_attribute'] . ', 0, 0)');
}
// Insert in shops if needed
$shops_id = array();
if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
if ((int) Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') == 1 && (Tools::getIsset('shop_linked') && Tools::getValue('shop_linked'))) {
$shops_id = array((int) Tools::getValue('shop_linked'));
} else {
$shops_id = Db::getInstance()->ExecuteS('SELECT id_shop FROM ' . _DB_PREFIX_ . 'shop WHERE active = 1');
}
}
// Save fixed dimension if needed
if ($return && $fixed_dimensions) {
// If update, delete fixed dimensions in DB before to add them
if ($update) {
Db::getInstance()->Execute('DELETE FROM ' . _DB_PREFIX_ . 'aimultidimensions_fixed_dimensions WHERE fd_product = ' . $product_id . ' AND fd_attribute_group = ' . $attribute['id_attribute_group']);
}
$fixed_dimensions = str_replace(', ', ',', $fixed_dimensions);
$fixed = explode(',', $fixed_dimensions);
foreach ($fixed as $value) {
if (Validate::isFloat($value)) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'aimultidimensions_fixed_dimensions (fd_product, fd_attribute_group, fd_value) VALUES (' . $product_id . ', ' . $attribute['id_attribute_group'] . ', ' . $value . ')');
}
// Attribut creation if needed
$attribute_id = (int) Db::getInstance()->getValue('SELECT a.id_attribute FROM ' . _DB_PREFIX_ . 'attribute AS a LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang AS al ON al.id_attribute = a.id_attribute WHERE ' . 'a.id_attribute_group = ' . $attribute['id_attribute_group'] . ' AND al.name = ' . $value . ' GROUP BY a.id_attribute ORDER BY a.id_attribute DESC');
if (!$attribute_id) {
// Attribut creation if needed
if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
$position = (int) Attribute::getHigherPosition($group_id);
$position++;
$request = 'INSERT INTO ' . _DB_PREFIX_ . 'attribute (id_attribute_group, position) VALUES (' . $group_id . ', ' . $position . ')';
} else {
$request = 'INSERT INTO ' . _DB_PREFIX_ . 'attribute (id_attribute_group) VALUES (' . $group_id . ')';
}
if (Db::getInstance()->Execute($request)) {
$attribute_id = Db::getInstance()->Insert_ID();
// Attribute lang creation if needed
for ($cpt = 1; $cpt < 6; $cpt++) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'attribute_lang (`id_attribute`, `id_lang`, `name`) VALUES (' . $attribute_id . ', ' . $cpt . ', ' . $value . ')');
}
// Add for Prestashop 1.5 version and above
if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
foreach ($shops_id as $shop_id) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'attribute_shop (id_attribute, id_shop) VALUES (' . $attribute_id . ', ' . (int) $shop_id['id_shop'] . ')');
}
}
}
}
}
}
// Save default dimensions
$default_dimension = Db::getInstance()->getRow('SELECT al.name, al.id_attribute FROM ' . _DB_PREFIX_ . 'attribute_lang AS al LEFT JOIN ' . _DB_PREFIX_ . 'attribute AS a ON a.id_attribute = al.id_attribute WHERE ' . 'a.id_attribute_group = ' . $group_id . ' AND al.id_lang = ' . (int) $cookie->id_lang . ' ORDER BY a.id_attribute ASC');
if ($default != (int) $default_dimension['name']) {
// Attribut creation if needed
$attribute_id = (int) Db::getInstance()->getValue('SELECT a.id_attribute FROM ' . _DB_PREFIX_ . 'attribute AS a LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang AS al ON al.id_attribute = a.id_attribute WHERE ' . 'a.id_attribute_group = ' . $group_id . ' AND al.name = ' . $default . ' GROUP BY a.id_attribute ORDER BY a.id_attribute DESC');
if (!$attribute_id) {
if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
$position = (int) Attribute::getHigherPosition($group_id);
$position++;
$request = 'INSERT INTO ' . _DB_PREFIX_ . 'attribute (id_attribute_group, position) VALUES (' . $group_id . ', ' . $position . ')';
} else {
$request = 'INSERT INTO ' . _DB_PREFIX_ . 'attribute (id_attribute_group) VALUES (' . $group_id . ')';
}
if (Db::getInstance()->Execute($request)) {
$attribute_id = Db::getInstance()->Insert_ID();
// Attribute lang creation if needed
//.........这里部分代码省略.........
示例12: getSQLRetrieveFilter
/**
* get SQL retrieve Filter
*
* @param string $sqlId
* @param string $filterValue
* @param string $tableAlias = 'main.'
* @return string
*/
protected function getSQLRetrieveFilter($sqlId, $filterValue, $tableAlias = 'main.')
{
$ret = '';
// "LIKE" case (=%[foo]%, =%[foo], =[foo]%)
preg_match('/^(.*)\\[(.*)\\](.*)$/', $filterValue, $matches);
if (count($matches) > 1) {
if ($matches[1] == '%' || $matches[3] == '%') {
$ret .= ' AND ' . $tableAlias . '`' . pSQL($sqlId) . '` LIKE "' . $matches[1] . pSQL($matches[2]) . $matches[3] . "\"\n";
} elseif ($matches[1] == '' && $matches[3] == '') {
// "OR" case
if (strpos($matches[2], '|') > 0) {
$values = explode('|', $matches[2]);
$ret .= ' AND (';
$temp = '';
foreach ($values as $value) {
$temp .= $tableAlias . '`' . pSQL($sqlId) . '` = "' . pSQL($value) . '" OR ';
}
// AND (field = value3 OR field = value7 OR field = value9)
$ret .= rtrim($temp, 'OR ') . ')' . "\n";
} elseif (preg_match('/^([\\d\\.:-\\s]+),([\\d\\.:-\\s]+)$/', $matches[2], $matches3)) {
unset($matches3[0]);
if (count($matches3) > 0) {
sort($matches3);
$ret .= ' AND ' . $tableAlias . '`' . pSQL($sqlId) . '` BETWEEN "' . $matches3[0] . '" AND "' . $matches3[1] . "\"\n";
// AND field BETWEEN value3 AND value4
}
} else {
$ret .= ' AND ' . $tableAlias . '`' . pSQL($sqlId) . '`="' . $matches[2] . '"' . "\n";
}
// AND field = value1
} elseif ($matches[1] == '>') {
$ret .= ' AND ' . $tableAlias . '`' . pSQL($sqlId) . '` > "' . pSQL($matches[2]) . "\"\n";
} elseif ($matches[1] == '<') {
$ret .= ' AND ' . $tableAlias . '`' . pSQL($sqlId) . '` < "' . pSQL($matches[2]) . "\"\n";
} elseif ($matches[1] == '!') {
$ret .= ' AND ' . $tableAlias . '`' . pSQL($sqlId) . '` != "' . pSQL($matches[2]) . "\"\n";
}
// AND field IS NOT value3
} else {
$ret .= ' AND ' . $tableAlias . '`' . pSQL($sqlId) . '` ' . (Validate::isFloat(pSQL($filterValue)) ? 'LIKE' : '=') . ' "' . pSQL($filterValue) . "\"\n";
}
return $ret;
}
示例13: postValidation
private function postValidation()
{
if (Tools::getValue('id_user') == null) {
$this->post_errors[] = $this->l('ID SO not specified');
}
if (Tools::getValue('key') == null) {
$this->post_errors[] = $this->l('Key SO not specified');
}
if (Tools::getValue('dypreparationtime') == null) {
$this->post_errors[] = $this->l('Preparation time not specified');
} elseif (!Validate::isInt(Tools::getValue('dypreparationtime'))) {
$this->post_errors[] = $this->l('Invalid preparation time');
}
if (Tools::getValue('overcost') == null) {
$this->post_errors[] = $this->l('Additional cost not specified');
} elseif (!Validate::isFloat(Tools::getValue('overcost'))) {
$this->post_errors[] = $this->l('Invalid additional cost');
}
if ((int) Tools::getValue('id_socolissimo_allocation') == (int) Tools::getValue('id_socolissimocc_allocation')) {
$this->post_errors[] = $this->l('Socolissimo carrier cannot be the same as socolissimo CC');
}
}
示例14: validateSettings
private function validateSettings()
{
if (!Tools::getValue(DpdGroupConfiguration::COUNTRY)) {
self::$errors[] = $this->l('DPD Country can not be empty');
}
if (!Tools::getValue(DpdGroupConfiguration::SENDER_ID)) {
self::$errors[] = $this->l('Sender Address Id can not be empty');
}
if (!Tools::getValue(DpdGroupConfiguration::PAYER_ID)) {
self::$errors[] = $this->l('Payer Id can not be empty');
}
if (!Tools::getValue(DpdGroupConfiguration::USERNAME)) {
self::$errors[] = $this->l('Web Service Username can not be empty');
}
if (!Tools::getValue(DpdGroupConfiguration::PASSWORD)) {
self::$errors[] = $this->l('Web Service Password can not be empty');
}
if (Tools::getValue(DpdGroupConfiguration::COUNTRY) == DpdGroupConfiguration::OTHER_COUNTRY && !Tools::getValue(DpdGroupConfiguration::PRODUCTION_URL) && !Tools::getValue(DpdGroupConfiguration::TEST_URL)) {
self::$errors[] = $this->l('At least one WS URL must be entered');
}
if (Tools::getValue(DpdGroupConfiguration::PRODUCTION_URL) !== '' && !Validate::isUrl(Tools::getValue(DpdGroupConfiguration::PRODUCTION_URL))) {
self::$errors[] = $this->l('Production WS URL is not valid');
}
if (Tools::getValue(DpdGroupConfiguration::TEST_URL) !== '' && !Validate::isUrl(Tools::getValue(DpdGroupConfiguration::TEST_URL))) {
self::$errors[] = $this->l('Test WS URL is not valid');
}
if (Tools::getValue(DpdGroupConfiguration::PASSWORD) !== '' && !Validate::isPasswd(Tools::getValue(DpdGroupConfiguration::PASSWORD))) {
self::$errors[] = $this->l('Web Service Password is not valid');
}
if (Tools::getValue(DpdGroupConfiguration::TIMEOUT) !== '' && !Validate::isUnsignedInt(Tools::getValue(DpdGroupConfiguration::TIMEOUT))) {
self::$errors[] = $this->l('Web Service Connection Timeout is not valid');
}
if (!Tools::getValue(DpdGroupConfiguration::WEIGHT_CONVERSATION_RATE)) {
self::$errors[] = $this->l('Weight conversation rate can not be empty');
} elseif (!Validate::isFloat(Tools::getValue(DpdGroupConfiguration::WEIGHT_CONVERSATION_RATE)) || Validate::isFloat(Tools::getValue(DpdGroupConfiguration::WEIGHT_CONVERSATION_RATE)) && Tools::getValue(DpdGroupConfiguration::WEIGHT_CONVERSATION_RATE) < 0) {
self::$errors[] = $this->l('Weight conversation rate is not valid');
}
$this->validateCODMethods();
}
示例15: _postValidation
private function _postValidation()
{
if (Tools::getValue('id_user') == NULL) {
$this->_postErrors[] = $this->l('ID SO not specified');
}
if (Tools::getValue('key') == NULL) {
$this->_postErrors[] = $this->l('Key SO not specified');
}
if (Tools::getValue('dypreparationtime') == NULL) {
$this->_postErrors[] = $this->l('Preparation time not specified');
} elseif (!Validate::isInt(Tools::getValue('dypreparationtime'))) {
$this->_postErrors[] = $this->l('Invalid preparation time');
}
if (Tools::getValue('overcost') == NULL) {
$this->_postErrors[] = $this->l('Overcost not specified');
} elseif (!Validate::isFloat(Tools::getValue('overcost'))) {
$this->_postErrors[] = $this->l('Invalid overcost');
}
}