3 # This program is in the public domain within the United States. Additionally,
4 # we waive copyright and related rights in the work worldwide through the CC0
5 # 1.0 Universal public domain dedication, which can be found at
6 # http://creativecommons.org/publicdomain/zero/1.0/
9 # This file is useful for putting message box(es) on the screen. If you include
10 # session_messages.php these messages can even persist accross http redirects
11 # (such as you should do after receiving a POST.
13 # Just call message("message here") whenever you have something to report.
16 # Once a template is loaded, call display_messages(). run.php will call
17 # display_messages() for you automaticallly after your main function returns
18 # (so long as you require_once this file.) If you want these messages to
19 # persist accross browser redirects, then you should
20 # require_once(__DIR__.'/'.'lib/wfpl/session_messages.php')
22 # Just make sure your template has a <!--~$messages {~--> section with a
23 # ~message html~ tag in it.
27 # <!--~$messages {~-->
28 # <p>~message html~</p>
31 # Full-featured example:
33 # <!--~$messages once_if {~-->
34 # <div id="wfpl_messages">
35 # <!--~$messages {~-->
36 # <p>~message html~</p>
44 require_once(__DIR__.'/'.'template.php');
46 # call this to display a message
47 function message($msg) {
48 if(!isset($GLOBALS['wfpl_messages'])) {
49 $GLOBALS['wfpl_messages'] = array();
52 $GLOBALS['wfpl_messages'][] = $msg;
56 function get_messages() {
57 if(!isset($GLOBALS['wfpl_messages'])) {
60 $messages = $GLOBALS['wfpl_messages'];
61 unset($GLOBALS['wfpl_messages']);
64 if(function_exists('session_restore_messages')) {
65 $messages = array_merge(session_restore_messages(), $messages);
71 # called automatically by run.php
72 function display_messages(&$tem = NULL, $key = '$messages') {
74 $tem = &$GLOBALS['wfpl_template'];
76 $tem->data[$key] = columnize(get_messages(), 'message');