디버그 기능 사용시 템플릿 경로를 표시하는 주석 태그 추가

관리자일 경우에만 표시
위젯 캐시 등 사용시 템플릿 주석이 노출될 가능성이 있으므로 HTMLDisplayHandler->prepareToPrint()에서 주석 제거 처리
This commit is contained in:
conory 2018-01-29 22:08:39 +09:00
parent afc0f26d6c
commit 913ccf4a3c
2 changed files with 17 additions and 3 deletions

View file

@ -251,6 +251,12 @@ class HTMLDisplayHandler
// replace the user-defined-language
$oModuleController = getController('module');
$oModuleController->replaceDefinedLangCode($output);
// remove comment tag
if(Context::get('logged_info')->is_admin !== 'Y')
{
$output = preg_replace('/\n?<!--[^\[].*?-->/s', '', $output);
}
}
/**

View file

@ -357,6 +357,14 @@ class TemplateHandler
{
$contents .= ob_get_clean();
}
// insert template path comment tag
if(config('debug.enabled') && Context::get('logged_info')->is_admin === 'Y')
{
$sign = PHP_EOL . '<!-- Template %s : ' . $this->web_path . $this->filename . ' -->' . PHP_EOL;
$contents = sprintf($sign, 'start') . $contents . sprintf($sign, 'end');
}
return $contents;
}