// merge 1.4 => 6117
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@6118 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -216,97 +216,6 @@ class AddressCore extends ObjectModel
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns values ordered in an array according to given fields
|
||||
* @param array $config set options for the method formated as
|
||||
$config = array(
|
||||
'spacer' => ' '
|
||||
, 'optional' => array(
|
||||
'company' => 1
|
||||
,'phone' => 1
|
||||
)
|
||||
, 'ignore' => array(
|
||||
'phone_mobile' => 1
|
||||
)
|
||||
, 'return_set' => true (true: hash return, false: String array)
|
||||
)
|
||||
* @param String $pattern lines of each needed fields \n splitted
|
||||
* @param array $values optionnal given values
|
||||
* @return array field values or hash values
|
||||
*/
|
||||
public static function getOrderedValuesFromArray($config, $pattern, array $values = null)
|
||||
{
|
||||
$tmp_address = new Address();
|
||||
$out = $tmp_address->getOrderedValues($config, $pattern, $values);
|
||||
unset($tmp_address);
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns values ordered in an array according to given fields
|
||||
* @param array $config set options for the method formated as
|
||||
$config = array(
|
||||
'spacer' => ' '
|
||||
, 'optional' => array(
|
||||
'company' => 1
|
||||
,'phone' => 1
|
||||
,'phone_mobile' => 1
|
||||
)
|
||||
, 'return_set' => true
|
||||
)
|
||||
* @param String $address_datas lines of each needed fields \n splitted
|
||||
* @param array $given_values optionnal given values
|
||||
* @return array field values or values in a hash
|
||||
*/
|
||||
|
||||
public function getOrderedValues(array $config, $address_datas, array $given_values = null)
|
||||
{
|
||||
|
||||
$spacer = $config["spacer"]; // String used for joining lines_out
|
||||
$optional_fields = (isset($config["optional"]))? $config["optional"] : array(); // array hash tells which fields are optional
|
||||
|
||||
$ignore = (isset($config["ignore"]))? $config["ignore"] : array(); // array hash tells which fields are ignored
|
||||
|
||||
|
||||
$return_set = (!empty($config["return_set"])) ? $config["return_set"] : false;
|
||||
|
||||
$line_breaker = "\n"; // used in address_datas format
|
||||
|
||||
|
||||
$lines_out = array();
|
||||
$fields_lines = explode($line_breaker, $address_datas);
|
||||
|
||||
foreach ($fields_lines as $one_line)
|
||||
if(!empty($one_line) && $one_line!= '')
|
||||
{
|
||||
$tmp_values = array();
|
||||
$val_added = false;
|
||||
|
||||
$words = explode(' ', trim($one_line));
|
||||
$tmp_words = array();
|
||||
|
||||
foreach ($words as $one_word)
|
||||
{
|
||||
if (!isset($ignore[$one_word]))
|
||||
{
|
||||
$one_word = trim($one_word);
|
||||
$val = (is_null($given_values)) ? $this->{$one_word} : $given_values[$one_word];
|
||||
if ((!empty($val) && $val != '') || ((empty($val) || $val == '') && (isset($optional_fields[$one_word]) != 1)))
|
||||
{
|
||||
$tmp_values[$one_word] = $val;
|
||||
$val_added = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($val_added)
|
||||
$lines_out[] = ($return_set) ? $tmp_values : implode($spacer, $tmp_values);
|
||||
}
|
||||
return $lines_out;
|
||||
}
|
||||
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
parent::validateFields();
|
||||
|
||||
@@ -60,6 +60,8 @@ class AddressFormatCore extends ObjectModel
|
||||
$out = true;
|
||||
$addr_f_validate = Address::getFieldsValidate();
|
||||
|
||||
$addr_f_validate['state_iso'] = 1; // adding state iso code into allowed fields
|
||||
|
||||
$fields_format = explode("\n", $this->format);
|
||||
foreach($fields_format as $field_line)
|
||||
{
|
||||
@@ -73,20 +75,30 @@ class AddressFormatCore extends ObjectModel
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns address format fields in array by country
|
||||
*
|
||||
* @param Integer PS_COUNTRY.id
|
||||
* @param Integer PS_COUNTRY.id if null using default country
|
||||
* @return Array String field address format
|
||||
*/
|
||||
public static function getOrderedAddressFields($id_country)
|
||||
public static function getOrderedAddressFields($id_country = 0, $split_all = false)
|
||||
{
|
||||
$out = array();
|
||||
$field_set = explode("\n", self::getAddressCountryFormat($id_country));
|
||||
foreach ($field_set as $field_item)
|
||||
{
|
||||
$out[] = trim($field_item);
|
||||
// $field_item = trim($field_item);
|
||||
|
||||
if ($split_all)
|
||||
{
|
||||
foreach(explode(' ',$field_item) as $word_item)
|
||||
$out[] = trim($word_item);
|
||||
}
|
||||
else
|
||||
$out[] = trim($field_item);
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
@@ -97,9 +109,16 @@ class AddressFormatCore extends ObjectModel
|
||||
* @param Integer PS_COUNTRY.id
|
||||
* @return String field address format
|
||||
*/
|
||||
public static function getAddressCountryFormat($id_country)
|
||||
public static function getAddressCountryFormat($id_country = 0)
|
||||
{
|
||||
$out = '';
|
||||
$out = '';
|
||||
$id_country = (int) $id_country;
|
||||
|
||||
if ($id_country <= 0)
|
||||
{
|
||||
$selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
}
|
||||
|
||||
$tmp_obj = new AddressFormat();
|
||||
$tmp_obj->id_country = $id_country;
|
||||
$out = $tmp_obj->getFormat($tmp_obj->id_country);
|
||||
@@ -131,7 +150,7 @@ class AddressFormatCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.$this->table.'`
|
||||
WHERE `id_country` = '.(int)($id_country));
|
||||
|
||||
return isset($result['format']) ? $result['format'] : false;
|
||||
return isset($result['format']) ? trim($result['format']) : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -319,7 +319,7 @@ abstract class AdminTabCore
|
||||
public function includeSubTab($methodname, $actions = array())
|
||||
{
|
||||
if (!isset($this->_includeTab) OR !is_array($this->_includeTab))
|
||||
return ;
|
||||
return false;
|
||||
$key = 0;
|
||||
$inc = false;
|
||||
foreach ($this->_includeTab as $subtab => $extraVars)
|
||||
@@ -1553,7 +1553,7 @@ abstract class AdminTabCore
|
||||
global $currentIndex, $cookie, $tab;
|
||||
|
||||
if (!isset($this->_fieldsOptions) OR !sizeof($this->_fieldsOptions))
|
||||
return ;
|
||||
return false;
|
||||
|
||||
$defaultLanguage = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
$this->_languages = Language::getLanguages(false);
|
||||
|
||||
@@ -305,7 +305,7 @@ class CustomerCore extends ObjectModel
|
||||
public function getAddresses($id_lang)
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||
SELECT a.*, cl.`name` AS country, s.name AS state
|
||||
SELECT a.*, cl.`name` AS country, s.name AS state, s.iso_code AS state_iso
|
||||
FROM `'._DB_PREFIX_.'address` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'country` c ON (a.`id_country` = c.`id_country`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country`)
|
||||
|
||||
@@ -146,6 +146,7 @@ class FeatureValueCore extends ObjectModel
|
||||
LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.`id_feature_value` = fv.`id_feature_value`)
|
||||
WHERE `value` = \''.pSQL($name).'\'
|
||||
AND fv.`id_feature` = '.(int)$id_feature.'
|
||||
AND fv.`custom` = 0
|
||||
GROUP BY fv.`id_feature_value` LIMIT 1');
|
||||
|
||||
if (!isset($rq[0]['id_feature_value']) OR !$id_feature_value = (int)$rq[0]['id_feature_value'])
|
||||
|
||||
@@ -79,7 +79,7 @@ class FrontControllerCore
|
||||
return;
|
||||
self::$initialized = true;
|
||||
|
||||
if ($this->ssl AND !(empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) != 'off') AND Configuration::get('PS_SSL_ENABLED'))
|
||||
if ($this->ssl AND (empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) == 'off') AND Configuration::get('PS_SSL_ENABLED'))
|
||||
{
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']);
|
||||
@@ -194,8 +194,8 @@ class FrontControllerCore
|
||||
$navigationPipe = (Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>');
|
||||
$smarty->assign('navigationPipe', $navigationPipe);
|
||||
|
||||
$protocol_link = (Configuration::get('PS_SSL_ENABLED') OR (isset($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) == 'on')) ? 'https://' : 'http://';
|
||||
$protocol_content = ((isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) OR (isset($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) == 'on')) ? 'https://' : 'http://';
|
||||
$protocol_link = (Configuration::get('PS_SSL_ENABLED') OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://';
|
||||
$protocol_content = ((isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://';
|
||||
if (!defined('_PS_BASE_URL_'))
|
||||
define('_PS_BASE_URL_', Tools::getShopDomain(true));
|
||||
if (!defined('_PS_BASE_URL_SSL_'))
|
||||
|
||||
+4
-3
@@ -439,7 +439,8 @@ class PDFCore extends PDF_PageGroupCore
|
||||
);
|
||||
$ignore_fields = array(
|
||||
'phone' => 1
|
||||
, 'mobile_phone' =>1
|
||||
, 'mobile_phone' => 1
|
||||
, 'state_iso' => 1
|
||||
);
|
||||
|
||||
$width = 100;
|
||||
@@ -469,12 +470,12 @@ class PDFCore extends PDF_PageGroupCore
|
||||
$tmp_dlv = $delivery_address->{$field_name};
|
||||
if (!((empty($tmp_inv) || $tmp_inv == '') && isset($optional_fields[$field_name])))
|
||||
{
|
||||
$tmp_inv = ($field_name == "country") ? $tmp_inv.($deliveryState ? ' - '.$deliveryState->name : ''): $tmp_inv;
|
||||
$tmp_inv = ($field_name == "country") ? $tmp_inv.($deliveryState ? ' - '.$deliveryState->iso_code : ''): $tmp_inv;
|
||||
$tmp_inv_vals[] = Tools::iconv('utf-8', self::encoding(), $tmp_inv);
|
||||
}
|
||||
if (!((empty($tmp_dlv) || $tmp_dlv == '') && isset($optional_fields[$field_name])))
|
||||
{
|
||||
$tmp_dlv = ($field_name == "country") ? $tmp_dlv.($deliveryState ? ' - '.$deliveryState->name : ''): $tmp_dlv;
|
||||
$tmp_dlv = ($field_name == "country") ? $tmp_dlv.($deliveryState ? ' - '.$deliveryState->iso_code : ''): $tmp_dlv;
|
||||
$tmp_dlv_vals[] = Tools::iconv('utf-8', self::encoding(), $tmp_dlv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,6 @@ abstract class PaymentModuleCore extends Module
|
||||
* @param string $paymentMethod Payment method (eg. 'Credit card')
|
||||
* @param string $message Message to attach to order
|
||||
*/
|
||||
|
||||
public function validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod = 'Unknown', $message = NULL, $extraVars = array(), $currency_special = NULL, $dont_touch_amount = false, $secure_key = false)
|
||||
{
|
||||
global $cart;
|
||||
|
||||
+18
-19
@@ -1594,35 +1594,34 @@ class ProductCore extends ObjectModel
|
||||
$quantity = ($id_cart AND $cart_quantity) ? $cart_quantity : $quantity;
|
||||
$id_currency = (int)(Validate::isLoadedObject($cur_cart) ? $cur_cart->id_currency : ((isset($cookie->id_currency) AND (int)($cookie->id_currency)) ? $cookie->id_currency : Configuration::get('PS_CURRENCY_DEFAULT')));
|
||||
|
||||
|
||||
// retrieve address informations
|
||||
$id_country = (int)Country::getDefaultCountryId();
|
||||
$id_country = (int)Country::getDefaultCountryId();
|
||||
$id_state = 0;
|
||||
$id_county = 0;
|
||||
|
||||
|
||||
|
||||
if (!$id_address)
|
||||
$id_address = $cur_cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
|
||||
|
||||
if ($id_address)
|
||||
{
|
||||
if ($id_address = $cur_cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')})
|
||||
$address_infos = Address::getCountryAndState($id_address);
|
||||
if ($address_infos['id_country'])
|
||||
{
|
||||
$address_infos = Address::getCountryAndState($id_address);
|
||||
if ($address_infos['id_country'])
|
||||
{
|
||||
$id_country = (int)($address_infos['id_country']);
|
||||
$id_state = (int)($address_infos['id_state']);
|
||||
$postcode = (int)$address_infos['postcode'];
|
||||
|
||||
$id_county = (int)County::getIdCountyByZipCode($id_state, $postcode);
|
||||
}
|
||||
} else if (isset($cookie->id_country)) {
|
||||
// fetch address from cookie
|
||||
$id_country = (int)$cookie->id_country;
|
||||
$id_state = (int)$cookie->id_state;
|
||||
$postcode = (int)$cookie->postcode;
|
||||
$id_country = (int)($address_infos['id_country']);
|
||||
$id_state = (int)($address_infos['id_state']);
|
||||
$postcode = (int)$address_infos['postcode'];
|
||||
|
||||
$id_county = (int)County::getIdCountyByZipCode($id_state, $postcode);
|
||||
}
|
||||
}
|
||||
elseif (isset($cookie->id_country))
|
||||
{
|
||||
// fetch address from cookie
|
||||
$id_country = (int)$cookie->id_country;
|
||||
$id_state = (int)$cookie->id_state;
|
||||
$postcode = (int)$cookie->postcode;
|
||||
|
||||
$id_county = (int)County::getIdCountyByZipCode($id_state, $postcode);
|
||||
}
|
||||
|
||||
if (Tax::excludeTaxeOption())
|
||||
|
||||
@@ -219,7 +219,7 @@ class WebserviceRequestCore
|
||||
$display_errors = strtolower(ini_get('display_errors')) != 'off';
|
||||
|
||||
// Error handler
|
||||
set_error_handler(array('WebserviceRequest', 'webserviceErrorHandler'));
|
||||
set_error_handler(array($this, 'webserviceErrorHandler'));
|
||||
ini_set('html_errors', 'off');
|
||||
$this->_wsUrl = Tools::getHttpHost(true).__PS_BASE_URI__.'api/';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user