PDA

View Full Version : Administrative and Maintenance Tools - Toggle Products


Mutt
06-20-2008, 10:00 PM
Toggle Products v1.01
Made by Mutt
06-21-08
------------------------
This lets you collapse the plugins at the product headers of the Plugin Manager. it makes it easy for you to flip thru your installed products and locate a plugin.

It now has "Expand All" & "Collapse All" links at the bottom of the page next to "Add New Plugin". Also after you save a plugin, when you are brought back to the main plugin page the product that you were working on is open.
------------------------
v1 initial release
v1.01 added [Expand All] & [Collapse All] links
------------------------

I have this running on 3.71

INSTALL

time for the bad news, there's no pretty product or plugin here. you have to edit forum/admincp/plugin.php in 2 places


find

// stuff to handle the redirect
define('CP_REDIRECT', 'plugin.php');
print_stop_message('saved_plugin_successfully');


and replace it with

// stuff to handle the redirect
define('CP_REDIRECT', 'plugin.php?open='.$vbulletin->GPC['product']);
print_stop_message('saved_plugin_successfully');



look for

$prevgroup = $product['title'];
print_description_row("$vbphrase[product] : " . $product['title'], 0, 4, 'tfoot');


replace it with

if ($prevgroup) {
echo "</tbody>";
$allproducts.="','";
}
$allproducts.=$product[productid];
$prevgroup = $product['title'];
$button="<a href=\"#top\" target=\"_self\" onclick=\"toggle_group('".$product[productid]."'); return false;\"><img src=\"../cpstyles/vBulletin_3_Silver/cp_expand.gif\" title=\"Expand Group\" id=\"button_".$product[productid]."\" alt=\"\" border=\"0\"></a>";
print_description_row("$button $vbphrase[product] : " . $product['title'], 0, 4, 'tfoot');
echo '<tbody id="group_'.$product[productid].'" style="display: none;">';



look for

print_submit_row($vbphrase['save_active_status'], false, 4);

echo '<p align="center">' . construct_link_code($vbphrase['add_new_plugin'], "plugin.php?" . $vbulletin->session->vars['sessionurl'] . "do=add") . '</p>';


replace it with

if ($group_by == 'product') {
echo "</tbody>";
}

print_submit_row($vbphrase['save_active_status'], false, 4);

if ($group_by == 'product') {
$controls = " <a href=\"#top\" target=\"_self\" onclick=\"expand_all_groups(1); return false;\">[ Expand Products ]</a> <a href=\"#top\" target=\"_self\" onclick=\"expand_all_groups(0); return false;\">[Collapse Products]</a>";
$vbulletin->input->clean_array_gpc('r', array(
'open' => TYPE_NOHTML
));

?>
<script type="text/javascript">
<!--
var files = new Array('<?php echo $allproducts; ?>');
<?php
if ($vbulletin->GPC['open']) {
echo "open_close_group('".$vbulletin->GPC['open']."', 1)";
}
?>

function expand_all_groups(doOpen)
{
for (var i = 0; i < files.length; i++) {
open_close_group(files[i], doOpen);
}
}

function open_close_group(group, doOpen)
{
var curdiv = fetch_object("group_" + group);
var curbtn = fetch_object("button_" + group);

if (doOpen)
{
curdiv.style.display = "";
curbtn.src = "../cpstyles/vBulletin_3_Silver/cp_collapse.gif";
curbtn.title = "";
}
else
{
curdiv.style.display = "none";
curbtn.src = "../cpstyles/vBulletin_3_Silver/cp_expand.gif";
curbtn.title = "";
}

}

function toggle_group(group)
{
var curdiv = fetch_object("group_" + group);

if (curdiv.style.display == "none")
{
open_close_group(group, true);
}
else
{
open_close_group(group, false);
}
}

//-->
</script>
<?php
}
echo '<p align="center">' . construct_link_code($vbphrase['add_new_plugin'], "plugin.php?" . $vbulletin->session->vars['sessionurl'] . "do=add") . $controls .'</p>';



please bear with me because it's been a loooong time since I released anything. if there's an easier way to do this, I'm all ears.

NOTE: toggle.js is a tiny chuck of javascript lifted from includes/adminfunctions_navpanel.php. if this is bad form, please let me know how to release this properly.

Stoebi
06-21-2008, 03:23 PM
Hi

*installed*

Wish:
What do you think about a Save & Reload options for plugins?

Mutt
06-21-2008, 04:27 PM
Hi

*installed*

Wish:
What do you think about a Save & Reload options for plugins?


yeah, as I'm using it I realize that saving the current stat of toggles would be nice. should be easy enough to do. would just have to grab a little bit more of that javascript. will wait till I find out if what I lifted so far is allowable.

would like to add expand all & collapse all. will have to look into it

Stoebi
06-21-2008, 05:40 PM
Hope, that helps, code is from a friend of mine (Surviver):

<script type="text/javascript">
<!--
function toggle_p_collapse(objid, un)
{
obj = fetch_object('collapseobj_' + objid);
img = fetch_object('collapseimg_' + objid);
cel = fetch_object('collapsecel_' + objid);

if (!obj)
{
return false;
}

if (un)
{
obj.style.display = '';
save_collapsed(objid, false);

if (img)
{
img_re = new RegExp("_collapsed\\.gif$");
img.src = img.src.replace(img_re, '.gif');
}

if (cel)
{
cel_re = new RegExp("^(thead|tcat)(_collapsed)$");
cel.className = cel.className.replace(cel_re, '$1');
}
}
else
{
obj.style.display = 'none';
save_collapsed(objid, true);

if (img)
{
img_re = new RegExp("_alt\\.gif$");
img.src = img.src.replace(img_re, '_alt_collapsed.gif');
}

if (cel)
{
cel_re = new RegExp("^(thead|tcat)$");
cel.className = cel.className.replace(cel_re, '$1_alt_collapsed');
}
}
return false;
}

function collapse_all(un)
{
if (un)
{
for (var i in products)
{
toggle_p_collapse(products[i], true);
}
}
else
{
for (var i in products)
{
toggle_p_collapse(products[i], false);
}
}
return false;
}
//-->
</script>

Mutt
06-21-2008, 10:30 PM
thanks Stoebi

UPDATED

I updated the directions. it now has "Expand All" & "Collapse All" links at the bottom of the page next to "Add New Plugin". Also after you save a plugin, when you are brought back to the main plugin page the product that you were working on is open.

It still doesn't let you save your preferred open / closed state.

you'll have to uninstall & reinstall. no files need to be uploaded this time.

Mutt
06-29-2008, 12:17 PM
worked fine in 3.72