XH 1.6.1: quick Access to Plugin Administration

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

XH 1.6.1: quick Access to Plugin Administration

Post by cmb » Thu Dec 26, 2013 12:50 pm

Hello community,

accessing the plugin administration currently requires to select the plugin from the admin menu; only then the plugin menu is shown. So usually one needs two clicks (and and two requests!) to get to the desired functionality. This can be partly circumvented by presenting the main plugin administration as the first "screen", as can be seen in several of Frank's (aka. svasti) plugins. However, that doesn't help if the user wants to go to the configuration directly, for instance. Furthermore the pluginmenu on top of the contents area seems somewhat misplaced -- why not have it as part of the admin menu?

[ external image ]

That would require plugins to register the desired menu functionality similar to print_plugin_admin() and pluginMenu(), if the core offers something like XH_registerPluginMenuItem() and for convenience, XH_registerStandardPluginMenuItems(). These functions could simply be called from the admin.php of a plugin (unconditionally, opposed to print_plugin_admin(), which only should be called if the plugin is requested). A typical use case would be adding the following single line:

Code: Select all

XH_registerStandardPluginMenuItems(true); 
A plugin author who wants his plugin to stay compatible with versions which do not have this new functionality, and wants to suppress the classic plugin menu otherwise, could do:

Code: Select all

if (function_exists('XH_registerStandardPluginMenuItems')) {
    XH_registerStandardPluginMenuItems(true);
}
if (isset($pagemanger) && $pagemanager == 'true') {
    if (!function_exists('XH_registerStandardPluginMenuItems')) {
        $o .= print_plugin_admin('on');
    }
} 
The necessary additions and modifications of the core are relatively simple. The base would be XH_registerPluginMenuItem():

Code: Select all

/**
 * Register a new plugin menu item, or returns the registered plugin menu items,
 * if <var>$label</var> and <var>$url</var> are null.
 *
 * @param string $plugin A plugin name.
 * @param string $label  A menu item label.
 * @param string $url    A URL to link to.
 *
 * @return mixed
 *
 * @staticvar array $pluginMenu The array of already registered menu items.
 */
function XH_registerPluginMenuItem($plugin, $label = null, $url = null)
{
    static $pluginMenu = array();

    if (isset($label) && isset($url)) {
        $pluginMenu[$plugin][] = array(
            'label' => $label,
            'url' => $url
        );
    } else {
        return $pluginMenu[$plugin];
    }
} 
XH_registerStandardPluginMenuItems() would be a variation of pluginMenu() (the common code should be refactored out). Then only XH_adminMenu() has to be slightly modified to add the registered menu items to the plugin menu. The CSS for the third menu level is already (still) there in core.css.

What do you think?

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1651
Joined: Wed Dec 17, 2008 5:08 pm

Re: XH 1.6.1: quick Access to Plugin Administration

Post by svasti » Thu Dec 26, 2013 6:19 pm

Ah, Christoph producing new ideas! Why not start a 1.6.1 roadmap? (1.6.1 'll be ready before 1.6.0 is out)
The proposition seems logical. Logical fits nicely with simple.
cmb wrote:Furthermore the pluginmenu on top of the contents area seems somewhat misplaced
However if I am in a plugin, I'd still like a direct link to the other plugin aspects instead of going to the top menu, scrolling down to my plugin, scrolling carefully to the right to get the plugin submenu and selecting the wanted plugin aspect.

svasti

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XH 1.6.1: quick Access to Plugin Administration

Post by cmb » Fri Dec 27, 2013 1:31 pm

svasti wrote:Why not start a 1.6.1 roadmap?
Done. :)
svasti wrote:1.6.1 'll be ready before 1.6.0 is out
No, I don't think so. IMHO we should concentrate on XH 1.5.10 after 1.6 is released; there are already some points on the roadmap, and some things from 1.6 should be backported.
svasti wrote:However if I am in a plugin, I'd still like a direct link to the other plugin aspects instead of going to the top menu, scrolling down to my plugin, scrolling carefully to the right to get the plugin submenu and selecting the wanted plugin aspect.
I see your point. In this case at least some improved styling of the plugin menu seems to be appropriate.
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1651
Joined: Wed Dec 17, 2008 5:08 pm

Re: XH 1.6.1: quick Access to Plugin Administration

Post by svasti » Sun May 04, 2014 11:02 am

I suddenly realise that I don't like this feature. Oh no, I voted "now" in the voting! Too bad.

Why? I am just realising that this feature is useful for a certain type of plugins only, that is: plugins, where in the back end one goes first the page with a big fat copyright notice and the name of the programmer. This page is is usually the most uninteresting for the user. Still every time you have to go to the plugin backend, you have to pass through this uninteresting page. Quick Access to Plugin Administration is a way to bypass this page.

I prefer plugins, where the user goes right away to the important page. That is the way my plugins are made. Therefore these plugins don't need an additional "Quick Access to Plugin Administration". They have already a quick access.

So what about the possibility, that this feature can be controlled by the plugins? And also: there are some plugins that need and have many more subpages than the standard plugin admin provides. What about them?

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XH 1.6.1: quick Access to Plugin Administration

Post by cmb » Sun May 04, 2014 11:34 am

svasti wrote:So what about the possibility, that this feature can be controlled by the plugins? And also: there are some plugins that need and have many more subpages than the standard plugin admin provides. What about them?
The proposal gives the plugin author complete control, as a plugin has to register its submenu items:
cmb wrote:That would require plugins to register the desired menu functionality similar to print_plugin_admin() and pluginMenu(), if the core offers something like XH_registerPluginMenuItem() and for convenience, XH_registerStandardPluginMenuItems(). These functions could simply be called from the admin.php of a plugin
So a plugin can register arbitrary menu items. And if a plugin doesn't register any items, everything will stay as it is now (what's especially important for compatibility with existing plugins).
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XH 1.6.1: quick Access to Plugin Administration

Post by cmb » Fri May 16, 2014 10:14 pm

I have implemented the proposal (r1291-r1295). I want to point out a few things:
  • To cater for menu items linking to help files and such, I've added an optional $target parameter to XH_registerPluginMenuItem()
  • It is possible to register menu items for other plugins, what might be interesting for plugins/addons which closely cooperate with another plugin.
  • I have refactored out a small class hierarchie (see cmsimple/classes/PluginMenu.php) to avoid code duplication, and to make the implementation of print_plugin_admin() and pluginMenu() easier to understand and modify (if necessary).
  • pluginMenu() is actually more flexible than I thought, especially as the $style parameter is a misnomer (actually, this might better be called $attributes). However, I'm not sure if this flexibility is really needed (most likely that is not used in any plugins, similar to the removed $hint parameter of plugin_admin_common()). We may consider to simplify interface and implementation.
  • pluginMenu() was actually a (clumsy) procedural interface to an object, and now it's possible to use the trimmed interface of XH_ClassicPluginMenu() (via the global $_XH_pluginMenu) directly (i.e. ::makeRow(), ::makeTab(), ::makeData(), ::show()). We may consider to deprecate pluginMenu() sometime in the not too distant future. I suppose this function is used by very few plugins anyway.
  • It might be reasonable to copy the menu items to a new toplevel item, when a plugin's administration is selected. For instance, if Pagemanager is selected, there could be a toplevel item "Pagemanager" right beside "Plugins" in the admin menu. I do not propose that for now, but we should keep this option in mind, depending on the acceptance of the new "integrated" plugin menu.
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply