- Timestamp:
- 12/06/07 13:16:58 (5 years ago)
- Files:
-
- 1 modified
-
lang/php/mumu/trunk/GunyaTemplate.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/php/mumu/trunk/GunyaTemplate.php
r2541 r2542 88 88 89 89 // 1�ĤΥƥ�졼�ȥե������ѡ����������� 90 // ��������˽Ф���������class GTFile {91 p rivate$nodelist; // �ե������ѡ�������NodeList90 // ��������˽Ф���������class GTFile extends GTNode { 91 public $nodelist; // �ե������ѡ�������NodeList 92 92 private $block_dict; // nodelist�������ock̾ => GTBlockNode(�λ��� 93 function __construct($nodelist, $block_dict) {93 private $parent_tfile; // extends���������ƥƥ�졼�� function __construct($nodelist, $block_dict, $parentPath = false) { 94 94 $this->nodelist = $nodelist; 95 95 $this->block_dict = $block_dict; 96 if ($parentPath) { 97 $p = new GTParser(); 98 if (($this->parent_tfile = $p->parse_from_file($parentPath)) === FALSE) { 99 // TODO: ���顼���������ƥ�졼�������˶����Ƥ����� } 100 } 96 101 } 97 102 public function render($raw_context) { … … 99 104 } 100 105 public function _render($context) { 101 return $this->nodelist->_render($context); 106 if ($this->parent_tfile) { 107 foreach ($this->block_dict as $blockname => $blocknode) { 108 if (($parent_block = $this->parent_tfile->get_block($blockname)) === FALSE) { 109 if ($this->parent_tfile->is_child()) { 110 $this->parent_tfile->append_block(&$blocknode); 111 } 112 } else { 113 $parent_block->parent = &$blocknode->parent; 114 $parent_block->add_parent(&$parent_block->nodelist); 115 $parent_block->nodelist = &$blocknode->nodelist; 116 } 117 } 118 return $this->parent_tfile->_render($context); 119 } else { 120 return $this->nodelist->_render($context); 121 } 102 122 } 103 123 public function get_block($blockname) { 104 if (array_key_exists($blockname, $ block_dict)) {105 return $ nodelist[$block_dict[$blockname]];124 if (array_key_exists($blockname, $this->block_dict)) { 125 return $this->block_dict[$blockname]; 106 126 } else { 107 127 return false; … … 112 132 // �ƤοƤˤ���������������ᡢ 113 133 // ¹�����˥֥������ 114 115 // �����Ĥη���TExtendsNode 116 $nodelist[$extends_index]->append_block($blocknode); 134 $this->nodelist->push($blocknode); 135 $this->block_dict[$blocknode->name] = &$blocknode; 117 136 } 118 137 public function is_child() { 119 return is_numeric($extends_index);138 return ($parent_tfile !== FALSE); 120 139 } 121 140 } … … 138 157 public function _render($context) { 139 158 return $this->filter_expression->resolve($context); 140 }141 }142 143 class GTExtendsNode extends GTNode {144 private $nodelist;145 private $block_dict;146 private $parent_tplfile;147 function __construct($nodelist, $block_dict, $parentPath) {148 // FIXME: �������ƥ�����å���̵�¥롼�ץ���å�149 $this->nodelist = $nodelist;150 $this->block_dict = $block_dict;151 $p = new GTParser();152 if (($this->parent_tplfile = $p->parse_from_file($parentPath)) === FALSE) {153 // TODO: ���顼���������ƥ�졼�������˶����Ƥ����� }154 }155 156 function _render($context) {157 if ($parent_nodelist) {158 $parent_is_child = $parent_tplfile->is_child();159 $bidxs = $parent_tplfile->get_block_indexes();160 foreach ($bidxs as $bidx) {161 }162 } else {163 return 'extends error';164 }165 }166 167 function append_block($blocknode) {168 array_push($this->nodelist, $blocknode);169 159 } 170 160 } … … 185 175 186 176 class GTBlockNode extends GTNode { 187 p rivate$name;188 p rivate$nodelist;189 p rivate$parent;177 public $name; 178 public $nodelist; 179 public $parent; 190 180 191 181 private $context; // for block.super … … 592 582 $this->template = $t; 593 583 $nl = $this->_parse(0, strlen($t)); 594 if ($this->extends !== FALSE) {595 $nl = new GTExtendsNode($nl);596 }597 584 unset($this->template); 598 return new GTFile($nl, $this->block_dict );585 return new GTFile($nl, $this->block_dict, $this->extends); 599 586 } 600 587
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)