vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.7 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=228)
-   -   Administrative and Maintenance Tools - Toggle Products (https://vborg.vbsupport.ru/showthread.php?t=183148)

Mutt 06-20-2008 10:00 PM

Toggle Products
 
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
Code:

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

and replace it with
Code:

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


look for
Code:

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

replace it with
Code:

                                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
Code:

        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
Code:

        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

Quote:

Originally Posted by Stoebi (Post 1555472)
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):
Code:

    <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


All times are GMT. The time now is 11:17 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01105 seconds
  • Memory Usage 1,759KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete