Dotclear

Changeset 3063:ef4de8819a71 for inc


Ignore:
Timestamp:
07/29/15 13:33:30 (10 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

tplNode(...) classes not more necessary in Dotclear (they have been moved some times ago to Clearbricks)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/public/class.dc.template.php

    r2953 r3063  
    30203020     } 
    30213021} 
    3022  
    3023 # Template nodes, for parsing purposes 
    3024  
    3025 # Generic list node, this one may only be instanciated 
    3026 # once for root element 
    3027 class tplNode 
    3028 { 
    3029      # Basic tree structure : links to parent, children forrest 
    3030      protected $parentNode; 
    3031      protected $children; 
    3032  
    3033      public function __construct() { 
    3034           $this->children = array(); 
    3035           $this->parentNode = null; 
    3036      } 
    3037  
    3038      // Returns compiled block 
    3039      public function compile($tpl) { 
    3040           $res=''; 
    3041           foreach ($this->children as $child) { 
    3042                $res .= $child->compile($tpl); 
    3043           } 
    3044           return $res; 
    3045      } 
    3046  
    3047      # Add a children to current node 
    3048      public function addChild ($child) { 
    3049           $this->children[] = $child; 
    3050           $child->setParent($this); 
    3051      } 
    3052  
    3053      # Defines parent for current node 
    3054      protected function setParent($parent) { 
    3055           $this->parentNode = $parent; 
    3056      } 
    3057  
    3058      # Retrieves current node parent. 
    3059      # If parent is root node, null is returned 
    3060      public function getParent() { 
    3061           return $this->parentNode; 
    3062      } 
    3063  
    3064      # Current node tag 
    3065      public function getTag() { 
    3066           return "ROOT"; 
    3067      } 
    3068 } 
    3069  
    3070 // Text node, for any non-tpl content 
    3071 class tplNodeText extends tplNode 
    3072 { 
    3073      // Simple text node, only holds its content 
    3074      protected $content; 
    3075  
    3076      public function __construct($text) { 
    3077           parent::__construct(); 
    3078           $this->content=$text; 
    3079      } 
    3080  
    3081      public function compile($tpl) { 
    3082           return $this->content; 
    3083      } 
    3084  
    3085      public function getTag() { 
    3086           return "TEXT"; 
    3087      } 
    3088 } 
    3089  
    3090 // Block node, for all <tpl:Tag>...</tpl:Tag> 
    3091 class tplNodeBlock extends tplNode 
    3092 { 
    3093      protected $attr; 
    3094      protected $tag; 
    3095      protected $closed; 
    3096  
    3097      public function __construct($tag,$attr) { 
    3098           parent::__construct(); 
    3099           $this->content=''; 
    3100           $this->tag = $tag; 
    3101           $this->attr = $attr; 
    3102           $this->closed=false; 
    3103      } 
    3104      public function setClosing() { 
    3105           $this->closed = true; 
    3106      } 
    3107      public function isClosed() { 
    3108           return $this->closed; 
    3109      } 
    3110      public function compile($tpl) { 
    3111           if ($this->closed) { 
    3112                $content = parent::compile($tpl); 
    3113                return $tpl->compileBlockNode($this->tag,$this->attr,$content); 
    3114           } else { 
    3115                // if tag has not been closed, silently ignore its content... 
    3116                return ''; 
    3117           } 
    3118      } 
    3119      public function getTag() { 
    3120           return $this->tag; 
    3121      } 
    3122 } 
    3123  
    3124 // Value node, for all {{tpl:Tag}} 
    3125 class tplNodeValue extends tplNode 
    3126 { 
    3127      protected $attr; 
    3128      protected $str_attr; 
    3129      protected $tag; 
    3130  
    3131      public function __construct($tag,$attr,$str_attr) { 
    3132           parent::__construct(); 
    3133           $this->content=''; 
    3134           $this->tag = $tag; 
    3135           $this->attr = $attr; 
    3136           $this->str_attr = $str_attr; 
    3137      } 
    3138  
    3139      public function compile($tpl) { 
    3140           return $tpl->compileValueNode($this->tag,$this->attr,$this->str_attr); 
    3141      } 
    3142  
    3143      public function getTag() { 
    3144           return $this->tag; 
    3145      } 
    3146 } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map