Using now templates instead of hard code in AdminUtilities smarty plugin
This commit is contained in:
@@ -199,7 +199,7 @@ class BaseAdminController extends BaseController
|
||||
$parser = $this->container->get("thelia.parser");
|
||||
|
||||
// Define the template thant shoud be used
|
||||
$parser->setTemplate($template ?: ConfigQuery::read('base_admin_template', 'admin/default'));
|
||||
$parser->setTemplate($template ?: ConfigQuery::read('base-admin-template', 'admin/default'));
|
||||
|
||||
return $parser;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Model\Config;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
/**
|
||||
* This class implements variour admin template utilities
|
||||
@@ -42,6 +44,26 @@ class AdminUtilities extends AbstractSmartyPlugin
|
||||
$this->securityContext = $securityContext;
|
||||
}
|
||||
|
||||
protected function fetch_snippet($smarty, $templateName, $variablesArray) {
|
||||
|
||||
$data = '';
|
||||
|
||||
$snippet_path = sprintf('%s/%s/%s.html',
|
||||
THELIA_TEMPLATE_DIR,
|
||||
ConfigQuery::read('base-admin-template', 'admin/default'),
|
||||
$templateName
|
||||
);
|
||||
|
||||
if (false !== $snippet_content = file_get_contents($snippet_path)) {
|
||||
|
||||
$smarty->assign($variablesArray);
|
||||
|
||||
$data = $smarty->fetch(sprintf('string:%s', $snippet_content));
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function generatePositionChangeBlock($params, &$smarty)
|
||||
{
|
||||
// The required permissions
|
||||
@@ -70,15 +92,15 @@ class AdminUtilities extends AbstractSmartyPlugin
|
||||
*/
|
||||
|
||||
if ($permissions == null || $this->securityContext->isGranted("ADMIN", array($resource), array($access))) {
|
||||
return sprintf(
|
||||
'<a href="%s"><i class="glyphicon glyphicon-arrow-up"></i></a><span class="%s" data-id="%s">%s</span><a href="%s"><i class="glyphicon glyphicon-arrow-down"></i></a>',
|
||||
URL::getInstance()->absoluteUrl($path, array('mode' => 'up', $url_parameter => $id)),
|
||||
$in_place_edit_class,
|
||||
$id,
|
||||
$position,
|
||||
URL::getInstance()->absoluteUrl($path, array('mode' => 'down', $url_parameter => $id))
|
||||
);
|
||||
} else {
|
||||
|
||||
return $this->fetch_snippet($smarty, 'includes/admin-utilities-position-block', array(
|
||||
'admin_utilities_go_up_url' => URL::getInstance()->absoluteUrl($path, array('mode' => 'up', $url_parameter => $id)),
|
||||
'admin_utilities_in_place_edit_class' => $in_place_edit_class,
|
||||
'admin_utilities_object_id' => $id,
|
||||
'admin_utilities_current_position' => $position,
|
||||
'admin_utilities_go_down_url' => URL::getInstance()->absoluteUrl($path, array('mode' => 'down', $url_parameter => $id))
|
||||
));
|
||||
} else {
|
||||
return $position;
|
||||
}
|
||||
}
|
||||
@@ -111,21 +133,20 @@ class AdminUtilities extends AbstractSmartyPlugin
|
||||
$request_parameter_name = $this->getParam($params, 'request_parameter_name', 'order');
|
||||
|
||||
if ($current_order == $order) {
|
||||
$icon = 'up';
|
||||
$sort_direction = 'up';
|
||||
$order_change = $reverse_order;
|
||||
} elseif ($current_order == $reverse_order) {
|
||||
$icon = 'down';
|
||||
$sort_direction = 'down';
|
||||
$order_change = $order;
|
||||
} else {
|
||||
$order_change = $order;
|
||||
}
|
||||
|
||||
if (! empty($icon))
|
||||
$output = sprintf('<i class="glyphicon glyphicon-chevron-%s"></i> ', $icon);
|
||||
else
|
||||
$output = '';
|
||||
|
||||
return sprintf('%s<a href="%s">%s</a>', $output, URL::getInstance()->absoluteUrl($path, array($request_parameter_name => $order_change)), $label);
|
||||
return $this->fetch_snippet($smarty, 'includes/admin-utilities-sortable-column-header', array(
|
||||
'admin_utilities_sort_direction' => $sort_direction,
|
||||
'admin_utilities_sorting_url' => URL::getInstance()->absoluteUrl($path, array($request_parameter_name => $order_change)),
|
||||
'admin_utilities_header_text' => $label
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat
|
||||
('session_config.default', '1', 1, 1, NOW(), NOW()),
|
||||
('verifyStock', '1', 0, 0, NOW(), NOW()),
|
||||
('active-template', 'default', 0, 0, NOW(), NOW()),
|
||||
('base-admin-template', 'admin/default', 0, 0, NOW(), NOW()),
|
||||
('default_lang_without_translation', '1', 1, 1, NOW(), NOW()),
|
||||
('rewriting_enable', '0', 0, 0, NOW(), NOW()),
|
||||
('imagine_graphic_driver', 'gd', 0, 0, NOW(), NOW()),
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
{* Include debug bar smarty calls *}
|
||||
|
||||
{debugbar_renderjs}
|
||||
{debugbar_renderresult}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{*
|
||||
This snippet is used by the AdminUtilities Smarty plugin to generate
|
||||
the position maagement block in tables
|
||||
*}
|
||||
<a href="{$admin_utilities_go_up_url}"><i class="glyphicon glyphicon-arrow-up"></i></a>
|
||||
<span class="{$admin_utilities_in_place_edit_class}" data-id="{$admin_utilities_object_id}">{$admin_utilities_current_position}</span>
|
||||
<a href="{$admin_utilities_go_down_url}"><i class="glyphicon glyphicon-arrow-down"></i></a>
|
||||
@@ -0,0 +1,10 @@
|
||||
{*
|
||||
This snippet is used by the AdminUtilities Smarty plugin to generate
|
||||
the header on a sortable column
|
||||
*}
|
||||
{if $admin_utilities_sort_direction == 'up'}
|
||||
<i class="glyphicon glyphicon-chevron-up"></i>
|
||||
{else if $admin_utilities_sort_direction == 'down'}
|
||||
<i class="glyphicon glyphicon-chevron-down"></i>
|
||||
{/if}
|
||||
<a href="{$admin_utilities_sorting_url}">{$admin_utilities_header_text}</a>
|
||||
@@ -9,7 +9,7 @@
|
||||
<div class="modules">
|
||||
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
|
||||
<div class="clearfix">
|
||||
<ul class="breadcrumb pull-left">
|
||||
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
|
||||
@@ -19,7 +19,8 @@
|
||||
<a class="btn btn-default btn-primary pull-right" title="{intl l='Install a new module'}" href="#install_dialog" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-import"></span> {intl l="Install a new module"}
|
||||
</a>
|
||||
{/loop}*}
|
||||
{/loop}
|
||||
*}
|
||||
</div>
|
||||
|
||||
{module_include location='modules_top'}
|
||||
|
||||
Reference in New Issue
Block a user