// Define default template dir on tree class
This commit is contained in:
@@ -245,7 +245,7 @@ class HelperFormCore extends Helper
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function renderAssoShop($params, $disable_shared = false)
|
||||
public function renderAssoShop($disable_shared = false, $template_directory = null)
|
||||
{
|
||||
if (!Shop::isFeatureActive())
|
||||
return;
|
||||
@@ -288,6 +288,8 @@ class HelperFormCore extends Helper
|
||||
}*/
|
||||
|
||||
$tree = new HelperTreeShops('shop-tree', 'Shops');
|
||||
if (isset($template_directory))
|
||||
$tree->setTemplateDirectory($template_directory);
|
||||
$tree->setSelectedShops($assos);
|
||||
$tree->setAttribute('table', $this->table);
|
||||
return $tree->render();
|
||||
|
||||
@@ -61,7 +61,7 @@ class TreeCore
|
||||
if (!isset($this->_toolbar))
|
||||
$this->setToolbar(new TreeToolbarCore());
|
||||
|
||||
$this->getToolbar()->setActions($value);
|
||||
$this->getToolbar()->setTemplateDirectory($this->getTemplateDirectory())->setActions($value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class TreeCore
|
||||
if (!isset($this->_toolbar))
|
||||
$this->setToolbar(new TreeToolbarCore());
|
||||
|
||||
return $this->getToolbar()->getActions();
|
||||
return $this->getToolbar()->setTemplateDirectory($this->getTemplateDirectory())->getActions();
|
||||
}
|
||||
|
||||
public function setAttribute($name, $value)
|
||||
@@ -293,7 +293,7 @@ class TreeCore
|
||||
if (!isset($this->_toolbar))
|
||||
$this->setToolbar(new TreeToolbarCore());
|
||||
|
||||
$this->getToolbar()->addAction($action);
|
||||
$this->getToolbar()->setTemplateDirectory($this->getTemplateDirectory())->addAction($action);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,12 +40,13 @@ class TreeToolbarCore implements ITreeToolbarCore
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
public function setActions($value)
|
||||
public function setActions($actions)
|
||||
{
|
||||
if (!is_array($value) && !$value instanceof Traversable)
|
||||
if (!is_array($actions) && !$actions instanceof Traversable)
|
||||
throw new PrestaShopException('Action value must be an traversable array');
|
||||
|
||||
$this->_actions = $value;
|
||||
foreach($actions as $action)
|
||||
$this->addAction($action);
|
||||
}
|
||||
|
||||
public function getActions()
|
||||
@@ -165,6 +166,9 @@ class TreeToolbarCore implements ITreeToolbarCore
|
||||
if (!isset($this->_actions))
|
||||
$this->_actions = array();
|
||||
|
||||
if (isset($this->_template_directory))
|
||||
$action->setTemplateDirectory($this->getTemplateDirectory());
|
||||
|
||||
$this->_actions[] = $action;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -155,13 +155,49 @@ abstract class TreeToolbarButtonCore
|
||||
public function getTemplateDirectory()
|
||||
{
|
||||
if (!isset($this->_template_directory))
|
||||
$this->_template_directory = $this->_normalizeDirectory(
|
||||
$this->getContext()->smarty->getTemplateDir(0)
|
||||
.self::DEFAULT_TEMPLATE_DIRECTORY);
|
||||
$this->_template_directory = $this->_normalizeDirectory(self::DEFAULT_TEMPLATE_DIRECTORY);
|
||||
|
||||
return $this->_template_directory;
|
||||
}
|
||||
|
||||
public function getTemplateFile($template)
|
||||
{
|
||||
if (preg_match_all('/((?:^|[A-Z])[a-z]+)/', get_class($this->getContext()->controller), $matches) !== FALSE)
|
||||
$controllerName = strtolower($matches[0][1]);
|
||||
|
||||
if ($this->getContext()->controller instanceof ModuleAdminController)
|
||||
return $this->_normalizeDirectory(
|
||||
$this->getContext()->controller->getTemplatePath())
|
||||
.$this->getTemplateDirectory().$template;
|
||||
else if ($this->getContext()->controller instanceof AdminController
|
||||
&& isset($controllerName) && file_exists($this->_normalizeDirectory(
|
||||
$this->getContext()->smarty->getTemplateDir(0)).'controllers'
|
||||
.DIRECTORY_SEPARATOR
|
||||
.$controllerName
|
||||
.DIRECTORY_SEPARATOR
|
||||
.$this->getTemplateDirectory().$template))
|
||||
return $this->_normalizeDirectory(
|
||||
$this->getContext()->smarty->getTemplateDir(0)).'controllers'
|
||||
.DIRECTORY_SEPARATOR
|
||||
.$controllerName
|
||||
.DIRECTORY_SEPARATOR
|
||||
.$this->getTemplateDirectory().$template;
|
||||
else if (file_exists($this->_normalizeDirectory(
|
||||
$this->getContext()->smarty->getTemplateDir(1))
|
||||
.$this->getTemplateDirectory().$template))
|
||||
return $this->_normalizeDirectory(
|
||||
$this->getContext()->smarty->getTemplateDir(1))
|
||||
.$this->getTemplateDirectory().$template;
|
||||
else if (file_exists($this->_normalizeDirectory(
|
||||
$this->getContext()->smarty->getTemplateDir(0))
|
||||
.$this->getTemplateDirectory().$template))
|
||||
return $this->_normalizeDirectory(
|
||||
$this->getContext()->smarty->getTemplateDir(0))
|
||||
.$this->getTemplateDirectory().$template;
|
||||
else
|
||||
return $this->getTemplateDirectory().$template;
|
||||
}
|
||||
|
||||
public function hasAttribute($name)
|
||||
{
|
||||
return (isset($this->_attributes)
|
||||
@@ -171,7 +207,7 @@ abstract class TreeToolbarButtonCore
|
||||
public function render()
|
||||
{
|
||||
return $this->getContext()->smarty->createTemplate(
|
||||
$this->getTemplateDirectory().$this->getTemplate(),
|
||||
$this->getTemplateFile($this->getTemplate()),
|
||||
$this->getContext()->smarty
|
||||
)->assign($this->getAttributes())->fetch();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user