1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164:
<?php
/**
* A static class for on-screen messages
*
* Using a static class instead of a include file with global functions, along with
* autoloading of classes, reduces the memory usage and only includes files when needed.
*
* @copyright (c) 2007-2008 The ImpressCMS Project - www.impresscms.org
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL)
* @category ICMS
* @package Core
* @subpackage Message
* @since 1.3
* @version SVN: $Id: Message.php 12310 2013-09-13 21:33:58Z skenow $
*/
/**
* Create and display messages on the screen
*/
class icms_core_Message {
/* Since all the methods are static, there is no __construct necessary */
/**
* Replaces xoops_warning() and icms_warning_msg()
* Given either an array of messages or a string, and an optional title, create a formatted warning
* message
*
* @author XOOPS - include/functions.php :: xoops_warning()
* @author modified by skenow <skenow@impresscms.org>
* @copyright copyright (c) 2000-2003 XOOPS.org
* You should have received a copy of XOOPS_copyrights.txt with
* this file. If not, you may obtain a copy from xoops.org
*
* @param string $msg
* @param string $title
* @param boolean $render
*/
static public function warning($msg, $title='', $render = FALSE) {
$ret = '<div class="warningMsg">';
if ($title != '') {
$ret .= '<h4>' . $title . '</h4>';
}
if (is_array($msg)) {
foreach ($msg as $m) {
$ret .= $m . '<br />';
}
} else {
$ret .= $msg;
}
$ret .= '</div>';
if ($render) {
echo $ret;
} else {
return $ret;
}
}
/**
* Replaces icms_error_msg()
*
* @author XOOPS - include/functions.php :: xoops_error()
* @copyright copyright (c) 2000-2003 XOOPS.org
* You should have received a copy of XOOPS_copyrights.txt with
* this file. If not, you may obtain a copy from xoops.org
*
* @param string $msg
* @param string $title
* @param boolean $render
* @return mixed
*/
static public function error($msg, $title = '', $render = true) {
$ret = '<div class="errorMsg">';
if ($title != '') {
$ret .= '<h4>' . $title . '</h4>';
}
if (is_array($msg)) {
foreach ($msg as $m) {
$ret .= $m . '<br />';
}
} else {
$ret .= $msg;
}
$ret .= '</div>';
if ($render) {
echo $ret;
} else {
return $ret;
}
}
/**
* Render result message (echo, so no return string)
*
* @author XOOPS - include/functions.php :: xoops_result()
* @copyright copyright (c) 2000-2003 XOOPS.org
* You should have received a copy of XOOPS_copyrights.txt with
* this file. If not, you may obtain a copy from xoops.org
*
* @author modified by skenow <skenow@impresscms.org>
* @param string $msg
* @param string $title
* @return void
*/
static public function result($msg, $title='') {
echo '<div class="resultMsg">';
if ($title != '') {
echo '<h4>' . $title . '</h4>';
}
if (is_array($msg)) {
foreach ($msg as $m) {
echo $m . '<br />';
}
} else {
echo $msg;
}
echo '</div>';
}
/**
* Will render (echo) the form so no return in this function
*
* @author XOOPS - include/functions.php :: xoops_confirm()
* @author modified by skenow <skenow@impresscms.org>
* @copyright copyright (c) 2000-2003 XOOPS.org
* You should have received a copy of XOOPS_copyrights.txt with
* this file. If not, you may obtain a copy from xoops.org
*
* @param array $hiddens Array of Hidden values
* @param string $action The Form action
* @param string $msg The message in the confirm form
* @param string $submit The text on the submit button
* @param boolean $addtoken Whether or not to add a security token
* @return void
*/
static public function confirm($hiddens, $action, $msg, $submit='', $addtoken = true) {
$submit = ($submit != '') ? trim($submit) : _SUBMIT;
echo '<div class="confirmMsg">
<h4>' . $msg . '</h4>
<form method="post" action="' . $action . '">';
foreach ($hiddens as $name => $value) {
if (is_array($value)) {
foreach ($value as $caption => $newvalue) {
echo '<input type="radio" name="' . $name . '" value="'
. htmlspecialchars($newvalue) . '" /> ' . $caption;
}
echo '<br />';
} else {
echo '<input type="hidden" name="' . $name . '" value="'
. htmlspecialchars($value) . '" />';
}
}
if ($addtoken !== false) {
echo icms::$security->getTokenHTML();
}
echo '<input type="submit" name="confirm_submit" value="' . $submit
. '" /> <input type="button" name="confirm_back" value="' . _CANCEL
.'" onclick="javascript:history.go(-1);" />
</form></div>';
}
}