2 /***********************************************************************/
4 /***********************************************************************/
5 /* Copyright (c) 2002-2009 */
6 /* Adaptive Technology Resource Centre / Inclusive Design Institution */
9 /* This program is free software. You can redistribute it and/or */
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /***********************************************************************/
14 if (!defined('AT_INCLUDE_PATH')) exit;
18 * Returns a plain message without using the savant template.
23 class AjaxMessage extends Message {
25 * Override constructor
27 function AjaxMessage(){
31 * Overrides Message.printAbstract. Now prings plain message
33 * @param string $type error|warning|info|feedback|help|help_pop
34 * @return string Singular message instant
37 function printAbstract($type) {
38 if (!isset($_SESSION['message'][$type])) return;
42 foreach($_SESSION['message'][$type] as $e => $item) {
45 // $item is either just a code or an array of argument with a particular code
46 if (is_array($item)) {
47 /* this is an array with terms to replace */
48 $first = array_shift($item);
49 $result = _AT($first); // lets translate the code
51 if ($result == '') { // if the code is not in the db lets just print out the code for easier trackdown
52 $result = '[' . $first . ']';
57 /* replace the tokens with the terms */
58 $result = vsprintf($result, $terms);
62 if ($result == '') // if the code is not in the db lets just print out the code for easier trackdown
63 $result = '[' . $item . ']';
66 array_push($_result, $result); // append to array
69 unset($_SESSION['message'][$type]);
71 if (count($_result) > 0) {
72 foreach ($_result as $e){
73 $e = preg_replace('/<small>(.*)<\/small>/', '', $e);
81 function printErrors($optional=null) {
82 if ($optional != null) // shortcut
83 $this->addAbstract('error', $optional);
84 return $this->printAbstract('error');