X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fhtml.php;h=ec7f90e37a186f7db2a9ce50ae3c902d36bc91ff;hb=2741e6248be474e1cd2c58aaf5f7c6682db2e59f;hp=75429eb2840bf2f2230162d6eaf448be2ae7524c;hpb=94ac35c67eff63dedaa4a7013f13d3d7a5f04e86;p=squirrelmail.git diff --git a/functions/html.php b/functions/html.php index 75429eb2..ec7f90e3 100644 --- a/functions/html.php +++ b/functions/html.php @@ -1,335 +1,351 @@ '' ) { - $bgc = " BGCOLOR=\"$bgcolor\""; - } - - switch ( $align ) { - case '': - $alg = ''; - break; - case 'right': - $alg = " ALIGN=\"$rgt\""; - break; - default: - $alg = " ALIGN=\"$lft\""; - } - - return( "<$tag DIR=\"$dir\"$bgc$alg $xtra>" ); - } - -/* - * Zookeeper - * Copyright (c) 2001 Partridge - * Licensed under the GNU GPL. For full terms see the file COPYING. - * - * $Id$ - */ /** - * ZkSvc_html + * Generates a hyperlink + * + * @param string $uri The target link location + * @param string $text The link text + * @param string $target The location where the link should + * be opened (OPTIONAL; default not used) + * @param string $onclick The onClick JavaScript handler (OPTIONAL; + * default not used) + * @param string $class The CSS class name (OPTIONAL; default + * not used) + * @param string $id The ID name (OPTIONAL; default not used) + * @param string $name The anchor name (OPTIONAL; default not used) + * @param array $aAttribs Any extra attributes: this must be an + * associative array, where keys will be + * added as the attribute name, and values + * (which are optional - should be null if + * none should be used) will be placed in + * double quotes (pending template implementation) + * as the attribute value (OPTIONAL; default empty). + * + * @return string The desired hyperlink tag. + * + * @since 1.5.2 * - * The ZkSvc_html class manages html output. */ -class ZkSvc_html { - - /* Constants */ - var $name = 'html'; // Module name - var $ver = '$Id$'; - - /* Properties */ - var $buffer; // Buffered output - var $htmlmod; // Module handler - var $title; // Page title - var $head_extras; // Extra header tags - var $bgcolor; // Background color - var $text; // Text color - var $link; // Link color - var $vlink; // Visited link color - var $alink; // Active link color - var $onload; // Onload event - var $onunload; // OnUnload event - var $dir; // Text direction - - var $tag_options; // Array of tag options array - - /** CONSTRUCTOR - */ - - function ZkSvc_html() { - - GLOBAL $languages, $language; - - $this->spool = FALSE; - $this->buffer = ''; - $this->title = 'Default zkHTML Title'; - $this->head_extras = ''; - $this->bgcolor = '#FFFFFF'; - $this->text = '#000000'; - $this->link = '#3300CC'; - $this->vlink = '#993333'; - $this->alink = '#993333'; - $this->onload = ''; - $this->onunload = ''; - - /* To know if a tag exists we check that it has got a place in the following array */ - $this->tag_options = array( 'table' => array( 'tag_name' => 'table', - 'tag_closed' => TRUE ), - 'tr' => array( 'tag_name' => 'tr', - 'tag_closed' => TRUE ), - 'th' => array( 'tag_name' => 'th', - 'tag_closed' => TRUE ), - 'td' => array( 'tag_name' => 'td', - 'tag_closed' => TRUE ), - 'li' => array( 'tag_name' => 'li', - 'tag_closed' => TRUE ), - 'ol' => array( 'tag_name' => 'ol', - 'tag_closed' => TRUE ), - 'form' => array( 'tag_name' => 'form', - 'tag_closed' => TRUE ), - 'input' => array( 'tag_name' => 'input', - 'tag_closed' => FALSE ), - 'br' => array( 'tag_name' => 'br', - 'tag_closed' => FALSE ), - 'textarea' => array( 'tag_name' => 'textarea', - 'tag_closed' => TRUE ), - 'p' => array( 'tag_name' => 'p', - 'tag_closed' => TRUE ), - 'a' => array( 'tag_name' => 'a', - 'tag_closed' => TRUE ), - 'center' => array( 'name' => 'center', - 'tag_closed' => TRUE ), - 'img' => array( 'name' => 'img', - 'tag_closed' => FALSE ), - 'font' => array( 'tag_closed' => TRUE ), - 'blockquote' => array( 'tag_name' => 'blockquote', - 'tag_closed' => TRUE ) - ); - - if ( isset( $languages[$language]['DIR']) ) { - $this->dir = strtolower( $languages[$language]['DIR'] ); - } else { - $this->dir = 'ltr'; - } - - } +function create_hyperlink($uri, $text, $target='', $onclick='', + $class='', $id='', $name='', $aAttribs=array()) { - /** - * Return the name of this service. - * - * @return string the name of this service - */ - function getServiceName() { - return( $this->name ); - } + global $oTemplate; - /** - * Replace the Zookeeper html module loaded for this service. (no modules yet) - * - */ - function loadModule(&$module) { - $this->htmlmod = &$module; - } + $oTemplate->assign('uri', $uri); + $oTemplate->assign('text', $text); + $oTemplate->assign('target', $target); + $oTemplate->assign('onclick', $onclick); + $oTemplate->assign('class', $class); + $oTemplate->assign('id', $id); + $oTemplate->assign('name', $name); - /** - * Outputs the buffer and re-initialize it. - * - */ - function flush( $string = '' ) { - echo $this->buffer . $string; - flush(); - $this->buffer = ''; - } + $oTemplate->assign('aAttribs', $aAttribs); - /** - * Builds a header string - * - */ - function header( $string = '' ) { + return $oTemplate->fetch('hyperlink.tpl'); + +} - // It initializes the buffer. - $this->buffer = '' . - "\n\n"; - if( $this->head_extras <> '' || $this->title <> '' ) { +/** + * Generates an image tag + * + * @param string $src The image source path + * @param string $alt Alternate link text (OPTIONAL; default + * not used) + * @param string $width The width the image should be shown in + * (OPTIONAL; default not used) + * @param string $height The height the image should be shown in + * (OPTIONAL; default not used) + * @param string $border The image's border attribute value + * (OPTIONAL; default not used) + * @param string $class The CSS class name (OPTIONAL; default + * not used) + * @param string $id The ID name (OPTIONAL; default not used) + * @param string $onclick The onClick JavaScript handler (OPTIONAL; + * default not used) + * @param string $title The image's title attribute value + * (OPTIONAL; default not used) + * @param string $align The image's alignment attribute value + * (OPTIONAL; default not used) + * @param string $hspace The image's hspace attribute value + * (OPTIONAL; default not used) + * @param string $vspace The image's vspace attribute value + * (OPTIONAL; default not used) + * @param string $text_alternative A text replacement for the entire + * image tag, to be used at the + * discretion of the template set, + * if for some reason the image tag + * cannot or should not be produced + * (OPTIONAL; default not used) + * @param array $aAttribs Any extra attributes: this must be an + * associative array, where keys will be + * added as the attribute name, and values + * (which are optional - should be null if + * none should be used) will be placed in + * double quotes (pending template implementation) + * as the attribute value (OPTIONAL; default empty). + * + * @return string The desired hyperlink tag. + * + * @since 1.5.2 + * + */ +function create_image($src, $alt='', $width='', $height='', + $border='', $class='', $id='', $onclick='', + $title='', $align='', $hspace='', $vspace='', + $text_alternative='', $aAttribs=array()) { + + global $oTemplate; + + $oTemplate->assign('src', $src); + $oTemplate->assign('alt', $alt); + $oTemplate->assign('width', $width); + $oTemplate->assign('height', $height); + $oTemplate->assign('border', $border); + $oTemplate->assign('class', $class); + $oTemplate->assign('id', $id); + $oTemplate->assign('onclick', $onclick); + $oTemplate->assign('title', $title); + $oTemplate->assign('align', $align); + $oTemplate->assign('hspace', $hspace); + $oTemplate->assign('vspace', $vspace); + $oTemplate->assign('text_alternative', $text_alternative); + + $oTemplate->assign('aAttribs', $aAttribs); + + return $oTemplate->fetch('image.tpl'); - $this->buffer .= "\n"; +} - if( $this->title <> '' ) - $this->buffer .= "$this->title\n"; - $this->buffer .= "$this->head_extras\n"; - } - $xtra = ''; - if ( $this->onload <> '' ) { - $xtra .= ' onload="' . $this->onload . '" '; - } - if ( $this->onunload <> '' ) { - $xtra .= ' onunload="' . $this->onunload . '" '; - } - $this->buffer .= "text\" BGCOLOR=\"$this->bgcolor\" LINK=\"$this->link\" VLINK=\"$this->vlink\" ALINK=\"$this->alink\" $xtra>\n"; - - /* See if we're asking for a closed strcuture */ - if( $string == '' ) { - $this->flush(); - } else { - $this->buffer .= $string . ''; - } +/** + * Generates a label tag + * + * @param string $value The contents that belong inside the label + * @param string $for The ID to which the label applies (OPTIONAL; + * default not used) + * @param array $aAttribs Any extra attributes: this must be an + * associative array, where keys will be + * added as the attribute name, and values + * (which are optional - should be null if + * none should be used) will be placed in + * double quotes (pending template implementation) + * as the attribute value (OPTIONAL; default empty). + * + * @return string The desired label tag. + * + * @since 1.5.2 + * + */ +function create_label($value, $for='', $aAttribs=array()) { - } + global $oTemplate; - /** - * Builds a footer string - * - */ - function footer() { + $oTemplate->assign('text', $value); + $oTemplate->assign('for', $for); - $this->buffer .= "\n\n\n"; - $this->flush(); + $oTemplate->assign('aAttribs', $aAttribs); - } + return $oTemplate->fetch('label.tpl'); - /** - * Builds a tag string - * - */ - function tag( $tag, $string = '', $options = '' ) { +} - $ret = ''; - if( $this->tag_options[$tag] <> NULL ) { - if( $options == '' ) { - $options = $this->tag_options[$tag]; - } - switch( strtolower( $tag ) ) { - case 'td': - case 'th': - if ( $this->dir == 'rtl' && isset( $options['align'] ) ) { - - } - case 'table': - if ( $this->dir <> '' ) { - $options['DIR'] = $this->dir; - } - break; - } - $ret = zkTag_html( $tag, $string, $options, $this->tag_options[$tag]['tag_closed'] ); - } - return( $ret ); - } +/** + * Generates a span tag + * + * @param string $value The contents that belong inside the span + * @param string $class The CSS class name (OPTIONAL; default + * not used) + * @param string $id The ID name (OPTIONAL; default not used) + * @param array $aAttribs Any extra attributes: this must be an + * associative array, where keys will be + * added as the attribute name, and values + * (which are optional - should be null if + * none should be used) will be placed in + * double quotes (pending template implementation) + * as the attribute value (OPTIONAL; default empty). + * + * @return string The desired span tag. + * + * @since 1.5.2 + * + */ +function create_span($value, $class='', $id='', $aAttribs=array()) { - /** - * Builds a header string - * - */ - function h( $string, $level = '1' ) { + global $oTemplate; - $buffer = ""; + $oTemplate->assign('value', $value); + $oTemplate->assign('class', $class); + $oTemplate->assign('id', $id); - /* See if we're asking for a closed strcuture */ - if( $string == '' ) { - $this->$buffer .= $buffer; - } else { - $buffer .= $string . ""; - } - return( $buffer ); + $oTemplate->assign('aAttribs', $aAttribs); - } + return $oTemplate->fetch('span.tpl'); } + /** - * Converts an array into a parameters tag list. + * Generates html tags +//FIXME: this should not be used anywhere in the core, or we should +// convert this to use templates. We sould not be assuming HTML output. * + * @param string $tag Tag to output + * @param string $val Value between tags + * @param string $align Alignment (left, center, etc) + * @param string $bgcolor Back color in hexadecimal + * @param string $xtra Extra options + * @return string HTML ready for output + * @since 1.3.0 */ -function zkGetParms_html( $parms ) { - - $buffer = ''; - foreach( $parms as $key => $opt ) { - if( substr( $key, 0, 3 ) <> 'tag' ) { - $buffer .= " $key"; - if ($opt <> '' ) { - $buffer .= "=\"$opt\""; - } - } +function html_tag( $tag, // Tag to output + $val = '', // Value between tags + $align = '', // Alignment + $bgcolor = '', // Back color + $xtra = '' ) { // Extra options + + GLOBAL $languages, $squirrelmail_language; + + $align = strtolower( $align ); + $bgc = ''; + $tag = strtolower( $tag ); + + if ( isset( $languages[$squirrelmail_language]['DIR']) ) { + $dir = $languages[$squirrelmail_language]['DIR']; + } else { + $dir = 'ltr'; } - return( $buffer ); -} -/** - * Composes a tag string with all its parameters. - * - */ -function zkTag_html( $tag, $string, $options, $closed ) { + if ( $dir == 'ltr' ) { + $rgt = 'right'; + $lft = 'left'; + } else { + $rgt = 'left'; + $lft = 'right'; + } + + if ( $bgcolor <> '' ) { + $bgc = " bgcolor=\"$bgcolor\""; + } - /* - We must check direction tag in case we have table, td or th - */ + switch ( $align ) { + case '': + $alg = ''; + break; + case 'right': + $alg = " align=\"$rgt\""; + break; + case 'left': + $alg = " align=\"$lft\""; + break; + default: + $alg = " align=\"$align\""; + break; + } - $ret = "<$tag" . - zkGetParms_html( $options ) . - '>' . - $string; + $ret = "<$tag"; - if ( $closed ) { - $ret .= ""; + if ( $dir <> 'ltr' ) { + $ret .= " dir=\"$dir\""; + } + $ret .= $bgc . $alg; + + if ( $xtra <> '' ) { + $ret .= " $xtra"; + } + + if ( $val <> '' ) { + $ret .= ">$val\n"; + } else { + $ret .= '>'. "\n"; } return( $ret ); } -function optionize( $name, $opts, $default, $xtra = '' ) { - $ret = "\n"; - return( $ret ); + if ($link) { + $url = str_replace('&','&',$url); + } + return $url; } -?> \ No newline at end of file +