Fixing "broken" strings
[squirrelmail.git] / functions / display_messages.php
CommitLineData
59177427 1<?php
2ba13803 2
35586184 3/**
4 * display_messages.php
5 *
82d304a0 6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This contains all messages, including information, error, and just
10 * about any other message you can think of.
11 *
31841a9e 12 * @version $Id$
d6c32258 13 * @package squirrelmail
35586184 14 */
3302d0d4 15
5100f68f 16/**
17 * including plugin functions
18 */
ebb9eaaf 19require_once(SM_PATH . 'functions/plugin.php');
20
c94b297c 21/**
22 * Find out where squirrelmail lives and try to be smart about it.
23 * The only problem would be when squirrelmail lives in directories
24 * called "src", "functions", or "plugins", but people who do that need
25 * to be beaten with a steel pipe anyway.
26 *
d6c32258 27 * @return string the base uri of squirrelmail installation.
c94b297c 28 */
399846ea 29function sqm_baseuri(){
30 global $base_uri, $PHP_SELF;
c94b297c 31 /**
32 * If it is in the session, just return it.
33 */
399846ea 34 if (isset($base_uri)){
35 return $base_uri;
36 }
7e156b3d 37 $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|');
38 $repl = array('', '', '');
399846ea 39 $base_uri = preg_replace($dirs, $repl, $PHP_SELF);
40 return $base_uri;
41}
42
ec5b189b 43function error_message($message, $mailbox, $sort, $startMessage, $color) {
44 $urlMailbox = urlencode($mailbox);
2ea16421 45 $string = '<tr><td align="center">' . $message . '</td></tr>'.
46 '<tr><td align="center">'.
47 '<a href="'.sqm_baseuri()."src/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=$urlMailbox\">".
48 sprintf (_("Click here to return to %s"),
49 strtoupper($mailbox) == 'INBOX' ? _("INBOX") : imap_utf7_decode_local($mailbox)).
50 '</a></td></tr>';
fd2611e9 51 error_box($string, $color);
ec5b189b 52}
aa4c3749 53
ec5b189b 54function plain_error_message($message, $color) {
fd2611e9 55 error_box($message, $color);
ec5b189b 56}
b6d8d08d 57
9be8198d 58function logout_error( $errString, $errTitle = '' ) {
1f05436e 59 global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
35185c82 60 $hide_sm_attributions, $version, $squirrelmail_language;
61
399846ea 62 $base_uri = sqm_baseuri();
26f9a94a 63
64 include_once( SM_PATH . 'functions/page_header.php' );
9be8198d 65 if ( !isset( $org_logo ) ) {
66 // Don't know yet why, but in some accesses $org_logo is not set.
26f9a94a 67 include( SM_PATH . 'config/config.php' );
9be8198d 68 }
69 /* Display width and height like good little people */
70 $width_and_height = '';
e16cb07b 71 if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
2ea16421 72 $width_and_height = " width=\"$org_logo_width\"";
9be8198d 73 }
e16cb07b 74 if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
2ea16421 75 $width_and_height .= " height=\"$org_logo_height\"";
9be8198d 76 }
77
78 if (!isset($frame_top) || $frame_top == '' ) {
79 $frame_top = '_top';
80 }
81
82 if ( !isset( $color ) ) {
83 $color = array();
2ea16421 84 $color[0] = '#dcdcdc'; /* light gray TitleBar */
9be8198d 85 $color[1] = '#800000'; /* red */
2ea16421 86 $color[2] = '#cc0000'; /* light red Warning/Error Messages */
87 $color[4] = '#ffffff'; /* white Normal Background */
88 $color[7] = '#0000cc'; /* blue Links */
9be8198d 89 $color[8] = '#000000'; /* black Normal text */
9be8198d 90 }
91
8d42e09a 92 list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle);
93
9be8198d 94 if ( $errTitle == '' ) {
2ea16421 95 $errTitle = $org_name . ' - ' . $errString;
9be8198d 96 }
97 set_up_language($squirrelmail_language, true);
1f05436e 98
99 displayHtmlHeader( $errTitle, '', false );
100
2ea16421 101 echo '<body text="'.$color[8].'" bgcolor="'.$color[4].'" link="'.$color[7].'" vlink="'.$color[7].'" alink="'.$color[7]."\">\n\n".
102 '<center>';
4cbcaebd 103
104 if (isset($org_logo) && ($org_logo != '')) {
2ea16421 105 echo '<img src="'.$org_logo.'" alt="'.sprintf(_("%s Logo"), $org_name).
106 "\"$width_and_height /><br />\n";
4cbcaebd 107 }
108 echo ( $hide_sm_attributions ? '' :
2ea16421 109 '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br />'.
110 _("By the SquirrelMail Development Team") . "<br /></small>\n" ).
111 '<table cellspacing="1" cellpadding="0" bgcolor="'.$color[1].'" width="70%">'.
112 '<tr><td>'.
113 '<table width="100%" border="0" bgcolor="'.$color[4].'" align="center">'.
114 '<tr><td bgcolor="'.$color[0].'" align="center">'.
115 '<font color="'.$color[2].'"><b>' . _("ERROR") . '</b></font>'.
116 '</td></tr>'.
117 '<tr><td align="center">' . $errString . '</td></tr>'.
118 '<tr><td bgcolor="'.$color[0].'" align="center">'.
119 '<font color="'.$color[2].'"><b>'.
120 '<a href="'.$base_uri.'src/login.php" target="'.$frame_top.'">'.
121 _("Go to the login page") . '</a></b></font></td></tr>'.
122 '</table></td></tr></table></center></body></html>';
9be8198d 123}
124
fd2611e9 125function error_box($string, $color) {
b6c283c4 126 global $pageheader_sent;
127
a429618b 128 if ( !isset( $color ) ) {
129 $color = array();
2ea16421 130 $color[0] = '#dcdcdc'; /* light gray TitleBar */
a429618b 131 $color[1] = '#800000'; /* red */
2ea16421 132 $color[2] = '#cc0000'; /* light red Warning/Error Messages */
133 $color[4] = '#ffffff'; /* white Normal Background */
134 $color[7] = '#0000cc'; /* blue Links */
a429618b 135 $color[8] = '#000000'; /* black Normal text */
2ea16421 136 $color[9] = '#ababab'; /* mid-gray Darker version of #0 */
a429618b 137 }
138
b6c283c4 139 $err = _("ERROR");
140
7753dac4 141 $ret = concat_hook_function('error_box', $string);
142 if($ret != '') {
143 $string = $ret;
144 }
8d42e09a 145
b6c283c4 146 /* check if the page header has been sent; if not, send it! */
147 if(!isset($pageheader_sent) && !$pageheader_sent) {
148 /* include this just to be sure */
149 include_once( SM_PATH . 'functions/page_header.php' );
150 displayHtmlHeader('SquirrelMail: '.$err);
151 $pageheader_sent = TRUE;
152 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n\n";
153 }
154
2ea16421 155 echo '<table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">'.
156 '<tr><td>'.
157 '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">'.
158 '<tr><td align="center" bgcolor="'.$color[0].'">'.
159 '<font color="'.$color[2].'"><b>' . $err . ':</b></font>'.
160 '</td></tr><tr><td>'.
161 '<table cellpadding="1" cellspacing="5" align="center" border="0">'.
162 '<tr>' . html_tag( 'td', $string."\n", 'left') . '</tr></table>'.
163 '</td></tr></table></td></tr></table>';
fd2611e9 164}
6c92ca88 165
288df1a0 166/**
167 * Adds message that informs about non fatal error that can happen while saving preferences
168 * @param string $message error message
169 * @since 1.5.1
170 */
171function error_option_save($message) {
172 global $optpage_save_error;
173
174 if (! is_array($optpage_save_error) )
175 $optpage_save_error=array();
176
177 $optpage_save_error=array_merge($optpage_save_error,array($message));
178}
6c92ca88 179// vim: et ts=4
2ea16421 180?>