···147147 array_push($_SESSION["flash_notices"], $string);
148148 }
149149150150+ /* store a success message in the session to be printed on the next view
151151+ * with the flash_success() helper */
152152+ public function add_flash_success($string) {
153153+ if (!isset($_SESSION["flash_successes"]) ||
154154+ !is_array($_SESSION["flash_successes"]))
155155+ $_SESSION["flash_successes"] = array();
156156+157157+ array_push($_SESSION["flash_successes"], $string);
158158+ }
159159+150160 /* cancel all buffered output, send a location: header and stop processing */
151161 public function redirect_to($obj_or_url) {
152162 $link = HTMLHelper::link_from_obj_or_string($obj_or_url);
+19
lib/helpers/html_helper.php
···108108 return $html;
109109 }
110110111111+ /* print the successes stored in the session and then reset the array */
112112+ public function flash_successes() {
113113+ $html = "";
114114+115115+ if (isset($_SESSION["flash_successes"]) &&
116116+ count((array)$_SESSION["flash_successes"])) {
117117+ $html = "<div class=\"flash-success\">"
118118+ . implode("<br />\n", array_map(function($e) {
119119+ return raw_or_h($e); },
120120+ (array)$_SESSION["flash_successes"]))
121121+ . "</div>";
122122+123123+ /* clear out for the next view */
124124+ $_SESSION["flash_successes"] = array();
125125+ }
126126+127127+ return $html;
128128+ }
129129+111130 /* create a link to a javascript file, appending its modification time to
112131 * force clients to reload it when it's modified */
113132 public function javascript_include_tag($files) {
+8-1
lib/utilities.php
···143143144144 /* when passed a closure containing print/<?=?> code, execute it, capture the
145145 * output, and return it as a string */
146146- static function to_s($obj, $closure) {
146146+ static function to_s($obj, $closure, $bind = null) {
147147 ob_start();
148148+149149+ if (version_compare(PHP_VERSION, "5.4.0") >= 0)
150150+ /* setup $this */
151151+ if (!empty($bind))
152152+ $closure->bindTo($bind);
153153+148154 $closure($obj);
155155+149156 $str = ob_get_contents();
150157 ob_end_clean();
151158