Blame view

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