// 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
2011-11-18 14:22:53 +00:00
parent eda71ac8fb
commit ae4a223509
8 changed files with 136 additions and 117 deletions
@@ -59,7 +59,7 @@
{else}
<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>
{/if}
</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>
{else}
<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>
{/if}
</p></fieldset></form>
@@ -24,7 +24,6 @@
* International Registered Trademark & Property of PrestaShop SA
*}
{if $show_toolbar}
<div class="toolbar-placeholder">
<div class="toolbarBox {if $toolbar_fix}toolbarHead{/if}">
@@ -23,14 +23,35 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* 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">
id_language = Number({$current_id_lang});
</script>
{block name="defaultOptions"}
<form action="{$current}&submitOptions{$table}=1&token={$token}"
{if isset($categoryData['name'])} name={$categoryData['name']}{/if}
<form action="{$current}&submitOptions{$table}=1&token={$token}"
id="{$table}_form"
{if isset($categoryData['name'])} name={$categoryData['name']}{/if}
{if isset($categoryData['id'])} id={$categoryData['id']} {/if}
method="post"
method="post"
enctype="multipart/form-data">
{foreach $option_list AS $category => $categoryData}
{if isset($categoryData['top'])}{$categoryData['top']}{/if}
@@ -195,9 +216,10 @@
{if isset($categoryData['submit'])}
<div class="margin-form">
<input type="submit"
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}"
class="{if isset($categoryData['submit']['class'])}{$categoryData['submit']['class']}{else}button{/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}"
class="{if isset($categoryData['submit']['class'])}{$categoryData['submit']['class']}{else}button{/if}"
id="{$table}_form_submit_btn"
/>
</div>
{/if}
+92 -76
View File
@@ -61,7 +61,7 @@ class AdminControllerCore extends Controller
/** @var integer Tab id */
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');
/** @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 */
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 */
protected $fieldsDisplay;
@@ -107,6 +104,9 @@ class AdminControllerCore extends Controller
/** @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;
@@ -116,6 +116,9 @@ class AdminControllerCore extends Controller
/** @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;
@@ -748,6 +751,7 @@ class AdminControllerCore extends Controller
if ($this->tabAccess['edit'] === '1')
{
$this->beforeUpdateOptions();
$languages = Language::getLanguages(false);
foreach ($this->options as $category => $category_data)
@@ -851,7 +855,7 @@ class AdminControllerCore extends Controller
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
// todo : return value ?
}
@@ -889,6 +893,10 @@ class AdminControllerCore extends Controller
}
break;
case 'options':
$this->toolbar_btn['save'] = array(
'href' => '#',
'desc' => $this->l('Save')
);
break;
default: // list
$this->toolbar_btn['new'] = array(
@@ -995,7 +1003,7 @@ class AdminControllerCore extends Controller
// new smarty : template_dir is an array.
// @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)))
$this->{$this->display.Tools::toCamelCase($this->className)}();
@@ -1301,6 +1309,9 @@ class AdminControllerCore extends Controller
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;
// Check if list templates have been overriden
// For compatibility reasons, we have to check standard actions in class attributes
@@ -1310,11 +1321,9 @@ class AdminControllerCore extends Controller
$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);
$this->toolbar_fix = false;
return $list;
}
@@ -1327,61 +1336,14 @@ class AdminControllerCore extends Controller
$this->initToolbarTitle();
$helper = new HelperView($this);
$helper->override_folder = $this->tpl_folder;
$helper->tpl_vars = $this->tpl_view_vars;
$this->setHelperDisplay($helper);
$helper->tpl_vars = $this->tpl_view_vars;
$view = $helper->generateView();
$this->toolbar_fix = false;
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
*/
@@ -1399,13 +1361,9 @@ class AdminControllerCore extends Controller
$this->getlanguages();
$helper = new HelperForm($this);
$helper->override_folder = $this->tpl_folder;
$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->tpl_vars = $this->tpl_form_vars;
$helper->multiple_fieldsets = $this->multiple_fieldsets;
if ($this->tabAccess['view'])
{
if (Tools::getValue('back'))
@@ -1415,6 +1373,7 @@ class AdminControllerCore extends Controller
}
$form = $helper->generateForm($this->fields_form);
$this->toolbar_fix = false;
return $form;
}
}
@@ -1426,18 +1385,71 @@ class AdminControllerCore extends Controller
{
if ($this->options && is_array($this->options))
{
$helper = new HelperOptions();
$helper->override_folder = $this->tpl_folder;
if (empty($this->toolbar_title))
$this->initToolbarTitle();
if ($this->display != 'options')
$this->show_toolbar = false;
$helper = new HelperOptions($this);
$this->setHelperDisplay($helper);
$helper->id = $this->id;
$helper->token = $this->token;
$helper->tpl_vars = $this->tpl_option_vars;
$helper->shopLinkType = $this->shopLinkType;
$helper->table = $this->table;
$helper->currentIndex = self::$currentIndex;
return $helper->generateOptions($this->options);
$options = $helper->generateOptions($this->options);
$this->toolbar_fix = false;
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()
{
$this->addCSS(_PS_CSS_DIR_.'admin.css', 'all');
@@ -1678,7 +1690,7 @@ class AdminControllerCore extends Controller
else
$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')
{
@@ -1706,13 +1718,17 @@ class AdminControllerCore extends Controller
break;
}
}
if ($this->ajax && method_exists($this, 'ajaxPreprocess'))
$this->ajaxPreProcess();
$this->context->smarty->assign(array(
'table' => $this->table,
'current' => self::$currentIndex,
'token' => $this->token,
));
else if (!empty($this->options) && empty($this->fieldsDisplay))
$this->display = 'options';
if ($this->ajax && method_exists($this, 'ajaxPreprocess'))
$this->ajaxPreProcess();
$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 $first_call = true;
public $toolbar = true;
/** @var array of forms fields */
protected $fields_form = array();
@@ -137,11 +136,11 @@ class HelperFormCore extends Helper
}
$this->tpl->assign(array(
'submit_action' => $this->submit_action,
'title' => $this->title,
'toolbar_btn' => $this->toolbar_btn,
'show_toolbar' => $this->show_toolbar,
'toolbar_fix' => $this->toolbar_fix,
'title' => $this->title,
'submit_action' => $this->submit_action,
'firstCall' => $this->first_call,
'current' => $this->currentIndex,
'token' => $this->token,
+6 -9
View File
@@ -65,8 +65,6 @@ class HelperListCore extends Helper
protected $is_dnd_identifier = false;
public $toolbar = true;
/* Customize list display
*
* align : determine value alignment
@@ -562,12 +560,15 @@ class HelperListCore extends Helper
}
$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,
'currentIndex' => $this->currentIndex,
'action' => $action,
'page' => $page,
'simple_header' => $this->simple_header,
'title' => $this->title,
'total_pages' => $total_pages,
'selected_pagination' => $selected_pagination,
'pagination' => $this->_pagination,
@@ -583,16 +584,12 @@ class HelperListCore extends Helper
'shop_link_type' => $this->shopLinkType,
'has_actions' => !empty($this->actions),
'has_bulk_actions' => !empty($this->bulk_actions),
'toolbar_btn' => $this->toolbar_btn,
'table_id' => isset($table_id) ? $table_id : null,
'table_dnd' => isset($table_dnd) ? $table_dnd : null,
'name' => isset($name) ? $name : null,
'name_id' => isset($name_id) ? $name_id : null,
'show_toolbar' => $this->show_toolbar,
'toolbar_fix' => $this->toolbar_fix,
'back' => Tools::getValue('back'),
'no_back' => $this->no_back,
/*'back' => Tools::getValue('back'),
'no_back' => $this->no_back,*/
)));
return $this->header_tpl->fetch();
+5 -20
View File
@@ -30,18 +30,8 @@
*/
class HelperOptionsCore extends Helper
{
public $first_call = true;
public $required = false;
/**
* @var array of forms fields
* Usage :
*
*/
protected $fields_form = array();
public $fields_value = array();
public function __construct()
{
$this->base_folder = 'helper/options/';
@@ -155,6 +145,10 @@ class HelperOptionsCore extends Helper
}
$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,
'table' => $this->table,
'token' => $this->token,
@@ -163,6 +157,7 @@ class HelperOptionsCore extends Helper
'required_fields' => isset($required_fields) ? $required_fields : false,
'languages' => isset($languages) ? $languages : null
));
return parent::generate();
}
@@ -225,14 +220,4 @@ class HelperOptionsCore extends Helper
$value = $field['defaultValue'];
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, ..)
$this->initToolbar();
unset($this->toolbar_btn['save']);
unset($this->toolbar_btn['cancel']);
if (!$this->loadObject(true))
return;