/classes/controller/AdminController.php
PHP | 2810 lines | 1984 code | 337 blank | 489 comment | 537 complexity | 14f3db9c3194db499b585cca91460c9a MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php
- /*
- * 2007-2012 PrestaShop
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@prestashop.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
- * versions in the future. If you wish to customize PrestaShop for your
- * needs please refer to http://www.prestashop.com for more information.
- *
- * @author PrestaShop SA <contact@prestashop.com>
- * @copyright 2007-2012 PrestaShop SA
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- * International Registered Trademark & Property of PrestaShop SA
- */
- class AdminControllerCore extends Controller
- {
- public $path;
- public static $currentIndex;
- public $content;
- public $warnings = array();
- public $informations = array();
- public $confirmations = array();
- public $shopShareDatas = false;
-
- protected $addons_url = 'api.addons.prestashop.com';
- public $_languages = array();
- public $default_form_language;
- public $allow_employee_form_lang;
- public $layout = 'layout.tpl';
- protected $meta_title;
- public $template = 'content.tpl';
- /** @var string Associated table name */
- public $table;
- /** @var string Object identifier inside the associated table */
- protected $identifier = false;
- /** @var string Tab name */
- public $className;
- /** @var array tabAccess */
- public $tabAccess;
- /** @var integer Tab id */
- public $id = -1;
- public $required_database = false;
- /** @var string Security token */
- public $token;
- /** @var string shop | group_shop */
- public $shopLinkType;
- /** @var string Default ORDER BY clause when $_orderBy is not defined */
- protected $_defaultOrderBy = false;
- protected $_defaultOrderWay = 'ASC';
- public $tpl_form_vars = array();
- public $tpl_list_vars = array();
- public $tpl_delete_link_vars = array();
- public $tpl_option_vars = array();
- public $tpl_view_vars = array();
- public $tpl_required_fields_vars = array();
- public $base_tpl_view = null;
- public $base_tpl_form = null;
- /** @var bool if you want more fieldsets in the form */
- public $multiple_fieldsets = false;
- public $fields_value = false;
- /** @var array Errors displayed after post processing */
- public $errors = array();
- /** @var define if the header of the list contains filter and sorting links or not */
- protected $list_simple_header;
- /** @var array list to be generated */
- protected $fields_list;
- /** @var array edit form to be generated */
- protected $fields_form;
- /** @var override of $fields_form */
- protected $fields_form_override;
- /** @var array list of option forms to be generated */
- protected $fields_options;
- protected $shopLink;
- /** @var string SQL query */
- protected $_listsql = '';
- /** @var array Cache for query results */
- protected $_list = array();
- /** @var define if the header of the list contains filter and sorting links or not */
- protected $toolbar_title;
- /** @var array list of toolbar buttons */
- protected $toolbar_btn = null;
- /** @var boolean scrolling toolbar */
- protected $toolbar_scroll = true;
- /** @var boolean set to false to hide toolbar and page title */
- protected $show_toolbar = true;
- /** @var boolean set to true to show toolbar and page title for options */
- protected $show_toolbar_options = false;
- /** @var integer Number of results in list */
- protected $_listTotal = 0;
- /** @var boolean Automatically join language table if true */
- public $lang = false;
- /** @var array WHERE clause determined by filter fields */
- protected $_filter;
- /** @var array Temporary SQL table WHERE clause determinated by filter fields */
- protected $_tmpTableFilter = '';
- /** @var array Number of results in list per page (used in select field) */
- protected $_pagination = array(20, 50, 100, 300);
- /** @var string ORDER BY clause determined by field/arrows in list header */
- protected $_orderBy;
- /** @var string Order way (ASC, DESC) determined by arrows in list header */
- protected $_orderWay;
- /** @var array list of available actions for each list row - default actions are view, edit, delete, duplicate */
- protected $actions_available = array('view', 'edit', 'delete', 'duplicate');
- /** @var array list of required actions for each list row */
- protected $actions = array();
- /** @var array list of row ids associated with a given action for witch this action have to not be available */
- protected $list_skip_actions = array();
- /* @var boolean don't show header & footer */
- protected $lite_display = false;
- /** @var bool boolean List content lines are clickable if true */
- protected $list_no_link = false;
- /** @var array $cache_lang cache for traduction */
- public static $cache_lang = array();
- /** @var array required_fields to display in the Required Fields form */
- public $required_fields = array();
- /**
- * @var array actions to execute on multiple selections
- * Usage:
- * array(
- * 'actionName' => array(
- * 'text' => $this->l('Message displayed on the submit button (mandatory)'),
- * 'confirm' => $this->l('If set, this confirmation message will pop-up (optional)')),
- * 'anotherAction' => array(...)
- * );
- *
- * If your action is named 'actionName', you need to have a method named bulkactionName() that will be executed when the button is clicked.
- */
- protected $bulk_actions;
- /**
- * @var array ids of the rows selected
- */
- protected $boxes;
-
- /** @var string Do not automatically select * anymore but select only what is necessary */
- protected $explicitSelect = false;
- /** @var string Add fields into data query to display list */
- protected $_select;
- /** @var string Join tables into data query to display list */
- protected $_join;
- /** @var string Add conditions into data query to display list */
- protected $_where;
- /** @var string Group rows into data query to display list */
- protected $_group;
- /** @var string Having rows into data query to display list */
- protected $_having;
- protected $is_cms = false;
- /** @var string identifier to use for changing positions in lists (can be omitted if positions cannot be changed) */
- protected $position_identifier;
- /** @var boolean Table records are not deleted but marked as deleted if set to true */
- protected $deleted = false;
- /**
- * @var bool is a list filter set
- */
- protected $filter;
- protected $noLink;
- protected $specificConfirmDelete = null;
- protected $colorOnBackground;
- /** @var bool If true, activates color on hover */
- protected $row_hover = true;
- /** @string Action to perform : 'edit', 'view', 'add', ... */
- protected $action;
- protected $display;
- protected $_includeContainer = true;
- public $tpl_folder;
- protected $bo_theme;
- /** @var bool Redirect or not ater a creation */
- protected $_redirect = true;
- /** @var array Name and directory where class image are located */
- public $fieldImageSettings = array();
- /** @var string Image type */
- public $imageType = 'jpg';
- /** @var instanciation of the class associated with the AdminController */
- protected $object;
- /** @var current object ID */
- protected $id_object;
- /**
- * @var current controller name without suffix
- */
- public $controller_name;
- public $multishop_context = -1;
- public $multishop_context_group = true;
- /**
- * Current breadcrumb position as an array of tab names
- */
- protected $breadcrumbs;
- public function __construct()
- {
- global $timer_start;
- $this->timer_start = $timer_start;
- // Has to be remove for the next Prestashop version
- global $token;
- $this->controller_type = 'admin';
- $this->controller_name = get_class($this);
- if (strpos($this->controller_name, 'Controller'))
- $this->controller_name = substr($this->controller_name, 0, -10);
- parent::__construct();
- if ($this->multishop_context == -1)
- $this->multishop_context = Shop::CONTEXT_ALL | Shop::CONTEXT_GROUP | Shop::CONTEXT_SHOP;
- $this->bo_theme = ((Validate::isLoadedObject($this->context->employee) && $this->context->employee->bo_theme) ? $this->context->employee->bo_theme : 'default');
- if (!file_exists(_PS_BO_ALL_THEMES_DIR_.$this->bo_theme.DIRECTORY_SEPARATOR.'template'))
- $this->bo_theme = 'default';
-
- $this->context->smarty->setTemplateDir(array(
- _PS_BO_ALL_THEMES_DIR_.$this->bo_theme.DIRECTORY_SEPARATOR.'template',
- _PS_OVERRIDE_DIR_.'controllers'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'templates'
- ));
- $this->id = Tab::getIdFromClassName($this->controller_name);
- $this->token = Tools::getAdminToken($this->controller_name.(int)$this->id.(int)$this->context->employee->id);
- $token = $this->token;
- $this->_conf = array(
- 1 => $this->l('Deletion successful'), 2 => $this->l('Selection successfully deleted'),
- 3 => $this->l('Creation successful'), 4 => $this->l('Update successful'),
- 5 => $this->l('Status update successful'), 6 => $this->l('Settings update successful'),
- 7 => $this->l('Image successfully deleted'), 8 => $this->l('Module downloaded successfully'),
- 9 => $this->l('Thumbnails successfully regenerated'), 10 => $this->l('Message sent to the customer'),
- 11 => $this->l('Comment added'), 12 => $this->l('Module(s) installed successfully'),
- 13 => $this->l('Module(s) uninstalled successfully'), 14 => $this->l('Language successfully copied'),
- 15 => $this->l('Translations successfully added'), 16 => $this->l('Module transplanted successfully to hook'),
- 17 => $this->l('Module removed successfully from hook'), 18 => $this->l('Upload successful'),
- 19 => $this->l('Duplication completed successfully'), 20 => $this->l('Translation added successfully but the language has not been created'),
- 21 => $this->l('Module reset successfully'), 22 => $this->l('Module deleted successfully'),
- 23 => $this->l('Localization pack imported successfully'), 24 => $this->l('Localization pack imported successfully'),
- 25 => $this->l('Images successfully moved'),
- 26 => $this->l('Cover selection saved'),
- 27 => $this->l('Image shop association modified'),
- 28 => $this->l('Zone assigned to the selection successfully'),
- 29 => $this->l('Upgrade successful'),
- 30 => $this->l('Partial refund successfully created'),
- 31 => $this->l('The discount successfully generated')
- );
- if (!$this->identifier) $this->identifier = 'id_'.$this->table;
- if (!$this->_defaultOrderBy) $this->_defaultOrderBy = $this->identifier;
- $this->tabAccess = Profile::getProfileAccess($this->context->employee->id_profile, $this->id);
- // Fix for AdminHome
- if ($this->controller_name == 'AdminHome')
- $_POST['token'] = $this->token;
- if (!Shop::isFeatureActive())
- $this->shopLinkType = '';
- //$this->base_template_folder = _PS_BO_ALL_THEMES_DIR_.$this->bo_theme.'/template';
- $this->override_folder = Tools::toUnderscoreCase(substr($this->controller_name, 5)).'/';
- // Get the name of the folder containing the custom tpl files
- $this->tpl_folder = Tools::toUnderscoreCase(substr($this->controller_name, 5)).'/';
- $this->initShopContext();
- $this->context->currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
- }
- /**
- * Set breadcrumbs array for the controller page
- */
- public function initBreadcrumbs()
- {
- $tabs = array();
- $tabs = Tab::recursiveTab($this->id, $tabs);
- $tabs = array_reverse($tabs);
- foreach ($tabs as $tab)
- $this->breadcrumbs[] = $tab['name'];
- }
- /**
- * set default toolbar_title to admin breadcrumb
- *
- * @return void
- */
- public function initToolbarTitle()
- {
- $bread_extended = array_unique($this->breadcrumbs);
- switch ($this->display)
- {
- case 'edit':
- $bread_extended[] = $this->l('Edit');
- break;
- case 'add':
- $bread_extended[] = $this->l('Add new');
- break;
- case 'view':
- $bread_extended[] = $this->l('View');
- break;
- }
- $this->toolbar_title = $bread_extended;
- }
- /**
- * Check rights to view the current tab
- *
- * @param bool $disable
- * @return boolean
- */
- public function viewAccess($disable = false)
- {
- if ($disable)
- return true;
- if ($this->tabAccess['view'] === '1')
- return true;
- return false;
- }
- /**
- * Check for security token
- */
- public function checkToken()
- {
- $token = Tools::getValue('token');
- return (!empty($token) && $token === $this->token);
- }
- public function ajaxProcessHelpAccess()
- {
- $this->json = true;
- $item = Tools::getValue('item');
- $iso_user = Tools::getValue('isoUser');
- $country = Tools::getValue('country');
- $version = Tools::getValue('version');
- if (isset($item) && isset($iso_user) && isset($country))
- {
- $helper = new HelperHelpAccess($item, $iso_user, $country, $version);
- $this->content = $helper->generate();
- }
- else
- $this->content = 'none';
- $this->display = 'content';
- }
- /**
- * Set the filters used for the list display
- */
- public function processFilter()
- {
- // Filter memorization
- if (isset($_POST) && !empty($_POST) && isset($this->table))
- foreach ($_POST as $key => $value)
- {
- if (is_array($this->table))
- {
- foreach ($this->table as $table)
- if (stripos($key, $table.'Filter_') === 0 || stripos($key, 'submitFilter') === 0)
- $this->context->cookie->$key = !is_array($value) ? $value : serialize($value);
- }
- elseif (stripos($key, $this->table.'Filter_') === 0 || stripos($key, 'submitFilter') === 0)
- $this->context->cookie->$key = !is_array($value) ? $value : serialize($value);
- }
- if (isset($_GET) && !empty($_GET) && isset($this->table))
- foreach ($_GET as $key => $value)
- {
- if (is_array($this->table))
- {
- foreach ($this->table as $table)
- if (stripos($key, $table.'OrderBy') === 0 || stripos($key, $table.'Orderway') === 0)
- $this->context->cookie->$key = $value;
- }
- elseif (stripos($key, $this->table.'OrderBy') === 0 || stripos($key, $this->table.'Orderway') === 0)
- $this->context->cookie->$key = $value;
- }
-
- $filters = $this->context->cookie->getFamily($this->table.'Filter_');
- foreach ($filters as $key => $value)
- {
- /* Extracting filters from $_POST on key filter_ */
- if ($value != null && !strncmp($key, $this->table.'Filter_', 7 + Tools::strlen($this->table)))
- {
- $key = Tools::substr($key, 7 + Tools::strlen($this->table));
- /* Table alias could be specified using a ! eg. alias!field */
- $tmp_tab = explode('!', $key);
- $filter = count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0];
- if ($field = $this->filterToField($key, $filter))
- {
- $type = (array_key_exists('filter_type', $field) ? $field['filter_type'] : (array_key_exists('type', $field) ? $field['type'] : false)); if (($type == 'date' || $type == 'datetime') && is_string($value))
- $value = Tools::unSerialize($value);
- $key = isset($tmp_tab[1]) ? $tmp_tab[0].'.`'.$tmp_tab[1].'`' : '`'.$tmp_tab[0].'`';
- // Assignement by reference
- if (array_key_exists('tmpTableFilter', $field))
- $sql_filter = & $this->_tmpTableFilter;
- elseif (array_key_exists('havingFilter', $field))
- $sql_filter = & $this->_filterHaving;
- else
- $sql_filter = & $this->_filter;
- /* Only for date filtering (from, to) */
- if (is_array($value))
- {
- if (isset($value[0]) && !empty($value[0]))
- {
- if (!Validate::isDate($value[0]))
- $this->errors[] = Tools::displayError('\'From:\' date format is invalid (YYYY-MM-DD)');
- else
- $sql_filter .= ' AND '.pSQL($key).' >= \''.pSQL(Tools::dateFrom($value[0])).'\'';
- }
- if (isset($value[1]) && !empty($value[1]))
- {
- if (!Validate::isDate($value[1]))
- $this->errors[] = Tools::displayError('\'To:\' date format is invalid (YYYY-MM-DD)');
- else
- $sql_filter .= ' AND '.pSQL($key).' <= \''.pSQL(Tools::dateTo($value[1])).'\'';
- }
- }
- else
- {
- $sql_filter .= ' AND ';
- $check_key = ($key == $this->identifier || $key == '`'.$this->identifier.'`');
- if ($type == 'int' || $type == 'bool')
- $sql_filter .= (($check_key || $key == '`active`') ? 'a.' : '').pSQL($key).' = '.(int)$value.' ';
- elseif ($type == 'decimal')
- $sql_filter .= ($check_key ? 'a.' : '').pSQL($key).' = '.(float)$value.' ';
- elseif ($type == 'select')
- $sql_filter .= ($check_key ? 'a.' : '').pSQL($key).' = \''.pSQL($value).'\' ';
- else
- $sql_filter .= ($check_key ? 'a.' : '').pSQL($key).' LIKE \'%'.pSQL($value).'%\' ';
- }
- }
- }
- }
- }
- /**
- * @todo uses redirectAdmin only if !$this->ajax
- */
- 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))))
- {
- // 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;
- }
- }
- }
- /**
- * Object Delete images
- */
- public function processDeleteImage()
- {
- if (Validate::isLoadedObject($object = $this->loadObject()))
- {
- if (($object->deleteImage()))
- {
- $redirect = self::$currentIndex.'&add'.$this->table.'&'.$this->identifier.'='.Tools::getValue($this->identifier).'&conf=7&token='.$this->token;
- if (!$this->ajax)
- $this->redirect_after = $redirect;
- else
- $this->content = 'ok';
- }
- }
- $this->errors[] = Tools::displayError('An error occurred during image deletion (cannot load object).');
- return $object;
- }
- /**
- * Object Delete
- */
- public function processDelete()
- {
- if (Validate::isLoadedObject($object = $this->loadObject()))
- {
- $res = true;
- // check if request at least one object with noZeroObject
- if (isset($object->noZeroObject) && count(call_user_func(array($this->className, $object->noZeroObject))) <= 1)
- {
- $this->errors[] = Tools::displayError('You need at least one object.').
- ' <b>'.$this->table.'</b><br />'.
- Tools::displayError('You cannot delete all of the items.');
- }
- elseif (array_key_exists('delete', $this->list_skip_actions) && in_array($object->id, $this->list_skip_actions['delete'])) //check if some ids are in list_skip_actions and forbid deletion
- $this->errors[] = Tools::displayError('You cannot delete this item.');
- else
- {
- if ($this->deleted)
- {
- if (!empty($this->fieldImageSettings))
- $res = $object->deleteImage();
- if (!$res)
- $this->errors[] = Tools::displayError('Unable to delete associated images');
- $object->deleted = 1;
- if ($object->update())
- $this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token;
- }
- elseif ($object->delete())
- $this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token;
- $this->errors[] = Tools::displayError('An error occurred during deletion.');
- }
- }
- else
- {
- $this->errors[] = Tools::displayError('An error occurred while deleting object.').
- ' <b>'.$this->table.'</b> '.
- Tools::displayError('(cannot load object)');
- }
- return $object;
- }
- /**
- * Call the right method for creating or updating object
- *
- * @return mixed
- */
- public function processSave()
- {
- if ($this->id_object)
- {
- $this->object = $this->loadObject();
- return $this->processUpdate();
- }
- else
- return $this->processAdd();
- }
- /**
- * Object creation
- */
- public function processAdd()
- {
- /* Checking fields validity */
- $this->validateRules();
- if (count($this->errors) <= 0)
- {
- $this->object = new $this->className();
- $this->copyFromPost($this->object, $this->table);
- $this->beforeAdd($this->object);
- if (method_exists($this->object, 'add') && !$this->object->add())
- {
- $this->errors[] = Tools::displayError('An error occurred while creating object.').
- ' <b>'.$this->table.' ('.Db::getInstance()->getMsgError().')</b>';
- }
- /* voluntary do affectation here */
- elseif (($_POST[$this->identifier] = $this->object->id) && $this->postImage($this->object->id) && !count($this->errors) && $this->_redirect)
- {
- $parent_id = (int)Tools::getValue('id_parent', 1);
- $this->afterAdd($this->object);
- $this->updateAssoShop($this->object->id);
- // Save and stay on same form
- if (empty($this->redirect_after) && $this->redirect_after !== false && Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
- $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$this->object->id.'&conf=3&update'.$this->table.'&token='.$this->token;
- // Save and back to parent
- if (empty($this->redirect_after) && $this->redirect_after !== false && Tools::isSubmit('submitAdd'.$this->table.'AndBackToParent'))
- $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$parent_id.'&conf=3&token='.$this->token;
- // Default behavior (save and back)
- if (empty($this->redirect_after) && $this->redirect_after !== false)
- $this->redirect_after = self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$this->object->id : '').'&conf=3&token='.$this->token;
- }
- }
- $this->errors = array_unique($this->errors);
- if (!empty($this->errors))
- {
- // if we have errors, we stay on the form instead of going back to the list
- $this->display = 'edit';
- return false;
- }
- return $this->object;
- }
- /**
- * Object update
- */
- public function processUpdate()
- {
- /* Checking fields validity */
- $this->validateRules();
- if (empty($this->errors))
- {
- $id = (int)Tools::getValue($this->identifier);
- /* Object update */
- if (isset($id) && !empty($id))
- {
- $object = new $this->className($id);
- if (Validate::isLoadedObject($object))
- {
- /* Specific to objects which must not be deleted */
- if ($this->deleted && $this->beforeDelete($object))
- {
- // Create new one with old objet values
- $object_new = $object->duplicateObject();
- if (Validate::isLoadedObject($object_new))
- {
- // Update old object to deleted
- $object->deleted = 1;
- $object->update();
- // Update new object with post values
- $this->copyFromPost($object_new, $this->table);
- $result = $object_new->update();
- if (Validate::isLoadedObject($object_new))
- $this->afterDelete($object_new, $object->id);
- }
- }
- else
- {
- $this->copyFromPost($object, $this->table);
- $result = $object->update();
- $this->afterUpdate($object);
- }
- if ($object->id)
- $this->updateAssoShop($object->id);
- if (!$result)
- {
- $this->errors[] = Tools::displayError('An error occurred while updating object.').
- ' <b>'.$this->table.'</b> ('.Db::getInstance()->getMsgError().')';
- }
- elseif ($this->postImage($object->id) && !count($this->errors) && $this->_redirect)
- {
- $parent_id = (int)Tools::getValue('id_parent', 1);
- // Specific back redirect
- if ($back = Tools::getValue('back'))
- $this->redirect_after = urldecode($back).'&conf=4';
- // Specific scene feature
- // @todo change stay_here submit name (not clear for redirect to scene ... )
- if (Tools::getValue('stay_here') == 'on' || Tools::getValue('stay_here') == 'true' || Tools::getValue('stay_here') == '1')
- $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=4&updatescene&token='.$this->token;
- // Save and stay on same form
- // @todo on the to following if, we may prefer to avoid override redirect_after previous value
- if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
- $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=4&update'.$this->table.'&token='.$this->token;
- // Save and back to parent
- if (Tools::isSubmit('submitAdd'.$this->table.'AndBackToParent'))
- $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$parent_id.'&conf=4&token='.$this->token;
- // Default behavior (save and back)
- if (empty($this->redirect_after))
- $this->redirect_after = self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=4&token='.$this->token;
- }
- }
- else
- $this->errors[] = Tools::displayError('An error occurred while updating object.').
- ' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
- }
- }
- $this->errors = array_unique($this->errors);
- if (!empty($this->errors))
- {
- // if we have errors, we stay on the form instead of going back to the list
- $this->display = 'edit';
- return false;
- }
- if (isset($object))
- return $object;
- return;
- }
- /**
- * Change object required fields
- */
- public function processUpdateFields()
- {
- if (!is_array($fields = Tools::getValue('fieldsBox')))
- $fields = array();
- $object = new $this->className();
- if (!$object->addFieldsRequiredDatabase($fields))
- $this->errors[] = Tools::displayError('Error in updating required fields');
- else
- $this->redirect_after = self::$currentIndex.'&conf=4&token='.$this->token;
- return $object;
- }
- /**
- * Change object status (active, inactive)
- */
- public function processStatus()
- {
- if (Validate::isLoadedObject($object = $this->loadObject()))
- {
- if ($object->toggleStatus())
- {
- $id_category = (($id_category = (int)Tools::getValue('id_category')) && Tools::getValue('id_product')) ? '&id_category='.$id_category : '';
- $this->redirect_after = self::$currentIndex.'&conf=5'.$id_category.'&token='.$this->token;
- }
- else
- $this->errors[] = Tools::displayError('An error occurred while updating status.');
- }
- else
- $this->errors[] = Tools::displayError('An error occurred while updating status for object.').
- ' <b>'.$this->table.'</b> '.
- Tools::displayError('(cannot load object)');
- return $object;
- }
- /**
- * Change object position
- */
- public function processPosition()
- {
- if (!Validate::isLoadedObject($object = $this->loadObject()))
- {
- $this->errors[] = Tools::displayError('An error occurred while updating status for object.').
- ' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
- }
- elseif (!$object->updatePosition((int)Tools::getValue('way'), (int)Tools::getValue('position')))
- $this->errors[] = Tools::displayError('Failed to update the position.');
- else
- {
- $id_identifier_str = ($id_identifier = (int)Tools::getValue($this->identifier)) ? '&'.$this->identifier.'='.$id_identifier : '';
- $redirect = self::$currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=5'.$id_identifier_str.'&token='.$this->token;
- $this->redirect_after = $redirect;
- }
- return $object;
- }
- /**
- * Cancel all filters for this tab
- */
- public function processResetFilters()
- {
- $filters = $this->context->cookie->getFamily($this->table.'Filter_');
- foreach ($filters as $cookie_key => $filter)
- if (strncmp($cookie_key, $this->table.'Filter_', 7 + Tools::strlen($this->table)) == 0)
- {
- $key = substr($cookie_key, 7 + Tools::strlen($this->table));
- /* Table alias could be specified using a ! eg. alias!field */
- $tmp_tab = explode('!', $key);
- $key = (count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0]);
- if (is_array($this->fields_list) && array_key_exists($key, $this->fields_list))
- unset($this->context->cookie->$cookie_key);
- }
- if (isset($this->context->cookie->{'submitFilter'.$this->table}))
- unset($this->context->cookie->{'submitFilter'.$this->table});
- if (isset($this->context->cookie->{$this->table.'Orderby'}))
- unset($this->context->cookie->{$this->table.'Orderby'});
- if (isset($this->context->cookie->{$this->table.'Orderway'}))
- unset($this->context->cookie->{$this->table.'Orderway'});
- unset($_POST);
- $this->_filter = false;
- unset($this->_filterHaving);
- unset($this->_having);
- }
- /**
- * Update options and preferences
- */
- protected function processUpdateOptions()
- {
- $this->beforeUpdateOptions();
- $languages = Language::getLanguages(false);
- $hide_multishop_checkbox = (Shop::getTotalShops(false, null) < 2) ? true : false;
- foreach ($this->fields_options as $category_data)
- {
- if (!isset($category_data['fields']))
- continue;
- $fields = $category_data['fields'];
- foreach ($fields as $field => $values)
- {
- if (isset($values['type']) && $values['type'] == 'selectLang')
- {
- foreach ($languages as $lang)
- if (Tools::getValue($field.'_'.strtoupper($lang['iso_code'])))
- $fields[$field.'_'.strtoupper($lang['iso_code'])] = array(
- 'type' => 'select',
- 'cast' => 'strval',
- 'identifier' => 'mode',
- 'list' => $values['list']
- );
- }
- }
- // Validate fields
- foreach ($fields as $field => $values)
- {
- // We don't validate fields with no visibility
- if (!$hide_multishop_checkbox && Shop::isFeatureActive() && isset($values['visibility']) && $values['visibility'] > Shop::getContext())
- continue;
- // Check if field is required
- if (isset($values['required']) && $values['required'] && !empty($_POST['multishopOverrideOption'][$field]))
- if (isset($values['type']) && $values['type'] == 'textLang')
- {
- foreach ($languages as $language)
- if (($value = Tools::getValue($field.'_'.$language['id_lang'])) == false && (string)$value != '0')
- $this->errors[] = sprintf(Tools::displayError('field %s is required.'), $values['title']);
- }
- elseif (($value = Tools::getValue($field)) == false && (string)$value != '0')
- $this->errors[] = sprintf(Tools::displayError('field %s is required.'), $values['title']);
- // Check field validator
- if (isset($values['type']) && $values['type'] == 'textLang')
- {
- foreach ($languages as $language)
- if (Tools::getValue($field.'_'.$language['id_lang']) && isset($values['validation']))
- if (!Validate::$values['validation'](Tools::getValue($field.'_'.$language['id_lang'])))
- $this->errors[] = sprintf(Tools::displayError('field %s is invalid.'), $values['title']);
- }
- elseif (Tools::getValue($field) && isset($values['validation']))
- if (!Validate::$values['validation'](Tools::getValue($field)))
- $this->errors[] = sprintf(Tools::displayError('field %s is invalid.'), $values['title']);
- // Set default value
- if (Tools::getValue($field) === false && isset($values['default']))
- $_POST[$field] = $values['default'];
- }
- if (!count($this->errors))
- {
- foreach ($fields as $key => $options)
- {
- if (!$hide_multishop_checkbox && Shop::isFeatureActive() && isset($options['visibility']) && $options['visibility'] > Shop::getContext())
- continue;
- if (!$hide_multishop_checkbox && Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && empty($options['no_multishop_checkbox']) && empty($_POST['multishopOverrideOption'][$key]))
- {
- Configuration::deleteFromContext($key);
- continue;
- }
- // check if a method updateOptionFieldName is available
- $method_name = 'updateOption'.Tools::toCamelCase($key, true);
- if (method_exists($this, $method_name))
- $this->$method_name(Tools::getValue($key));
- elseif (isset($options['type']) && in_array($options['type'], array('textLang', 'textareaLang')))
- {
- $list = array();
- foreach ($languages as $language)
- {
- $key_lang = Tools::getValue($key.'_'.$language['id_lang']);
- $val = (isset($options['cast']) ? $options['cast']($key_lang) : $key_lang);
- if ($this->validateField($val, $options))
- {
- if (Validate::isCleanHtml($val))
- $list[$language['id_lang']] = $val;
- else
- $this->errors[] = Tools::displayError('Can not add configuration '.$key.' for lang '.Language::getIsoById((int)$language['id_lang']));
- }
- }
- Configuration::updateValue($key, $list);
- }
- else
- {
- $val = (isset($options['cast']) ? $options['cast'](Tools::getValue($key)) : Tools::getValue($key));
- if ($this->validateField($val, $options))
- {
- if (Validate::isCleanHtml($val))
- Configuration::updateValue($key, $val);
- else
- $this->errors[] = Tools::displayError('Can not add configuration '.$key);
- }
- }
- }
- }
- }
- $this->display = 'list';
- if (empty($this->errors))
- $this->confirmations[] = $this->_conf[6];
- }
- /**
- * assign default action in toolbar_btn smarty var, if they are not set.
- * uses override to specifically add, modify or remove items
- *
- */
- public function initToolbar()
- {
- switch ($this->display)
- {
- case 'add':
- case 'edit':
- // Default save button - action dynamically handled in javascript
- $this->toolbar_btn['save'] = array(
- 'href' => '#',
- 'desc' => $this->l('Save')
- );
- //no break
- case 'view':
- // Default cancel button - like old back link
- $back = Tools::safeOutput(Tools::getValue('back', ''));
- if (empty($back))
- $back = self::$currentIndex.'&token='.$this->token;
- if (!Validate::isCleanHtml($back))
- die(Tools::displayError());
- if (!$this->lite_display)
- $this->toolbar_btn['back'] = array(
- 'href' => $back,
- 'desc' => $this->l('Back to list')
- );
- break;
- case 'options':
- $this->toolbar_btn['save'] = array(
- 'href' => '#',
- 'desc' => $this->l('Save')
- );
- break;
- case 'view':
- break;
- default: // list
- $this->toolbar_btn['new'] = array(
- 'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token,
- 'desc' => $this->l('Add new')
- );
- }
- }
- /**
- * Load class object using identifier in $_GET (if possible)
- * otherwise return an empty object, or die
- *
- * @param boolean $opt Return an empty object if load fail
- * @return object
- */
- protected function loadObject($opt = false)
- {
- $id = (int)Tools::getValue($this->identifier);
- if ($id && Validate::isUnsignedId($id))
- {
- if (!$this->object)
- $this->object = new $this->className($id);
- if (Validate::isLoadedObject($this->object))
- return $this->object;
- // throw exception
- $this->errors[] = Tools::displayError('Object cannot be loaded (not found)');
- return false;
- }
- elseif ($opt)
- {
- if (!$this->object)
- $this->object = new $this->className();
- return $this->object;
- }
- else
- {
- $this->errors[] = Tools::displayError('Object cannot be loaded (identifier missing or invalid)');
- return false;
- }
- return $this->object;
- }
- /**
- * Check if the token is valid, else display a warning page
- */
- public function checkAccess()
- {
- if (!$this->checkToken())
- {
- // If this is an XSS attempt, then we should only display a simple, secure page
- // ${1} in the replacement string of the regexp is required,
- // because the token may begin with a number and mix up with it (e.g. $17)
- $url = preg_replace('/([&?]token=)[^&]*(&.*)?$/', '${1}'.$this->token.'$2', $_SERVER['REQUEST_URI']);
- if (false === strpos($url, '?token=') && false === strpos($url, '&token='))
- $url .= '&token='.$this->token;
- if (strpos($url, '?') === false)
- $url = str_replace('&token', '?controller=AdminHome&token', $url);
- $this->context->smarty->assign('url', htmlentities($url));
- return false;
- }
- return true;
- }
- protected function filterToField($key, $filter)
- {
- foreach ($this->fields_list as $field)
- if (array_key_exists('filter_key', $field) && $field['filter_key'] == $key)
- return $field;
- if (array_key_exists($filter, $this->fields_list))
- return $this->fields_list[$filter];
- return false;
- }
- public function displayNoSmarty()
- {
- }
- public function displayAjax()
- {
- if ($this->json)
- {
- $this->context->smarty->assign(array(
- 'json' => true,
- 'status' => $this->status,
- ));
- }
- $this->layout = 'layout-ajax.tpl';
- return $this->display();
- }
- protected function redirect()
- {
- header('Location: '.$this->redirect_after);
- exit;
- }
- public function display()
- {
- $this->context->smarty->assign(array(
- 'display_header' => $this->display_header,
- 'display_footer' => $this->display_footer,
- )
- );
- // Use page title from meta_title if it has been set else from the breadcrumbs array
- if (!$this->meta_title)
- $this->meta_title = isset($this->breadcrumbs[1]) ? $this->breadcrumbs[1] : $this->breadcrumbs[0];
- $this->context->smarty->assign('meta_title', $this->meta_title);
- $tpl_action = $this->tpl_folder.$this->display.'.tpl';
- // Check if action template has been override
- foreach ($this->context->smarty->getTemplateDir() as $template_dir)
- if (file_exists($template_dir.DIRECTORY_SEPARATOR.$tpl_action) && $this->display != 'view' && $this->display != 'options')
- {
- if (method_exists($this, $this->display.Tools::toCamelCase($this->className)))
- $this->{$this->display.Tools::toCamelCase($this->className)}();
- $this->context->smarty->assign('content', $this->context->smarty->fetch($tpl_action));
- break;
- }
- if (!$this->ajax)
- {
- $template = $this->createTemplate($this->template);
- $page = $template->fetch();
- }
- else
- $page = $this->content;
- if ($conf = Tools::getValue('conf'))
- if ($this->json)
- $this->context->smarty->assign('conf', Tools::jsonEncode($this->_conf[(int)$conf]));
- else
- $this->context->smarty->assign('conf', $this->_conf[(int)$conf]);
- if ($this->json)
- $this->context->smarty->assign('errors', Tools::jsonEncode($this->errors));
- else
- $this->context->smarty->assign('errors', $this->errors);
- if ($this->json)
- $this->context->smarty->assign('warnings', Tools::jsonEncode($this->warnings));
- else
- $this->context->smarty->assign('warnings', $this->warnings);
- if ($this->json)
- $this->context->smarty->assign('informations', Tools::jsonEncode($this->informations));
- else
- $this->context->smarty->assign('informations', $this->informations);
- if ($this->json)
- $this->context->smarty->assign('confirmations', Tools::jsonEncode($this->confirmations));
- else
- $this->context->smarty->assign('confirmations', $this->confirmations);
- if ($this->json)
- $this->context->smarty->assign('page', Tools::jsonEncode($page));
- else
- $this->context->smarty->assign('page', $page);
- $this->smartyOutputContent($this->layout);
- }
- /**
- * add a warning message to display at the top of the page
- *
- * @param string $msg
- */
- protected function displayWarning($msg)
- {
- $this->warnings[] = $msg;
- }
- /**
- * add a info message to display at the top of the page
- *
- * @param string $msg
- */
- protected function displayInformation($msg)
- {
- $this->informations[] = $msg;
- }
- /**
- * Assign smarty variables for the header
- */
- public function initHeader()
- {
- // Multishop
- $is_multishop = Shop::isFeatureActive();
- // Quick access
- $quick_access = QuickAccess::getQuickAccesses($this->context->language->id);
- foreach ($quick_access as $index => $quick)
- {
- if ($quick['link'] == '../' && Shop::getContext() == Shop::CONTEXT_SHOP)
- {
- $url = $this->context->shop->getBaseURL();
- if (!$url)
- {
- unset($quick_access[$index]);
- continue;
- }
- $quick_access[$index]['link'] = $url;
- }
- else
- {
- preg_match('/controller=(.+)(&.+)?$/', $quick['link'], $admin_tab);
- if (isset($admin_tab[1]))
- {
- if (strpos($admin_tab[1], '&'))
- $admin_tab[1] = substr($admin_tab[1], 0, strpos($admin_tab[1], '&'));
- $token = Tools::getAdminToken($admin_tab[1].(int)Tab::getIdFromClassName($admin_tab[1]).(int)$this->context->employee->id);
- $quick_access[$index]['link'] .= '&token='.$token;
- }
- }
- }
- // Tab list
- $tabs = Tab::getTabs($this->context->language->id, 0);
- $current_id = Tab::getCurrentParentId();
- foreach ($tabs as $index => $tab)
- {
- if ($tab['class_name'] == 'AdminStock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0)
- {
- unset($tabs[$index]);
- continue;
- }
- $img_cache_url = 'themes/'.$this->context->employee->bo_theme.'/img/t/'.$tab['class_name'].'.png';
- $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_.$img_cache_url);
- // retrocompatibility : change png to gif if icon not exists
- if (!$img_exists_cache)
- $img_exists_cache = Tools::file_exists_cache(_PS_ADMIN_DIR_.str_replace('.png', '.gif', $img_cache_url));
- if ($img_exists_cache)
- $path_img = $img = $img_exists_cache;
- else
- {
- $path_img = _PS_IMG_DIR_.'t/'.$tab['class_name'].'.png';
- // Relative link will always work, whatever the base uri set in the admin
- $img = '../img/t/'.$tab['class_name'].'.png';
- }
- if (trim($tab['module']) != '')
- {
- $path_img = _PS_MODULE_DIR_.$tab['module'].'/'.$tab['class_name'].'.png';
- // Relative link will always work, whatever the base uri set in the admin
- $img = '../modules/'.$tab['module'].'/'.$tab['class_name'].'.png';
- }
- // retrocompatibility
- if (!file_exists($path_img))
- $img = str_replace('png', 'gif', $img);
- // tab[class_name] does not contains the "Controller" suffix
- $tabs[$index]['current'] = ($tab['class_name'].'Controller' == get_class($this)) || ($current_id == $tab['id_tab']);
- $tabs[$index]['img'] = $img;
- $tabs[$index]['href'] = $this->context->link->getAdminLink($tab['class_name']);
- $sub_tabs = Tab::getTabs($this->context->language->id, $tab['id_tab']);
- foreach ($sub_tabs as $index2 => $sub_tab)
- {
- // class_name is the name of the class controller
- if (Tab::checkTabRights($sub_tab['id_tab']) === true
- && (bool)$sub_tab['active'])
- $sub_tabs[$index2]['href'] = $this->context->link->getAdminLink($sub_tab['class_name']);
- else
- unset($sub_tabs[$index2]);
- }
- $tabs[$index]['sub_tabs'] = $sub_tabs;
- // If there are no subtabs, we don't want to display the parent tab in menu
- if (empty($sub_tabs))
- unset($tabs[$index]);
- }
-
- if (Validate::isLoadedObject($this->context->employee))
- {
- $accesses = Profile::getProfileAccesses($this->context->employee->id_profile, 'class_name');
- /* Hooks are volontary out the initialize array (need those variables already assigned) */
- $bo_color = empty($this->context->employee->bo_color) ? '#FFFFFF' : $this->context->employee->bo_color;
- $this->context->smarty->assign(array(
- 'autorefresh_notifications' => Configuration::get('PS_ADMIN_REFRESH_NOTIFICATION'),
- 'help_box' => Configuration::get('PS_HELPBOX'),
- 'round_mode' => Configuration::get('PS_PRICE_ROUND_MODE'),
- 'brightness' => Tools::getBrightness($bo_color) < 128 ? 'white' : '#383838',
- 'bo_width' => (int)$this->context->employee->bo_width,
- 'bo_color' => isset($this->context->employee->bo_color) ? Tools::htmlentitiesUTF8($this->context->employee->bo_color) : null,
- 'show_new_orders' => Configuration::get('PS_SHOW_NEW_ORDERS') && $accesses['AdminOrders']['view'],
- 'show_new_customers' => Configuration::get('PS_SHOW_NEW_CUSTOMERS') && $accesses['AdminCustomers']['view'],
- 'show_new_messages' => Configuration::get('PS_SHOW_NEW_MESSAGES') && $accesses['AdminCustomerThreads']['view'],
- 'first_name' => Tools::substr($this->context->employee->firstname, 0, 1),
- 'last_name' => htmlentities($this->context->employee->lastname, ENT_COMPAT, 'UTF-8'),
- 'employee' => $this->context->employee,
- 'search_type' => Tools::getValue('bo_search_type'),
- 'bo_query' => Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))),
- 'quick_access' => $quick_access,
- 'multi_shop' => Shop::isFeatureActive(),
- 'shop_list' => Helper::renderShopList(),
- 'shop' => $this->context->shop,
- 'shop_group' => new ShopGroup((int)Shop::getContextShopGroupID()),
- 'current_parent_id' => (int)Tab::getCurrentParentId(),
- 'tabs' => $tabs,
- 'is_multishop' => $is_multishop,
- 'multishop_context' => $this->multishop_context,
- ));
- }
- $this->context->smarty->assign(array(
- 'img_dir' => _PS_IMG_,
- 'iso' => $this->context->language->iso_code,
- 'class_name' => $this->className,
- 'iso_user' => $this->context->language->iso_code,
- 'country_iso_code' => $this->context->country->iso_code,
- 'version' => _PS_VERSION_,
- 'lang_iso' => $this->context->language->iso_code,
- 'link' => $this->context->link,
- 'shop_name' => Configuration::get('PS_SHOP_NAME'),
- 'base_url' => $this->context->shop->getBaseURL(),
- 'tab' => $tab, // Deprecated, this tab is declared in the foreach, so it's the last tab in the foreach
- 'current_parent_id' => (int)Tab::getCurrentParentId(),
- 'tabs' => $tabs,
- 'install_dir_exists' => file_exists(_PS_ADMIN_DIR_.'/../install'),
- 'pic_dir' => _THEME_PROD_PIC_DIR_,
- 'controller_name' => htmlentities(Tools::getValue('controller')),
- 'currentIndex' => self::$currentIndex
- ));
- }
- /**
- * Declare an action to use for each row in the list
- */
- public function addRowAction($action)
- {
- $action = strtolower($action);
- $this->actions[] = $action;
- }
- /**
- * Add an action to use for each row in the list
- */
- public function addRowActionSkipList($action, $list)
- {
- $action = strtolower($action);
- $list = (array)$list;
- if (array_key_exists($action, $this->list_skip_actions))
- $this->list_skip_actions[$action] = array_merge($this->list_skip_actions[$action], $list);
- else
- $this->list_skip_actions[$action] = $list;
- }
- /**
- * Assign smarty variables for all default views, list and form, then call other init functions
- */
- public function initContent()
- {
- if (!$this->viewAccess())
- {
- $this->errors[] = Tools::displayError('You do not have permission to view here.');
- return;
- }
-
- $this->getLanguages();
- // toolbar (save, cancel, new, ..)
- $this->initToolbar();
- if ($this->display == 'edit' || $this->display == 'add')
- {
- if (!$this->loadObject(true))
- return;
- $this->content .= $this->renderForm();
- }
- elseif ($this->display == 'view')
- {
- // Some controllers use the view action without an object
- if ($this->className)
- $this->loadObject(true);
- $this->content .= $this->renderView();
- }
- elseif (!$this->ajax)
- {
- $this->content .= $this->renderList();
- $this->content .= $this->renderOptions();
- // if we have to display the required fields form
- if ($this->required_database)
- $this->content .= $this->displayRequiredFields();
- }
- $this->context->smarty->assign(array(
- 'content' => $this->content,
- 'url_post' => self::$currentIndex.'&token='.$this->token,
- ));
- }
- /**
- * initialize the invalid doom page of death
- *
- * @return void
- */
- public function initCursedPage()
- {
- $this->layout = 'invalid_token.tpl';
- }
- /**
- * Assign smarty variables for the footer
- */
- public function initFooter()
- {
- // We assign js and css files on the last step before display template, because controller can add many js and css files
- $this->context->smarty->assign('css_files', $this->css_files);
- $this->context->smarty->assign('js_files', array_unique($this->js_files));
- $this->context->smarty->assign(array(
- 'ps_version' => _PS_VERSION_,
- 'timer_start' => $this->timer_start,
- 'iso_is_fr' => strtoupper($this->context->language->iso_code) == 'FR',
- ));
- }
- /**
- * Function used to render the list to display for this controller
- */
- public function renderList()
- {
- if (!($this->fields_list && is_array($this->fields_list)))
- return false;
- $this->getList($this->context->language->id);
- // Empty list is ok
- if (!is_array($this->_list))
- return false;
- $helper = new HelperList();
- $this->setHelperDisplay($helper);
- $helper->tpl_vars = $this->tpl_list_vars;
- $helper->tpl_delete_link_vars = $this->tpl_delete_link_vars;
- // 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;
- }
- $list = $helper->generateList($this->_list, $this->fields_list);
- return $list;
- }
- /**
- * Override to render the view page
- */
- public function renderView()
- {
- $helper = new HelperView($this);
- $this->setHelperDisplay($helper);
- $helper->tpl_vars = $this->tpl_view_vars;
- if (!is_null($this->base_tpl_view))
- $helper->base_tpl = $this->base_tpl_view;
- $view = $helper->generateView();
- return $view;
- }
- /**
- * Function used to render the form for this controller
- */
- public function renderForm()
- {
- if (!$this->default_form_language)
- $this->getLanguages();
- if (Tools::getValue('submitFormAjax'))
- $this->content .= $this->context->smarty->fetch('form_submit_ajax.tpl');
- if ($this->fields_form && is_array($this->fields_form))
- {
- if (!$this->multiple_fieldsets)
- $this->fields_form = array(array('form' => $this->fields_form));
- // For add a fields via an override of $fields_form, use $fields_form_override
- if (is_array($this->fields_form_override) && !empty($this->fields_form_override))
- $this->fields_form[0]['form'][…
Large files files are truncated, but you can click here to view the full file