| [ Index ] |
PHP Cross Reference of Web Application Component Toolkit |
[Summary view] [Print] [Text view]
1 <?php 2 //-------------------------------------------------------------------------------- 3 // Copyright 2003 Procata, Inc. 4 // Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html) 5 //-------------------------------------------------------------------------------- 6 /** 7 * @package WACT_TAG 8 * @version $Id: base.tag.php,v 1.5 2004/02/12 20:27:20 jeffmoore Exp $ 9 */ 10 //-------------------------------------------------------------------------------- 11 /** 12 * Base tag (not directly used) for HTML tags 13 * @todo EXPERIMENTAL 14 * @see http://wact.sourceforge.net/index.php/HtmlBaseTag 15 * @access protected 16 * @package WACT_TAG 17 */ 18 class HtmlBaseTag extends ServerComponentTag { 19 /** 20 * Instance of CssWriter 21 * @var CssWriter 22 * @access private 23 */ 24 var $CssWriter; 25 26 /** 27 * Constructs HtmlBaseTag 28 * @access protected 29 */ 30 function HtmlBaseTag() { 31 $this->CssWriter = & new CssWriter(); 32 } 33 /** 34 * @param CodeWriter 35 * @return void 36 * @access protected 37 */ 38 function generateConstructor(&$code) { 39 parent::generateConstructor($code); 40 if ($this->getBoolAttribute('hide')) { 41 $code->writePHP($this->getComponentRefCode() . '->visible = FALSE;'); 42 } 43 } 44 /** 45 * @param CodeWriter 46 * @return void 47 * @access protected 48 */ 49 function preGenerate(&$code) { 50 parent::preGenerate($code); 51 $code->writePHP('if (' . $this->getComponentRefCode() . '->IsVisible()) {'); 52 } 53 /** 54 * @param CodeWriter 55 * @return void 56 * @access protected 57 */ 58 function generateContents(&$code) { 59 if ( $accesskey = $this->getAttribute('accesskey') ) { 60 $code->writeHTML(' accesskey="'.$accesskey.'"'); 61 } 62 if ( $background_color = $this->getAttribute('background-color') ) { 63 $this->CssWriter->add('background-color',$background_color); 64 } 65 if ( $border_color = $this->getAttribute('border-color') ) { 66 $this->CssWriter->add('border-color',$border_color); 67 } 68 if ( $border_style = $this->getAttribute('border-style') ) { 69 $border_styles = array('none','dotted','dashed','solid', 70 'double','groove','ridge','inset','outset',''); 71 if ( in_array($border_style,$border_styles) ) { 72 $this->CssWriter->add('border-style',$border_style); 73 } 74 } 75 if ( $border_width = $this->getAttribute('border-width') ) { 76 $this->CssWriter->add('border-width',$border_width); 77 } 78 if ( $class = $this->getAttribute('class') ) { 79 $code->writeHTML(' class="'.$class.'"'); 80 } 81 if ( $color = $this->getAttribute('color') ) { 82 $this->CssWriter->add('color',$color); 83 } 84 if ( $font = $this->getAttribute('font') ) { 85 $this->CssWriter->add('font',$font); 86 } 87 if ( $font_family = $this->getAttribute('font-family') ) { 88 $this->CssWriter->add('font-family',$font_family); 89 } 90 if ( $font_size = $this->getAttribute('font-size') ) { 91 $this->CssWriter->add('font-size',$font_size); 92 } 93 if ( $font_weight = $this->getAttribute('font-weight') ) { 94 $this->CssWriter->add('font-weight',$font_weight); 95 } 96 if ( $height = $this->getAttribute('height') ) { 97 $this->CssWriter->add('height',$height); 98 } 99 if ( $id = $this->getAttribute('id') ) { 100 $code->writeHTML(' id="'.$id.'"'); 101 } 102 if ( $style = $this->getAttribute('style') ) { 103 $code->writeHTML(' style="'.$style.'"'); 104 } 105 if ( $tabindex = $this->getAttribute('tabindex') ) { 106 $code->writeHTML(' tabindex="'.$tabindex.'"'); 107 } 108 if ( $title = $this->getAttribute('title') ) { 109 $code->writeHTML(' title="'.$title.'"'); 110 } 111 if ( $width = $this->getAttribute('width') ) { 112 $this->CssWriter->add('width',$width); 113 } 114 $this->CssWriter->render($code); 115 $code->writeHtml('>'); 116 parent::generateContents($code); 117 } 118 /** 119 * @param CodeWriter 120 * @return void 121 * @access protected 122 */ 123 function postGenerate(&$code) { 124 $code->writePHP('}'); 125 parent::postGenerate($code); 126 } 127 } 128 129 /** 130 * Build a CSS string for use is style attributes 131 * @todo EXPERIMENTAL 132 * @see http://wact.sourceforge.net/index.php/CssWriter 133 * @access protected 134 * @package WACT_TAG 135 */ 136 class CssWriter { 137 var $css = ''; 138 var $sep = ''; 139 function add($name,$value) { 140 $this->css.=$this->sep.$name.': '.$value.';'; 141 $this->sep = ' '; 142 } 143 function render(&$code) { 144 if ( !empty($this->css) ) { 145 $code->writeHtml(' style="'.$this->css.'"'); 146 } 147 } 148 } 149 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sun Nov 28 19:36:09 2004 | Cross-referenced by PHPXref 0.5 |