I think we must modify how Piwigo gets and displays messages (infos, errors).
Currently if a page needs to display it adds it to $page['infos'] or $page['errors'], assign it to the template...
But not all pages have the necessary vars and template part, what is a shame for pugins (I've done very bad stuff in Subscribe to Comments ^^)
My idea is to add a unified messages system :
- all messages templates are moved to header.tpl
- when we need to add a message we adds it to $page['infos'] or $page['errors'] (initiliazed in common.inc.php allowing to use array_push without any test) as before
- these array are assigned to the template in page_header.php
What do you think ?
I've also a question about messages : in header.tpl there are $header_msgs and $header_notes, but the display is the same, why two arrays ?
After test, the display is better if messages are in the #content block, so I've put the messages template in a file messages.tpl included in ALL page (even where we don't need messages in the core)
yep it's much better if it could be a .tpl.
Could we integer also the mysql error in it ? Is there a way to catch them ? Then we would be able to filter the type of message displayed if is_admin or not
[Bugtracker, bug 2538, fixed] Make a unified messages management
well I didn't think to add fonctionnalities but rewrite the existing one
what the interest of display MySQL errors ? in most cases the engine just said there is a syntax error with an approximative location (very very approximative)
and in thoses cases the corresponding php script crashes with enough info (not less that mysql provides)
ouch I don't understand what I say ! but yeah I don't like MySQL error reporting :)
Last edited by mistic100 (2011-12-18 22:41:04)
I also want to add a session variable to save info or error message to be displayed after a redirection.
Maybe this can be done throught a function...
We can also make an easy way to add dynamic message with jQuery (after an ajax request for example...)
I've reviewed the patch by mistic100 (and it was commited in [Subversion] r12764), I agree with this changes: it makes the code on gallery side equivalent to admin side, regarding errors/infos display.
I've duplicate what is done in admin.php http://piwigo.org/dev/changeset/12764#file2
it reads $_SESSION['page_infos']) and $_SESSION['page_errors']) vars