1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17:
18: if (!class_exists('PHPTAL')) { require_once 'PHPTAL.php'; }
19: if (!class_exists('PHPTAL_Namespace')) { require_once 'PHPTAL/Namespace.php'; }
20: if (!class_exists('PHPTAL_Php_Attribute_TAL_Attributes')) { require_once 'PHPTAL/Php/Attribute/TAL/Attributes.php'; }
21:
22: 23: 24: 25:
26: class Pinoco_PAL_Attr extends PHPTAL_Php_Attribute_TAL_Attributes
27: {
28: public function before(PHPTAL_Php_CodeWriter $codewriter)
29: {
30:
31: $codewriter->pushCode('if (isset($ctx->attr)) {$_pal_attr_bak=$ctx->attr;}');
32: $codewriter->doSetVar('$ctx->attr', 'array()');
33: $attrs = $this->phpelement->getAttributeNodes();
34: foreach ($attrs as $attr) {
35:
36: $qname = $attr->getQualifiedName();
37: $default_attr = $attr->getValueEscaped();
38: $codewriter->doSetVar('$ctx->attr[\'' . $qname . '\']', '\''. addcslashes($default_attr, "\\$\'\"\\\0\n\r\t") . '\'');
39: }
40:
41: parent::before($codewriter);
42:
43: $codewriter->pushCode('unset($ctx->attr)');
44: $codewriter->pushCode('if (isset($_pal_attr_bak)) {$ctx->attr=$_pal_attr_bak;unset($_pal_attr_bak);}');
45: }
46: }
47:
48: