From 949c2d424429df8be672906ff0dfb3de16dbc261 Mon Sep 17 00:00:00 2001 From: mMarinetti Date: Sun, 13 Nov 2011 17:01:43 +0000 Subject: [PATCH] [+] BO : #PSFV-94 - AdminWebserviceController --- admin-dev/themes/template/webservice/form.tpl | 44 +++++++ .../admin/AdminWebserviceController.php | 112 ++++++------------ 2 files changed, 83 insertions(+), 73 deletions(-) create mode 100644 admin-dev/themes/template/webservice/form.tpl rename admin-dev/tabs/AdminWebservice.php => controllers/admin/AdminWebserviceController.php (70%) diff --git a/admin-dev/themes/template/webservice/form.tpl b/admin-dev/themes/template/webservice/form.tpl new file mode 100644 index 000000000..9b6411862 --- /dev/null +++ b/admin-dev/themes/template/webservice/form.tpl @@ -0,0 +1,44 @@ +{extends file="helper/form/form.tpl"} +{block name="defaultForm"} +{$custom_form} + +{/block} diff --git a/admin-dev/tabs/AdminWebservice.php b/controllers/admin/AdminWebserviceController.php similarity index 70% rename from admin-dev/tabs/AdminWebservice.php rename to controllers/admin/AdminWebserviceController.php index 890c9f36c..042649ac5 100755 --- a/admin-dev/tabs/AdminWebservice.php +++ b/controllers/admin/AdminWebserviceController.php @@ -25,10 +25,10 @@ * International Registered Trademark & Property of PrestaShop SA */ -include_once(dirname(__FILE__).'/../../classes/AdminTab.php'); - -class AdminWebservice extends AdminTab +class AdminWebserviceController extends AdminController { + // this will be filled later + public $fields_form = array('webservice form'); public function __construct() { @@ -46,7 +46,7 @@ class AdminWebservice extends AdminTab ); if (file_exists(_PS_ROOT_DIR_.'/.htaccess')) - $this->optionsList = array( + $this->options = array( 'general' => array( 'title' => $this->l('Configuration'), 'fields' => array( @@ -76,47 +76,49 @@ class AdminWebservice extends AdminTab public function checkForWarning() { - $warnings = array(); if (!file_exists(_PS_ROOT_DIR_.'/.htaccess')) - $warnings[] = $this->l('In order to enable the PrestaShop Webservice, please generate the .htaccess file via the "Generators" tab (in the "Tools" tab).'); + $this->warnings[] = $this->l('In order to enable the PrestaShop Webservice, please generate the .htaccess file via the "Generators" tab (in the "Tools" tab).'); if (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) - $warnings[] = $this->l('To avoid operating problems, please use an Apache server.'); + $this->warnings[] = $this->l('To avoid operating problems, please use an Apache server.'); { if (function_exists('apache_get_modules')) { $apache_modules = apache_get_modules(); if (!in_array('mod_auth_basic', $apache_modules)) - $warnings[] = $this->l('Please activate the Apache module \'mod_auth_basic\' to allow authentication of PrestaShop webservice.'); + $this->warnings[] = $this->l('Please activate the Apache module \'mod_auth_basic\' to allow authentication of PrestaShop webservice.'); if (!in_array('mod_rewrite', $apache_modules)) - $warnings[] = $this->l('Please activate the Apache module \'mod_rewrite\' to allow using the PrestaShop webservice.'); + $this->warnings[] = $this->l('Please activate the Apache module \'mod_rewrite\' to allow using the PrestaShop webservice.'); } else { - $warnings[] = $this->l('We could not check if basic authentication and rewrite extensions are activated. Please manually check if they are activated in order to use the PrestaShop webservice.'); + $this->warnings[] = $this->l('We could not check if basic authentication and rewrite extensions are activated. Please manually check if they are activated in order to use the PrestaShop webservice.'); } } if (!extension_loaded('SimpleXML')) - $warnings[] = $this->l('Please activate the PHP extension \'SimpleXML\' to allow testing of PrestaShop webservice.'); + $this->warnings[] = $this->l('Please activate the PHP extension \'SimpleXML\' to allow testing of PrestaShop webservice.'); if (!configuration::get('PS_SSL_ENABLED')) - $warnings[] = $this->l('If possible, it is preferable to use SSL (https) for webservice calls, as it avoids the security issues of type "man in the middle".'); + $this->warnings[] = $this->l('If possible, it is preferable to use SSL (https) for webservice calls, as it avoids the security issues of type "man in the middle".'); - $this->displayWarning($warnings); foreach ($this->_list as $k => $item) if ($item['is_module'] && $item['class_name'] && $item['module_name'] && ($instance = Module::getInstanceByName($item['module_name'])) && !$instance->useNormalPermissionBehaviour()) unset($this->_list[$k]); - parent::displayList(); + $this->initList(); } - public function displayForm($isMainTab = true) + /** @todo : to fill $this->fields_form in order to generate + * the form automatically.. + * + */ + public function initForm($isMainTab = true) { - parent::displayForm(); + $content = ''; if (!($obj = $this->loadObject(true))) return; - echo ' + $content = '
'.($obj->id ? '' : '').'
'.$this->l('Webservice Accounts').' @@ -165,11 +167,11 @@ class AdminWebservice extends AdminTab - '; -$ressources = WebserviceRequest::getResources(); -$permissions = WebserviceKey::getPermissionForAccount($obj->key); -foreach ($ressources as $resourceName => $resource) -echo ' + '; + $ressources = WebserviceRequest::getResources(); + $permissions = WebserviceKey::getPermissionForAccount($obj->key); + foreach ($ressources as $resourceName => $resource) + $content .= ' '.$resourceName.' @@ -179,51 +181,9 @@ echo ' '; -echo ' + $content .= ' -
@@ -231,6 +191,8 @@ echo '
* '.$this->l('Required field').'
'; + $this->tpl_form_vars['custom_form'] = $content; + return parent::initForm(); } public function postProcess() @@ -242,8 +204,9 @@ echo ' return parent::postProcess(); } - public function display() + public function initContent() { + $content = ''; // Include other tab in current tab if ($this->includeSubTab('display', array('submitAdd2', 'add', 'update', 'view'))){} @@ -252,31 +215,32 @@ echo ' { if ($this->tabAccess['add'] === '1') { - $this->displayForm(); + $this->display = 'add'; +// $content .= $this->initForm(); if ($this->tabAccess['view']) - echo '

'.((Tools::getValue('back')) ? $this->l('Back') : $this->l('Back to list')).'
'; + $content .= '

'.((Tools::getValue('back')) ? $this->l('Back') : $this->l('Back to list')).'
'; } else - echo $this->l('You do not have permission to add here'); + $content .= $this->l('You do not have permission to add here'); } elseif (isset($_GET['update'.$this->table])) { if ($this->tabAccess['edit'] === '1' OR ($this->table == 'employee' AND $this->context->employee->id == Tools::getValue('id_employee'))) { - $this->displayForm(); + $content .= $this->initForm(); if ($this->tabAccess['view']) - echo '

'.((Tools::getValue('back')) ? $this->l('Back') : $this->l('Back to list')).'
'; + $content .= '

'.((Tools::getValue('back')) ? $this->l('Back') : $this->l('Back to list')).'
'; } else - echo $this->l('You do not have permission to edit here'); + $content .= $this->l('You do not have permission to edit here'); } elseif (isset($_GET['view'.$this->table])) $this->{'view'.$this->table}(); - else { $this->checkForWarning(); +/* $this->getList($this->context->language->id); $this->displayList(); @@ -288,7 +252,9 @@ echo ' elseif (isset($assos_shop[$this->table]) AND $assos_shop[$this->table]['type'] == 'group_shop') $this->displayAssoShop('group_shop'); $this->displayOptionsList(); +*/ } + parent::initContent(); } }