diff --git a/admin-dev/themes/template/request_sql/view.tpl b/admin-dev/themes/template/request_sql/view.tpl index 1ef3217d0..b4bdaa0b5 100644 --- a/admin-dev/themes/template/request_sql/view.tpl +++ b/admin-dev/themes/template/request_sql/view.tpl @@ -24,47 +24,44 @@ * International Registered Trademark & Property of PrestaShop SA *} -{if isset($view['error'])} -

{l s ='This query has no result.'}

-{else} -

{$view['name']}

- - - - {foreach $view['key'] AS $key} - - {/foreach} - - - - {foreach $view['results'] AS $result} - - {foreach $view['key'] AS $name} - {if isset($view['attributes'][$name])} - - {else} - - {/if} - {/foreach} - - {/foreach} - -
{$key}
{$view['attributes'][$name]}{$result[$name]}
+{extends file="helper/view/view.tpl"} - -{/if} - -

- -{if isset($back)} - {l s='Back to list'} -{/if} -
+{block name="override_tpl"} + {if isset($view['error'])} +

{l s ='This query has no result.'}

+ {else} +

{$view['name']}

+ + + + {foreach $view['key'] AS $key} + + {/foreach} + + + + {foreach $view['results'] AS $result} + + {foreach $view['key'] AS $name} + {if isset($view['attributes'][$name])} + + {else} + + {/if} + {/foreach} + + {/foreach} + +
{$key}
{$view['attributes'][$name]}{$result[$name]}
+ + + {/if} +{/block} diff --git a/controllers/admin/AdminRequestSqlController.php b/controllers/admin/AdminRequestSqlController.php index 361dff3f3..7fa792430 100644 --- a/controllers/admin/AdminRequestSqlController.php +++ b/controllers/admin/AdminRequestSqlController.php @@ -35,16 +35,7 @@ class AdminRequestSqlControllerCore extends AdminController $this->export = true; $this->requiredDatabase = true; - $this->addRowAction('view'); - $this->addRowAction('edit'); - $this->addRowAction('delete'); - $this->context = Context::getContext(); - $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')), - 'export' => array('text' => $this->l('Export selected'))); - - if (!Tools::getValue('realedit')) - $this->deleted = false; $this->fieldsDisplay = array( 'id_request_sql' => array('title' => $this->l('ID'), 'width' => 25), @@ -52,6 +43,41 @@ class AdminRequestSqlControllerCore extends AdminController 'sql' => array('title' => $this->l('Request'), 'width' => 500) ); + parent::__construct(); + } + + public function initList() + { + $this->displayWarning($this->l('When saving the query, only the request type "SELECT" are allowed.')); + $this->displayInformation(' + '.$this->l('How to create a new sql query?').' +
+ + '); + + $this->addRowAction('view'); + $this->addRowAction('edit'); + $this->addRowAction('delete'); + $this->bulk_actions = array( + 'delete' => array( + 'text' => $this->l('Delete selected'), + 'confirm' => $this->l('Delete selected items?') + ), + 'export' => array( + 'text' => $this->l('Export selected') + ) + ); + + return parent::initList(); + } + + public function initForm() + { $this->fields_form = array( 'legend' => array( 'title' => $this->l('Request') @@ -79,32 +105,35 @@ class AdminRequestSqlControllerCore extends AdminController ) ); - parent::__construct(); + return parent::initForm(); } - public function viewRequestSql() + public function initView() { if (!($obj = $this->loadObject(true))) return; - $content = array(); + $view = array(); if ($results = Db::getInstance()->executeS($obj->sql)) { foreach (array_keys($results[0]) as $key) $tab_key[] = $key; - $content['name'] = $obj->name; - $content['key'] = $tab_key; - $content['results'] = $results; + $view['name'] = $obj->name; + $view['key'] = $tab_key; + $view['results'] = $results; $request_sql = new RequestSql(); - $content['attributes'] = $request_sql->attributes; + $view['attributes'] = $request_sql->attributes; } else - $content['error'] = true; + $view['error'] = true; - return $content; + $this->tpl_view_vars = array( + 'view' => $view + ); + return parent::initView(); } public function _childValidation() @@ -120,47 +149,6 @@ class AdminRequestSqlControllerCore extends AdminController } } - public function initContent() - { - $this->displayWarning($this->l('When saving the query, only the request type "SELECT" are allowed.')); - $this->displayInformation(' - '.$this->l('How to create a new sql query?').' -
- - '); - - $smarty = $this->context->smarty; - - if ($this->display != 'edit' && $this->display != 'add' && $this->display != 'view') - $this->display = 'list'; - - switch ($this->display) - { - case 'edit': - $this->informations = false; - break; - - case 'view': - $this->warnings = false; - $this->informations = false; - - if (Tools::getValue('back')) - $smarty->assign('back', Tools::safeOutput(Tools::getValue('back'))); - else - $smarty->assign('back', Tools::safeOutput(self::$currentIndex.'&token='.$this->token)); - - $smarty->assign('view', $this->viewRequestSql()); - break; - } - - parent::initContent(); - } - public function bulkexport($boxes) { if (!$boxes || count($boxes) > 1)