75429eb2840bf2f2230162d6eaf448be2ae7524c
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * The idea is to inlcude here some functions to make easier
10 * the right to left implementation by "functionize" some
16 function html_tag( $tag,
21 GLOBAL $languages, $language;
23 $align = strtolower( $align );
24 $dir = strtolower( $dir );
26 if ( isset( $languages[$language]['DIR']) ) {
27 $dir = $languages[$language]['DIR'];
32 if ( $dir == 'ltr' ) {
40 if ( $bgcolor <> '' ) {
41 $bgc = " BGCOLOR=\"$bgcolor\"";
49 $alg = " ALIGN=\"$rgt\"";
52 $alg = " ALIGN=\"$lft\"";
55 return( "<$tag DIR=\"$dir\"$bgc$alg $xtra>" );
60 * Copyright (c) 2001 Partridge
61 * Licensed under the GNU GPL. For full terms see the file COPYING.
69 * The ZkSvc_html class manages html output.
74 var $name = 'html'; // Module name
78 var $buffer; // Buffered output
79 var $htmlmod; // Module handler
80 var $title; // Page title
81 var $head_extras; // Extra header tags
82 var $bgcolor; // Background color
83 var $text; // Text color
84 var $link; // Link color
85 var $vlink; // Visited link color
86 var $alink; // Active link color
87 var $onload; // Onload event
88 var $onunload; // OnUnload event
89 var $dir; // Text direction
91 var $tag_options; // Array of tag options array
96 function ZkSvc_html() {
98 GLOBAL $languages, $language;
100 $this->spool
= FALSE;
102 $this->title
= 'Default zkHTML Title';
103 $this->head_extras
= '';
104 $this->bgcolor
= '#FFFFFF';
105 $this->text
= '#000000';
106 $this->link
= '#3300CC';
107 $this->vlink
= '#993333';
108 $this->alink
= '#993333';
110 $this->onunload
= '';
112 /* To know if a tag exists we check that it has got a place in the following array */
113 $this->tag_options
= array( 'table' => array( 'tag_name' => 'table',
114 'tag_closed' => TRUE ),
115 'tr' => array( 'tag_name' => 'tr',
116 'tag_closed' => TRUE ),
117 'th' => array( 'tag_name' => 'th',
118 'tag_closed' => TRUE ),
119 'td' => array( 'tag_name' => 'td',
120 'tag_closed' => TRUE ),
121 'li' => array( 'tag_name' => 'li',
122 'tag_closed' => TRUE ),
123 'ol' => array( 'tag_name' => 'ol',
124 'tag_closed' => TRUE ),
125 'form' => array( 'tag_name' => 'form',
126 'tag_closed' => TRUE ),
127 'input' => array( 'tag_name' => 'input',
128 'tag_closed' => FALSE ),
129 'br' => array( 'tag_name' => 'br',
130 'tag_closed' => FALSE ),
131 'textarea' => array( 'tag_name' => 'textarea',
132 'tag_closed' => TRUE ),
133 'p' => array( 'tag_name' => 'p',
134 'tag_closed' => TRUE ),
135 'a' => array( 'tag_name' => 'a',
136 'tag_closed' => TRUE ),
137 'center' => array( 'name' => 'center',
138 'tag_closed' => TRUE ),
139 'img' => array( 'name' => 'img',
140 'tag_closed' => FALSE ),
141 'font' => array( 'tag_closed' => TRUE ),
142 'blockquote' => array( 'tag_name' => 'blockquote',
143 'tag_closed' => TRUE )
146 if ( isset( $languages[$language]['DIR']) ) {
147 $this->dir
= strtolower( $languages[$language]['DIR'] );
155 * Return the name of this service.
157 * @return string the name of this service
159 function getServiceName() {
160 return( $this->name
);
164 * Replace the Zookeeper html module loaded for this service. (no modules yet)
167 function loadModule(&$module) {
168 $this->htmlmod
= &$module;
172 * Outputs the buffer and re-initialize it.
175 function flush( $string = '' ) {
176 echo $this->buffer
. $string;
182 * Builds a header string
185 function header( $string = '' ) {
187 // It initializes the buffer.
188 $this->buffer
= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' .
191 if( $this->head_extras
<> '' ||
$this->title
<> '' ) {
193 $this->buffer
.= "<HEAD>\n";
195 if( $this->title
<> '' )
196 $this->buffer
.= "<TITLE>$this->title</TITLE>\n";
198 $this->buffer
.= "$this->head_extras</HEAD>\n";
201 if ( $this->onload
<> '' ) {
202 $xtra .= ' onload="' . $this->onload
. '" ';
204 if ( $this->onunload
<> '' ) {
205 $xtra .= ' onunload="' . $this->onunload
. '" ';
207 $this->buffer
.= "<BODY TEXT=\"$this->text\" BGCOLOR=\"$this->bgcolor\" LINK=\"$this->link\" VLINK=\"$this->vlink\" ALINK=\"$this->alink\" $xtra>\n";
209 /* See if we're asking for a closed strcuture */
210 if( $string == '' ) {
213 $this->buffer
.= $string . '</BODY></HTML>';
219 * Builds a footer string
224 $this->buffer
.= "\n</body>\n</html>\n";
230 * Builds a tag string
233 function tag( $tag, $string = '', $options = '' ) {
236 if( $this->tag_options
[$tag] <> NULL ) {
237 if( $options == '' ) {
238 $options = $this->tag_options
[$tag];
240 switch( strtolower( $tag ) ) {
243 if ( $this->dir
== 'rtl' && isset( $options['align'] ) ) {
247 if ( $this->dir
<> '' ) {
248 $options['DIR'] = $this->dir
;
252 $ret = zkTag_html( $tag, $string, $options, $this->tag_options
[$tag]['tag_closed'] );
259 * Builds a header string
262 function h( $string, $level = '1' ) {
264 $buffer = "<h$level>";
266 /* See if we're asking for a closed strcuture */
267 if( $string == '' ) {
268 $this->$buffer .= $buffer;
270 $buffer .= $string . "</h$level>";
279 * Converts an array into a parameters tag list.
282 function zkGetParms_html( $parms ) {
285 foreach( $parms as $key => $opt ) {
286 if( substr( $key, 0, 3 ) <> 'tag' ) {
289 $buffer .= "=\"$opt\"";
297 * Composes a tag string with all its parameters.
300 function zkTag_html( $tag, $string, $options, $closed ) {
303 We must check direction tag in case we have table, td or th
307 zkGetParms_html( $options ) .
318 function optionize( $name, $opts, $default, $xtra = '' ) {
320 $ret = "<select name=\"$name\" $xtra>\n";
322 foreach( $opts as $key => $opt ) {
323 if( $opt == $default ) {
328 $ret .= "<option value=\"$opt\"$chk>$opt</option>\n";
331 $ret .= "</select>\n";