1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16:
17: 18: 19: 20: 21:
22: class Pinoco_TALRenderer extends Pinoco_Renderer
23: {
24: 25: 26: 27: 28: 29: 30: 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:
44: include_once dirname(__FILE__) . '/PAL/NamespaceLoader.php';
45: $template->addPreFilter(new Pinoco_PAL_NamespaceLoader());
46:
47:
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:
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:
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:
75:
76: echo $template->execute();
77:
78: }
79: }
80:
81:
82: