--- /dev/null
+<?php
+
+# this file is much like register_shutdown_function(), except:
+#
+# 1. it uses the standard name you know and love
+#
+# 2. wfpl will call it before calling display_messages() for you, or before
+# calling session_save_messages() (when it's about to redirect.
+
+$GLOBALS['wfpl_atexit_queue'] = array();
+
+# your passed function will be called by run.php just before display_messages
+# (or right before an http redirect)
+#
+# order is fifo
+function atexit($func, $args) {
+ $GLOBALS['wfpl_atexit_queue'][] = array($func, $args);
+}
+
+# call the functions queued up by atexit()
+# atexit() can be called from one of these functions (even the last)
+function atexit_now() {
+ while(count($GLOBALS['wfpl_atexit_queue'])) {
+ list($func, $args) = array_shift($GLOBALS['wfpl_atexit_queue']);
+ call_user_func_array($func, $args);
+ }
+}
+
+# for those cases where display_messages() and session_save_messages() don't
+# get called automatically by wfpl:
+register_shutdown_function("atexit_now");
$GLOBALS['wfpl_template'] = $GLOBALS['wfpl_main_template'];
}
- # If you have a site-wide template (template.html) then messages will
- # be displayed there. If you instead want messages displayed on your
- # page, call display_messages() from your page_main().
- #
- # Either way, you'll need to require_once('code/wfpl/messages.php')
- # or require_once('code/wfpl/session_messages.php'). code/config.php
- # is a nice place to do this.
+
+ # You'll probably want to require_once('code/wfpl/messages.php') or
+ # require_once('code/wfpl/session_messages.php') in code/config.php
if(function_exists('display_messages')) {
+ if(function_exists('atexit_now')) {
+ atexit_now();
+ }
display_messages();
}