Overview

Packages

  • Pinoco
    • PAL

Classes

  • Pinoco_PAL_Attr
  • Pinoco_PAL_ContentNl2br
  • Pinoco_PAL_Namespace
  • Pinoco_PAL_NamespaceLoader
  • Pinoco_PAL_ReplaceNl2br
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Pinoco: makes existing static web site dynamic transparently.
 4:  * Copyright 2010-2011, Hisateru Tanaka <tanakahisateru@gmail.com>
 5:  *
 6:  * Licensed under The MIT License
 7:  * Redistributions of files must retain the above copyright notice.
 8:  *
 9:  * PHP Version 5
10:  *
11:  * @author     Hisateru Tanaka <tanakahisateru@gmail.com>
12:  * @copyright  Copyright 2010-2011, Hisateru Tanaka <tanakahisateru@gmail.com>
13:  * @license    MIT License (http://www.opensource.org/licenses/mit-license.php)
14:  * @package    Pinoco
15:  * @subpackage PAL
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:  * @package Pinoco
24:  * @subpackage PAL
25:  */
26: class Pinoco_PAL_Attr extends PHPTAL_Php_Attribute_TAL_Attributes
27: {
28:     public function before(PHPTAL_Php_CodeWriter $codewriter)
29:     {
30:         // prepare
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:             /* @var PHPTAL_Dom_Attr $attr */
36:             $qname = $attr->getQualifiedName();
37:             $default_attr = $attr->getValueEscaped();
38:             $codewriter->doSetVar('$ctx->attr[\'' . $qname . '\']', '\''. addcslashes($default_attr, "\\$\'\"\\\0\n\r\t") . '\'');
39:         }
40:         // main
41:         parent::before($codewriter);
42:         // cleanup
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: 
Pinoco 0.8.0 Documentation API documentation generated by ApiGen 2.8.0