Overview

Packages

  • Pinoco
    • PAL

Classes

  • Pinoco
  • Pinoco_Delegate
  • Pinoco_DynamicVars
  • Pinoco_HttpRequestVars
  • Pinoco_List
  • Pinoco_MIMEType
  • Pinoco_NativeRenderer
  • Pinoco_NothingVars
  • Pinoco_NullRenderer
  • Pinoco_OptionalParam
  • Pinoco_Pagination
  • Pinoco_PDOStatementWrapper
  • Pinoco_PDOWrapper
  • Pinoco_Renderer
  • Pinoco_Router
  • Pinoco_TALRenderer
  • Pinoco_TestEnvironment
  • Pinoco_Validator
  • Pinoco_ValidatorContext
  • Pinoco_Vars

Interfaces

  • Pinoco_ArrayConvertible

Functions

  • __pinoco_autoload_impl
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Pinoco: makes existing static web site dynamic transparently.
 4:  * Copyright 2010-2012, 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-2012, Hisateru Tanaka <tanakahisateru@gmail.com>
13:  * @license    MIT License (http://www.opensource.org/licenses/mit-license.php)
14:  * @package    Pinoco
15:  */
16: 
17: /**
18:  * Preferred HTML page renderer using PHPTAL
19:  *
20:  * @package Pinoco
21:  */
22: class Pinoco_TALRenderer extends Pinoco_Renderer
23: {
24:     /**
25:      * Renders the web page.
26:      *
27:      * @param string $page
28:      * @param array $extravars
29:      * @throws RuntimeException
30:      * @return void
31:      */
32:     public function render($page, $extravars=array())
33:     {
34:         if (!class_exists('PHPTAL')) {
35:             include_once 'PHPTAL.php';
36:             if (!class_exists('PHPTAL')) {
37:                 throw new RuntimeException("PHPTAL is not installed.");
38:             }
39:         }
40: 
41:         $template = new PHPTAL($page);
42: 
43:         //pal namespace loading
44:         include_once dirname(__FILE__) . '/PAL/NamespaceLoader.php';
45:         $template->addPreFilter(new Pinoco_PAL_NamespaceLoader());
46: 
47:         //config
48:         $template->setTemplateRepository($this->_sysref->basedir);
49:         foreach ($this->cfg as $k => $v) {
50:             $meth = 'set' . strtoupper($k[0]) . substr($k, 1);
51:             if (method_exists($template, $meth)) {
52:                 call_user_func(array($template, $meth), $v);
53:             }
54:         }
55: 
56:         //extra TALES definition
57:         if (!function_exists("phptal_tales_url")) {
58:             function phptal_tales_url($src, $nothrow)
59:             {
60:                 $src = phptal_tales('string:' . trim($src), $nothrow);
61:                 return '$ctx->this->url(' . $src . ')';
62:             }
63:         }
64: 
65:         //extract vars
66:         foreach ($this->_sysref->autolocal as $name=>$value) {
67:             $template->set($name, $value);
68:         }
69:         foreach ($extravars as $name=>$value) {
70:             $template->set($name, $value);
71:         }
72:         $template->set('this', $this->_sysref);
73: 
74:         //exec
75:         //ob_start();
76:         echo $template->execute();
77:         //ob_end_flush();
78:     }
79: }
80: 
81: 
82: 
Pinoco 0.8.0 Documentation API documentation generated by ApiGen 2.8.0