Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2017-11-09 11:10:41

etc
Developer
Registered: 2010-11-11
Posts: 5,187
Website GitHub

Re: Add the ability to alterate admin UI messages

NicolasGraph wrote #307739:

No, the page is updated normally; nothing more.

Then it’s probably not async. Check the posted data in browser console.

Offline

#14 2017-11-09 11:13:37

etc
Developer
Registered: 2010-11-11
Posts: 5,187
Website GitHub

Re: Add the ability to alterate admin UI messages

Or try this:

...
        public function sendMessage($event, $step)
        {
            send_script_response(announce(array('ERROR!', E_ERROR)));

            exit;
        }
...

Offline

#15 2017-11-09 11:49:38

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Add the ability to alterate admin UI messages

etc wrote #307741:

Then it’s probably not async. Check the posted data in browser console.

It is in async mode, but my custom message is overridden.
See the response in the console:

;
                $(document).ready(function ()
                {
                    $("#messagepane").html("<span class=\"messageflash error\" role=\"alert\" aria-live=\"assertive\"><span class=\"ui-icon ui-icon-alert\"></span> ERROR!&#160;<a class=\"close\" role=\"button\" title=\"Close\" aria-label=\"Close\" href=\"#close\">&#215;</a></span>");
                });;
;
                $(document).ready(function ()
                {
                    $("#messagepane").html("<span class=\"messageflash success\" role=\"alert\" aria-live=\"assertive\"><span class=\"ui-icon ui-icon-check\"></span> Page <strong>error_defa</strong> updated.&#160;<a class=\"close\" role=\"button\" title=\"Close\" aria-label=\"Close\" href=\"#close\">&#215;</a></span>");
                });;
var $html = $("<div>\n<section class=\"txp-details\" id=\"all_pages\" aria-labelledby=\"all_pages-label\">\n<h3 id=\"all_pages-label\">All pages</h3>\n\n<div role=\"group\"><ul class=\"switcher-list\"><li class=\"active\">\n<a href=\"?event=page&amp;name=error_defa&amp;_txp_token=c5db78b24de2a4042322ff89b8056790\">error_defa</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"error_defa\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&amp;name=j&amp;_txp_token=c5db78b24de2a4042322ff89b8056790\">j</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"j\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&amp;name=jhffh&amp;_txp_token=c5db78b24de2a4042322ff89b8056790\">jhffh</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"jhffh\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&amp;name=jhgj&amp;_txp_token=c5db78b24de2a4042322ff89b8056790\">jhgj</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"jhgj\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&amp;name=jhgjh&amp;_txp_token=c5db78b24de2a4042322ff89b8056790\">jhgjh</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"jhgjh\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&amp;name=khgjg&amp;_txp_token=c5db78b24de2a4042322ff89b8056790\">khgjg</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"khgjg\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&amp;name=lo&amp;_txp_token=c5db78b24de2a4042322ff89b8056790\">lo</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"lo\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&amp;name=mo&amp;_txp_token=c5db78b24de2a4042322ff89b8056790\">mo</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"mo\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&amp;name=no&amp;_txp_token=c5db78b24de2a4042322ff89b8056790\">no</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"no\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&amp;name=salut&amp;_txp_token=c5db78b24de2a4042322ff89b8056790\">salut</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"salut\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&amp;name=yeo&amp;_txp_token=c5db78b24de2a4042322ff89b8056790\">yeo</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"yeo\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&amp;name=yes&amp;_txp_token=c5db78b24de2a4042322ff89b8056790\">yes</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"yes\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&amp;name=Yop&amp;_txp_token=c5db78b24de2a4042322ff89b8056790\">Yop</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"Yop\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li></ul>\n</div>\n</section></div>");
$("#all_pages").replaceWith($html.find("#all_pages"));
var $html = $("<div>\n<div class=\"txp-form-field name\">\n<div class=\"txp-form-field-label\"><label for=\"new_page\">Page name</label></div>\n<div class=\"txp-form-field-value\">\n<input class=\"input-medium\" id=\"new_page\" name=\"newname\" type=\"text\" size=\"16\" required=\"required\" value=\"error_defa\" /></div>\n</div>\n<input name=\"name\" type=\"hidden\" value=\"error_defa\" />\n<input name=\"skin\" type=\"hidden\" value=\"b\" />\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_save\" /></div>");
$("div.name").replaceWith($html.find("div.name"));
$("#new_page,input[name=name]").val("error_defa");

Last edited by NicolasGraph (2017-11-09 11:50:02)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#16 2017-11-09 12:47:43

etc
Developer
Registered: 2010-11-11
Posts: 5,187
Website GitHub

Re: Add the ability to alterate admin UI messages

Even with exit? Anyway, I will commit shortly a more flexible messaging system, please be my guest.

Offline

#17 2017-11-09 13:07:21

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Add the ability to alterate admin UI messages

etc wrote #307748:

Even with exit?

Sorry for my inattention, it works with exit.

Anyway, I will commit shortly a more flexible messaging system, please be my guest.

Sure!


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#18 2017-11-09 14:10:29

etc
Developer
Registered: 2010-11-11
Posts: 5,187
Website GitHub

Re: Add the ability to alterate admin UI messages

Now you should be able to inject your own message, try replacing exit with return again.

Offline

#19 2017-11-10 07:53:24

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Add the ability to alterate admin UI messages

etc wrote #307751:

Now you should be able to inject your own message, try replacing exit with return again.

Thanks; my custom message is now prepended to the existing one and the error status is correctly alterated. Maybe it should come after the one generated by the core? No big deal.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#20 2017-11-10 09:04:04

etc
Developer
Registered: 2010-11-11
Posts: 5,187
Website GitHub

Re: Add the ability to alterate admin UI messages

NicolasGraph wrote #307760:

Thanks; my custom message is now prepended to the existing one and the error status is correctly alterated. Maybe it should come after the one generated by the core? No big deal.

Messages are appended as they arrive. This can be tweaked, but needs some thinking first.

Offline

#21 2018-07-10 11:20:26

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Add the ability to alterate admin UI messages

Hi, I’m back in this thread because I would like to affect the Preferences tab related message on saving but I can’t; it is not in async mode. Anything I could do?
Thanks.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

Board footer

Powered by FluxBB