mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
Fixed tabbed admin interface
This commit is contained in:
@@ -16,31 +16,111 @@
|
|||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
|
||||||
|
new tabbed;
|
||||||
|
|
||||||
|
class tabbed
|
||||||
|
{
|
||||||
|
protected $links = array();
|
||||||
|
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
$core = e107::getNav()->adminLinks('assoc');
|
||||||
|
$plugs = e107::getNav()->pluginLinks(E_16_PLUGMANAGER, "array");
|
||||||
|
|
||||||
|
$this->links = array_merge($core,$plugs);
|
||||||
|
require_once(e_HANDLER."admin_handler.php");
|
||||||
|
$this->links = multiarray_sort($this->links,'title'); //XXX Move this function in e107_class?
|
||||||
|
$this->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function render()
|
||||||
|
{
|
||||||
|
$ns = e107::getRender();
|
||||||
|
$mes = e107::getMessage();
|
||||||
|
$admin_cat = e107::getNav()->adminCats();
|
||||||
|
|
||||||
|
$text = "<div>";
|
||||||
|
$text .= "<ul class='nav nav-tabs'>";
|
||||||
|
|
||||||
|
foreach ($admin_cat['id'] as $cat_key => $cat_id)
|
||||||
|
{
|
||||||
|
$cls = ($cat_key == 1) ? "class='active'" : "";
|
||||||
|
$text .= "<li {$cls} ><a data-toggle='tab' href='#core-main-".$cat_key."'>".$admin_cat['title'][$cat_key]."</a></li>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$text .= "</ul>";
|
||||||
|
// print_a($this->links);
|
||||||
|
$text .= "<div class='tab-content adminform'>";
|
||||||
|
foreach ($admin_cat['id'] as $id => $cat_id)
|
||||||
|
{
|
||||||
|
$cls = ($id == 1) ? "active" : "";
|
||||||
|
$text .= "<div class='tab-pane {$cls} adminform' style='width:95%' id='core-main-{$id}'>".$this->renderCat($id)."</div>";
|
||||||
|
}
|
||||||
|
$text .= "</div>";
|
||||||
|
$text .= "</div>";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$ns->tablerender(ADLAN_47." ".ADMINNAME, $mes->render().$text);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function renderCat($cat)
|
||||||
|
{
|
||||||
|
$text = "";
|
||||||
|
foreach($this->links as $val)
|
||||||
|
{
|
||||||
|
if($val['cat'] != $cat)
|
||||||
|
{
|
||||||
|
// echo "<br />".$funcinfo['cat']." != ".$cat;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$text .= e107::getNav()->renderAdminButton($val['link'], $val['title'], $val['caption'], $val['perms'], $val['icon_32'], "div");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function render2()
|
||||||
|
{
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
$admin_cat = e107::getNav()->adminCats();
|
$admin_cat = e107::getNav()->adminCats();
|
||||||
|
|
||||||
$text = "<div style='text-align:center'>
|
$text = "<div class='center'>
|
||||||
<div class='admintabs' id='tab-container'>
|
|
||||||
<ul class='e-tabs' id='core-emote-tabs'>";
|
<ul class='nav nav-tabs'>";
|
||||||
|
|
||||||
foreach ($admin_cat['id'] as $cat_key => $cat_id)
|
foreach ($admin_cat['id'] as $cat_key => $cat_id)
|
||||||
{
|
{
|
||||||
// $text .= "<li id='tab-main_".$cat_key."' ><span style='white-space:nowrap'><img class='icon S16' src='".$admin_cat['img'][$cat_key]."' alt='' style='margin-right:3px' /><a href='#core-main_".$cat_key."'>".$admin_cat['title'][$cat_key]."</a></span></li>";
|
// $text .= "<li id='tab-main_".$cat_key."' ><span style='white-space:nowrap'><img class='icon S16' src='".$admin_cat['img'][$cat_key]."' alt='' style='margin-right:3px' /><a href='#core-main_".$cat_key."'>".$admin_cat['title'][$cat_key]."</a></span></li>";
|
||||||
$text .= "<li id='tab-main_".$cat_key."' ><a href='#core-main_".$cat_key."'>".$admin_cat['title'][$cat_key]."</a></li>";
|
$text .= "<li id='tab-main_".$cat_key."' ><a data-toggle='tab' href='#core-main_".$cat_key."'>".$admin_cat['title'][$cat_key]."</a></li>";
|
||||||
}
|
}
|
||||||
$text .= "</ul>";
|
$text .= "</ul>";
|
||||||
|
|
||||||
|
$text .= "<div id='tab-content'>";
|
||||||
|
|
||||||
|
print_a($admin_cat);
|
||||||
|
|
||||||
foreach ($admin_cat['id'] as $cat_key => $cat_id)
|
foreach ($admin_cat['id'] as $cat_key => $cat_id)
|
||||||
{
|
{
|
||||||
$text_check = FALSE;
|
$text_check = FALSE;
|
||||||
|
|
||||||
$text_cat = "<div class='adminform' id='core-main_".$cat_key."'>
|
$text_cat = "";
|
||||||
<div style='border:1px solid silver;margin:10px'>
|
|
||||||
<div class='main_caption bevel'><b>".$admin_cat['title'][$cat_key]."</b></div>
|
|
||||||
<table style='width:100%'>";
|
|
||||||
|
|
||||||
|
|
||||||
if ($cat_key != 5) // Note the Plugin category.
|
if ($cat_key != 5) // Note the Plugin category.
|
||||||
@@ -49,7 +129,7 @@ foreach ($admin_cat['id'] as $cat_key => $cat_id)
|
|||||||
{
|
{
|
||||||
if ($funcinfo[4] == $cat_key)
|
if ($funcinfo[4] == $cat_key)
|
||||||
{
|
{
|
||||||
$text_rend = e107::getNav()->renderAdminButton($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[6], 'classis');
|
$text_rend = e107::getNav()->renderAdminButton($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[6], 'div');
|
||||||
if ($text_rend)
|
if ($text_rend)
|
||||||
{
|
{
|
||||||
$text_check = TRUE;
|
$text_check = TRUE;
|
||||||
@@ -60,7 +140,7 @@ foreach ($admin_cat['id'] as $cat_key => $cat_id)
|
|||||||
}
|
}
|
||||||
else // Plugin category.
|
else // Plugin category.
|
||||||
{
|
{
|
||||||
$text_rend = e107::getNav()->pluginLinks(E_32_PLUGMANAGER, "classis");
|
$text_rend = e107::getNav()->pluginLinks(E_32_PLUGMANAGER, "div");
|
||||||
|
|
||||||
if ($text_rend)
|
if ($text_rend)
|
||||||
{
|
{
|
||||||
@@ -68,14 +148,18 @@ foreach ($admin_cat['id'] as $cat_key => $cat_id)
|
|||||||
}
|
}
|
||||||
$text_cat .= $text_rend;
|
$text_cat .= $text_rend;
|
||||||
}
|
}
|
||||||
$text_cat .= render_clean();
|
//$text_cat .= render_clean();
|
||||||
$text_cat .= "</table></div>
|
|
||||||
</div>";
|
|
||||||
|
|
||||||
if ($text_check)
|
if ($text_check)
|
||||||
{
|
{
|
||||||
|
$text .= "<div class='tab-pane adminform' id='core-main_".$cat_key."'>\n";
|
||||||
|
$text .= " <div class='main_caption bevel'><b>".$admin_cat['title'][$cat_key]."</b></div>";
|
||||||
$text .= $text_cat ;
|
$text .= $text_cat ;
|
||||||
|
$text .= "</div><!-- End tab-pane -->";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -84,5 +168,6 @@ $text .= "</div></div>";
|
|||||||
|
|
||||||
$ns->tablerender(ADLAN_47." ".ADMINNAME, $mes->render().$text);
|
$ns->tablerender(ADLAN_47." ".ADMINNAME, $mes->render().$text);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
@@ -71,159 +71,3 @@ if (!function_exists('multiarray_sort')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Experiment
|
|
||||||
* Most basic & performance wise solution for admin icons override
|
|
||||||
*/
|
|
||||||
class e_admin_icons
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string icons absolute URL path
|
|
||||||
*/
|
|
||||||
protected $path;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string icons relative server path
|
|
||||||
*/
|
|
||||||
protected $relpath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function __construct()
|
|
||||||
{
|
|
||||||
//XXX maybe we should use admintheme pref instead THEME here?
|
|
||||||
if(is_readable(THEME.'icons/admin/'))
|
|
||||||
{
|
|
||||||
$this->path = THEME_ABS.'icons/admin/';
|
|
||||||
$this->relpath = THEME.'icons/admin/';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->path = e_IMAGE_ABS.'admin_images/';
|
|
||||||
$this->relpath = e_IMAGE.'admin_images/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get icon absolute path (url, without domain)
|
|
||||||
*
|
|
||||||
* @param string $name without size and extension e.g. 'edit'
|
|
||||||
* @param integer size pixel , default 16
|
|
||||||
* @param string $extension without leading dot, default 'png'
|
|
||||||
* @return string icon url without domain
|
|
||||||
*/
|
|
||||||
public function url($name, $size = 16, $extension = 'png')
|
|
||||||
{
|
|
||||||
if($size)
|
|
||||||
{
|
|
||||||
$name .= '_'.$size;
|
|
||||||
}
|
|
||||||
return $this->path.$name.'.'.$extension;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get image tag of an icon
|
|
||||||
*
|
|
||||||
* @param string $name without size and extension e.g. 'edit'
|
|
||||||
* @param integer $size default 16
|
|
||||||
* @param string $class default empty
|
|
||||||
* @param string $alt default empty
|
|
||||||
* @param string $extension default 'png'
|
|
||||||
* @return string img tag
|
|
||||||
*/
|
|
||||||
public function tag($name, $size = 16, $class='', $alt = '', $extension = 'png')
|
|
||||||
{
|
|
||||||
$_class = 'icon';
|
|
||||||
if($size)
|
|
||||||
{
|
|
||||||
$_class .= ' S'.$size;
|
|
||||||
}
|
|
||||||
if($class)
|
|
||||||
{
|
|
||||||
$_class .= ' '.$class;
|
|
||||||
}
|
|
||||||
$src = $this->url($name, $size, $extension);
|
|
||||||
|
|
||||||
return '<img src="'.$src.'" alt="'.$alt.'" class="'.$_class.'" />';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get icon relative server path
|
|
||||||
*
|
|
||||||
* @param string $name without size and extension e.g. 'edit'
|
|
||||||
* @param integer size pixel , default 16
|
|
||||||
* @param string $extension without leading dot, default 'png'
|
|
||||||
* @return string icon relative server path
|
|
||||||
*/
|
|
||||||
public function path($name, $size = 16, $extension = 'png')
|
|
||||||
{
|
|
||||||
if($size)
|
|
||||||
{
|
|
||||||
$name .= '_'.$size;
|
|
||||||
}
|
|
||||||
return $this->relpath.$name.'.'.$extension;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenient proxy to e_admin_icons::url()
|
|
||||||
* Get icon absolute path (url, without domain)
|
|
||||||
* Example:
|
|
||||||
* <code>
|
|
||||||
* echo _I('edit');
|
|
||||||
* // If icon path is overloaded by current admin theme:
|
|
||||||
* // '/e107_themes/current_theme/icons/admin/edit_16.png'
|
|
||||||
* // else
|
|
||||||
* // '/e107_images/admin_images/edit_16.png'
|
|
||||||
* </code>
|
|
||||||
*
|
|
||||||
* @param string $name without size and extension e.g. 'edit'
|
|
||||||
* @param integer size pixel , default 16
|
|
||||||
* @param string $extension without leading dot, default 'png'
|
|
||||||
* @return string icon url without domain
|
|
||||||
*/
|
|
||||||
function _I($name, $size = 16, $extension = 'png')
|
|
||||||
{
|
|
||||||
return e107::getSingleton('e_admin_icons')->url($name, $size, $extension);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenient proxy to e_admin_icons::tag()
|
|
||||||
* Get image tag of an icon
|
|
||||||
* Example: <code>echo _ITAG('edit');</code>
|
|
||||||
* @see _I()
|
|
||||||
* @param string $name without size and extension e.g. 'edit'
|
|
||||||
* @param integer $size default 16
|
|
||||||
* @param string $class default empty
|
|
||||||
* @param string $alt default empty
|
|
||||||
* @param string $extension default 'png'
|
|
||||||
* @return string img tag
|
|
||||||
*/
|
|
||||||
function _ITAG($name, $size = 16, $class = '', $alt = '', $extension = 'png')
|
|
||||||
{
|
|
||||||
return e107::getSingleton('e_admin_icons')->tag($name, $size, $class, $alt, $extension);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenient proxy to e_admin_icons::path()
|
|
||||||
* Get icon relative server path
|
|
||||||
* <code>
|
|
||||||
* echo _IPATH('edit');
|
|
||||||
* // If icon path is overloaded by current admin theme:
|
|
||||||
* // '../e107_themes/current_theme/icons/admin/edit_16.png'
|
|
||||||
* // else
|
|
||||||
* // '../e107_images/admin_images/edit_16.png'
|
|
||||||
* </code>
|
|
||||||
*
|
|
||||||
* @param string $name without size and extension e.g. 'edit'
|
|
||||||
* @param integer size pixel , default 16
|
|
||||||
* @param string $extension without leading dot, default 'png'
|
|
||||||
* @return string icon relative server path
|
|
||||||
*/
|
|
||||||
function _IPATH($name, $size = 16, $extension = 'png')
|
|
||||||
{
|
|
||||||
return e107::getSingleton('e_admin_icons')->path($name, $size, $extension);
|
|
||||||
}
|
|
||||||
|
@@ -743,6 +743,7 @@ class e_navigation
|
|||||||
$val['title'] = $val[1];
|
$val['title'] = $val[1];
|
||||||
$val['link'] = $val[0];
|
$val['link'] = $val[0];
|
||||||
$val['caption'] = $val['2'];
|
$val['caption'] = $val['2'];
|
||||||
|
$val['cat'] = $val['4'];
|
||||||
$val['perms'] = $val['3'];
|
$val['perms'] = $val['3'];
|
||||||
$array_functions_assoc[$key] = $val;
|
$array_functions_assoc[$key] = $val;
|
||||||
}
|
}
|
||||||
@@ -751,6 +752,24 @@ class e_navigation
|
|||||||
return $array_functions_assoc;
|
return $array_functions_assoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert from plugin category found in plugin.xml to Navigation Category ID number.
|
||||||
|
*/
|
||||||
|
function plugCatToCoreCat($cat)
|
||||||
|
{
|
||||||
|
$convert = array(
|
||||||
|
'settings' => array(1,'setMenu'),
|
||||||
|
'users' => array(2,'userMenu'),
|
||||||
|
'content' => array(3,'contMenu'),
|
||||||
|
'tools' => array(4,'toolMenu'),
|
||||||
|
'manage' => array(6,'managMenu'),
|
||||||
|
'misc' => array(7,'miscMenu'),
|
||||||
|
'help' => array(20,'helpMenu')
|
||||||
|
);
|
||||||
|
|
||||||
|
return (int) vartrue($convert[$cat][0]);
|
||||||
|
}
|
||||||
|
|
||||||
// Function renders all the plugin links according to the required icon size and layout style
|
// Function renders all the plugin links according to the required icon size and layout style
|
||||||
// - common to the various admin layouts such as infopanel, classis etc.
|
// - common to the various admin layouts such as infopanel, classis etc.
|
||||||
function pluginLinks($iconSize = E_16_PLUGMANAGER, $linkStyle = 'adminb')
|
function pluginLinks($iconSize = E_16_PLUGMANAGER, $linkStyle = 'adminb')
|
||||||
@@ -785,9 +804,11 @@ class e_navigation
|
|||||||
|
|
||||||
$plugin_path = $plug;
|
$plugin_path = $plug;
|
||||||
$name = $plugs->plug_vars['@attributes']['name'];
|
$name = $plugs->plug_vars['@attributes']['name'];
|
||||||
|
/*
|
||||||
|
echo "<h1>".$name." ($plug)</h1>";
|
||||||
|
print_a($plugs->plug_vars);
|
||||||
|
*/
|
||||||
|
|
||||||
/* echo "<h1>".$name." ($plug)</h1>";
|
|
||||||
print_a($plugs->plug_vars);*/
|
|
||||||
if(!varset($plugs->plug_vars['adminLinks']['link']))
|
if(!varset($plugs->plug_vars['adminLinks']['link']))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -815,7 +836,14 @@ class e_navigation
|
|||||||
$eplug_name = $tp->toHTML($eplug_name,FALSE,"defs, emotes_off");
|
$eplug_name = $tp->toHTML($eplug_name,FALSE,"defs, emotes_off");
|
||||||
$plugin_icon = $eplug_icon_small ? "<img class='icon S16' src='".e_PLUGIN.$eplug_icon_small."' alt='' />" : E_16_PLUGIN;
|
$plugin_icon = $eplug_icon_small ? "<img class='icon S16' src='".e_PLUGIN.$eplug_icon_small."' alt='' />" : E_16_PLUGIN;
|
||||||
$plugin_icon_32 = $eplug_icon ? "<img class='icon S32' src='".e_PLUGIN.$eplug_icon."' alt='' />" : E_32_PLUGIN;
|
$plugin_icon_32 = $eplug_icon ? "<img class='icon S32' src='".e_PLUGIN.$eplug_icon."' alt='' />" : E_32_PLUGIN;
|
||||||
$plugin_array['p-'.$plugin_path] = array('link' => e_PLUGIN.$plugin_path."/".$eplug_conffile, 'title' => $eplug_name, 'caption' => $eplug_caption, 'perms' => "P".varset($plug_id[$plugin_path]), 'icon' => $plugin_icon, 'icon_32' => $plugin_icon_32);
|
$plugin_array['p-'.$plugin_path] = array(
|
||||||
|
'link' => e_PLUGIN.$plugin_path."/".$eplug_conffile,
|
||||||
|
'title' => $eplug_name, 'caption' => $eplug_caption,
|
||||||
|
'perms' => "P".varset($plug_id[$plugin_path]),
|
||||||
|
'icon' => $plugin_icon,
|
||||||
|
'icon_32' => $plugin_icon_32,
|
||||||
|
'cat' => $this->plugCatToCoreCat($plugs->plug_vars['category'])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user