Tobias
02-18-2007, 10:24 AM
Subdreamer's display of Custom Plugins and Downloaded Plugins in the Control Panel can get really huge and therefore a struggle to work with as they are not sorted by name.
The code changes to "admin/menu.php" (for v2.4.x) offers these improvements (tested ok with IE7 and FF2):
Sort by Name Asc/Desc links for both
Plugin selection box for both (loads when plugin is selected)
Full list is now a secondary collapsable block (both)
Custom Plugins: option to list by Displayname
Downloaded Plugins: added display of Plugin ID and link to directly open the "Plugin Settings" (same as menu "Settings|Plugins")
Step 1:
Make a backup of "admin/index.php" and "admin/menu.php" before any changes - as usual.
Step 2:
Widen the left "menu" frame to accomodate better display of names:
In "admin/index.php", line 117, find this line:
<frameset cols="185,*" framespacing="0" border="0" frameborder="0" frameborder="no">
Replace that line with below line:
<frameset cols="210,*" framespacing="0" border="0" frameborder="0" frameborder="no">
Step 3:
Open "admin/menu.php" and find at line 222, this:
<table width="150" border="0" cellpadding="0" cellspacing="0" align="center">
Replace that line with below line:
<table width="180" border="0" cellpadding="0" cellspacing="0" align="center">
Step 4:
Find at line 342 - 385, this block of code:
// custom plugins
$getcustomplugins = $DB->query("SELECT custompluginid, name FROM " . TABLE_PREFIX . "customplugins ORDER BY custompluginid ASC");
$showmenu = true;
if($DB->get_num_rows($getcustomplugins) > 0)
{
while($customplugin = $DB->fetch_array($getcustomplugins))
{
if(@in_array($customplugin['custompluginid'], $userinfo['custompluginadminids']))
{
if($showmenu)
{
PrintMenuTitle('Custom Plugins', false);
PrintMenuRow('customplugins.php','<b>Create New Plugin</b>');
$showmenu = false;
}
PrintMenuRow('customplugins.php?custompluginid='.$ customplugin['custompluginid'].'', $customplugin['name']);
}
}
}
EndBlock();
// downloaded plugins
$getdwplugins = $DB->query("SELECT pluginid, name FROM " . TABLE_PREFIX . "plugins WHERE authorname != 'subdreamer' AND authorname != 'subdreamer_cloner' ORDER BY pluginid ASC");
$showmenu = true;
if($DB->get_num_rows($getdwplugins) > 0)
{
while($dwplugin = $DB->fetch_array($getdwplugins))
{
if(@in_array($dwplugin['pluginid'], $userinfo['pluginadminids']))
{
if($showmenu)
{
PrintMenuTitle('Downloaded Plugins', false);
$showmenu = false;
}
PrintMenuRow('myplugins.php?pluginid='.$dwplugin['pluginid'].'', $dwplugin['name']);
}
}
}
EndBlock();
EndMenu();
Replace above block with the enhanced code listed below:
// Custom Plugins
// SDDepot.com: 2007-02-18: added sorting links a plugin selection box
$cp_sortdir = (!empty($_GET['cp_sortdir'])&&ereg("^asc$|^desc$",$_GET['cp_sortdir']))?$_GET['cp_sortdir']:'asc';
$cp_showdispname = (!empty($_GET['cp_showdispname'])&&ereg("^0$|^1$",$_GET['cp_showdispname']))?$_GET['cp_showdispname']:'0';
$getcustomplugins = $DB->query("SELECT custompluginid, name, displayname FROM " .
TABLE_PREFIX . "customplugins ORDER BY ".
($cp_showdispname?'displayname':'name')." $cp_sortdir");
$showmenu = true;
if($DB->get_num_rows($getcustomplugins) > 0)
{
$cp_selection = '
<select name="cpselector" size="1" onchange="LoadCP(this);" style="margin-top:6px;width:145px;font-size=100%;">
<option value="">Choose a Plugin</option>
<option value="">---------------</option>';
$customplugins = array();
while($customplugin = $DB->fetch_array($getcustomplugins))
{
$customplugins[] = array('custompluginid'=>$customplugin['custompluginid'],
'name'=>$customplugin['name'],
'displayname'=>$customplugin['displayname']);
$cp_selection .= '
<option value="'.$customplugin['custompluginid'].'">'.
($cp_showdispname?$customplugin['displayname']:$customplugin['name']).'</option>';
}
$cp_selection .= "\n </select>\n";
for($cpi=0;$cpi<count($customplugins);$cpi++)
{
$customplugin = $customplugins[$cpi];
if(@in_array($customplugin['custompluginid'], $userinfo['custompluginadminids']))
{
if($showmenu)
{
$showmenu = false;
PrintMenuTitle('Custom Plugins', false);
PrintMenuRow('customplugins.php','<strong>Create New Plugin</strong>');
echo '
<div class="menulink-normal" onmouseover="this.className=\'menulink-hover\';" onmouseout="this.className=\'menulink-normal\'">
<span style="color:#819AAD;">Sort by Name: </span>
<a '.($cp_sortdir=='asc'?'style="color:red" ':'').'href="menu.php?cp_showdispname='.$cp_showdispname.'&cp_sortdir=asc" target="leftFrame">Asc</a>
<a '.($cp_sortdir=='desc'?'style="color:red" ':'').'href="menu.php?cp_showdispname='.$cp_showdispname.'&cp_sortdir=desc" target="leftFrame">Desc</a>
<a '.($cp_showdispname=='1'?'style="color:red" ':'').'href="menu.php?cp_showdispname=1&cp_sortdir='.$cp_sortdir.'" target="leftFrame">Displayname ON</a>
<a '.($cp_showdispname=='0'?'style="color:red" ':'').'href="menu.php?cp_showdispname=0&cp_sortdir='.$cp_sortdir.'" target="leftFrame">OFF</a>
<br />
<form name="cp_select" method="post" action="">
<script type="text/javaScript" language="javaScript">
<!--
function LoadCP(x){
var selected="";
selected=x.options[x.selectedIndex].value;
if(selected>0){
window.document.dp_select.dpselector.selectedIndex =0;
parent.frames.mainFrame.location = "customplugins.php?custompluginid="+selected;
//window.document.cp_select.cpselector.selectedIndex =0;
}
}
-->
</script>
<span style="white-space:nowrap;">
'.$cp_selection.'
<a href="javascript:void(0);" title="Reload Plugin" onclick="LoadCP(window.document.cp_select.cpselector);"><strong>»</strong></a>
</span>
</form>
';
PrintMenuTitle('Custom Plugins ('.count($customplugins).')',false);
}
PrintMenuRow('customplugins.php?custompluginid='.$ customplugin['custompluginid'],
($cp_showdispname?($customplugin['displayname'].'<br /><b>'.$customplugin['name'].'</b>'):
'<b>'.$customplugin['name'].'</b><br />'.$customplugin['displayname']));
}
}
unset($cp_selection);
EndBlock();
EndBlock();
EndBlock();
}
// Downloaded Plugins
// SDDepot.com: 2007-02-18: added sorting links a plugin selection box
$dlp_sortby = (!empty($_GET['dlp_sortby'])&&ereg("^pluginid$|^name$",$_GET['dlp_sortby']))?$_GET['dlp_sortby']:'name';
$dlp_sortdir = (!empty($_GET['dlp_sortdir'])&&ereg("^asc$|^desc$",$_GET['dlp_sortdir']))?$_GET['dlp_sortdir']:'asc';
$getdwplugins = $DB->query("SELECT pluginid, name FROM " . TABLE_PREFIX . "plugins
WHERE authorname != 'subdreamer' AND authorname != 'subdreamer_cloner' ORDER BY $dlp_sortby $dlp_sortdir");
$showmenu = true;
if($DB->get_num_rows($getdwplugins) > 0)
{
$dp_selection = '
<select name="dpselector" size="1" onchange="LoadDP(this);" style="margin-top:6px;width:145px;font-size=100%;">
<option value="">Choose a Plugin</option>
<option value="">---------------</option>';
$dwplugins = array();
while($dwplugin = $DB->fetch_array($getdwplugins))
{
$dwplugins[] = array('pluginid'=>$dwplugin['pluginid'],
'name'=>$dwplugin['name']);
$dp_selection .= '
<option value="'.$dwplugin['pluginid'].'">'.$dwplugin['name'].' ('.$dwplugin['pluginid'].')</option>';
}
$dp_selection .= "\n </select>\n";
for($dpi=0;$dpi<count($dwplugins);$dpi++)
{
$dwplugin = $dwplugins[$dpi];
if(@in_array($dwplugin['pluginid'], $userinfo['pluginadminids']))
{
if($showmenu)
{
$showmenu = false;
PrintMenuTitle('Downloaded Plugins', false);
PrintMenuRow('plugins.php', '<strong>Goto Plugin Settings</strong>');
echo '
<div class="menulink-normal" onmouseover="this.className=\'menulink-hover\';" onmouseout="this.className=\'menulink-normal\'">
<span style="color:#819AAD;">Sort by Name: </span>
<a '.(($dlp_sortby=='name'&&$dlp_sortdir=='asc')?'style="color:red" ':'').'href="menu.php?dlp_sortby=name&dlp_sortdir=asc" target="leftFrame">Asc</a>
<a '.(($dlp_sortby=='name'&&$dlp_sortdir=='desc')?'style="color:red" ':'').'href="menu.php?dlp_sortby=name&dlp_sortdir=desc" target="leftFrame">Desc</a><br />
<span style="color:#819AAD;">Sort by ID: </span>
<a '.(($dlp_sortby=='pluginid'&&$dlp_sortdir=='asc')?'style="color:red" ':'').'href="menu.php?dlp_sortby=pluginid&dlp_sortdir=asc" target="leftFrame">Asc</a>
<a '.(($dlp_sortby=='pluginid'&&$dlp_sortdir=='desc')?'style="color:red" ':'').'href="menu.php?dlp_sortby=pluginid&dlp_sortdir=desc" target="leftFrame">Desc</a>
<br />
<form name="dp_select" method="post" action="">
<script type="text/javaScript" language="javaScript">
<!--
function LoadDP(x){
var selected="";
selected=x.options[x.selectedIndex].value;
if(selected>0){
window.document.cp_select.cpselector.selectedIndex =0;
parent.frames.mainFrame.location = "myplugins.php?pluginid="+selected;
//window.document.dp_select.dpselector.selectedIndex =0;
}
}
-->
</script>
<span style="white-space:nowrap;">
'.$dp_selection.'
<a href="javascript:void(0);" title="Reload Plugin" onclick="LoadDP(window.document.dp_select.dpselector);"><strong>»</strong></a>
</span>
</form>
';
PrintMenuTitle('Downl. Plugins ('.count($dwplugins).')', false);
}
PrintMenuRow('myplugins.php?pluginid='.$dwplugin['pluginid'].'', $dwplugin['name'].' ('.$dwplugin['pluginid'].')');
}
}
echo '</div>
</div>
';
unset($dp_selection);
EndBlock();
EndBlock();
EndBlock();
}
Step 5:
Upload both changed files into your "admin" folder of your Subdreamer 2.4.x installation.
This MOD is a free courtesy of SDDepot (http://www.sddepot.com).
Cheers,
Tobias
The code changes to "admin/menu.php" (for v2.4.x) offers these improvements (tested ok with IE7 and FF2):
Sort by Name Asc/Desc links for both
Plugin selection box for both (loads when plugin is selected)
Full list is now a secondary collapsable block (both)
Custom Plugins: option to list by Displayname
Downloaded Plugins: added display of Plugin ID and link to directly open the "Plugin Settings" (same as menu "Settings|Plugins")
Step 1:
Make a backup of "admin/index.php" and "admin/menu.php" before any changes - as usual.
Step 2:
Widen the left "menu" frame to accomodate better display of names:
In "admin/index.php", line 117, find this line:
<frameset cols="185,*" framespacing="0" border="0" frameborder="0" frameborder="no">
Replace that line with below line:
<frameset cols="210,*" framespacing="0" border="0" frameborder="0" frameborder="no">
Step 3:
Open "admin/menu.php" and find at line 222, this:
<table width="150" border="0" cellpadding="0" cellspacing="0" align="center">
Replace that line with below line:
<table width="180" border="0" cellpadding="0" cellspacing="0" align="center">
Step 4:
Find at line 342 - 385, this block of code:
// custom plugins
$getcustomplugins = $DB->query("SELECT custompluginid, name FROM " . TABLE_PREFIX . "customplugins ORDER BY custompluginid ASC");
$showmenu = true;
if($DB->get_num_rows($getcustomplugins) > 0)
{
while($customplugin = $DB->fetch_array($getcustomplugins))
{
if(@in_array($customplugin['custompluginid'], $userinfo['custompluginadminids']))
{
if($showmenu)
{
PrintMenuTitle('Custom Plugins', false);
PrintMenuRow('customplugins.php','<b>Create New Plugin</b>');
$showmenu = false;
}
PrintMenuRow('customplugins.php?custompluginid='.$ customplugin['custompluginid'].'', $customplugin['name']);
}
}
}
EndBlock();
// downloaded plugins
$getdwplugins = $DB->query("SELECT pluginid, name FROM " . TABLE_PREFIX . "plugins WHERE authorname != 'subdreamer' AND authorname != 'subdreamer_cloner' ORDER BY pluginid ASC");
$showmenu = true;
if($DB->get_num_rows($getdwplugins) > 0)
{
while($dwplugin = $DB->fetch_array($getdwplugins))
{
if(@in_array($dwplugin['pluginid'], $userinfo['pluginadminids']))
{
if($showmenu)
{
PrintMenuTitle('Downloaded Plugins', false);
$showmenu = false;
}
PrintMenuRow('myplugins.php?pluginid='.$dwplugin['pluginid'].'', $dwplugin['name']);
}
}
}
EndBlock();
EndMenu();
Replace above block with the enhanced code listed below:
// Custom Plugins
// SDDepot.com: 2007-02-18: added sorting links a plugin selection box
$cp_sortdir = (!empty($_GET['cp_sortdir'])&&ereg("^asc$|^desc$",$_GET['cp_sortdir']))?$_GET['cp_sortdir']:'asc';
$cp_showdispname = (!empty($_GET['cp_showdispname'])&&ereg("^0$|^1$",$_GET['cp_showdispname']))?$_GET['cp_showdispname']:'0';
$getcustomplugins = $DB->query("SELECT custompluginid, name, displayname FROM " .
TABLE_PREFIX . "customplugins ORDER BY ".
($cp_showdispname?'displayname':'name')." $cp_sortdir");
$showmenu = true;
if($DB->get_num_rows($getcustomplugins) > 0)
{
$cp_selection = '
<select name="cpselector" size="1" onchange="LoadCP(this);" style="margin-top:6px;width:145px;font-size=100%;">
<option value="">Choose a Plugin</option>
<option value="">---------------</option>';
$customplugins = array();
while($customplugin = $DB->fetch_array($getcustomplugins))
{
$customplugins[] = array('custompluginid'=>$customplugin['custompluginid'],
'name'=>$customplugin['name'],
'displayname'=>$customplugin['displayname']);
$cp_selection .= '
<option value="'.$customplugin['custompluginid'].'">'.
($cp_showdispname?$customplugin['displayname']:$customplugin['name']).'</option>';
}
$cp_selection .= "\n </select>\n";
for($cpi=0;$cpi<count($customplugins);$cpi++)
{
$customplugin = $customplugins[$cpi];
if(@in_array($customplugin['custompluginid'], $userinfo['custompluginadminids']))
{
if($showmenu)
{
$showmenu = false;
PrintMenuTitle('Custom Plugins', false);
PrintMenuRow('customplugins.php','<strong>Create New Plugin</strong>');
echo '
<div class="menulink-normal" onmouseover="this.className=\'menulink-hover\';" onmouseout="this.className=\'menulink-normal\'">
<span style="color:#819AAD;">Sort by Name: </span>
<a '.($cp_sortdir=='asc'?'style="color:red" ':'').'href="menu.php?cp_showdispname='.$cp_showdispname.'&cp_sortdir=asc" target="leftFrame">Asc</a>
<a '.($cp_sortdir=='desc'?'style="color:red" ':'').'href="menu.php?cp_showdispname='.$cp_showdispname.'&cp_sortdir=desc" target="leftFrame">Desc</a>
<a '.($cp_showdispname=='1'?'style="color:red" ':'').'href="menu.php?cp_showdispname=1&cp_sortdir='.$cp_sortdir.'" target="leftFrame">Displayname ON</a>
<a '.($cp_showdispname=='0'?'style="color:red" ':'').'href="menu.php?cp_showdispname=0&cp_sortdir='.$cp_sortdir.'" target="leftFrame">OFF</a>
<br />
<form name="cp_select" method="post" action="">
<script type="text/javaScript" language="javaScript">
<!--
function LoadCP(x){
var selected="";
selected=x.options[x.selectedIndex].value;
if(selected>0){
window.document.dp_select.dpselector.selectedIndex =0;
parent.frames.mainFrame.location = "customplugins.php?custompluginid="+selected;
//window.document.cp_select.cpselector.selectedIndex =0;
}
}
-->
</script>
<span style="white-space:nowrap;">
'.$cp_selection.'
<a href="javascript:void(0);" title="Reload Plugin" onclick="LoadCP(window.document.cp_select.cpselector);"><strong>»</strong></a>
</span>
</form>
';
PrintMenuTitle('Custom Plugins ('.count($customplugins).')',false);
}
PrintMenuRow('customplugins.php?custompluginid='.$ customplugin['custompluginid'],
($cp_showdispname?($customplugin['displayname'].'<br /><b>'.$customplugin['name'].'</b>'):
'<b>'.$customplugin['name'].'</b><br />'.$customplugin['displayname']));
}
}
unset($cp_selection);
EndBlock();
EndBlock();
EndBlock();
}
// Downloaded Plugins
// SDDepot.com: 2007-02-18: added sorting links a plugin selection box
$dlp_sortby = (!empty($_GET['dlp_sortby'])&&ereg("^pluginid$|^name$",$_GET['dlp_sortby']))?$_GET['dlp_sortby']:'name';
$dlp_sortdir = (!empty($_GET['dlp_sortdir'])&&ereg("^asc$|^desc$",$_GET['dlp_sortdir']))?$_GET['dlp_sortdir']:'asc';
$getdwplugins = $DB->query("SELECT pluginid, name FROM " . TABLE_PREFIX . "plugins
WHERE authorname != 'subdreamer' AND authorname != 'subdreamer_cloner' ORDER BY $dlp_sortby $dlp_sortdir");
$showmenu = true;
if($DB->get_num_rows($getdwplugins) > 0)
{
$dp_selection = '
<select name="dpselector" size="1" onchange="LoadDP(this);" style="margin-top:6px;width:145px;font-size=100%;">
<option value="">Choose a Plugin</option>
<option value="">---------------</option>';
$dwplugins = array();
while($dwplugin = $DB->fetch_array($getdwplugins))
{
$dwplugins[] = array('pluginid'=>$dwplugin['pluginid'],
'name'=>$dwplugin['name']);
$dp_selection .= '
<option value="'.$dwplugin['pluginid'].'">'.$dwplugin['name'].' ('.$dwplugin['pluginid'].')</option>';
}
$dp_selection .= "\n </select>\n";
for($dpi=0;$dpi<count($dwplugins);$dpi++)
{
$dwplugin = $dwplugins[$dpi];
if(@in_array($dwplugin['pluginid'], $userinfo['pluginadminids']))
{
if($showmenu)
{
$showmenu = false;
PrintMenuTitle('Downloaded Plugins', false);
PrintMenuRow('plugins.php', '<strong>Goto Plugin Settings</strong>');
echo '
<div class="menulink-normal" onmouseover="this.className=\'menulink-hover\';" onmouseout="this.className=\'menulink-normal\'">
<span style="color:#819AAD;">Sort by Name: </span>
<a '.(($dlp_sortby=='name'&&$dlp_sortdir=='asc')?'style="color:red" ':'').'href="menu.php?dlp_sortby=name&dlp_sortdir=asc" target="leftFrame">Asc</a>
<a '.(($dlp_sortby=='name'&&$dlp_sortdir=='desc')?'style="color:red" ':'').'href="menu.php?dlp_sortby=name&dlp_sortdir=desc" target="leftFrame">Desc</a><br />
<span style="color:#819AAD;">Sort by ID: </span>
<a '.(($dlp_sortby=='pluginid'&&$dlp_sortdir=='asc')?'style="color:red" ':'').'href="menu.php?dlp_sortby=pluginid&dlp_sortdir=asc" target="leftFrame">Asc</a>
<a '.(($dlp_sortby=='pluginid'&&$dlp_sortdir=='desc')?'style="color:red" ':'').'href="menu.php?dlp_sortby=pluginid&dlp_sortdir=desc" target="leftFrame">Desc</a>
<br />
<form name="dp_select" method="post" action="">
<script type="text/javaScript" language="javaScript">
<!--
function LoadDP(x){
var selected="";
selected=x.options[x.selectedIndex].value;
if(selected>0){
window.document.cp_select.cpselector.selectedIndex =0;
parent.frames.mainFrame.location = "myplugins.php?pluginid="+selected;
//window.document.dp_select.dpselector.selectedIndex =0;
}
}
-->
</script>
<span style="white-space:nowrap;">
'.$dp_selection.'
<a href="javascript:void(0);" title="Reload Plugin" onclick="LoadDP(window.document.dp_select.dpselector);"><strong>»</strong></a>
</span>
</form>
';
PrintMenuTitle('Downl. Plugins ('.count($dwplugins).')', false);
}
PrintMenuRow('myplugins.php?pluginid='.$dwplugin['pluginid'].'', $dwplugin['name'].' ('.$dwplugin['pluginid'].')');
}
}
echo '</div>
</div>
';
unset($dp_selection);
EndBlock();
EndBlock();
EndBlock();
}
Step 5:
Upload both changed files into your "admin" folder of your Subdreamer 2.4.x installation.
This MOD is a free courtesy of SDDepot (http://www.sddepot.com).
Cheers,
Tobias