// Code review : normalise and todo
This commit is contained in:
+13
-23
@@ -98,16 +98,7 @@ class HelperCore
|
||||
}
|
||||
|
||||
/**
|
||||
* Since 1.5 - This function will be deprecated in 1.6 - use Helper::renderCategoryTree() instead
|
||||
* @static
|
||||
* @param $translations
|
||||
* @param array $selected_cat
|
||||
* @param string $input_name
|
||||
* @param bool $use_radio
|
||||
* @param bool $use_search
|
||||
* @param array $disabled_categories
|
||||
* @param bool $use_in_popup
|
||||
* @return mixed
|
||||
* @deprecated 1.5.0
|
||||
*/
|
||||
public static function renderAdminCategorieTree($translations,
|
||||
$selected_cat = array(),
|
||||
@@ -117,6 +108,8 @@ class HelperCore
|
||||
$disabled_categories = array(),
|
||||
$use_in_popup = false)
|
||||
{
|
||||
Tools::displayAsDeprecated();
|
||||
|
||||
$helper = new Helper();
|
||||
if (isset($translations['Root']))
|
||||
$root = $translations['Root'];
|
||||
@@ -169,7 +162,7 @@ class HelperCore
|
||||
'Check All' => $this->l('Check All'),
|
||||
'Uncheck All' => $this->l('Uncheck All'),
|
||||
'search' => $this->l('Find a category')
|
||||
);
|
||||
);
|
||||
|
||||
if (!$root)
|
||||
{
|
||||
@@ -180,22 +173,20 @@ class HelperCore
|
||||
if (!$use_radio)
|
||||
$input_name = $input_name.'[]';
|
||||
|
||||
$context = Context::getContext();
|
||||
|
||||
$context->controller->addCSS(_PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.css');
|
||||
$context->controller->addJs(array(
|
||||
$this->context->controller->addCSS(_PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.css');
|
||||
$this->context->controller->addJs(array(
|
||||
_PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.js',
|
||||
_PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.async.js',
|
||||
_PS_JS_DIR_.'jquery/plugins/treeview/jquery.treeview.edit.js',
|
||||
_PS_JS_DIR_.'admin-categories-tree.js'));
|
||||
if ($use_search)
|
||||
$context->controller->addJs(_PS_JS_DIR_.'jquery/plugins/autocomplete/jquery.autocomplete.js');
|
||||
$this->context->controller->addJs(_PS_JS_DIR_.'jquery/plugins/autocomplete/jquery.autocomplete.js');
|
||||
|
||||
$html = '
|
||||
<script type="text/javascript">
|
||||
var inputName = "'.$input_name.'";
|
||||
';
|
||||
if (sizeof($selected_cat) > 0)
|
||||
if (count($selected_cat) > 0)
|
||||
{
|
||||
if (isset($selected_cat[0]))
|
||||
$html .= 'var selectedCat = "'.implode(',', $selected_cat).'";';
|
||||
@@ -232,8 +223,7 @@ class HelperCore
|
||||
';
|
||||
|
||||
$home_is_selected = false;
|
||||
|
||||
foreach($selected_cat AS $cat)
|
||||
foreach ($selected_cat as $cat)
|
||||
{
|
||||
if (is_array($cat))
|
||||
{
|
||||
@@ -252,6 +242,7 @@ class HelperCore
|
||||
$home_is_selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
$html .= '
|
||||
<ul id="categories-treeview" class="filetree">
|
||||
<li id="'.$root['id_category'].'" class="hasChildren">
|
||||
@@ -278,7 +269,7 @@ class HelperCore
|
||||
* @param boolean $htmlentities if set to true(default), the return value will pass through htmlentities($string, ENT_QUOTES, 'utf-8')
|
||||
* @return string the translation if available, or the english default text.
|
||||
*/
|
||||
protected function l($string, $class = 'AdminTab', $addslashes = FALSE, $htmlentities = TRUE)
|
||||
protected function l($string, $class = 'AdminTab', $addslashes = false, $htmlentities = true)
|
||||
{
|
||||
// if the class is extended by a module, use modules/[module_name]/xx.php lang file
|
||||
$currentClass = get_class($this);
|
||||
@@ -314,11 +305,10 @@ class HelperCore
|
||||
$type = 'shop';
|
||||
|
||||
$assos = array();
|
||||
|
||||
if ((int)$this->id)
|
||||
{
|
||||
$sql = 'SELECT `id_'.bqSQL($type).'`, `'.bqSQL($this->identifier).'`
|
||||
FROM `'._DB_PREFIX_.bqSQL($this->table).'_'.bqSQL($type).'`
|
||||
$sql = 'SELECT `id_'.$type.'`, `'.bqSQL($this->identifier).'`
|
||||
FROM `'._DB_PREFIX_.bqSQL($this->table).'_'.$type.'`
|
||||
WHERE `'.bqSQL($this->identifier).'` = '.(int)$this->id;
|
||||
|
||||
foreach (Db::getInstance()->executeS($sql) as $row)
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class HelperFormCore extends Helper
|
||||
{
|
||||
public $id;
|
||||
|
||||
@@ -35,7 +35,6 @@ class HelperHelpAccessCore extends Helper
|
||||
public $country;
|
||||
public $ps_version;
|
||||
|
||||
|
||||
public function __construct($label, $iso_lang, $country, $ps_version)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class HelperListCore extends Helper
|
||||
{
|
||||
/** @var array Cache for query results */
|
||||
@@ -65,7 +68,8 @@ class HelperListCore extends Helper
|
||||
|
||||
protected $is_dnd_identifier = false;
|
||||
|
||||
/* Customize list display
|
||||
/**
|
||||
* @var string Customize list display
|
||||
*
|
||||
* align : determine value alignment
|
||||
* prefix : displayed before value
|
||||
@@ -111,12 +115,6 @@ class HelperListCore extends Helper
|
||||
/** @var boolean ask for simple header : no filters, no paginations and no sorting */
|
||||
public $simple_header = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* Usage : Set the value to false if you want to simply display the back button
|
||||
*/
|
||||
public $no_back = true;
|
||||
|
||||
public $ajax_params = array();
|
||||
|
||||
public function __construct()
|
||||
@@ -131,15 +129,15 @@ class HelperListCore extends Helper
|
||||
* Return an html list given the data to fill it up
|
||||
*
|
||||
* @param array $list entries to display (rows)
|
||||
* @param array $fieldsDisplay fields (cols)
|
||||
* @param array $fields_display fields (cols)
|
||||
* @return string html
|
||||
*/
|
||||
public function generateList($list, $fields_display)
|
||||
{
|
||||
/*if ($this->edit AND (!isset($this->noAdd) OR !$this->noAdd))
|
||||
/*if ($this->edit && (!isset($this->noAdd) || !$this->noAdd))
|
||||
$this->displayAddButton();*/
|
||||
|
||||
/* Append when we get a syntax error in SQL query */
|
||||
// Append when we get a syntax error in SQL query
|
||||
if ($list === false)
|
||||
{
|
||||
$this->displayWarning($this->l('Bad SQL query', 'helper'));
|
||||
@@ -153,13 +151,15 @@ class HelperListCore extends Helper
|
||||
|
||||
$this->_list = $list;
|
||||
$this->fieldsDisplay = $fields_display;
|
||||
/* Display list header (filtering, pagination and column names) */
|
||||
$tpl_vars['header'] = $this->displayListHeader();
|
||||
/* Show the content of the table */
|
||||
$tpl_vars['content'] = $this->displayListContent();
|
||||
/* Close list table and submit button */
|
||||
$tpl_vars['footer'] = $this->displayListFooter();
|
||||
|
||||
// Display list header (filtering, pagination and column names)
|
||||
$tpl_vars['header'] = $this->displayListHeader();
|
||||
|
||||
// Show the content of the table
|
||||
$tpl_vars['content'] = $this->displayListContent();
|
||||
|
||||
// Close list table and submit button
|
||||
$tpl_vars['footer'] = $this->displayListFooter();
|
||||
|
||||
$this->tpl->assign($tpl_vars);
|
||||
return parent::generate();
|
||||
@@ -174,6 +174,7 @@ class HelperListCore extends Helper
|
||||
* @param string $active status
|
||||
* @param int $id_category
|
||||
* @param int $id_product
|
||||
* @return string
|
||||
*/
|
||||
protected function displayEnableLink($token, $id, $value, $active, $id_category = null, $id_product = null)
|
||||
{
|
||||
@@ -186,12 +187,12 @@ class HelperListCore extends Helper
|
||||
return $tpl_enable->fetch();
|
||||
}
|
||||
|
||||
public function displayListContent($token = null)
|
||||
public function displayListContent()
|
||||
{
|
||||
if ($this->is_dnd_identifier)
|
||||
$id_category = (int)Tools::getValue('id_'.($this->is_cms ? 'cms_' : '').'category', '1');
|
||||
else
|
||||
$id_category = 1; // default categ
|
||||
$id_category = Category::getRootCategory();
|
||||
|
||||
if (isset($this->fieldsDisplay['position']))
|
||||
{
|
||||
@@ -202,8 +203,6 @@ class HelperListCore extends Helper
|
||||
$identifier = in_array($this->identifier, array('id_category', 'id_cms_category')) ? '_parent' : '';
|
||||
$key_to_get = 'id_'.($this->is_cms ? 'cms_' : '').'category'.$identifier;
|
||||
|
||||
$fields = array();
|
||||
|
||||
foreach ($this->_list as $index => $tr)
|
||||
{
|
||||
$id = $tr[$this->identifier];
|
||||
@@ -220,10 +219,9 @@ class HelperListCore extends Helper
|
||||
$method_name = 'display'.ucfirst($action).'Link';
|
||||
|
||||
if (method_exists($this->context->controller, $method_name))
|
||||
$this->_list[$index][$action] = $this->context->controller->$method_name($token, $id, $name);
|
||||
$this->_list[$index][$action] = $this->context->controller->$method_name($this->token, $id, $name);
|
||||
else if (method_exists($this, $method_name))
|
||||
$this->_list[$index][$action] = $this->$method_name($token, $id, $name);
|
||||
|
||||
$this->_list[$index][$action] = $this->$method_name($this->token, $id, $name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +271,8 @@ class HelperListCore extends Helper
|
||||
{
|
||||
$image = new Image((int)$tr['id_image']);
|
||||
$path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$image->getExistingImgPath().'.'.$this->imageType;
|
||||
}else
|
||||
}
|
||||
else
|
||||
$path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$item_id.(isset($tr['id_image']) ? '-'.(int)$tr['id_image'] : '').'.'.$this->imageType;
|
||||
|
||||
$this->_list[$index][$key] = cacheImage($path_to_image, $this->table.'_mini_'.$item_id.'.'.$this->imageType, 45, $this->imageType);
|
||||
@@ -300,15 +299,13 @@ class HelperListCore extends Helper
|
||||
else
|
||||
$echo = $tr[$key];
|
||||
|
||||
$this->_list[$index][$key] = isset($params['callback'])
|
||||
?
|
||||
call_user_func_array(array((isset($params['callback_object']))
|
||||
?
|
||||
$params['callback_object']
|
||||
:
|
||||
$this->context->controller, $params['callback']), array($echo, $tr))
|
||||
:
|
||||
$echo;
|
||||
if (isset($params['callback']))
|
||||
{
|
||||
$callback_obj = (isset($params['callback_object'])) ? $params['callback_object'] : $this->context->controller;
|
||||
$this->_list[$index][$key] = call_user_func_array(array($callback_obj, $params['callback']), array($echo, $tr));
|
||||
}
|
||||
else
|
||||
$this->_list[$index][$key] = $echo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -442,7 +439,6 @@ class HelperListCore extends Helper
|
||||
));
|
||||
|
||||
return $tpl->fetch();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -495,7 +491,7 @@ class HelperListCore extends Helper
|
||||
/**
|
||||
* Display list header (filtering, pagination and column names)
|
||||
*/
|
||||
public function displayListHeader($token = null)
|
||||
public function displayListHeader()
|
||||
{
|
||||
$id_cat = (int)Tools::getValue('id_'.($this->is_cms ? 'cms_' : '').'category');
|
||||
|
||||
@@ -521,7 +517,8 @@ class HelperListCore extends Helper
|
||||
|
||||
/* Determine current page number */
|
||||
$page = (int)Tools::getValue('submitFilter'.$this->table);
|
||||
if (!$page) $page = 1;
|
||||
if (!$page)
|
||||
$page = 1;
|
||||
|
||||
/* Choose number of results per page */
|
||||
$selected_pagination = Tools::getValue(
|
||||
@@ -563,6 +560,7 @@ class HelperListCore extends Helper
|
||||
{
|
||||
case 'bool':
|
||||
break;
|
||||
|
||||
case 'date':
|
||||
case 'datetime':
|
||||
if (is_string($value))
|
||||
@@ -573,6 +571,7 @@ class HelperListCore extends Helper
|
||||
$name_id = str_replace('!', '__', $name);
|
||||
$this->context->controller->addJqueryUI('ui.datepicker');
|
||||
break;
|
||||
|
||||
case 'select':
|
||||
foreach ($params['list'] as $option_value => $option_display)
|
||||
{
|
||||
@@ -582,6 +581,7 @@ class HelperListCore extends Helper
|
||||
$this->fieldsDisplay[$key]['select'][$option_value]['selected'] = 'selected';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
if (!Validate::isCleanHtml($value))
|
||||
$value = '';
|
||||
@@ -628,7 +628,7 @@ class HelperListCore extends Helper
|
||||
/**
|
||||
* Close list table and submit button
|
||||
*/
|
||||
public function displayListFooter($token = null)
|
||||
public function displayListFooter()
|
||||
{
|
||||
$this->footer_tpl->assign(array_merge($this->tpl_vars, array(
|
||||
'token' => $this->token,
|
||||
@@ -638,5 +638,4 @@ class HelperListCore extends Helper
|
||||
)));
|
||||
return $this->footer_tpl->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class HelperOptionsCore extends Helper
|
||||
|
||||
foreach ($option_list as $category => $category_data)
|
||||
{
|
||||
if(!is_array($category_data))
|
||||
if (!is_array($category_data))
|
||||
continue;
|
||||
|
||||
if (!isset($category_data['image']))
|
||||
@@ -92,7 +92,6 @@ class HelperOptionsCore extends Helper
|
||||
// Fill values for all languages for all lang fields
|
||||
if (substr($field['type'], -4) == 'Lang')
|
||||
{
|
||||
|
||||
foreach ($languages as $language)
|
||||
{
|
||||
if ($field['type'] == 'textLang')
|
||||
@@ -107,6 +106,7 @@ class HelperOptionsCore extends Helper
|
||||
}
|
||||
|
||||
// pre-assign vars to the tpl
|
||||
// @todo move this
|
||||
if ($field['type'] == 'maintenance_ip')
|
||||
{
|
||||
$field['script_ip'] = '
|
||||
@@ -159,7 +159,7 @@ class HelperOptionsCore extends Helper
|
||||
|
||||
/**
|
||||
* Type = image
|
||||
* @ TODO
|
||||
* @TODO
|
||||
*/
|
||||
public function displayOptionTypeImage($key, $field, $value)
|
||||
{
|
||||
@@ -187,7 +187,7 @@ class HelperOptionsCore extends Helper
|
||||
|
||||
/**
|
||||
* Type = price
|
||||
* @ TODO
|
||||
* @TODO
|
||||
*/
|
||||
public function displayOptionTypePrice($key, $field, $value)
|
||||
{
|
||||
@@ -199,7 +199,7 @@ class HelperOptionsCore extends Helper
|
||||
/**
|
||||
* Type = disabled
|
||||
*
|
||||
* @ TODO
|
||||
* @TODO
|
||||
*/
|
||||
public function displayOptionTypeDisabled($key, $field, $value)
|
||||
{
|
||||
|
||||
@@ -340,7 +340,6 @@ class AdminTaxRulesGroupControllerCore extends AdminController
|
||||
$helper->fields_value = $this->getFieldsValue($this->object);
|
||||
$helper->toolbar_btn = null;
|
||||
$helper->submit_action = 'create_rule';
|
||||
$helper->no_back = true;
|
||||
|
||||
return $helper->generateForm($this->fields_form);
|
||||
}
|
||||
|
||||
@@ -1669,7 +1669,8 @@ class BlockLayered extends Module
|
||||
'Uncheck All' => $this->l('Uncheck All'),
|
||||
'search' => $this->l('Search a category')
|
||||
);
|
||||
|
||||
|
||||
// @todo renderAdminCategorieTree is deprecated in 1.5
|
||||
$html .= Helper::renderAdminCategorieTree($trads, $selectedCat, 'categoryBox');
|
||||
|
||||
$html .= '
|
||||
|
||||
Reference in New Issue
Block a user