Commit 303a333b authored by Côme Chilliet's avatar Côme Chilliet
Browse files

feat(management) Move action menu HTML to smarty template

parent 91e67a9b
{function menu level=2}
<ul class="level{$level}">
{foreach $data as $entry}
{if isset($entry.actions)}
<li id="actionmenu_{$entry.name|escape}">
<a href="#">
<img src="{$entry.icon|escape}" alt="{$entry.name|escape}"/>&nbsp;{$entry.label|escape}
&nbsp;<img src="images/forward-arrow.png" alt="forward arrow"/>
</a>
{menu data=$entry.actions level=$level+1}
</li>
{else}
<li id="actionmenu_{$entry.name|escape}">
<a href="#" onClick="document.getElementById('actionmenu').value='{$entry.name|escape}';document.getElementById('exec_act').click();">
<img src="{$entry.icon|escape}" alt="{$entry.name|escape}">&nbsp;{$entry.label|escape}
</a>
</li>
{/if}
{/foreach}
</ul>
{/function}
<div id="pulldown">
<input type="hidden" name="act" id="actionmenu" value=""/>
<div style="display:none"><input type="submit" name="exec_act" id="exec_act" value=""/></div>
<ul class="level1" id="root">
<li>
<a href="#">{t}Actions{/t}&nbsp;<img class="center optional" src="images/down-arrow.png" alt="down arrow"/></a>
{menu data=$actions}
</li>
</ul>
</div>
......@@ -415,8 +415,9 @@ class management
{
global $config;
$list = $this->listing->render();
$filter = $this->filter->render();
$list = $this->listing->render();
$filter = $this->filter->render();
$actions = $this->renderActionMenu();
$smarty = get_smarty();
$smarty->assign('usePrototype', 'true');
......@@ -429,7 +430,7 @@ class management
$smarty->assign('NAVIGATION', $this->listing->renderNavigation()); // TODO: move here?
//~ // Assign action menu / base
$smarty->assign('ACTIONS', $this->renderActionMenu());
$smarty->assign('ACTIONS', $actions);
$smarty->assign('BASE', $this->listing->renderBase()); // TODO: move here?
// Assign summary
......@@ -440,19 +441,15 @@ class management
function renderActionMenu()
{
// Load shortcut
$result = '<input type="hidden" name="act" id="actionmenu" value=""/>'."\n".
'<div style="display:none"><input type="submit" name="exec_act" id="exec_act" value=""/></div>'."\n".
'<ul class="level1" id="root"><li><a href="#">'._('Actions').
'&nbsp;<img class="center optional" src="images/down-arrow.png" alt="down arrow"/></a>'."\n";
$result .= '<ul class="level2">'."\n";
$menuActions = array();
foreach ($this->actions as $action) {
// TODO: ACL handling
// Build ul/li list
$result .= $action->renderMenuItems();
$action->fillMenuItems($menuActions);
}
return '<div id="pulldown">'.$result.'</ul></li></ul></div>'."\n";
$smarty = get_smarty();
$smarty->assign('actions', $menuActions);
return $smarty->fetch(get_template_path('management/actionmenu.tpl'));
}
function renderActionColumn(ListingEntry $entry)
......@@ -561,6 +558,7 @@ class management
return '';
}
// TODO move to smarty template
// In case an of locked entry, we may have opened a read-only tab.
$str = '';
if ($this->tabObject->readOnly()) {
......
......@@ -115,17 +115,16 @@ class Action
return call_user_func($func, $action);
}
function renderMenuItems()
function fillMenuItems(&$actions)
{
if (!$this->inmenu) {
return '';
return;
}
return '<li id="actionmenu_'.$this->name.'">'
.'<a href="#" onClick="'
."document.getElementById('actionmenu').value='".$this->name."';document.getElementById('exec_act').click();"
.'">'
.'<img src="'.htmlentities($this->icon, ENT_COMPAT, 'UTF-8').'" alt="'.$this->name.'">&nbsp;'.$this->label.'</a>'
.'</li>'."\n";
$actions[] = array(
'name' => $this->name,
'icon' => $this->icon,
'label' => $this->label
);
}
function getRowClasses(ListingEntry $entry)
......@@ -219,26 +218,21 @@ class ActionSubMenu extends Action
}
}
function renderMenuItems($level = 2)
function fillMenuItems(&$actions)
{
if (!$this->inmenu) {
return '';
}
$result = '';
if (!empty($this->label)) {
$img = '';
if (!empty($this->icon)) {
$img = '<img src="'.htmlentities($this->icon, ENT_COMPAT, 'UTF-8').'" alt="'.$this->label.'"/>&nbsp;';
}
$result .= '<li id="actionmenu_'.$this->name.'"><a href="#">'.$img.'&nbsp;'.$this->label.'&nbsp;<img src="images/forward-arrow.png" alt="forward arrow"/></a>'."\n";
return;
}
$level++;
$result .= '<ul class="level'.$level.'">'."\n";
$subactions = array();
foreach ($this->actions as $action) {
$result .= $action->renderMenuItems($level);
$action->fillMenuItems($subactions);
}
return $result.'</li></ul>'."\n";
$actions[] = array(
'name' => $this->name,
'icon' => $this->icon,
'label' => $this->label,
'actions' => $subactions
);
}
function renderColumnIcons(ListingEntry $entry)
......
......@@ -45,24 +45,23 @@ class LockAction extends Action
return NULL;
}
function renderMenuItems()
function fillMenuItems(&$actions)
{
if (!$this->inmenu) {
return '';
return;
}
return '<li id="actionmenu_'.$this->name.'_lock">'
.'<a href="#" onClick="'
."document.getElementById('actionmenu').value='".$this->name."_lock';document.getElementById('exec_act').click();"
.'">'
.'<img src="'.htmlentities($this->icon['lock'], ENT_COMPAT, 'UTF-8').'" alt="'.$this->name.'" class="center">&nbsp;'.$this->label['lock'].'</a>'
.'</li>'."\n".
'<li id="actionmenu_'.$this->name.'_unlock">'
.'<a href="#" onClick="'
."document.getElementById('actionmenu').value='".$this->name."_unlock';document.getElementById('exec_act').click();"
.'">'
.'<img src="'.htmlentities($this->icon['unlock'], ENT_COMPAT, 'UTF-8').'" alt="'.$this->name.'" class="center">&nbsp;'.$this->label['unlock'].'</a>'
.'</li>'."\n";
$actions[] = array(
'name' => $this->name.'_lock',
'icon' => $this->icon['lock'],
'label' => $this->label['lock'],
);
$actions[] = array(
'name' => $this->name.'_unlock',
'icon' => $this->icon['unlock'],
'label' => $this->label['unlock'],
);
}
function getRowClasses(ListingEntry $entry)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment