Changeset 2542 for lang/php

Show
Ignore:
Timestamp:
12/06/07 13:16:58 (5 years ago)
Author:
tasuku
Message:

r270@dhcp158 (orig r13): tasuku | 2007-09-06 04:58:53 +0900
extends dekita--!!!!


Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/php/mumu/trunk/GunyaTemplate.php

    r2541 r2542  
    8888 
    8989// 1�ĤΥƥ�졼�ȥե������ѡ����������� 
    90 // ��������˽Ф���������class GTFile { 
    91   private $nodelist;        // �ե������ѡ�������NodeList 
     90// ��������˽Ф���������class GTFile extends GTNode { 
     91  public $nodelist;        // �ե������ѡ�������NodeList 
    9292  private $block_dict;      // nodelist�������ock̾ => GTBlockNode(�λ��� 
    93   function __construct($nodelist, $block_dict) { 
     93  private $parent_tfile;    // extends���������ƥƥ�졼��  function __construct($nodelist, $block_dict, $parentPath = false) { 
    9494    $this->nodelist = $nodelist; 
    9595    $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    } 
    96101  } 
    97102  public function render($raw_context) { 
     
    99104  } 
    100105  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    } 
    102122  } 
    103123  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]; 
    106126    } else { 
    107127      return false; 
     
    112132    // �ƤοƤˤ���������������ᡢ 
    113133    // ¹�����˥֥������ 
    114  
    115     // �����Ĥη���TExtendsNode 
    116     $nodelist[$extends_index]->append_block($blocknode); 
     134    $this->nodelist->push($blocknode); 
     135    $this->block_dict[$blocknode->name] = &$blocknode; 
    117136  } 
    118137  public function is_child() { 
    119     return is_numeric($extends_index); 
     138    return ($parent_tfile !== FALSE); 
    120139  } 
    121140} 
     
    138157  public function _render($context) { 
    139158    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); 
    169159  } 
    170160} 
     
    185175 
    186176class GTBlockNode extends GTNode { 
    187   private $name; 
    188   private $nodelist; 
    189   private $parent; 
     177  public $name; 
     178  public $nodelist; 
     179  public $parent; 
    190180 
    191181  private $context; // for block.super 
     
    592582    $this->template = $t; 
    593583    $nl = $this->_parse(0, strlen($t)); 
    594     if ($this->extends !== FALSE) { 
    595       $nl = new GTExtendsNode($nl); 
    596     } 
    597584    unset($this->template); 
    598     return new GTFile($nl, $this->block_dict); 
     585    return new GTFile($nl, $this->block_dict, $this->extends); 
    599586  } 
    600587