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_Dom_Defs')) { require_once 'PHPTAL/Dom/Defs.php'; }
21: 
22: /**
23:  * PHPTAL extensions
24:  *
25:  * <code>
26:  *   <p pal:content-nl2br="this/var">foo</p> <!-- nl2br text escaped -->
27:  *   <p pal:content-nl2br="structure this/var">foo</p> <!-- like markdown -->
28:  *   <p>
29:  *       <span pal:replace-nl2br="this/var">foo</span>
30:  *   </p>
31:  *   <a href="prev.html" pal:attr="href url:/page/${attr/href}">prev</a>
32:  *   <a href="next.html" pal:attr="href url:/page/${attr/href}">next</a>
33:  * </code>
34:  *
35:  * @package Pinoco
36:  * @subpackage PAL
37:  */
38: class Pinoco_PAL_Namespace extends PHPTAL_Namespace
39: {
40:     public function __construct()
41:     {
42:         // namespace
43:         parent::__construct('pal', 'http://pinoco.org/ns/pal');
44:         // attributes in namescape
45:         $this->addAttribute(new PHPTAL_NamespaceAttributeContent('content-nl2br', 11));
46:         $this->addAttribute(new PHPTAL_NamespaceAttributeReplace('replace-nl2br', 9));
47:         $this->addAttribute(new PHPTAL_NamespaceAttributeSurround('attr', 9));
48:     }
49: 
50:     public function createAttributeHandler(PHPTAL_NamespaceAttribute $att, PHPTAL_Dom_Element $tag, $expression)
51:     {
52:         $attrNames = array(
53:             'content-nl2br' => 'Pinoco_PAL_ContentNl2br',
54:             'replace-nl2br' => 'Pinoco_PAL_ReplaceNl2br',
55:             'attr'          => 'Pinoco_PAL_Attr',
56:         );
57:         $class = $attrNames[$att->getLocalName()];
58:         return new $class($tag, $expression);
59:     }
60: }
61: 
62: PHPTAL_Dom_Defs::getInstance()->registerNamespace(new Pinoco_PAL_Namespace());
63: 
64: 
Pinoco 0.8.0 Documentation API documentation generated by ApiGen 2.8.0