1<?php 2/** 3 * PHPTAL templating engine 4 * 5 * PHP Version 5 6 * 7 * @category HTML 8 * @package PHPTAL 9 * @author Laurent Bedubourg <lbedubourg@motion-twin.com> 10 * @author Kornel Lesiński <kornel@aardvarkmedia.co.uk> 11 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License 12 * @version SVN: $Id$ 13 * @link http://phptal.org/ 14 */ 15 16/** 17 * Information about TAL attributes (in which order they are executed and how they generate the code) 18 * 19 * From http://dev.zope.org/Wikis/DevSite/Projects/ZPT/TAL%20Specification%201.4 20 * 21 * Order of Operations 22 * 23 * When there is only one TAL statement per element, the order in which 24 * they are executed is simple. Starting with the root element, each 25 * element's statements are executed, then each of its child elements is 26 * visited, in order, to do the same. 27 * 28 * Any combination of statements may appear on the same elements, except 29 * that the content and replace statements may not appear together. 30 * 31 * When an element has multiple statements, they are executed in this 32 * order: 33 * 34 * * define 35 * * condition 36 * * repeat 37 * * content or replace 38 * * attributes 39 * * omit-tag 40 * 41 * Since the on-error statement is only invoked when an error occurs, it 42 * does not appear in the list. 43 * 44 * The reasoning behind this ordering goes like this: You often want to set 45 * up variables for use in other statements, so define comes first. The 46 * very next thing to do is decide whether this element will be included at 47 * all, so condition is next; since the condition may depend on variables 48 * you just set, it comes after define. It is valuable be able to replace 49 * various parts of an element with different values on each iteration of a 50 * repeat, so repeat is next. It makes no sense to replace attributes and 51 * then throw them away, so attributes is last. The remaining statements 52 * clash, because they each replace or edit the statement element. 53 * 54 * If you want to override this ordering, you must do so by enclosing the 55 * element in another element, possibly div or span, and placing some of 56 * the statements on this new element. 57 * 58 * 59 * @package PHPTAL 60 * @subpackage Namespace 61 */ 62abstract class PHPTAL_NamespaceAttribute 63{ 64 /** Attribute name without the namespace: prefix */ 65 private $local_name; 66 67 /** [0 - 1000] */ 68 private $_priority; 69 70 /** PHPTAL_Namespace */ 71 private $_namespace; 72 73 /** 74 * @param string $name The attribute name 75 * @param int $priority Attribute execution priority 76 */ 77 public function __construct($local_name, $priority) 78 { 79 $this->local_name = $local_name; 80 $this->_priority = $priority; 81 } 82 83 /** 84 * @return string 85 */ 86 public function getLocalName() 87 { 88 return $this->local_name; 89 } 90 91 public function getPriority() { return $this->_priority; } 92 public function getNamespace() { return $this->_namespace; } 93 public function setNamespace(PHPTAL_Namespace $ns) { $this->_namespace = $ns; } 94 95 public function createAttributeHandler(PHPTAL_Dom_Element $tag, $expression) 96 { 97 return $this->_namespace->createAttributeHandler($this, $tag, $expression); 98 } 99} 100