| [ 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 * class WactTagInfoExtractor. 12 * 13 * @package wact 14 * @version $Id: WactTagInfoExtractor.class.php 5945 2007-06-06 08:31:43Z pachanga $ 15 */ 16 class WactTagInfoExtractor 17 { 18 protected $dictionary; 19 protected $file; 20 protected $annotations = array(); 21 22 function __construct($dict, $file) 23 { 24 $this->dictionary = $dict; 25 $this->file = $file; 26 } 27 28 function setCurrentFile($file) 29 { 30 $this->file = $file; 31 } 32 33 function annotation($name, $value) 34 { 35 $this->annotations[$name] = $value; 36 } 37 38 function beginClass($class, $parent_class) 39 { 40 $this->_validate(); 41 42 $tag_aliases = explode(',' , $this->annotations['tag']); 43 foreach($tag_aliases as $tag) 44 { 45 $info = new WactTagInfo(trim($tag), $class); 46 47 $this->_fillTagInfo($info); 48 49 $this->dictionary->registerWactTagInfo($info, $this->file); 50 } 51 } 52 53 protected function _fillTagInfo($info) 54 { 55 if(isset($this->annotations['suppress_attributes'])) 56 { 57 $attrs = $this->_processAttributesString($this->annotations['suppress_attributes']); 58 $info->setSuppressAttributes($attrs); 59 } 60 61 if(isset($this->annotations['req_attributes'])) 62 { 63 $attrs = $this->_processAttributesString($this->annotations['req_attributes']); 64 $info->setRequiredAttributes($attrs); 65 } 66 67 if(isset($this->annotations['req_const_attributes'])) 68 { 69 $attrs = $this->_processAttributesString($this->annotations['req_const_attributes']); 70 $info->setRequiredConstantAttributes($attrs); 71 } 72 73 if(array_key_exists('forbid_parsing', $this->annotations)) 74 $info->setForbidParsing(); 75 76 if(isset($this->annotations['parent_tag_class'])) 77 $info->setParentTagClass($this->annotations['parent_tag_class']); 78 79 if(array_key_exists('restrict_self_nesting', $this->annotations)) 80 $info->setRestrictSelfNesting(); 81 82 if(array_key_exists('forbid_end_tag', $this->annotations)) 83 $info->setForbidEndTag(); 84 85 if(isset($this->annotations['runat'])) 86 $info->setRunat($this->annotations['runat']); 87 88 if(isset($this->annotations['runat_as'])) 89 $info->setRunatAs($this->annotations['runat_as']); 90 91 // this code added to support old form of DBE expressions in some attributes 92 // like <core:optional for='var'> should actually be <core:optional for='{$var}'> 93 if(isset($this->annotations['convert_to_expression'])) 94 { 95 $attrs = $this->_processAttributesString($this->annotations['convert_to_expression']); 96 $info->setConvertAttributesToExpressions($attrs); 97 } 98 } 99 100 function endClass() 101 { 102 $this->annotations = array(); 103 } 104 105 function _processAttributesString($attributes_string) 106 { 107 return explode(' ', preg_replace('~\s+~', ' ', trim($attributes_string))); 108 } 109 110 function _validate() 111 { 112 if(!file_exists($this->file)) 113 throw new WactException('File not found', array('file' => $this->file)); 114 115 if(!isset($this->annotations['tag'])) 116 throw new WactException('Annotation not found in file', 117 array('annotation' => 'tag', 'file' => $this->file)); 118 } 119 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Dec 1 03:56:46 2008 | Cross-referenced by PHPXref 0.7 |