3 # Copyright (C) 2007 Jason Woofenden
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This file is useful for putting message box(es) on the screen.
21 # Just call message("message here") whenever you have something to report.
23 # Once a template is loaded, call display_messages(). Your template should have
24 # a <!--~message?~--> section with a ~text:html~ tag in it.
26 # If you want a divider (any text between message boxes when there are
27 # multiple boxes) provide a sub-template section named "separator"
28 # INSIDE "message" at the begining of it.
30 # If you'd like something around the group of all message boxes, you can put
31 # the whole thing in a sub-template section called "messages"
39 # Full-featured example:
42 # <div style="border: 2px solid red; background: #f88; padding: 5px">
47 # <p style="font-size: 120%">~text:html~</p>
52 require_once('code/wfpl/template.php');
54 function message($msg) {
55 if(!isset($GLOBALS['wfpl_messages'])) {
56 if(function_exists('session_restore_messages')) {
57 $GLOBALS['wfpl_messages'] = session_restore_messages();
58 } else $GLOBALS['wfpl_messages'] = array();
61 $GLOBALS['wfpl_messages'][] = $msg;
64 function display_messages(&$tem = NULL) {
65 if(!$GLOBALS['wfpl_messages']) return;
66 foreach($GLOBALS['wfpl_messages'] as $msg) {
67 $sub = array('text' => $msg);
68 $GLOBALS['wfpl_template']['message'][] = $sub;
69 $GLOBALS['wfpl_template']['messages'] = TRUE;