45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace ctiso\View;
|
|
use ctiso\View\View,
|
|
PHPTAL;
|
|
use PHPTAL_TranslationService;
|
|
|
|
class Composite extends View
|
|
{
|
|
private PHPTAL $tal;
|
|
|
|
function __construct(string $file)
|
|
{
|
|
parent::__construct();
|
|
|
|
$this->tal = new PHPTAL($file);
|
|
$this->tal->setPhpCodeDestination(PHPTAL_PHP_CODE_DESTINATION);
|
|
$this->tal->setEncoding(PHPTAL_DEFAULT_ENCODING);
|
|
$this->tal->setTemplateRepository(PHPTAL_TEMPLATE_REPOSITORY);
|
|
$this->tal->setOutputMode(PHPTAL::HTML5);
|
|
$this->tal->stripComments(true);
|
|
// $this->tal->addPreFilter(new PHPTAL_PreFilter_Normalize());
|
|
}
|
|
|
|
function set(string $key, mixed $val): void {
|
|
if ($key == 'title') {
|
|
$this->setTitle($val);
|
|
}
|
|
$this->tal->set($key, $val);
|
|
}
|
|
|
|
function __set(string $key, mixed $val): void {
|
|
$this->tal->set($key, $val);
|
|
}
|
|
|
|
function execute(): string
|
|
{
|
|
$this->processChild();
|
|
return $this->tal->execute();
|
|
}
|
|
|
|
function setTranslator(PHPTAL_TranslationService $t): void {
|
|
$this->tal->setTranslator($t);
|
|
}
|
|
}
|