ACC SHELL
<?php
// Author: Jakub Macek, CZ; Copyright: Poski.com s.r.o.; Code is 100% my work. Do not copy.
class DwooEx extends Dwoo
{
public $_return = array();
public function __get($key)
{
if (substr($key, 0, 2) == '__')
return $this->readVar(substr($key, 2));
}
public function __set($key, $value)
{
if (substr($key, 0, 2) == '__')
$this->assignInScope($value, $key);
}
public function preprocessor($compiler, $source)
{
if ($this->__this)
{
$part = $this->__this->part;
$source = str_replace('**}', '**}'.chr(255), $source);
$source = str_replace('{**', chr(255).'{**', $source);
$blocks = explode(chr(255), $source);
$write = true;
$source = '';
foreach ($blocks as $block)
{
if (substr($block, 0, 3) == '{**')
{
$block = substr($block, 4, strlen($block) - 8);
if ($block == 'ENDBLOCK')
$write = true;
else if (substr($block, 0, 5) == 'BLOCK')
{
$temp = explode(' ', substr($block, 6));
$write = (in_array($part, $temp));
}
}
else if ($write)
$source .= $block;
}
}
$source = str_replace(array('{php}<?php', '?>{/php}'), array('<?php', '?>'), $source);
$source = str_replace(array('{php}<?'), array('<?php'), $source);
$source = str_replace(array('<?=', '=?>'), array('<?php print(', '); ?>'), $source);
$source = str_replace("\r\n", "\n", $source);
$source = str_replace(array('$G.', '$G['), array('$dwoo.globals.', '$dwoo.globals['), $source);
//$source = preg_replace('~^\s+(\{/?[\w\$].*\})$~m', '\1', $source);
return $source;
}
public function postprocessor($compiler, $source)
{
$source = str_replace(array('$this->globals["globals"]'), array('$GLOBALS'), $source);
return $source;
}
public function __construct()
{
parent::__construct(DATA . 'cache/', DATA . 'cache/');
$this->data = array();
$this->data['constPATH'] = PATH;
$this->data['constLPATH'] = LPATH;
$this->data['constL'] = L;
}
public function get($_tpl, $data = null, $_compiler = null, $_output = false)
{
if ($_compiler === null)
{
$_compiler = new Dwoo_Compiler();
$_compiler->addPreProcessor(array($this, 'preprocessor'));
$_compiler->addPostProcessor(array($this, 'postprocessor'));
}
if ($data === null)
$data = array();
$data_stack = $this->data;
$data = array_merge($this->data, $data);
$result = parent::get($_tpl, $data, $_compiler, $_output);
$this->data = $data_stack;
return $result;
}
}
class Dwoo_Template_FileEx extends Dwoo_Template_File
{
protected function getCompiledFilename(Dwoo $dwoo)
{
// no compile id was provided, set default
if ($this->compileId===null) {
$this->compileId = str_replace('../', '__', strtr($this->getResourceIdentifier(), '\\:', '/-'));
foreach (site()->base as $base)
$this->compileId = str_replace($base, '', $this->compileId);
$this->compileId = str_replace('/', '-', $this->compileId);
if ($dwoo->__this && $dwoo->__this->part)
$this->compileId = str_replace('.tpl', '-' . $dwoo->__this->part, $this->compileId);
}
return $dwoo->getCompileDir() . $this->compileId.'.d'.Dwoo::RELEASE_TAG.'.php';
}
}
?>
ACC SHELL 2018