3 # Copyright (C) 2007 Jason Woofenden
5 # This file is part of wfpl.
7 # wfpl is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU Lesser General Public License as published by the Free
9 # Software Foundation; either version 2.1 of the License, or (at your option)
12 # wfpl is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with wfpl; if not, write to the Free Software Foundation, Inc., 51
19 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 # This file is useful for putting message boxe(s) on the screen.
25 # Just call message("message here") whenever you have something to report.
27 # Once a template is loaded, call display_messages(). Your template should have
28 # a <!--~message_box start~--> section with ~message_text.html~ tag in it.
30 # If you want a divider (any text between message boxes when there are multiple
31 # boxes) provide a sub-template section named "message_divider" INSIDE
32 # "message_box" at the begining of it.
34 # If you'd like something around the group of all message boxes, you can put
35 # the whole thing in a sub-template section called "message_container"
39 # <!--~message_box start~-->
40 # <p>~message_text.html~</p>
43 # Full-featured example:
45 # <!--~message_container start~-->
46 # <div style="border: 2px solid red; background: #f88; padding: 5px">
47 # <!--~message_box start~-->
48 # <!--~message_divider start~-->
51 # <p style="font-size: 120%">~message_text.html~</p>
56 require_once('code/wfpl/template.php');
58 function message($msg) {
59 if(!isset($GLOBALS['wfpl_messages'])) {
60 $GLOBALS['wfpl_messages'] = array();
63 $GLOBALS['wfpl_messages'][] = $msg;
66 # if you want the messages in a template other than the default one, pass it like so:
68 # display_messages(ref($my_template));
69 function display_messages($template = 0) {
72 $template = &$GLOBALS['wfpl_template'];
74 $template = &$template->ref;
77 if(function_exists('session_restore_messages')) {
78 session_restore_messages();
81 if($GLOBALS['wfpl_messages']) {
82 foreach($GLOBALS['wfpl_messages'] as $msg) {
86 $template->sub('message_divider');
88 $template->set('message_text', $msg);
89 $template->sub('message_box');
91 $template->sub('message_container');