News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

[WIP] Menu Button Manager mod

Started by Kays, February 21, 2013, 06:03:11 PM

Previous topic - Next topic

Kays

Thanks for that Ema. :)

Fixed those and finally got around to getting the second menu to show. Unfortunately, that's a bit theme defendant.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

emanuele

Quote from: Kays on March 14, 2013, 08:12:17 PM
Fixed those and finally got around to getting the second menu to show. Unfortunately, that's a bit theme defendant.
Great!

Yes, I can imagine that the appearance of a second menu depends highly on the theme...
Out of curiosity, where is it placed the second one?
Is it in a fixed position or it can be placed around from the admin panel or from the template?
Or is an alternative to the original one?


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Kays

The second menu is independent from the first and there's three options for placement. Top right, as it is here, under the current nav bar and manual so a user can manually place it in the theme. There's also a ssi function so it can be shown on external pages. It can also show as being active on those pages.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

emanuele

#23
Great, great!
* emanuele feels it could be possible to create any number of menus... O:)

I was playing with it a bit before trying to use it, I found that adding a new menu entry there is an Undefined index: button_order_last
File: /xxx/Sources/Subs-Buttons.php
Line: 249

Probably the first time the mod inserts a button this value doesn't exists, TBH, I'm not sure if this setting is actually used...from a search doesn't seem so...maybe it can just be removed?

And a:
The database value you're trying to insert does not exist: value
Function: updateSettings
File: /home/emanuele/webserver/htdocs/_update/2.0.4/Sources/Subs.php
Line: 621

That is the result of the previous undefined index.

Commenting out:
'button_order_last' => $modSettings['button_order_last']++,

everything seems to work as expected.
And for consistency I commented out also:
'button_order_last' => $modSettings['button_order_last'] - count($buttons_to_remove),


ETA: also a small problem with the custom code permissions, using && it becomes && in the menu file. ;)

ETA2: the button_show fields should be a bit longer (I set it to text just to stay on the safe side :P)
Also, it would be nice to probably encapsulate somehow the code evaluated in a function so that is a semi-colon is added by mistake it doesn't break everything ;)


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Kays

Hi, thanks for the feedback. :)

Yes, more than two menus are possible with a few code tweeks. Just need to find room to place them. :P

Sorry about the problem with "button_order_last". It is no longer in use and I thought that I removed all traces of it. ::)

Quote
ETA: also a small problem with the custom code permissions, using && it becomes && in the menu file. ;)

Grr, damn htmlspecialchars().

Quote
ETA2: the button_show fields should be a bit longer (I set it to text just to stay on the safe side :P

I was thinking of making it a textarea. But decided against it for some silly reason.

Quote
Also, it would be nice to probably encapsulate somehow the code evaluated in a function so that is a semi-colon is added by mistake it doesn't break everything ;)

Thanks, something else for my list of things to look into.

Started looking at portal compatibility a while ago and realised that most of it had to do with button permissions. So I ended up doing a bit of a major rewrite so that the permissions from the buttons in the $buttons array is now used. So now the permissions no longer need to manually input. Which of course resulted in other minor issues cropping up. But I'm finalising that and should post an updated version sometime in the near future. I still have quite a todo list. Something which seems to be growing rather than diminishing. ::)








If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

emanuele

Quote from: Kays on April 06, 2013, 02:56:52 PM
Yes, more than two menus are possible with a few code tweeks. Just need to find room to place them. :P
8)

Quote from: Kays on April 06, 2013, 02:56:52 PM
Sorry about the problem with "button_order_last". It is no longer in use and I thought that I removed all traces of it. ::)
No problem! ;)

Quote from: Kays on April 06, 2013, 02:56:52 PM
Quote
ETA: also a small problem with the custom code permissions, using && it becomes && in the menu file. ;)

Grr, damn htmlspecialchars().
Same reaction! LOL

Quote from: Kays on April 06, 2013, 02:56:52 PM
Quote
ETA2: the button_show fields should be a bit longer (I set it to text just to stay on the safe side :P

I was thinking of making it a textarea. But decided against it for some silly reason.
Just to be clear, I mean the db-field! ;)
At the moment is a varchar(128) and I hit that limit with...I think it was the mod that adds 6 entries to the menu, so I changed the db field from VARCHAR to TEXT.

Quote from: Kays on April 06, 2013, 02:56:52 PM
Quote
Also, it would be nice to probably encapsulate somehow the code evaluated in a function so that is a semi-colon is added by mistake it doesn't break everything ;)

Thanks, something else for my list of things to look into.
Well, that's something I'm not sure about to be honest, it may just be enough to remove the semi-colon if it is present...

