// Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into bootstrap
Conflicts: .gitignore admin-dev/themes/default/css/admin.css admin-dev/themes/default/template/controllers/categories/helpers/list/list_header.tpl admin-dev/themes/default/template/controllers/customers/helpers/list/list_header.tpl admin-dev/themes/default/template/controllers/modules/list.tpl admin-dev/themes/default/template/controllers/modules/page.tpl admin-dev/themes/default/template/controllers/modules/tab_module_line.tpl admin-dev/themes/default/template/controllers/orders/_documents.tpl admin-dev/themes/default/template/controllers/orders/_shipping.tpl admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl admin-dev/themes/default/template/controllers/payment/helpers/view/view.tpl admin-dev/themes/default/template/controllers/payment/restrictions.tpl admin-dev/themes/default/template/controllers/products/images.tpl admin-dev/themes/default/template/controllers/products/informations.tpl admin-dev/themes/default/template/header.tpl admin-dev/themes/default/template/helpers/form/form.tpl admin-dev/themes/default/template/helpers/modules_list/list.tpl classes/Tools.php controllers/admin/AdminCartRulesController.php controllers/admin/AdminProductsController.php css/admin.css
This commit is contained in:
+102
-58
@@ -338,11 +338,9 @@ class ToolsCore
|
||||
/* If language does not exist or is disabled, erase it */
|
||||
if ($cookie->id_lang)
|
||||
{
|
||||
//echo $cookie->id_lang;exit;
|
||||
$lang = new Language((int)$cookie->id_lang);
|
||||
if (!Validate::isLoadedObject($lang) || !$lang->active || !$lang->isAssociatedToShop())
|
||||
$cookie->id_lang = null;
|
||||
|
||||
}
|
||||
|
||||
/* Automatically detect language if not already defined */
|
||||
@@ -399,7 +397,7 @@ class ToolsCore
|
||||
{
|
||||
$context->cookie->id_lang = $id_lang;
|
||||
$language = new Language($id_lang);
|
||||
if (Validate::isLoadedObject($language))
|
||||
if (Validate::isLoadedObject($language) && $language->active)
|
||||
$context->language = $language;
|
||||
|
||||
$params = $_GET;
|
||||
@@ -433,8 +431,11 @@ class ToolsCore
|
||||
{
|
||||
// get currency from context
|
||||
$currency = Shop::getEntityIds('currency', Context::getContext()->shop->id);
|
||||
$cookie->id_currency = $currency[0]['id_currency'];
|
||||
return Currency::getCurrencyInstance((int)$cookie->id_currency);
|
||||
if (isset($currency[0]) && $currency[0]['id_currency'])
|
||||
{
|
||||
$cookie->id_currency = $currency[0]['id_currency'];
|
||||
return Currency::getCurrencyInstance((int)$cookie->id_currency);
|
||||
}
|
||||
}
|
||||
}
|
||||
$currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
@@ -681,17 +682,21 @@ class ToolsCore
|
||||
if ($files = scandir($dirname))
|
||||
{
|
||||
foreach ($files as $file)
|
||||
if ($file != '.' && $file != '..' && $file != '.svn')
|
||||
{
|
||||
if (is_dir($dirname.$file))
|
||||
Tools::deleteDirectory($dirname.$file, true);
|
||||
elseif (file_exists($dirname.$file))
|
||||
unlink($dirname.$file);
|
||||
}
|
||||
|
||||
if ($file != '.' && $file != '..' && $file != '.svn')
|
||||
{
|
||||
if (is_dir($dirname.$file))
|
||||
Tools::deleteDirectory($dirname.$file, true);
|
||||
elseif (file_exists($dirname.$file))
|
||||
unlink($dirname.$file);
|
||||
}
|
||||
if ($delete_self)
|
||||
rmdir($dirname);
|
||||
if (!rmdir($dirname))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display an error according to an error code
|
||||
@@ -1023,47 +1028,66 @@ class ToolsCore
|
||||
*/
|
||||
public static function replaceAccentedChars($str)
|
||||
{
|
||||
/* One source among others:
|
||||
http://www.tachyonsoft.com/uc0000.htm
|
||||
http://www.tachyonsoft.com/uc0001.htm
|
||||
*/
|
||||
$patterns = array(
|
||||
|
||||
/* Lowercase */
|
||||
'/[\x{0105}\x{00E0}\x{00E1}\x{00E2}\x{00E3}\x{00E4}\x{00E5}]/u',
|
||||
'/[\x{00E7}\x{010D}\x{0107}]/u',
|
||||
'/[\x{010F}]/u',
|
||||
'/[\x{00E8}\x{00E9}\x{00EA}\x{00EB}\x{011B}\x{0119}]/u',
|
||||
'/[\x{00EC}\x{00ED}\x{00EE}\x{00EF}]/u',
|
||||
'/[\x{011F}]/u',
|
||||
'/[\x{0142}\x{013E}\x{013A}]/u',
|
||||
'/[\x{00F1}\x{0148}]/u',
|
||||
'/[\x{00F2}\x{00F3}\x{00F4}\x{00F5}\x{00F6}\x{00F8}]/u',
|
||||
'/[\x{0159}\x{0155}]/u',
|
||||
'/[\x{015B}\x{0161}\x{015F}]/u',
|
||||
'/[\x{00DF}]/u',
|
||||
'/[\x{0165}]/u',
|
||||
'/[\x{00F9}\x{00FA}\x{00FB}\x{00FC}\x{016F}]/u',
|
||||
'/[\x{00FD}\x{00FF}]/u',
|
||||
'/[\x{017C}\x{017A}\x{017E}]/u',
|
||||
'/[\x{00E6}]/u',
|
||||
'/[\x{0153}]/u',
|
||||
/* a */ '/[\x{00E0}\x{00E1}\x{00E2}\x{00E3}\x{00E4}\x{00E5}\x{0101}\x{0103}\x{0105}]/u',
|
||||
/* c */ '/[\x{00E7}\x{0107}\x{0109}\x{010D}]/u',
|
||||
/* d */ '/[\x{010F}\x{0111}]/u',
|
||||
/* e */ '/[\x{00E8}\x{00E9}\x{00EA}\x{00EB}\x{0113}\x{0115}\x{0117}\x{0119}\x{011B}]/u',
|
||||
/* g */ '/[\x{011F}\x{0121}\x{0123}]/u',
|
||||
/* h */ '/[\x{0125}\x{0127}]/u',
|
||||
/* i */ '/[\x{00EC}\x{00ED}\x{00EE}\x{00EF}\x{0129}\x{012B}\x{012D}\x{012F}\x{0131}]/u',
|
||||
/* j */ '/[\x{0135}]/u',
|
||||
/* k */ '/[\x{0137}\x{0138}]/u',
|
||||
/* l */ '/[\x{013A}\x{013C}\x{013E}\x{0140}\x{0142}]/u',
|
||||
/* n */ '/[\x{00F1}\x{0144}\x{0146}\x{0148}\x{0149}\x{014B}]/u',
|
||||
/* o */ '/[\x{00F2}\x{00F3}\x{00F4}\x{00F5}\x{00F6}\x{00F8}\x{014D}\x{014F}\x{0151}]/u',
|
||||
/* r */ '/[\x{0155}\x{0157}\x{0159}]/u',
|
||||
/* s */ '/[\x{015B}\x{015D}\x{015F}\x{0161}]/u',
|
||||
/* ss*/ '/[\x{00DF}]/u',
|
||||
/* t */ '/[\x{0163}\x{0165}\x{0167}]/u',
|
||||
/* u */ '/[\x{00F9}\x{00FA}\x{00FB}\x{00FC}\x{0169}\x{016B}\x{016D}\x{016F}\x{0171}\x{0173}]/u',
|
||||
/* w */ '/[\x{0175}]/u',
|
||||
/* y */ '/[\x{00FF}\x{0177}\x{00FD}]/u',
|
||||
/* z */ '/[\x{017A}\x{017C}\x{017E}]/u',
|
||||
/* ae*/ '/[\x{00E6}]/u',
|
||||
/* oe*/ '/[\x{0153}]/u',
|
||||
|
||||
/* Uppercase */
|
||||
'/[\x{0104}\x{00C0}\x{00C1}\x{00C2}\x{00C3}\x{00C4}\x{00C5}]/u',
|
||||
'/[\x{00C7}\x{010C}\x{0106}]/u',
|
||||
'/[\x{010E}]/u',
|
||||
'/[\x{00C8}\x{00C9}\x{00CA}\x{00CB}\x{011A}\x{0118}]/u',
|
||||
'/[\x{011E}]/u',
|
||||
'/[\x{0141}\x{013D}\x{0139}]/u',
|
||||
'/[\x{00D1}\x{0147}]/u',
|
||||
'/[\x{00D3}]/u',
|
||||
'/[\x{0158}\x{0154}]/u',
|
||||
'/[\x{015A}\x{0160}\x{015E}]/u',
|
||||
'/[\x{0164}]/u',
|
||||
'/[\x{00D9}\x{00DA}\x{00DB}\x{00DC}\x{016E}]/u',
|
||||
'/[\x{017B}\x{0179}\x{017D}]/u',
|
||||
'/[\x{00C6}]/u',
|
||||
'/[\x{0152}]/u');
|
||||
/* A */ '/[\x{0100}\x{0102}\x{0104}\x{00C0}\x{00C1}\x{00C2}\x{00C3}\x{00C4}\x{00C5}]/u',
|
||||
/* C */ '/[\x{00C7}\x{0106}\x{0108}\x{010A}\x{010C}]/u',
|
||||
/* D */ '/[\x{010E}\x{0110}]/u',
|
||||
/* E */ '/[\x{00C8}\x{00C9}\x{00CA}\x{00CB}\x{0112}\x{0114}\x{0116}\x{0118}\x{011A}]/u',
|
||||
/* G */ '/[\x{011C}\x{011E}\x{0120}\x{0122}]/u',
|
||||
/* H */ '/[\x{0124}\x{0126}]/u',
|
||||
/* I */ '/[\x{0128}\x{012A}\x{012C}\x{012E}\x{0130}]/u',
|
||||
/* J */ '/[\x{0134}]/u',
|
||||
/* K */ '/[\x{0136}]/u',
|
||||
/* L */ '/[\x{0139}\x{013B}\x{013D}\x{0139}\x{0141}]/u',
|
||||
/* N */ '/[\x{00D1}\x{0143}\x{0145}\x{0147}\x{014A}]/u',
|
||||
/* O */ '/[\x{00D3}\x{014C}\x{014E}\x{0150}]/u',
|
||||
/* R */ '/[\x{0154}\x{0156}\x{0158}]/u',
|
||||
/* S */ '/[\x{015A}\x{015C}\x{015E}\x{0160}]/u',
|
||||
/* T */ '/[\x{0162}\x{0164}\x{0166}]/u',
|
||||
/* U */ '/[\x{00D9}\x{00DA}\x{00DB}\x{00DC}\x{0168}\x{016A}\x{016C}\x{016E}\x{0170}\x{0172}]/u',
|
||||
/* W */ '/[\x{0174}]/u',
|
||||
/* Y */ '/[\x{0176}]/u',
|
||||
/* Z */ '/[\x{0179}\x{017B}\x{017D}]/u',
|
||||
/* AE*/ '/[\x{00C6}]/u',
|
||||
/* OE*/ '/[\x{0152}]/u');
|
||||
|
||||
// ö to oe
|
||||
// å to aa
|
||||
// ä to ae
|
||||
|
||||
$replacements = array(
|
||||
'a', 'c', 'd', 'e', 'i', 'g', 'l', 'n', 'o', 'r', 's', 'ss', 't', 'u', 'y', 'z', 'ae', 'oe',
|
||||
'A', 'C', 'D', 'E', 'G', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'Z', 'AE', 'OE'
|
||||
'a', 'c', 'd', 'e', 'g', 'h', 'i', 'j', 'k', 'l', 'n', 'o', 'r', 's', 'ss', 't', 'u', 'y', 'w', 'z', 'ae', 'oe',
|
||||
'A', 'C', 'D', 'E', 'G', 'H', 'I', 'J', 'K', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'Z', 'AE', 'OE'
|
||||
);
|
||||
|
||||
return preg_replace($patterns, $replacements, $str);
|
||||
@@ -1304,14 +1328,16 @@ class ToolsCore
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, $curl_timeout);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
$opts = stream_context_get_options($stream_context);
|
||||
if (isset($opts['http']['method']) && Tools::strtolower($opts['http']['method']) == 'post')
|
||||
{
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
if (isset($opts['http']['content']))
|
||||
if ($stream_context != null) {
|
||||
$opts = stream_context_get_options($stream_context);
|
||||
if (isset($opts['http']['method']) && Tools::strtolower($opts['http']['method']) == 'post')
|
||||
{
|
||||
parse_str($opts['http']['content'], $datas);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas);
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
if (isset($opts['http']['content']))
|
||||
{
|
||||
parse_str($opts['http']['content'], $datas);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas);
|
||||
}
|
||||
}
|
||||
}
|
||||
$content = curl_exec($curl);
|
||||
@@ -1564,7 +1590,7 @@ class ToolsCore
|
||||
}
|
||||
|
||||
// Write .htaccess data
|
||||
if (!$write_fd = @fopen($path, 'w'))
|
||||
if (!$write_fd = fopen($path, 'w'))
|
||||
return false;
|
||||
fwrite($write_fd, trim($specific_before)."\n\n");
|
||||
|
||||
@@ -2102,6 +2128,9 @@ exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 1.5 use Controller::getController('PageNotFoundController')->run();
|
||||
*/
|
||||
public static function display404Error()
|
||||
{
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
@@ -2402,7 +2431,7 @@ exit;
|
||||
return $pattern;
|
||||
return preg_replace('/\\\[px]\{[a-z]\}{1,2}|(\/[a-z]*)u([a-z]*)$/i', "$1$2", $pattern);
|
||||
}
|
||||
|
||||
|
||||
public static function addonsRequest($request, $params = array())
|
||||
{
|
||||
$addons_url = 'api.addons.prestashop.com';
|
||||
@@ -2488,6 +2517,21 @@ exit;
|
||||
// No content, return false
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function fileAttachment($input = 'fileUpload')
|
||||
{
|
||||
$fileAttachment = null;
|
||||
if (isset($_FILES[$input]['name']) && !empty($_FILES[$input]['name']) && !empty($_FILES[$input]['tmp_name']))
|
||||
{
|
||||
$fileAttachment['rename'] = uniqid(). self::strtolower(substr($_FILES[$input]['name'], -5));
|
||||
$fileAttachment['content'] = file_get_contents($_FILES[$input]['tmp_name']);
|
||||
$fileAttachment['tmp_name'] = $_FILES[$input]['tmp_name'];
|
||||
$fileAttachment['name'] = $_FILES[$input]['name'];
|
||||
$fileAttachment['mime'] = $_FILES[$input]['type'];
|
||||
$fileAttachment['error'] = $_FILES[$input]['error'];
|
||||
}
|
||||
return $fileAttachment;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user