mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 18:51:41 +09:00
Use $lang as a local variable in template handler
This commit is contained in:
parent
9d06f6a9e2
commit
e0a762d03a
1 changed files with 9 additions and 8 deletions
|
|
@ -344,22 +344,27 @@ class TemplateHandler
|
|||
*/
|
||||
private function _fetch($filename)
|
||||
{
|
||||
// Import Context and lang as local variables.
|
||||
$__Context = Context::getAll();
|
||||
$__Context->tpl_path = $this->path;
|
||||
|
||||
global $lang;
|
||||
|
||||
// Start the output buffer.
|
||||
$__ob_level_before_fetch = ob_get_level();
|
||||
ob_start();
|
||||
|
||||
// Include the compiled template.
|
||||
include $filename;
|
||||
|
||||
// Fetch contents of the output buffer until the buffer level is the same as before.
|
||||
$contents = '';
|
||||
while (ob_get_level() > $__ob_level_before_fetch)
|
||||
{
|
||||
$contents .= ob_get_clean();
|
||||
}
|
||||
|
||||
// insert template path comment tag
|
||||
if(config('debug.enabled') && Rhymix\Framework\Debug::isEnabledForCurrentUser())
|
||||
// Insert template path comment tag.
|
||||
if(config('debug.enabled') && Rhymix\Framework\Debug::isEnabledForCurrentUser() && !starts_with('<!DOCTYPE', $contents))
|
||||
{
|
||||
$sign = PHP_EOL . '<!-- Template %s : ' . $this->web_path . $this->filename . ' -->' . PHP_EOL;
|
||||
$contents = sprintf($sign, 'start') . $contents . sprintf($sign, 'end');
|
||||
|
|
@ -979,14 +984,10 @@ class TemplateHandler
|
|||
}
|
||||
|
||||
return preg_replace_callback('@(?<!::|\\\\|(?<!eval\()\')\$([a-z_][a-z0-9_]*)@i', function($matches) {
|
||||
if (preg_match('/^(?:GLOBALS|_SERVER|_COOKIE|_GET|_POST|_REQUEST|__Context|this)$/', $matches[1]))
|
||||
if (preg_match('/^(?:GLOBALS|_SERVER|_COOKIE|_GET|_POST|_REQUEST|__Context|this|lang)$/', $matches[1]))
|
||||
{
|
||||
return '$' . $matches[1];
|
||||
}
|
||||
elseif ($matches[1] === 'lang')
|
||||
{
|
||||
return '$GLOBALS[\'lang\']';
|
||||
}
|
||||
else
|
||||
{
|
||||
return '$__Context->' . $matches[1];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue