[+] BO : Adding tree templates and functions
This commit is contained in:
@@ -23,8 +23,8 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<div class="panel">
|
||||
{if $header}{$header}{/if}
|
||||
{if $nodes}
|
||||
{if isset($header)}{$header}{/if}
|
||||
{if isset($nodes)}
|
||||
<ul id="{$id}" class="nav nav-list tree">{$nodes}</ul>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -22,4 +22,4 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<div class="panel-heading">{l s=$title}{if $toolbar}{$toolbar}{/if}</div>
|
||||
<div class="panel-heading">{l s=$title}{if isset($toolbar)}{$toolbar}{/if}</div>
|
||||
+1
-1
@@ -22,4 +22,4 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<div class="pull-right">{if $actions}{foreach from=$actions item=action}{$action}{/foreach}{/if}</div>
|
||||
<div class="pull-right">{if isset($actions)}{foreach from=$actions item=action}{$action}{/foreach}{/if}</div>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
{*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 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/afl-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-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<label for="node-search">{l s=$label}</label> <input type="text" id="node-search" name="node-search"{if isset($class)} class="{$class}"{/if}{if isset($categories_name)} data-provide="typeahead" data-source="[{$categories_name}]"{/if} />
|
||||
@@ -23,8 +23,8 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<div class="panel">
|
||||
{if $header}{$header}{/if}
|
||||
{if $nodes}
|
||||
{if isset($header)}{$header}{/if}
|
||||
{if isset($nodes)}
|
||||
<ul id="{$id}" class="nav nav-list tree">{$nodes}</ul>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -22,4 +22,4 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<div class="panel-heading">{l s=$title}{if $toolbar}{$toolbar}{/if}</div>
|
||||
<div class="panel-heading">{l s=$title}{if isset($toolbar)}{$toolbar}{/if}</div>
|
||||
@@ -22,4 +22,4 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<div class="pull-right">{if $actions}{foreach from=$actions item=action}{$action}{/foreach}{/if}</div>
|
||||
<div class="pull-right">{if isset($actions)}{foreach from=$actions item=action}{$action}{/foreach}{/if}</div>
|
||||
@@ -0,0 +1,25 @@
|
||||
{*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 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/afl-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-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<label for="node-search">{l s=$label}</label> <input type="text" id="node-search" name="node-search"{if isset($class)} class="{$class}"{/if}{if isset($data_source)} data-provide="typeahead" data-source="[{$data_source}]"{/if} />
|
||||
@@ -29,6 +29,10 @@ interface HelperITreeToolbarButtonCore
|
||||
public function __toString();
|
||||
public function setAction($value);
|
||||
public function getAction();
|
||||
public function setAttributes($value);
|
||||
public function getAttributes();
|
||||
public function setClass($value);
|
||||
public function getClass();
|
||||
public function setContext($value);
|
||||
public function getContext();
|
||||
public function setLabel($value);
|
||||
@@ -37,5 +41,6 @@ interface HelperITreeToolbarButtonCore
|
||||
public function getTemplate();
|
||||
public function setTemplateDirectory($value);
|
||||
public function getTemplateDirectory();
|
||||
public function addAttribute($name, $value);
|
||||
public function render();
|
||||
}
|
||||
@@ -29,15 +29,18 @@ abstract class HelperTreeToolbarButtonCore
|
||||
const DEFAULT_TEMPLATE_DIRECTORY = 'helpers/tree';
|
||||
|
||||
private $_action;
|
||||
private $_attributes;
|
||||
private $_class;
|
||||
private $_context;
|
||||
private $_label;
|
||||
protected $_template;
|
||||
protected $_template_directory;
|
||||
|
||||
public function __construct($label, $action = null)
|
||||
public function __construct($label, $action = null, $class = null)
|
||||
{
|
||||
$this->setLabel($label);
|
||||
$this->setAction($action);
|
||||
$this->setClass($class);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
@@ -56,6 +59,34 @@ abstract class HelperTreeToolbarButtonCore
|
||||
return $this->_action;
|
||||
}
|
||||
|
||||
public function setAttributes($value)
|
||||
{
|
||||
if (!is_array($value) && !$value instanceof Traversable)
|
||||
throw new PrestaShopException('Data value must be an traversable array');
|
||||
|
||||
$this->_attributes = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAttributes()
|
||||
{
|
||||
if (!isset($this->_attributes))
|
||||
$this->_attributes = array();
|
||||
|
||||
return $this->_attributes;
|
||||
}
|
||||
|
||||
public function setClass($value)
|
||||
{
|
||||
$this->_class = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getClass()
|
||||
{
|
||||
return $this->_class;
|
||||
}
|
||||
|
||||
public function setContext($value)
|
||||
{
|
||||
$this->_context = $value;
|
||||
@@ -108,12 +139,21 @@ abstract class HelperTreeToolbarButtonCore
|
||||
return $this->_template_directory;
|
||||
}
|
||||
|
||||
public function addAttribute($name, $value)
|
||||
{
|
||||
if (!isset($this->_attributes))
|
||||
$this->_attributes = array();
|
||||
|
||||
$this->_attributes[$name] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return $this->getContext()->smarty->createTemplate(
|
||||
$this->getTemplateDirectory().$this->getTemplate(),
|
||||
$this->getContext()->smarty
|
||||
);
|
||||
)->assign($this->getAttributes());
|
||||
}
|
||||
|
||||
private function _normalizeDirectory($directory)
|
||||
|
||||
@@ -70,6 +70,7 @@ class HelperTreeToolbarLinkCore extends HelperTreeToolbarButtonCore implements
|
||||
'link' => $this->getLink(),
|
||||
'action' => $this->getAction(),
|
||||
'label' => $this->getLabel(),
|
||||
'class' => $this->getClass(),
|
||||
'icon_class' => $this->getIconClass()
|
||||
));
|
||||
return $template->fetch();
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 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-2013 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 HelperTreeToolbarSearchCore extends HelperTreeToolbarButtonCore implements
|
||||
HelperITreeToolbarButtonCore
|
||||
{
|
||||
protected $_template = 'tree_toolbar_search.tpl';
|
||||
|
||||
public function __construct($label, $action = null, $class = null)
|
||||
{
|
||||
parent::__construct($label, $action, $class);
|
||||
|
||||
$admin_webpath = str_ireplace(_PS_ROOT_DIR_, '', _PS_ADMIN_DIR_);
|
||||
$admin_webpath = preg_replace('/^'.preg_quote(DIRECTORY_SEPARATOR, '/').'/', '', $admin_webpath);
|
||||
$bo_theme = ((Validate::isLoadedObject($this->getContext()->employee)
|
||||
&& $this->getContext()->employee->bo_theme) ? $this->getContext()->employee->bo_theme : 'default');
|
||||
|
||||
if (!file_exists(_PS_BO_ALL_THEMES_DIR_.$bo_theme.DIRECTORY_SEPARATOR
|
||||
.'template'))
|
||||
$bo_theme = 'default';
|
||||
$this->getContext()->controller->addJs(__PS_BASE_URI__.$admin_webpath
|
||||
.'/themes/'.$bo_theme.'/js/vendor/typeahead.min.js');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$template = parent::render();
|
||||
$template->assign(array(
|
||||
'action' => $this->getAction(),
|
||||
'label' => $this->getLabel(),
|
||||
'class' => $this->getClass()
|
||||
));
|
||||
return $template->fetch();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user