6 * The idea is to inlcude here some functions to make easier
7 * the right to left implementation by "functionize" some
10 * @copyright © 1999-2006 The SquirrelMail Project Team
11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 * @package squirrelmail
19 * Generates a hyperlink
21 * @param string $uri The target link location
22 * @param string $text The link text
23 * @param string $target The location where the link should
24 * be opened (OPTIONAL; default not used)
25 * @param string $onclick The onClick JavaScript handler (OPTIONAL;
27 * @param string $class The CSS class name (OPTIONAL; default
29 * @param string $id The ID name (OPTIONAL; default not used)
31 * @return string The desired hyperlink tag.
36 function create_hyperlink($uri, $text, $target='', $onclick='', $class='', $id='') {
40 $oTemplate->assign('uri', $uri);
41 $oTemplate->assign('text', $text);
42 $oTemplate->assign('target', $target);
43 $oTemplate->assign('onclick', $onclick);
44 $oTemplate->assign('class', $class);
45 $oTemplate->assign('id', $id);
47 return $oTemplate->fetch('hyperlink.tpl');
53 * Generates an image tag
55 * @param string $src The image source path
56 * @param string $alt Alternate link text (OPTIONAL; default
58 * @param string $width The width the image should be shown in
59 * (OPTIONAL; default not used)
60 * @param string $height The height the image should be shown in
61 * (OPTIONAL; default not used)
62 * @param string $border The image's border attribute value
63 * (OPTIONAL; default not used)
64 * @param string $class The CSS class name (OPTIONAL; default
66 * @param string $id The ID name (OPTIONAL; default not used)
67 * @param string $onclick The onClick JavaScript handler (OPTIONAL;
69 * @param string $title The image's title attribute value
70 * (OPTIONAL; default not used)
71 * @param string $align The image's alignment attribute value
72 * (OPTIONAL; default not used)
73 * @param string $hspace The image's hspace attribute value
74 * (OPTIONAL; default not used)
75 * @param string $vspace The image's vspace attribute value
76 * (OPTIONAL; default not used)
78 * @return string The desired hyperlink tag.
83 function create_image($src, $alt='', $width='', $height='',
84 $border='', $class='', $id='', $onclick='',
85 $title='', $align='', $hspace='', $vspace='') {
89 $oTemplate->assign('src', $src);
90 $oTemplate->assign('alt', $alt);
91 $oTemplate->assign('width', $width);
92 $oTemplate->assign('height', $height);
93 $oTemplate->assign('border', $border);
94 $oTemplate->assign('class', $class);
95 $oTemplate->assign('id', $id);
96 $oTemplate->assign('onclick', $onclick);
97 $oTemplate->assign('title', $title);
98 $oTemplate->assign('align', $align);
99 $oTemplate->assign('hspace', $hspace);
100 $oTemplate->assign('vspace', $vspace);
102 return $oTemplate->fetch('image.tpl');
108 * Generates html tags
110 * @param string $tag Tag to output
111 * @param string $val Value between tags
112 * @param string $align Alignment (left, center, etc)
113 * @param string $bgcolor Back color in hexadecimal
114 * @param string $xtra Extra options
115 * @return string HTML ready for output
118 function html_tag( $tag, // Tag to output
119 $val = '', // Value between tags
120 $align = '', // Alignment
121 $bgcolor = '', // Back color
122 $xtra = '' ) { // Extra options
124 GLOBAL $languages, $squirrelmail_language;
126 $align = strtolower( $align );
128 $tag = strtolower( $tag );
130 if ( isset( $languages[$squirrelmail_language]['DIR']) ) {
131 $dir = $languages[$squirrelmail_language]['DIR'];
136 if ( $dir == 'ltr' ) {
144 if ( $bgcolor <> '' ) {
145 $bgc = " bgcolor=\"$bgcolor\"";
153 $alg = " align=\"$rgt\"";
156 $alg = " align=\"$lft\"";
159 $alg = " align=\"$align\"";
165 if ( $dir <> 'ltr' ) {
166 $ret .= " dir=\"$dir\"";
175 $ret .= ">$val</$tag>\n";
185 * handy function to set url vars
187 * especially useful when $url = $PHP_SELF
188 * @param string $url url that must be modified
189 * @param string $var variable name
190 * @param string $val variable value
191 * @param boolean $link controls sanitizing of ampersand in urls (since 1.3.2)
192 * @return string $url modified url
195 function set_url_var($url, $var, $val=0, $link=true) {
198 '/.+(\\&'.$var.')=(.*)\\&/AU', /* in the middle */
199 '/.+\\?('.$var.')=(.*\\&).+/AU', /* at front, more follow */
200 '/.+(\\?'.$var.')=(.*)$/AU', /* at front and only var */
201 '/.+(\\&'.$var.')=(.*)$/AU' /* at the end */
203 $url = str_replace('&','&',$url);
205 // FIXME: why switch is used instead of if () or one preg_match()
207 case (preg_match($pat_a[0],$url,$regs)):
211 case (preg_match($pat_a[1],$url,$regs)):
215 case (preg_match($pat_a[2],$url,$regs)):
219 case (preg_match($pat_a[3],$url,$regs)):
225 if (strpos($url,'?')) {
226 $url .= "&$var=$val";
228 $url .= "?$var=$val";
240 if( substr($v,-1)=='&' ) {
244 $url = preg_replace($pat,$rpl,$url);
247 $url = str_replace('&','&',$url);