Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into development
This commit is contained in:
@@ -2217,6 +2217,7 @@ exit;
|
||||
if (!is_array($args) || !count($args))
|
||||
return;
|
||||
$_GET = array_merge($args, $_GET);
|
||||
$_SERVER['QUERY_STRING'] = $argv[1];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -513,37 +513,42 @@ class AdminControllerCore extends Controller
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
if ($this->ajax)
|
||||
{
|
||||
// from ajax-tab.php
|
||||
$action = Tools::getValue('action');
|
||||
// no need to use displayConf() here
|
||||
if (!empty($action) && method_exists($this, 'ajaxProcess'.Tools::toCamelCase($action)))
|
||||
return $this->{'ajaxProcess'.Tools::toCamelCase($action)}();
|
||||
elseif (method_exists($this, 'ajaxProcess'))
|
||||
return $this->ajaxProcess();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Process list filtering
|
||||
if ($this->filter)
|
||||
$this->processFilter();
|
||||
|
||||
// If the method named after the action exists, call "before" hooks, then call action method, then call "after" hooks
|
||||
if (!empty($this->action) && method_exists($this, 'process'.ucfirst(Tools::toCamelCase($this->action))))
|
||||
try {
|
||||
if ($this->ajax)
|
||||
{
|
||||
// Hook before action
|
||||
Hook::exec('actionAdmin'.ucfirst($this->action).'Before', array('controller' => $this));
|
||||
Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this));
|
||||
// Call process
|
||||
$return = $this->{'process'.Tools::toCamelCase($this->action)}();
|
||||
// Hook After Action
|
||||
Hook::exec('actionAdmin'.ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
|
||||
Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
|
||||
|
||||
return $return;
|
||||
// from ajax-tab.php
|
||||
$action = Tools::getValue('action');
|
||||
// no need to use displayConf() here
|
||||
if (!empty($action) && method_exists($this, 'ajaxProcess'.Tools::toCamelCase($action)))
|
||||
return $this->{'ajaxProcess'.Tools::toCamelCase($action)}();
|
||||
elseif (method_exists($this, 'ajaxProcess'))
|
||||
return $this->ajaxProcess();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Process list filtering
|
||||
if ($this->filter)
|
||||
$this->processFilter();
|
||||
|
||||
// If the method named after the action exists, call "before" hooks, then call action method, then call "after" hooks
|
||||
if (!empty($this->action) && method_exists($this, 'process'.ucfirst(Tools::toCamelCase($this->action))))
|
||||
{
|
||||
// Hook before action
|
||||
Hook::exec('actionAdmin'.ucfirst($this->action).'Before', array('controller' => $this));
|
||||
Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this));
|
||||
// Call process
|
||||
$return = $this->{'process'.Tools::toCamelCase($this->action)}();
|
||||
// Hook After Action
|
||||
Hook::exec('actionAdmin'.ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
|
||||
Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
} catch (PrestaShopException $e) {
|
||||
$this->errors[] = $e->getMessage();
|
||||
};
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -583,16 +588,27 @@ class AdminControllerCore extends Controller
|
||||
$headers = array();
|
||||
foreach ($this->fields_list as $datas)
|
||||
$headers[] = Tools::htmlentitiesDecodeUTF8($datas['title']);
|
||||
|
||||
$content = array();
|
||||
foreach ($this->_list as $i => $row)
|
||||
{
|
||||
$content[$i] = array();
|
||||
foreach ($this->fields_list as $key => $value)
|
||||
if (isset($row[$key]))
|
||||
$content[$i][] = Tools::htmlentitiesDecodeUTF8($row[$key]);
|
||||
|
||||
$path_to_image = false;
|
||||
foreach ($this->fields_list as $key => $params)
|
||||
{
|
||||
$field_value = isset($row[$key]) ? Tools::htmlentitiesDecodeUTF8($row[$key]) : '';
|
||||
if ($key == 'image')
|
||||
{
|
||||
if ($params['image'] != 'p' || Configuration::get('PS_LEGACY_IMAGES'))
|
||||
$path_to_image = Tools::getShopDomain(true)._PS_IMG_.$params['image'].'/'.$row['id_'.$this->table].(isset($row['id_image']) ? '-'.(int)$row['id_image'] : '').'.'.$this->imageType;
|
||||
else
|
||||
$path_to_image = Tools::getShopDomain(true)._PS_IMG_.$params['image'].'/'.Image::getImgFolderStatic($row['id_image']).(int)$row['id_image'].'.'.$this->imageType;
|
||||
if ($path_to_image)
|
||||
$field_value = $path_to_image;
|
||||
}
|
||||
$content[$i][] = $field_value;
|
||||
}
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'export_precontent' => "\xEF\xBB\xBF",
|
||||
'export_headers' => $headers,
|
||||
@@ -1161,6 +1177,7 @@ class AdminControllerCore extends Controller
|
||||
header('Location: '.$this->redirect_after);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$this->context->smarty->assign(array(
|
||||
|
||||
+15
-4
@@ -352,13 +352,24 @@ class ShopCore extends ObjectModel
|
||||
if ((!$id_shop && defined('_PS_ADMIN_DIR_')) || Tools::isPHPCLI())
|
||||
{
|
||||
// If in admin, we can access to the shop without right URL
|
||||
$shop = new Shop((int)Configuration::get('PS_SHOP_DEFAULT'));
|
||||
if ((!$id_shop && Tools::isPHPCLI()) || defined('_PS_ADMIN_DIR_'))
|
||||
$id_shop = (int)Configuration::get('PS_SHOP_DEFAULT');
|
||||
|
||||
$shop = new Shop((int)$id_shop);
|
||||
if (!Validate::isLoadedObject($shop))
|
||||
$shop = new Shop((int)Configuration::get('PS_SHOP_DEFAULT'));
|
||||
|
||||
$shop->physical_uri = preg_replace('#/+#', '/', str_replace('\\', '/', dirname(dirname($_SERVER['SCRIPT_NAME']))).'/');
|
||||
$shop->virtual_uri = '';
|
||||
|
||||
// Define HTTP_HOST if PHP is launched with php-cli
|
||||
if (Tools::isPHPCLI() && !isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
|
||||
$_SERVER['HTTP_HOST'] = $shop->domain;
|
||||
// Define some $_SERVER variables like HTTP_HOST if PHP is launched with php-cli
|
||||
if (Tools::isPHPCLI())
|
||||
{
|
||||
if(!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST']))
|
||||
$_SERVER['HTTP_HOST'] = $shop->domain;
|
||||
if(!isset($_SERVER['SERVER_NAME']) || empty($_SERVER['SERVER_NAME']))
|
||||
$_SERVER['SERVER_NAME'] = $shop->domain;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -312,36 +312,32 @@ class AdminGroupsControllerCore extends AdminController
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
protected function formatCategoryDiscountList($id)
|
||||
protected function formatCategoryDiscountList($id_group)
|
||||
{
|
||||
$category = GroupReduction::getGroupReductions((int)$id, $this->context->language->id);
|
||||
$group_reductions = GroupReduction::getGroupReductions((int)$id_group, $this->context->language->id);
|
||||
$category_reductions = array();
|
||||
$category_reduction = Tools::getValue('category_reduction');
|
||||
|
||||
foreach ($category as $category)
|
||||
foreach ($group_reductions as $category)
|
||||
{
|
||||
if (is_array($category_reduction) && array_key_exists($category['id_category'], $category_reduction))
|
||||
$category['reduction'] = $category_reduction[$category['id_category']];
|
||||
|
||||
$tmp = array();
|
||||
$tmp['path'] = getPath(self::$currentIndex.'?tab=AdminCategories', (int)$category['id_category']);
|
||||
$tmp['reduction'] = (float)$category['reduction'] * 100;
|
||||
$tmp['id_category'] = (int)$category['id_category'];
|
||||
$category_reductions[(int)$category['id_category']] = $tmp;
|
||||
$category_reductions[(int)$category['id_category']] = array(
|
||||
'path' => getPath(self::$currentIndex.'?tab=AdminCategories', (int)$category['id_category']),
|
||||
'reduction' => (float)$category['reduction'] * 100,
|
||||
'id_category' => (int)$category['id_category']
|
||||
);
|
||||
}
|
||||
|
||||
if (is_array($category_reduction))
|
||||
foreach ($category_reduction as $key => $val)
|
||||
{
|
||||
if (!array_key_exists($key, $category_reductions))
|
||||
{
|
||||
$tmp = array();
|
||||
$tmp['path'] = getPath(self::$currentIndex.'?tab=AdminCategories', $key);
|
||||
$tmp['reduction'] = (float)$val * 100;
|
||||
$tmp['id_category'] = (int)$key;
|
||||
$category_reductions[(int)$category['id_category']] = $tmp;
|
||||
}
|
||||
}
|
||||
$category_reductions[(int)$key] = array(
|
||||
'path' => getPath(self::$currentIndex.'?tab=AdminCategories', $key),
|
||||
'reduction' => (float)$val * 100,
|
||||
'id_category' => (int)$key
|
||||
);
|
||||
|
||||
return $category_reductions;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user