// fix added toolbar in HelperOptions

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10271 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
lLefevre committed 2011-11-18 14:22:53 +00:00
1 parent eda71ac8fb
commit ae4a223509
8 files changed
+132 -113

No files matched your search

@@ -59,7 +59,7 @@
{else} {else}
<p style="color:red; font-weight:bold;">{l s='Before being able to use this tool, you need to:'}</p> <p style="color:red; font-weight:bold;">{l s='Before being able to use this tool, you need to:'}</p>
<p>{l s='- create a'} <b>'. $this->l('.htaccess').'</b> {l s='blank file in directory'} <b>'.__PS_BASE_URI__.'</b> <p>{l s='- create a'} <b>{l s='.htaccess'}</b> {l s='blank file in directory'} <b>{$smarty.const.__PS_BASE_URI__}</b>
<br />{l s='- give it write permissions (CHMOD 666 on Unix system)'}</p> <br />{l s='- give it write permissions (CHMOD 666 on Unix system)'}</p>
{/if} {/if}
</p></fieldset></form> </p></fieldset></form>
@@ -77,7 +77,7 @@
<p>{l s='This will erase your'}<b> {l s='old'}</b> {l s='robots.txt file!'}</p> <p>{l s='This will erase your'}<b> {l s='old'}</b> {l s='robots.txt file!'}</p>
{else} {else}
<p style="color:red; font-weight:bold;">{l s='Before being able to use this tool, you need to:'}</p> <p style="color:red; font-weight:bold;">{l s='Before being able to use this tool, you need to:'}</p>
<p>{l s='- create a'} <b>'. $this->l('robots.txt').'</b> {l s='blank file in dir:'} <b>{$smarty.const.__PS_BASE_URI__}</b> <p>{l s='- create a'} <b>{l s='robots.txt'}</b> {l s='blank file in dir:'} <b>{$smarty.const.__PS_BASE_URI__}</b>
<br />{l s='- give it write permissions (CHMOD 666 on Unix system)'}</p> <br />{l s='- give it write permissions (CHMOD 666 on Unix system)'}</p>
{/if} {/if}
</p></fieldset></form> </p></fieldset></form>
@@ -24,7 +24,6 @@
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*} *}
{if $show_toolbar} {if $show_toolbar}
<div class="toolbar-placeholder"> <div class="toolbar-placeholder">
<div class="toolbarBox {if $toolbar_fix}toolbarHead{/if}"> <div class="toolbarBox {if $toolbar_fix}toolbarHead{/if}">
@@ -23,11 +23,32 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*} *}
{if $show_toolbar}
<div class="toolbar-placeholder">
<div class="toolbarBox {if $toolbar_fix}toolbarHead{/if}">
{include file="toolbar.tpl" toolbar_btn=$toolbar_btn}
<div class="pageTitle">
<h3>
{block name=pageTitle}
<span id="current_obj" style="font-weight: normal;">
{$title|default:'&nbsp;'}
</span>
{/block}
</h3>
</div>
</div>
</div>
<div class="leadin">{block name="leadin"}{/block}</div>
{/if}
<script type="text/javascript"> <script type="text/javascript">
id_language = Number({$current_id_lang}); id_language = Number({$current_id_lang});
</script> </script>
{block name="defaultOptions"} {block name="defaultOptions"}
<form action="{$current}&submitOptions{$table}=1&token={$token}" <form action="{$current}&submitOptions{$table}=1&token={$token}"
id="{$table}_form"
{if isset($categoryData['name'])} name={$categoryData['name']}{/if} {if isset($categoryData['name'])} name={$categoryData['name']}{/if}
{if isset($categoryData['id'])} id={$categoryData['id']} {/if} {if isset($categoryData['id'])} id={$categoryData['id']} {/if}
method="post" method="post"
@@ -195,9 +216,10 @@
{if isset($categoryData['submit'])} {if isset($categoryData['submit'])}
<div class="margin-form"> <div class="margin-form">
<input type="submit" <input type="submit"
value="{if isset($categoryData['submit']['title'])}{$categoryData['submit']['title']}{else}{l s=' Save '}{/if}" value="{if isset($categoryData['submit']['title'])}{$categoryData['submit']['title']}{else}{l s=' Save '}{/if}"
name="{if isset($categoryData['submit']['name'])}$categoryData['submit']['name']{else}submit{$category|ucfirst}{$table}{/if}" name="{if isset($categoryData['submit']['name'])}$categoryData['submit']['name']{else}submit{$category|ucfirst}{$table}{/if}"
class="{if isset($categoryData['submit']['class'])}{$categoryData['submit']['class']}{else}button{/if}" class="{if isset($categoryData['submit']['class'])}{$categoryData['submit']['class']}{else}button{/if}"
id="{$table}_form_submit_btn"
/> />
</div> </div>
{/if} {/if}
+91 -75
View File
@@ -61,7 +61,7 @@ class AdminControllerCore extends Controller
/** @var integer Tab id */ /** @var integer Tab id */
public $id = -1; public $id = -1;
/** @var array noTabLink array of admintabs with no content */ /** @var array noTabLink array of admintab names witch have no content */
public $noTabLink = array('AdminCatalog', 'AdminTools', 'AdminStock', 'AdminAccounting'); public $noTabLink = array('AdminCatalog', 'AdminTools', 'AdminStock', 'AdminAccounting');
/** @var string Security token */ /** @var string Security token */
@@ -90,9 +90,6 @@ class AdminControllerCore extends Controller
/** @var define if the header of the list contains filter and sorting links or not */ /** @var define if the header of the list contains filter and sorting links or not */
protected $list_simple_header; protected $list_simple_header;
/** @var define if the header of the list contains filter and sorting links or not */
protected $toolbar_title;
/** @var array list to be generated */ /** @var array list to be generated */
protected $fieldsDisplay; protected $fieldsDisplay;
@@ -107,6 +104,9 @@ class AdminControllerCore extends Controller
/** @var array Cache for query results */ /** @var array Cache for query results */
protected $_list = array(); 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 */ /** @var array list of toolbar buttons */
protected $toolbar_btn = null; protected $toolbar_btn = null;
@@ -116,6 +116,9 @@ class AdminControllerCore extends Controller
/** @var boolean set to false to hide toolbar and page title */ /** @var boolean set to false to hide toolbar and page title */
protected $show_toolbar = true; 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 */ /** @var integer Number of results in list */
protected $_listTotal = 0; protected $_listTotal = 0;
@@ -748,6 +751,7 @@ class AdminControllerCore extends Controller
if ($this->tabAccess['edit'] === '1') if ($this->tabAccess['edit'] === '1')
{ {
$this->beforeUpdateOptions(); $this->beforeUpdateOptions();
$languages = Language::getLanguages(false); $languages = Language::getLanguages(false);
foreach ($this->options as $category => $category_data) foreach ($this->options as $category => $category_data)
@@ -889,6 +893,10 @@ class AdminControllerCore extends Controller
} }
break; break;
case 'options': case 'options':
$this->toolbar_btn['save'] = array(
'href' => '#',
'desc' => $this->l('Save')
);
break; break;
default: // list default: // list
$this->toolbar_btn['new'] = array( $this->toolbar_btn['new'] = array(
@@ -995,7 +1003,7 @@ class AdminControllerCore extends Controller
// new smarty : template_dir is an array. // new smarty : template_dir is an array.
// @todo : add override path to the smarty config, and checking all array item // @todo : add override path to the smarty config, and checking all array item
if (file_exists($this->context->smarty->template_dir[0].'/'.$tpl_action) && $this->display != 'view') if (file_exists($this->context->smarty->template_dir[0].'/'.$tpl_action) && $this->display != 'view' && $this->display != 'options')
{ {
if (method_exists($this, $this->display.Tools::toCamelCase($this->className))) if (method_exists($this, $this->display.Tools::toCamelCase($this->className)))
$this->{$this->display.Tools::toCamelCase($this->className)}(); $this->{$this->display.Tools::toCamelCase($this->className)}();
@@ -1301,6 +1309,9 @@ class AdminControllerCore extends Controller
return false; return false;
$helper = new HelperList(); $helper = new HelperList();
$this->setHelperDisplay($helper);
$helper->tpl_vars = $this->tpl_list_vars;
$helper->tpl_delete_link_vars = $this->tpl_delete_link_vars;
// Check if list templates have been overriden // Check if list templates have been overriden
// For compatibility reasons, we have to check standard actions in class attributes // For compatibility reasons, we have to check standard actions in class attributes
@@ -1310,11 +1321,9 @@ class AdminControllerCore extends Controller
$this->actions[] = $action; $this->actions[] = $action;
} }
$helper->tpl_vars = $this->tpl_list_vars;
$helper->tpl_delete_link_vars = $this->tpl_delete_link_vars;
$this->setHelperDisplay($helper);
$list = $helper->generateList($this->_list, $this->fieldsDisplay); $list = $helper->generateList($this->_list, $this->fieldsDisplay);
$this->toolbar_fix = false; $this->toolbar_fix = false;
return $list; return $list;
} }
@@ -1327,61 +1336,14 @@ class AdminControllerCore extends Controller
$this->initToolbarTitle(); $this->initToolbarTitle();
$helper = new HelperView($this); $helper = new HelperView($this);
$helper->override_folder = $this->tpl_folder;
$helper->tpl_vars = $this->tpl_view_vars;
$this->setHelperDisplay($helper); $this->setHelperDisplay($helper);
$helper->tpl_vars = $this->tpl_view_vars;
$view = $helper->generateView(); $view = $helper->generateView();
$this->toolbar_fix = false; $this->toolbar_fix = false;
return $view; return $view;
} }
/**
* this function set various display option for helper list
*
* @param Helper $helper
* @return void
*/
public function setHelperDisplay(Helper $helper)
{
if (empty($this->toolbar_title))
$this->initToolbarTitle();
// tocheck
if ($this->object && $this->object->id)
$helper->id = $this->object->id;
// @todo : move that in Helper
$helper->actions = $this->actions;
$helper->simple_header = $this->list_simple_header;
$helper->title = $this->toolbar_title;
$helper->toolbar_btn = $this->toolbar_btn;
$helper->show_toolbar = $this->show_toolbar;
$helper->toolbar_fix = $this->toolbar_fix;
$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->override_folder = $this->tpl_folder;
$helper->token = $this->token;
$helper->languages = $this->_languages;
$helper->specificConfirmDelete = $this->specificConfirmDelete;
$helper->imageType = $this->imageType;
$helper->no_link = $this->list_no_link;
$helper->colorOnBackground = $this->colorOnBackground;
$helper->no_back = isset($this->no_back) ? $this->no_back : true;
$helper->ajax_params = (isset($this->ajax_params) ? $this->ajax_params : null);
// For each action, try to add the corresponding skip elements list
$helper->list_skip_actions = $this->list_skip_actions;
}
/** /**
* Function used to initialise the form to display for this controller * Function used to initialise the form to display for this controller
*/ */
@@ -1399,13 +1361,9 @@ class AdminControllerCore extends Controller
$this->getlanguages(); $this->getlanguages();
$helper = new HelperForm($this); $helper = new HelperForm($this);
$helper->override_folder = $this->tpl_folder;
$this->setHelperDisplay($helper); $this->setHelperDisplay($helper);
$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); $helper->fields_value = $this->getFieldsValue($this->object);
$helper->tpl_vars = $this->tpl_form_vars; $helper->tpl_vars = $this->tpl_form_vars;
$helper->multiple_fieldsets = $this->multiple_fieldsets;
if ($this->tabAccess['view']) if ($this->tabAccess['view'])
{ {
if (Tools::getValue('back')) if (Tools::getValue('back'))
@@ -1415,6 +1373,7 @@ class AdminControllerCore extends Controller
} }
$form = $helper->generateForm($this->fields_form); $form = $helper->generateForm($this->fields_form);
$this->toolbar_fix = false; $this->toolbar_fix = false;
return $form; return $form;
} }
} }
@@ -1426,18 +1385,71 @@ class AdminControllerCore extends Controller
{ {
if ($this->options && is_array($this->options)) if ($this->options && is_array($this->options))
{ {
$helper = new HelperOptions(); if (empty($this->toolbar_title))
$helper->override_folder = $this->tpl_folder; $this->initToolbarTitle();
if ($this->display != 'options')
$this->show_toolbar = false;
$helper = new HelperOptions($this);
$this->setHelperDisplay($helper);
$helper->id = $this->id; $helper->id = $this->id;
$helper->token = $this->token;
$helper->tpl_vars = $this->tpl_option_vars; $helper->tpl_vars = $this->tpl_option_vars;
$helper->shopLinkType = $this->shopLinkType; $options = $helper->generateOptions($this->options);
$helper->table = $this->table; $this->toolbar_fix = false;
$helper->currentIndex = self::$currentIndex;
return $helper->generateOptions($this->options); return $options;
} }
} }
/**
* this function set various display option for helper list
*
* @param Helper $helper
* @return void
*/
public function setHelperDisplay(Helper $helper)
{
if (empty($this->toolbar_title))
$this->initToolbarTitle();
// tocheck
if ($this->object && $this->object->id)
$helper->id = $this->object->id;
// @todo : move that in Helper
$helper->title = $this->toolbar_title;
$helper->toolbar_btn = $this->toolbar_btn;
$helper->show_toolbar = $this->show_toolbar;
$helper->toolbar_fix = $this->toolbar_fix;
$helper->override_folder = $this->tpl_folder;
$helper->actions = $this->actions;
$helper->simple_header = $this->list_simple_header;
$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->languages = $this->_languages;
$helper->specificConfirmDelete = $this->specificConfirmDelete;
$helper->imageType = $this->imageType;
$helper->no_link = $this->list_no_link;
$helper->colorOnBackground = $this->colorOnBackground;
$helper->no_back = isset($this->no_back) ? $this->no_back : true;
$helper->ajax_params = (isset($this->ajax_params) ? $this->ajax_params : null);
$helper->default_form_language = $this->default_form_language;
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
$helper->multiple_fieldsets = $this->multiple_fieldsets;
// For each action, try to add the corresponding skip elements list
$helper->list_skip_actions = $this->list_skip_actions;
}
public function setMedia() public function setMedia()
{ {
$this->addCSS(_PS_CSS_DIR_.'admin.css', 'all'); $this->addCSS(_PS_CSS_DIR_.'admin.css', 'all');
@@ -1678,7 +1690,7 @@ class AdminControllerCore extends Controller
else else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.'); $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
} }
if (isset($_GET['view'.$this->table])) else if (isset($_GET['view'.$this->table]))
{ {
if ($this->tabAccess['view'] === '1') if ($this->tabAccess['view'] === '1')
{ {
@@ -1706,13 +1718,17 @@ class AdminControllerCore extends Controller
break; break;
} }
} }
if ($this->ajax && method_exists($this, 'ajaxPreprocess')) else if (!empty($this->options) && empty($this->fieldsDisplay))
$this->ajaxPreProcess(); $this->display = 'options';
$this->context->smarty->assign(array(
'table' => $this->table, if ($this->ajax && method_exists($this, 'ajaxPreprocess'))
'current' => self::$currentIndex, $this->ajaxPreProcess();
'token' => $this->token,
)); $this->context->smarty->assign(array(
'table' => $this->table,
'current' => self::$currentIndex,
'token' => $this->token,
));
} }
/** /**
+2 -3
View File
@@ -29,7 +29,6 @@ class HelperFormCore extends Helper
{ {
public $id; public $id;
public $first_call = true; public $first_call = true;
public $toolbar = true;
/** @var array of forms fields */ /** @var array of forms fields */
protected $fields_form = array(); protected $fields_form = array();
@@ -137,11 +136,11 @@ class HelperFormCore extends Helper
} }
$this->tpl->assign(array( $this->tpl->assign(array(
'submit_action' => $this->submit_action, 'title' => $this->title,
'toolbar_btn' => $this->toolbar_btn, 'toolbar_btn' => $this->toolbar_btn,
'show_toolbar' => $this->show_toolbar, 'show_toolbar' => $this->show_toolbar,
'toolbar_fix' => $this->toolbar_fix, 'toolbar_fix' => $this->toolbar_fix,
'title' => $this->title, 'submit_action' => $this->submit_action,
'firstCall' => $this->first_call, 'firstCall' => $this->first_call,
'current' => $this->currentIndex, 'current' => $this->currentIndex,
'token' => $this->token, 'token' => $this->token,
+6 -9
View File
@@ -65,8 +65,6 @@ class HelperListCore extends Helper
protected $is_dnd_identifier = false; protected $is_dnd_identifier = false;
public $toolbar = true;
/* Customize list display /* Customize list display
* *
* align : determine value alignment * align : determine value alignment
@@ -562,12 +560,15 @@ class HelperListCore extends Helper
} }
$this->header_tpl->assign(array_merge($this->tpl_vars, array( $this->header_tpl->assign(array_merge($this->tpl_vars, array(
'title' => $this->title,
'show_toolbar' => $this->show_toolbar,
'toolbar_fix' => $this->toolbar_fix,
'toolbar_btn' => $this->toolbar_btn,
'table' => $this->table, 'table' => $this->table,
'currentIndex' => $this->currentIndex, 'currentIndex' => $this->currentIndex,
'action' => $action, 'action' => $action,
'page' => $page, 'page' => $page,
'simple_header' => $this->simple_header, 'simple_header' => $this->simple_header,
'title' => $this->title,
'total_pages' => $total_pages, 'total_pages' => $total_pages,
'selected_pagination' => $selected_pagination, 'selected_pagination' => $selected_pagination,
'pagination' => $this->_pagination, 'pagination' => $this->_pagination,
@@ -583,16 +584,12 @@ class HelperListCore extends Helper
'shop_link_type' => $this->shopLinkType, 'shop_link_type' => $this->shopLinkType,
'has_actions' => !empty($this->actions), 'has_actions' => !empty($this->actions),
'has_bulk_actions' => !empty($this->bulk_actions), 'has_bulk_actions' => !empty($this->bulk_actions),
'toolbar_btn' => $this->toolbar_btn,
'table_id' => isset($table_id) ? $table_id : null, 'table_id' => isset($table_id) ? $table_id : null,
'table_dnd' => isset($table_dnd) ? $table_dnd : null, 'table_dnd' => isset($table_dnd) ? $table_dnd : null,
'name' => isset($name) ? $name : null, 'name' => isset($name) ? $name : null,
'name_id' => isset($name_id) ? $name_id : null, 'name_id' => isset($name_id) ? $name_id : null,
'show_toolbar' => $this->show_toolbar, /*'back' => Tools::getValue('back'),
'toolbar_fix' => $this->toolbar_fix, 'no_back' => $this->no_back,*/
'back' => Tools::getValue('back'),
'no_back' => $this->no_back,
))); )));
return $this->header_tpl->fetch(); return $this->header_tpl->fetch();
+5 -20
View File
@@ -30,18 +30,8 @@
*/ */
class HelperOptionsCore extends Helper class HelperOptionsCore extends Helper
{ {
public $first_call = true;
public $required = false; public $required = false;
/**
* @var array of forms fields
* Usage :
*
*/
protected $fields_form = array();
public $fields_value = array();
public function __construct() public function __construct()
{ {
$this->base_folder = 'helper/options/'; $this->base_folder = 'helper/options/';
@@ -155,6 +145,10 @@ class HelperOptionsCore extends Helper
} }
$this->tpl->assign(array( $this->tpl->assign(array(
'title' => $this->title,
'toolbar_btn' => $this->toolbar_btn,
'show_toolbar' => $this->show_toolbar,
'toolbar_fix' => $this->toolbar_fix,
'current' => $this->currentIndex, 'current' => $this->currentIndex,
'table' => $this->table, 'table' => $this->table,
'token' => $this->token, 'token' => $this->token,
@@ -163,6 +157,7 @@ class HelperOptionsCore extends Helper
'required_fields' => isset($required_fields) ? $required_fields : false, 'required_fields' => isset($required_fields) ? $required_fields : false,
'languages' => isset($languages) ? $languages : null 'languages' => isset($languages) ? $languages : null
)); ));
return parent::generate(); return parent::generate();
} }
@@ -225,14 +220,4 @@ class HelperOptionsCore extends Helper
$value = $field['defaultValue']; $value = $field['defaultValue'];
return $value; return $value;
} }
public function getFieldsRequired()
{
if (isset($this->fields_form['input']))
foreach ($this->fields_form['input'] as $input)
if (array_key_exists('required', $input) && $input['required'])
return true;
return false;
}
} }
@@ -85,6 +85,7 @@ class AdminAccessController extends AdminController
// toolbar (save, cancel, new, ..) // toolbar (save, cancel, new, ..)
$this->initToolbar(); $this->initToolbar();
unset($this->toolbar_btn['save']); unset($this->toolbar_btn['save']);
unset($this->toolbar_btn['cancel']);
if (!$this->loadObject(true)) if (!$this->loadObject(true))
return; return;