From bcb0f0fbf023c9d94afc6e087d28f892de2dc424 Mon Sep 17 00:00:00 2001 From: tDidierjean Date: Thu, 20 Oct 2011 13:45:52 +0000 Subject: [PATCH] [*] BO : #PSFV-94 - changes to helpers git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9500 b9a71923-0436-4b27-9f14-aed3839534dd --- admin-dev/themes/template/backup/content.tpl | 1 - classes/AdminController.php | 203 ++++++------ classes/HelperList.php | 24 +- classes/HelperOptions.php | 2 +- .../admin/AdminAddressesController.php | 313 +++++++++--------- controllers/admin/AdminAliasesController.php | 21 +- controllers/admin/AdminBackupController.php | 9 +- controllers/admin/AdminContactsController.php | 26 +- .../admin/AdminCurrenciesController.php | 8 - controllers/admin/AdminEmailsController.php | 12 - controllers/admin/AdminImagesController.php | 12 +- 11 files changed, 289 insertions(+), 342 deletions(-) diff --git a/admin-dev/themes/template/backup/content.tpl b/admin-dev/themes/template/backup/content.tpl index 0034dc011..0bd3e32ab 100644 --- a/admin-dev/themes/template/backup/content.tpl +++ b/admin-dev/themes/template/backup/content.tpl @@ -46,7 +46,6 @@
  • {l s='Always check your data.'}
  • {l s='Never restore a Backup on a live site.'}
  • - {if $show_form}
    diff --git a/classes/AdminController.php b/classes/AdminController.php index b9b1969dd..15415fa0d 100644 --- a/classes/AdminController.php +++ b/classes/AdminController.php @@ -77,7 +77,11 @@ class AdminControllerCore extends Controller /** @var array Errors displayed after post processing */ public $_errors = array(); - protected $list_display; + /** @var array list to be generated */ + protected $fieldsDisplay; + + /** @var array edit form to be generated */ + protected $fields_form; /** @var array list of option forms to be generated */ protected $options; @@ -187,6 +191,9 @@ class AdminControllerCore extends Controller /** @var string Image type */ public $imageType = 'jpg'; + /** @var instanciation of the class associated with the AdminController */ + protected $object; + public function __construct() { // retro-compatibility : className for admin without controller @@ -271,7 +278,7 @@ class AdminControllerCore extends Controller // no need to use displayConf() here if (!empty($action) && method_exists($this, 'ajaxProcess'.Tools::toCamelCase($action))) $this->{'ajaxProcess'.Tools::toCamelCase($action)}(); - else if (method_exists($this, 'ajaxProcess')) + else if (method_exists($this, 'ajaxProcess')) $this->ajaxProcess(); // @TODO We should use a displayAjaxError @@ -290,6 +297,7 @@ class AdminControllerCore extends Controller // Sub included tab postProcessing $this->includeSubTab('postProcess', array('status', 'submitAdd1', 'submitDel', 'delete', 'submitFilter', 'submitReset')); + switch ($this->action) { /* Delete object image */ @@ -1009,111 +1017,26 @@ class AdminControllerCore extends Controller } /** - * initContent - * Assign smarty variables for all default views, list and form - * + * Assign smarty variables for all default views, list and form, then call other init functions */ public function initContent() { - $this->context->smarty->assign(array( - 'current' => self::$currentIndex, - 'token' => $this->token, - 'table' => $this->table - )); - if ($this->display == 'edit' || $this->display == 'add') { - if (!($obj = $this->loadObject(true))) + if (!($this->object = $this->loadObject(true))) return; - - // init form declaration $this->initForm(); - - if (isset($this->fields_form)) - { - $this->getlanguages(); - $helper = new HelperForm(); - // Check if form template has been overriden - if (file_exists($this->context->smarty->template_dir[0].'/'.$this->tpl_folder.'form.tpl')) - $helper->tpl = $this->tpl_folder.'form.tpl'; - $helper->currentIndex = self::$currentIndex; - $helper->token = $this->token; - $helper->table = $this->table; - $helper->identifier = $this->identifier; - $helper->id = $obj->id; - $helper->languages = $this->_languages; - $helper->default_form_language = $this->default_form_language; - $helper->allow_employee_form_lang = $this->allow_employee_form_lang; - $helper->fields_value = $this->getFieldsValue($obj); - $this->content .= $helper->generateForm($this->fields_form); - } - else - // TODO delete when all forms use the helper - $this->content .= $this->displayForm(); - - if ($this->tabAccess['view']) - { - if (Tools::getValue('back')) - $this->context->smarty->assign('back', Tools::safeOutput(Tools::getValue('back'))); - else - $this->context->smarty->assign('back', Tools::safeOutput(Tools::getValue(self::$currentIndex.'&token='.$this->token))); - } } - else if ($this->display == 'list') + else if ($this->display != 'view') { - // init list declaration $this->initList(); - - $this->getList($this->context->language->id); - - $helper = new HelperList(); - // Check if list templates have been overriden - if (file_exists($this->context->smarty->template_dir[0].'/'.$this->tpl_folder.'list_header.tpl')) - $helper->header_tpl = $this->tpl_folder.'list_header.tpl'; - if (file_exists($this->context->smarty->template_dir[0].'/'.$this->tpl_folder.'list_content.tpl')) - $helper->header_tpl = $this->tpl_folder.'list_content.tpl'; - if (file_exists($this->context->smarty->template_dir[0].'/'.$this->tpl_folder.'list_footer.tpl')) - $helper->header_tpl = $this->tpl_folder.'list_footer.tpl'; - - // For compatibility reasons, we have to check standard actions in class attributes - foreach ($this->actions_available as $action) - { - if (!in_array($action, $this->actions) && isset($this->$action) && $this->$action) - $this->actions[] = $action; - } - - $helper->actions = $this->actions; - $helper->bulk_actions = $this->bulk_actions; - $helper->currentIndex = self::$currentIndex; - $helper->className = $this->className; - $helper->table = $this->table; - $helper->_orderBy = $this->_orderBy; - $helper->_orderWay = $this->_orderWay; - $helper->_listTotal = $this->_listTotal; - $helper->shopLink = $this->shopLink; - $helper->shopLinkType = $this->shopLinkType; - $helper->identifier = $this->identifier; - $helper->token = $this->token; - $helper->imageType = $this->imageType; - $helper->no_add = isset($this->no_add) ? $this->no_add : false; - $helper->colorOnBackground = $this->colorOnBackground; - - // For each action, try to add the corresponding skip elements list - $helper->list_skip_actions = $this->list_skip_actions; - $this->content .= $helper->generateList($this->_list, $this->fieldsDisplay); - - // init options declaration $this->initOptions(); - - if ($this->options) - { - $helper = new HelperOptions(); - $helper->id = $this->id; - $helper->currentIndex = self::$currentIndex; - $this->content .= $helper->generateOptions($this->options); - } } - + $this->context->smarty->assign(array( + 'table' => $this->table, + 'current' => self::$currentIndex, + 'token' => $this->token, + )); } /** @@ -1141,6 +1064,48 @@ class AdminControllerCore extends Controller */ public function initList() { + if (!($this->fieldsDisplay && is_array($this->fieldsDisplay))) + return false; + $this->getList($this->context->language->id); + + if (!($this->_list && is_array($this->_list))) + return false; + + $helper = new HelperList(); + // Check if list templates have been overriden + if (file_exists($this->context->smarty->template_dir[0].'/'.$this->tpl_folder.'list_header.tpl')) + $helper->header_tpl = $this->tpl_folder.'list_header.tpl'; + if (file_exists($this->context->smarty->template_dir[0].'/'.$this->tpl_folder.'list_content.tpl')) + $helper->header_tpl = $this->tpl_folder.'list_content.tpl'; + if (file_exists($this->context->smarty->template_dir[0].'/'.$this->tpl_folder.'list_footer.tpl')) + $helper->header_tpl = $this->tpl_folder.'list_footer.tpl'; + + // For compatibility reasons, we have to check standard actions in class attributes + foreach ($this->actions_available as $action) + { + if (!in_array($action, $this->actions) && isset($this->$action) && $this->$action) + $this->actions[] = $action; + } + + $helper->actions = $this->actions; + $helper->bulk_actions = $this->bulk_actions; + $helper->currentIndex = self::$currentIndex; + $helper->className = $this->className; + $helper->table = $this->table; + $helper->orderBy = $this->_orderBy; + $helper->orderWay = $this->_orderWay; + $helper->listTotal = $this->_listTotal; + $helper->shopLink = $this->shopLink; + $helper->shopLinkType = $this->shopLinkType; + $helper->identifier = $this->identifier; + $helper->token = $this->token; + $helper->imageType = $this->imageType; + $helper->no_add = isset($this->no_add) ? $this->no_add : false; + $helper->colorOnBackground = $this->colorOnBackground; + + // For each action, try to add the corresponding skip elements list + $helper->list_skip_actions = $this->list_skip_actions; + $this->content .= $helper->generateList($this->_list, $this->fieldsDisplay); } /** @@ -1148,6 +1113,35 @@ class AdminControllerCore extends Controller */ public function initForm() { + if ($this->fields_form && is_array($this->fields_form)) + { + $this->getlanguages(); + $helper = new HelperForm(); + // Check if form template has been overriden + if (file_exists($this->context->smarty->template_dir[0].'/'.$this->tpl_folder.'form.tpl')) + $helper->tpl = $this->tpl_folder.'form.tpl'; + $helper->currentIndex = self::$currentIndex; + $helper->token = $this->token; + $helper->table = $this->table; + $helper->identifier = $this->identifier; + $helper->id = $this->object->id; + $helper->languages = $this->_languages; + $helper->default_form_language = $this->default_form_language; + $helper->allow_employee_form_lang = $this->allow_employee_form_lang; + $helper->fields_value = $this->getFieldsValue($this->object); + if ($this->tabAccess['view']) + { + if (Tools::getValue('back')) + $this->context->smarty->assign('back', Tools::safeOutput(Tools::getValue('back'))); + else + $this->context->smarty->assign('back', Tools::safeOutput(Tools::getValue(self::$currentIndex.'&token='.$this->token))); + } + + $this->content .= $helper->generateForm($this->fields_form); + } + // TODO delete when all forms use the helper + else + $this->content .= $this->displayForm(); } /** @@ -1155,6 +1149,14 @@ class AdminControllerCore extends Controller */ public function initOptions() { + if ($this->options && is_array($this->options)) + { + $helper = new HelperOptions(); + $helper->id = $this->id; + $helper->token = $this->token; + $helper->currentIndex = self::$currentIndex; + $this->content .= $helper->generateOptions($this->options); + } } public function setMedia() @@ -1250,7 +1252,7 @@ class AdminControllerCore extends Controller $protocol_content = (isset($useSSL) && $useSSL && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://'; $link = new Link($protocol_link, $protocol_content); $this->context->link = $link; - // @todo : put the definitions in Controller class + // @todo : put the definitions in Controller class if (!defined('_PS_BASE_URL_')) define('_PS_BASE_URL_', Tools::getShopDomain(true)); if (!defined('_PS_BASE_URL_SSL_')) @@ -1386,7 +1388,7 @@ class AdminControllerCore extends Controller else if (isset($_POST['submitReset'.$this->table])) $this->action = 'reset_filters'; /* Submit options list */ - else if (Tools::getValue('submitOptions'.$this->table)) + else if (Tools::getValue('submitOptions'.$this->table) || Tools::getValue('submitOptions')) $this->action = 'update_options'; else if (Tools::isSubmit('submitFields') && $this->requiredDatabase && $this->tabAccess['add'] === '1' && $this->tabAccess['delete'] === '1') $this->action = 'update_fields'; @@ -1440,7 +1442,6 @@ class AdminControllerCore extends Controller $orderBy = $this->context->cookie->__get($this->table.'Orderby') ? $this->context->cookie->__get($this->table.'Orderby') : $this->_defaultOrderBy; if (empty($orderWay)) $orderWay = $this->context->cookie->__get($this->table.'Orderway') ? $this->context->cookie->__get($this->table.'Orderway') : 'ASC'; - $limit = (int)Tools::getValue('pagination', $limit); $this->context->cookie->{$this->table.'_pagination'} = $limit; @@ -1780,7 +1781,7 @@ class AdminControllerCore extends Controller /** * Update the associations of shops - * + * * @param int $id_object * @param int $new_id_object */ @@ -1840,10 +1841,10 @@ class AdminControllerCore extends Controller } /** - * displayAssoShop + * displayAssoShop * @todo : create assoshop.tpl and use smarty var asso_shop in pages * - * @param string $type + * @param string $type * @return void */ protected function displayAssoShop($type = 'shop') diff --git a/classes/HelperList.php b/classes/HelperList.php index 74bf38edd..46a26f488 100644 --- a/classes/HelperList.php +++ b/classes/HelperList.php @@ -31,7 +31,7 @@ class HelperListCore extends Helper protected $_list = array(); /** @var integer Number of results in list */ - public $_listTotal = 0; + public $listTotal = 0; /** @var array WHERE clause determined by filter fields */ protected $_filter; @@ -43,13 +43,13 @@ class HelperListCore extends Helper protected $_pagination = array(20, 50, 100, 300); /** @var string ORDER BY clause determined by field/arrows in list header */ - public $_orderBy; + public $orderBy; - /** @var string Default ORDER BY clause when $_orderBy is not defined */ + /** @var string Default ORDER BY clause when $orderBy is not defined */ public $_defaultOrderBy = false; /** @var string Order way (ASC, DESC) determined by arrows in list header */ - public $_orderWay; + public $orderWay; public $identifier; @@ -425,14 +425,14 @@ class HelperListCore extends Helper else $default_pagination = $this->_pagination[0]; - $total_pages = ceil($this->_listTotal / Tools::getValue('pagination', ($default_pagination))); + $total_pages = ceil($this->listTotal / Tools::getValue('pagination', ($default_pagination))); if (!$total_pages) $total_pages = 1; $identifier = Tools::getIsset($this->identifier) ? '&'.$this->identifier.'='.(int)Tools::getValue($this->identifier) : ''; $order = ''; if (Tools::getIsset($this->table.'Orderby')) - $order = '&'.$this->table.'Orderby='.urlencode($this->_orderBy).'&'.$this->table.'Orderway='.urlencode(strtolower($this->_orderWay)); + $order = '&'.$this->table.'Orderby='.urlencode($this->orderBy).'&'.$this->table.'Orderway='.urlencode(strtolower($this->orderWay)); $action = $this->currentIndex.$identifier.'&token='.$token.$order.'#'.$this->table; @@ -455,7 +455,7 @@ class HelperListCore extends Helper substr($this->identifier,3,strlen($this->identifier))) } .' class="table'.( - if ($is_dnd_identifier AND ($this->_orderBy != 'position 'AND $this->_orderWay != 'DESC')) + if ($is_dnd_identifier AND ($this->orderBy != 'position 'AND $this->orderWay != 'DESC')) ' tableDnD' .'" cellpadding="0" cellspacing="0">*/ @@ -466,7 +466,7 @@ class HelperListCore extends Helper if (array_key_exists($this->identifier, $this->identifiersDnd) && (int)Tools::getValue($this->identifiersDnd[$this->identifier], 1)) $table_id = substr($this->identifier, 3, strlen($this->identifier)); - if (array_key_exists($this->identifier, $this->identifiersDnd) && ($this->_orderBy != 'position' && $this->_orderWay != 'DESC')) + if (array_key_exists($this->identifier, $this->identifiersDnd) && ($this->orderBy != 'position' && $this->orderWay != 'DESC')) $table_dnd = true; foreach ($this->fieldsDisplay as $key => $params) @@ -517,10 +517,10 @@ class HelperListCore extends Helper 'total_pages' => $total_pages, 'selected_pagination' => $selected_pagination, 'pagination' => $this->_pagination, - 'list_total' => $this->_listTotal, - 'is_order_position' => array_key_exists($this->identifier, $this->identifiersDnd) && $this->_orderBy == 'position', - 'order_way' => $this->_orderWay, - 'order_by' => $this->_orderBy, + 'list_total' => $this->listTotal, + 'is_order_position' => array_key_exists($this->identifier, $this->identifiersDnd) && $this->orderBy == 'position', + 'order_way' => $this->orderWay, + 'order_by' => $this->orderBy, 'token' => $this->token, 'fields_display' => $this->fieldsDisplay, 'delete' => in_array('delete', $this->actions), diff --git a/classes/HelperOptions.php b/classes/HelperOptions.php index 78034af44..974f7fb65 100644 --- a/classes/HelperOptions.php +++ b/classes/HelperOptions.php @@ -124,7 +124,7 @@ class HelperOptionsCore extends Helper 'option_list' => $option_list, 'current_id_lang' => $this->context->language->id, 'required_fields' => isset($required_fields) ? $required_fields : false, - 'languages' => isset($languages) ? $languages : false + 'languages' => isset($languages) ? $languages : null, )); return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/'.$this->tpl); } diff --git a/controllers/admin/AdminAddressesController.php b/controllers/admin/AdminAddressesController.php index ed96e934b..42cdd2bf5 100644 --- a/controllers/admin/AdminAddressesController.php +++ b/controllers/admin/AdminAddressesController.php @@ -48,6 +48,21 @@ class AdminAddressesControllerCore extends AdminController if (!Tools::getValue('realedit')) $this->deleted = true; + + $this->fieldsDisplay = array( + 'id_address' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), + 'firstname' => array('title' => $this->l('First name'), 'width' => 80, 'filter_key' => 'a!firstname'), + 'lastname' => array('title' => $this->l('Last name'), 'width' => 100, 'filter_key' => 'a!lastname'), + 'address1' => array('title' => $this->l('Address'), 'width' => 200), + 'postcode' => array('title' => $this->l('Postcode/ Zip Code'), 'align' => 'right', 'width' => 50), + 'city' => array('title' => $this->l('City'), 'width' => 150), + 'country' => array('title' => $this->l('Country'), 'width' => 100, 'type' => 'select', 'select' => $this->countriesArray, 'filter_key' => 'cl!id_country')); + + parent::__construct(); + } + + public function initList() + { $this->_select = 'cl.`name` as country'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (cl.`id_country` = a.`id_country` AND cl.`id_lang` = '.(int)$this->context->language->id.')'; @@ -57,15 +72,11 @@ class AdminAddressesControllerCore extends AdminController foreach ($countries AS $country) $this->countriesArray[$country['id_country']] = $country['name']; - $this->fieldsDisplay = array( - 'id_address' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), - 'firstname' => array('title' => $this->l('First name'), 'width' => 80, 'filter_key' => 'a!firstname'), - 'lastname' => array('title' => $this->l('Last name'), 'width' => 100, 'filter_key' => 'a!lastname'), - 'address1' => array('title' => $this->l('Address'), 'width' => 200), - 'postcode' => array('title' => $this->l('Postcode/ Zip Code'), 'align' => 'right', 'width' => 50), - 'city' => array('title' => $this->l('City'), 'width' => 150), - 'country' => array('title' => $this->l('Country'), 'width' => 100, 'type' => 'select', 'select' => $this->countriesArray, 'filter_key' => 'cl!id_country')); + parent::initList(); + } + public function initForm() + { $this->fields_form = array( 'legend' => array( 'title' => $this->l('Addresses'), @@ -125,7 +136,143 @@ class AdminAddressesControllerCore extends AdminController ) ); - parent::__construct(); + if (Validate::isLoadedObject($this->object)) + { + $customer = new Customer($this->object->id_customer); + $tokenCustomer = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id); + } + + if (Configuration::get('VATNUMBER_MANAGEMENT')) + if (file_exists(_PS_MODULE_DIR_.'vatnumber/vatnumber.php') && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT'))) + $vat = 'is_applicable'; + else + $vat = 'management'; + + $this->context->smarty->assign(array( + 'vat' => isset($vat) ? $vat : null, + 'customer' => isset($customer) ? $customer : null, + 'tokenCustomer' => isset ($tokenCustomer) ? $tokenCustomer : null + )); + + // Order address fields depending on country format + $addresses_fields = $this->processAddressFormat(); + $addresses_fields = $addresses_fields["dlv_all_fields"]; // we use delivery address + + $temp_fields = array(); + + foreach($addresses_fields as $addr_field_item) + { + if ($addr_field_item == 'company') + { + $temp_fields[] = array( + 'type' => 'text', + 'label' => $this->l('Company'), + 'name' => 'company', + 'size' => 33, + 'required' => false, + 'p' => ''.$this->l('Invalid characters:').' <>;=#{} ' + ); + $temp_fields[] = array( + 'type' => 'text', + 'label' => $this->l('VAT number'), + 'name' => 'vat_number', + 'size' => 33, + '' + ); + } + elseif ($addr_field_item == 'lastname') + { + $temp_fields[] = array( + 'type' => 'text', + 'label' => $this->l('Last name'), + 'name' => 'lastname', + 'size' => 33, + 'required' => true, + 'p' => ''.$this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%: ' + ); + } + elseif ($addr_field_item == 'firstname') + { + $temp_fields[] = array( + 'type' => 'text', + 'label' => $this->l('First name'), + 'name' => 'firstname', + 'size' => 33, + 'required' => true, + 'p' => ''.$this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%: ' + ); + } + elseif ($addr_field_item == 'address1') + { + $temp_fields[] = array( + 'type' => 'text', + 'label' => $this->l('Address'), + 'name' => 'address1', + 'size' => 33, + 'required' => true, + ); + } + elseif ($addr_field_item == 'address2') + { + $temp_fields[] = array( + 'type' => 'text', + 'label' => $this->l('Address').' (2)', + 'name' => 'address2', + 'size' => 33, + 'required' => false, + ); + } + elseif ($addr_field_item == 'postcode') + { + $temp_fields[] = array( + 'type' => 'text', + 'label' => $this->l('Postcode/ Zip Code'), + 'name' => 'postcode', + 'size' => 33, + 'required' => false, + ); + } + elseif ($addr_field_item == 'city') + { + $temp_fields[] = array( + 'type' => 'text', + 'label' => $this->l('City'), + 'name' => 'city', + 'size' => 33, + 'required' => true, + ); + } + elseif ($addr_field_item == 'country' || $addr_field_item == 'Country:name') + { + $temp_fields[] = array( + 'type' => 'select', + 'label' => $this->l('Country:'), + 'name' => 'id_country', + 'required' => false, + 'options' => array( + 'query' => Country::getCountries($this->context->language->id), + 'id' => 'id_country', + 'name' => 'name' + ) + ); + $temp_fields[] = array( + 'type' => 'select', + 'label' => $this->l('State'), + 'name' => 'id_state', + 'required' => false, + 'options' => array( + 'id' => 'id_state', + 'name' => 'name' + ) + ); + + } + } + + // merge address format with the rest of the form + array_splice($this->fields_form['input'], 3, 0, $temp_fields); + + parent::initForm(); } public function postProcess() @@ -241,152 +388,4 @@ class AdminAddressesControllerCore extends AdminController return $out; } - - public function initContent() - { - if ($this->display == 'edit' || $this->display == 'add') - { - if (!($address = $this->loadObject(true))) - return false; - - if (Validate::isLoadedObject($address)) - { - $customer = new Customer($address->id_customer); - $tokenCustomer = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id); - } - - if (Configuration::get('VATNUMBER_MANAGEMENT')) - if (file_exists(_PS_MODULE_DIR_.'vatnumber/vatnumber.php') && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT'))) - $vat = 'is_applicable'; - else - $vat = 'management'; - - $this->context->smarty->assign(array( - 'vat' => isset($vat) ? $vat : null, - 'customer' => isset($customer) ? $customer : null, - 'tokenCustomer' => isset ($tokenCustomer) ? $tokenCustomer : null - )); - - // Order address fields depending on country format - $addresses_fields = $this->processAddressFormat(); - $addresses_fields = $addresses_fields["dlv_all_fields"]; // we use delivery address - - $temp_fields = array(); - - foreach($addresses_fields as $addr_field_item) - { - if ($addr_field_item == 'company') - { - $temp_fields[] = array( - 'type' => 'text', - 'label' => $this->l('Company'), - 'name' => 'company', - 'size' => 33, - 'required' => false, - 'p' => ''.$this->l('Invalid characters:').' <>;=#{} ' - ); - $temp_fields[] = array( - 'type' => 'text', - 'label' => $this->l('VAT number'), - 'name' => 'vat_number', - 'size' => 33, - '' - ); - } - elseif ($addr_field_item == 'lastname') - { - $temp_fields[] = array( - 'type' => 'text', - 'label' => $this->l('Last name'), - 'name' => 'lastname', - 'size' => 33, - 'required' => true, - 'p' => ''.$this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%: ' - ); - } - elseif ($addr_field_item == 'firstname') - { - $temp_fields[] = array( - 'type' => 'text', - 'label' => $this->l('First name'), - 'name' => 'firstname', - 'size' => 33, - 'required' => true, - 'p' => ''.$this->l('Invalid characters:').' 0-9!<>,;?=+()@#"�{}_$%: ' - ); - } - elseif ($addr_field_item == 'address1') - { - $temp_fields[] = array( - 'type' => 'text', - 'label' => $this->l('Address'), - 'name' => 'address1', - 'size' => 33, - 'required' => true, - ); - } - elseif ($addr_field_item == 'address2') - { - $temp_fields[] = array( - 'type' => 'text', - 'label' => $this->l('Address').' (2)', - 'name' => 'address2', - 'size' => 33, - 'required' => false, - ); - } - elseif ($addr_field_item == 'postcode') - { - $temp_fields[] = array( - 'type' => 'text', - 'label' => $this->l('Postcode/ Zip Code'), - 'name' => 'postcode', - 'size' => 33, - 'required' => false, - ); - } - elseif ($addr_field_item == 'city') - { - $temp_fields[] = array( - 'type' => 'text', - 'label' => $this->l('City'), - 'name' => 'city', - 'size' => 33, - 'required' => true, - ); - } - elseif ($addr_field_item == 'country' || $addr_field_item == 'Country:name') - { - $temp_fields[] = array( - 'type' => 'select', - 'label' => $this->l('Country:'), - 'name' => 'id_country', - 'required' => false, - 'options' => array( - 'query' => Country::getCountries($this->context->language->id), - 'id' => 'id_country', - 'name' => 'name' - ) - ); - $temp_fields[] = array( - 'type' => 'select', - 'label' => $this->l('State'), - 'name' => 'id_state', - 'required' => false, - 'options' => array( - 'id' => 'id_state', - 'name' => 'name' - ) - ); - - } - } - // merge address format with the rest of the form - array_splice($this->fields_form['input'], 3, 0, $temp_fields); - } - else - $this->display = 'list'; - - parent::initContent(); - } } \ No newline at end of file diff --git a/controllers/admin/AdminAliasesController.php b/controllers/admin/AdminAliasesController.php index fcbac70ad..3f51abe09 100644 --- a/controllers/admin/AdminAliasesController.php +++ b/controllers/admin/AdminAliasesController.php @@ -85,6 +85,13 @@ class AdminAliasesControllerCore extends AdminController parent::__construct(); } + public function initForm() + { + $this->fields_value = array('alias' => $this->object->getAliases()); + + parent::initForm(); + } + public function postProcess() { if (isset($_POST['submitAdd'.$this->table])) @@ -112,20 +119,6 @@ class AdminAliasesControllerCore extends AdminController else parent::postProcess(); } - - public function initContent() - { - if (!($obj = $this->loadObject(true))) - return; - - $this->fields_value = array('alias' => $obj->getAliases()); - - if ($this->display != 'edit' && $this->display != 'add') - $this->display = 'list'; - - parent::initContent(); - } - } diff --git a/controllers/admin/AdminBackupController.php b/controllers/admin/AdminBackupController.php index 12707514a..e0f128722 100644 --- a/controllers/admin/AdminBackupController.php +++ b/controllers/admin/AdminBackupController.php @@ -36,12 +36,13 @@ class AdminBackupControllerCore extends AdminController $this->className = 'Backup'; parent::__construct(); - $this->addRowAction('delete'); $this->addRowAction('view'); + $this->addRowAction('delete'); + $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); $this->deleted = false; - $this->requiredDatabase = false; + $this->identifier = 'filename'; $this->fieldsDisplay = array ( 'date' => array('title' => $this->l('Date'), 'type' => 'datetime', 'width' => 120, 'align' => 'right'), @@ -62,7 +63,6 @@ class AdminBackupControllerCore extends AdminController 'submit' => array() ), ); - $this->identifier = 'filename'; } /** @@ -107,7 +107,6 @@ class AdminBackupControllerCore extends AdminController $this->display = 'list'; $show_form = true; } - $this->context->smarty->assign(array( 'current' => self::$currentIndex, 'show_form' => $show_form, @@ -115,6 +114,7 @@ class AdminBackupControllerCore extends AdminController 'how_to' => true, )); } + parent::initContent(); } @@ -154,7 +154,6 @@ class AdminBackupControllerCore extends AdminController public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = NULL) { - if (!Validate::isTableOrIdentifier($this->table)) die('filter is corrupted'); if (empty($orderBy)) diff --git a/controllers/admin/AdminContactsController.php b/controllers/admin/AdminContactsController.php index 2b4e1a559..3b70abd29 100644 --- a/controllers/admin/AdminContactsController.php +++ b/controllers/admin/AdminContactsController.php @@ -43,20 +43,11 @@ class AdminContactsControllerCore extends AdminController 'description' => array('title' => $this->l('Description'), 'width' => 150), ); - $this->options = array( - 'general' => array( - 'title' => $this->l('Contact options'), - 'fields' => array( - 'PS_CUSTOMER_SERVICE_FILE_UPLOAD' => array('title' => $this->l('Allow file upload'), 'desc' => $this->l('Allow customers to upload file using contact page'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array( - '0' => array('value' => 0, 'name' => $this->l('No')), - '1' => array('value' => 1, 'name' => $this->l('Yes')) - )), - 'PS_CUSTOMER_SERVICE_SIGNATURE' => array('title' => $this->l('Pre-defined message'), 'desc' => $this->l('Please fill the message that appears by default when you answer a thread on the customer service page'), 'cast' => 'pSQL', 'type' => 'textareaLang', 'identifier' => 'value', 'cols' => 40, 'rows' => 8), - ), - 'submit' => array() - ), - ); + parent::__construct(); + } + public function initForm() + { $this->fields_form = array( 'legend' => array( 'title' => $this->l('Contacts'), @@ -120,16 +111,9 @@ class AdminContactsControllerCore extends AdminController ) ); - parent::__construct(); + parent::initForm(); } - public function initContent() - { - if ($this->display != 'edit') - $this->display = 'list'; - - parent::initContent(); - } } diff --git a/controllers/admin/AdminCurrenciesController.php b/controllers/admin/AdminCurrenciesController.php index bd35dd33d..d7d331947 100644 --- a/controllers/admin/AdminCurrenciesController.php +++ b/controllers/admin/AdminCurrenciesController.php @@ -274,13 +274,5 @@ class AdminCurrenciesControllerCore extends AdminController Configuration::updateValue('PS_CURRENCY_DEFAULT', $value); Currency::refreshCurrencies(); } - - public function initContent() - { - if ($this->display != 'edit' && $this->display != 'add') - $this->display = 'list'; - - parent::initContent(); - } } diff --git a/controllers/admin/AdminEmailsController.php b/controllers/admin/AdminEmailsController.php index a3bff0089..c04ebd09a 100644 --- a/controllers/admin/AdminEmailsController.php +++ b/controllers/admin/AdminEmailsController.php @@ -90,18 +90,6 @@ class AdminEmailsControllerCore extends AdminController ); } - public function initContent() - { - $helper = new HelperOptions(); - $helper->id = $this->id; - $helper->currentIndex = self::$currentIndex; - $helper->table = $this->table; - $helper->token = $this->token; - $this->content .= $helper->generateOptions($this->options); - - parent::initContent(); - } - public function beforeUpdateOptions() { /* PrestaShop demo mode */ diff --git a/controllers/admin/AdminImagesController.php b/controllers/admin/AdminImagesController.php index 0d44adf12..d56399af1 100644 --- a/controllers/admin/AdminImagesController.php +++ b/controllers/admin/AdminImagesController.php @@ -527,17 +527,7 @@ class AdminImagesController extends AdminController public function initContent() { if ($this->display != 'edit' && $this->display != 'add') - $this->display = 'list'; - - parent::initContent(); - - if ($this->display == 'list') { - $helper = new HelperOptions(); - $helper->id = $this->id; - $helper->currentIndex = self::$currentIndex; - $this->content .= $helper->generateOptions($this->options); - $this->initRegenerate(); $this->initMoveImages(); @@ -549,5 +539,7 @@ class AdminImagesController extends AdminController if ($this->display == 'edit') $this->warnings[] = $this->l('After modification, do not forget to regenerate thumbnails'); + + parent::initContent(); } }