| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 10 /** 11 * Used to store complex expressions like "{$var1}_my_{$var2}" found inside tag attributes 12 * @package wact 13 * @version $Id: WactAttribute.class.php 5945 2007-06-06 08:31:43Z pachanga $ 14 */ 15 class WactAttribute implements WactExpressionInterface 16 { 17 protected $name; 18 protected $fragments = array(); 19 20 function __construct($name, $value = null) 21 { 22 $this->name = $name; 23 24 if($value) 25 $this->addFragment(new WactAttributeLiteralFragment($value)); 26 } 27 28 function getName() 29 { 30 return $this->name; 31 } 32 33 function addFragment($fragment) 34 { 35 $this->fragments[] = $fragment; 36 } 37 38 function getFragment($index) 39 { 40 if(isset($this->fragments[$index])) 41 return $this->fragments[$index]; 42 } 43 44 function isConstant() 45 { 46 $isConstant = TRUE; 47 foreach( array_keys($this->fragments) as $key) 48 $isConstant = $isConstant && $this->fragments[$key]->isConstant(); 49 return $isConstant; 50 } 51 52 function getValue() 53 { 54 if(!count($this->fragments)) 55 return null; 56 57 $value = ""; 58 foreach( array_keys($this->fragments) as $key) 59 $value .= $this->fragments[$key]->getValue(); 60 61 return $value; 62 } 63 64 function generate($code_writer) 65 { 66 $code_writer->writeHTML(' ' . $this->name); 67 68 if(!count($this->fragments)) 69 return; 70 71 $code_writer->writeHTML('="'); 72 73 foreach( array_keys($this->fragments) as $key) 74 $this->fragments[$key]->generateFragment($code_writer); 75 76 $code_writer->writeHTML('"'); 77 } 78 79 function generatePreStatement($code_writer) 80 { 81 foreach( array_keys($this->fragments) as $key) 82 $this->fragments[$key]->generatePreStatement($code_writer); 83 } 84 85 function generateExpression($code_writer) 86 { 87 $code_writer->writePHP('('); 88 $separator = ''; 89 foreach( array_keys($this->fragments) as $key) 90 { 91 $code_writer->writePHP($separator); 92 $this->fragments[$key]->generateExpression($code_writer); 93 $separator = "."; 94 } 95 $code_writer->writePHP(')'); 96 } 97 98 function generatePostStatement($code_writer) 99 { 100 foreach( array_keys($this->fragments) as $key) 101 $this->fragments[$key]->generatePostStatement($code_writer); 102 } 103 104 function prepare() 105 { 106 foreach( array_keys($this->fragments) as $key) 107 $this->fragments[$key]->prepare(); 108 } 109 } 110 111 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Aug 29 04:49:26 2008 | Cross-referenced by PHPXref 0.7 |