Quote from: Kays on April 06, 2013, 02:56:52 PM
Started looking at portal compatibility a while ago and realised that most of it had to do with button permissions. So I ended up doing a bit of a major rewrite so that the permissions from the buttons in the $buttons array is now used.
That is cool!! :D

Quote from: Kays on April 06, 2013, 02:56:52 PM
So now the permissions no longer need to manually input. Which of course resulted in other minor issues cropping up. But I'm finalising that and should post an updated version sometime in the near future. I still have quite a todo list. Something which seems to be growing rather than diminishing. ::)
You know how it works! :P


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Kays

Quote
Just to be clear, I mean the db-field! ;)
At the moment is a varchar(128) and I hit that limit with...I think it was the mod that adds 6 entries to the menu, so I changed the db field from VARCHAR to TEXT.

Oh.. ::)

Since the mod now uses the permissions from the $buttons array I don't envision someone trying to input such a long string. But that has been raised that to 255 already. Which should be enough, I hope. I could also change the htmlspecialchars() to addslashes() which will decrease the character count a fair amount.

Quote
Well, that's something I'm not sure about to be honest, it may just be enough to remove the semi-colon if it is present...

That's all I did. As well as removing any double quotation marks jut in case. Can you think of anything else which might mess things up there?

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

emanuele

There are probably several kind of syntaxes that could break the cache file, but detect them is another kind of problem.
One thing you may want to consider is to cut the string down to 255 chars before test it, so that it doesn't go into the database broken (better safe than sorry :P).

And, now that I think about it, you may even try to check the entire cached file before actually use it.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Kindred

interesting...   


I do wonder though, if you might want to move this to the WIP mods board. :)
http://www.simplemachines.org/community/index.php?board=195.0
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

emanuele



Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Kindred

rotfl...   I must have missed that one in the read through that I did.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Kays

Yep, that's why. Thanks. :)

Quote
One thing you may want to consider is to cut the string down to 255 chars before test it, so that it doesn't go into the database broken (better safe than sorry :P).

The heck with it. That field is now meduiumtext. ;)

Quote
And, now that I think about it, you may even try to check the entire cached file before actually use it.

Better yet, I can check the syntax before it's written to file.

Duh, don't know why I didn't think of that earlier. Thanks for the nudge in the right direction. :)




If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Arantor

QuoteThe heck with it. That field is now meduiumtext.

~1MB should be enough for anyone ;)

Kays

More like enough for everyone as well. :)

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

emanuele

Quote from: Kays on April 08, 2013, 08:07:07 PM
Quote
One thing you may want to consider is to cut the string down to 255 chars before test it, so that it doesn't go into the database broken (better safe than sorry :P).

The heck with it. That field is now meduiumtext. ;)
lol
It was just to stay on the safe side... :P


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Kays

OK finally, a major update Beta 4.0. :)

As mentioned earlier the mod is now using the permissions from the existing buttons. As well it also updates automatically if another mod adds a new button. So the operation is now seamless. Also added the changes suggested by Ema.

With a few exceptions, it seems to work quite well with most portals (see first post). I also added to ability for active button highlighting for pages creates by SP and ADK-P. There is a bit of a problem with the active button highlighting with some portals if a portal generated button is moved to the second menu. Something I need to look into further. Also need to add a means to edit the button name now. ::)

Except for Aeva, I really haven't looked at the gallery mods or Simple Desk yet.


If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Arantor

Aeva and SimpleDesk really are very, very special. They do very much their own thing. Both implement their own permissions systems for reasons I won't get into.

Kays

Avea wasn't that uncooperative. And the biggest headache with Simple Desk is the fact that some of the subbuttons have the same names as other buttons. Something my mod don't like. :)

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Kays

Updated to Beta 4.1 :)

Fixed a bug in display permissions for the second level buttons.Verified Aeva & SimpleDesk compatibility

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Kays

OK, another update, Beta 4.2. And I think that this is about it. :)

Thanks to a post by ChalkCat I made a change in how the active button highlighting works. Which takes care of some funkyness when a top level button is moved to where it shouldn't be. Especially if it's moved to the second menu or set as a sub-button. So basically now it's playing quite nicely with most portals.

Add a the ability to automatically remove any buttons which are deleted when a mod is uninstalled. In the process I cleaned up the delete confirmation page. Now there are only two options. Either delete all, or delete the button and any selected sub-buttons. With the remaining buttons being placed in the selected location.

Also added more checks when the menu file is written. Less chance now of a corrupt menu file and better recovery should there be a problem.

Basically, pending any reported problems, the only thing left to look at is caching. I've got an idea of how I want to handle it. But I've got a question on something which is puzzling me.


if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);


That's the code for the current caching. Anyone know why it's only enabled for level 2 and beyond? ???

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Advertisement: