Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into development

This commit is contained in:
gRoussac
2013-05-15 17:12:55 +02:00
4 changed files with 80 additions and 55 deletions
+1
View File
@@ -2217,6 +2217,7 @@ exit;
if (!is_array($args) || !count($args)) if (!is_array($args) || !count($args))
return; return;
$_GET = array_merge($args, $_GET); $_GET = array_merge($args, $_GET);
$_SERVER['QUERY_STRING'] = $argv[1];
} }
/** /**
+51 -34
View File
@@ -513,37 +513,42 @@ class AdminControllerCore extends Controller
*/ */
public function postProcess() public function postProcess()
{ {
if ($this->ajax) try {
{ 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))))
{ {
// Hook before action // from ajax-tab.php
Hook::exec('actionAdmin'.ucfirst($this->action).'Before', array('controller' => $this)); $action = Tools::getValue('action');
Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this)); // no need to use displayConf() here
// Call process if (!empty($action) && method_exists($this, 'ajaxProcess'.Tools::toCamelCase($action)))
$return = $this->{'process'.Tools::toCamelCase($this->action)}(); return $this->{'ajaxProcess'.Tools::toCamelCase($action)}();
// Hook After Action elseif (method_exists($this, 'ajaxProcess'))
Hook::exec('actionAdmin'.ucfirst($this->action).'After', array('controller' => $this, 'return' => $return)); return $this->ajaxProcess();
Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
return $return;
} }
} 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(); $headers = array();
foreach ($this->fields_list as $datas) foreach ($this->fields_list as $datas)
$headers[] = Tools::htmlentitiesDecodeUTF8($datas['title']); $headers[] = Tools::htmlentitiesDecodeUTF8($datas['title']);
$content = array(); $content = array();
foreach ($this->_list as $i => $row) foreach ($this->_list as $i => $row)
{ {
$content[$i] = array(); $content[$i] = array();
foreach ($this->fields_list as $key => $value) $path_to_image = false;
if (isset($row[$key])) foreach ($this->fields_list as $key => $params)
$content[$i][] = Tools::htmlentitiesDecodeUTF8($row[$key]); {
$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( $this->context->smarty->assign(array(
'export_precontent' => "\xEF\xBB\xBF", 'export_precontent' => "\xEF\xBB\xBF",
'export_headers' => $headers, 'export_headers' => $headers,
@@ -1161,6 +1177,7 @@ class AdminControllerCore extends Controller
header('Location: '.$this->redirect_after); header('Location: '.$this->redirect_after);
exit; exit;
} }
public function display() public function display()
{ {
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
+15 -4
View File
@@ -352,13 +352,24 @@ class ShopCore extends ObjectModel
if ((!$id_shop && defined('_PS_ADMIN_DIR_')) || Tools::isPHPCLI()) if ((!$id_shop && defined('_PS_ADMIN_DIR_')) || Tools::isPHPCLI())
{ {
// If in admin, we can access to the shop without right URL // 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->physical_uri = preg_replace('#/+#', '/', str_replace('\\', '/', dirname(dirname($_SERVER['SCRIPT_NAME']))).'/');
$shop->virtual_uri = ''; $shop->virtual_uri = '';
// Define HTTP_HOST if PHP is launched with php-cli // Define some $_SERVER variables like HTTP_HOST if PHP is launched with php-cli
if (Tools::isPHPCLI() && !isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST'])) if (Tools::isPHPCLI())
$_SERVER['HTTP_HOST'] = $shop->domain; {
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 else
{ {
+13 -17
View File
@@ -312,36 +312,32 @@ class AdminGroupsControllerCore extends AdminController
return parent::renderForm(); 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_reductions = array();
$category_reduction = Tools::getValue('category_reduction'); $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)) if (is_array($category_reduction) && array_key_exists($category['id_category'], $category_reduction))
$category['reduction'] = $category_reduction[$category['id_category']]; $category['reduction'] = $category_reduction[$category['id_category']];
$tmp = array(); $category_reductions[(int)$category['id_category']] = array(
$tmp['path'] = getPath(self::$currentIndex.'?tab=AdminCategories', (int)$category['id_category']); 'path' => getPath(self::$currentIndex.'?tab=AdminCategories', (int)$category['id_category']),
$tmp['reduction'] = (float)$category['reduction'] * 100; 'reduction' => (float)$category['reduction'] * 100,
$tmp['id_category'] = (int)$category['id_category']; 'id_category' => (int)$category['id_category']
$category_reductions[(int)$category['id_category']] = $tmp; );
} }
if (is_array($category_reduction)) if (is_array($category_reduction))
foreach ($category_reduction as $key => $val) foreach ($category_reduction as $key => $val)
{
if (!array_key_exists($key, $category_reductions)) if (!array_key_exists($key, $category_reductions))
{ $category_reductions[(int)$key] = array(
$tmp = array(); 'path' => getPath(self::$currentIndex.'?tab=AdminCategories', $key),
$tmp['path'] = getPath(self::$currentIndex.'?tab=AdminCategories', $key); 'reduction' => (float)$val * 100,
$tmp['reduction'] = (float)$val * 100; 'id_category' => (int)$key
$tmp['id_category'] = (int)$key; );
$category_reductions[(int)$category['id_category']] = $tmp;
}
}
return $category_reductions; return $category_reductions;
} }