SF Feature #3294932 - Hiding not used templates

This commit is contained in:
Deon George 2011-05-03 20:49:16 +10:00
parent 3919825000
commit a2828b2cf0
3 changed files with 17 additions and 1 deletions

View File

@ -913,6 +913,14 @@ class Template extends xmlTemplate {
return $this->visible;
}
public function setVisible() {
$this->visible = true;
}
public function setInvisible() {
$this->visible = false;
}
public function getRegExp() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->regexp);

View File

@ -107,6 +107,10 @@ class Config {
'desc'=>'Hide the features that may provide sensitive debugging information to the browser',
'default'=>true);
$this->default->appearance['hide_template_regexp'] = array(
'desc'=>'Templates that are disabled by their regex are not shown',
'default'=>false);
$this->default->appearance['hide_template_warning'] = array(
'desc'=>'Hide template errors from being displayed',
'default'=>false);

View File

@ -198,9 +198,13 @@ abstract class xmlTemplates {
# Clone this, as we'll disable some templates, as a result of the container being requested.
$template = clone $details;
if (! is_null($container) && ($regexp = $template->getRegExp()) && (! @preg_match('/'.$regexp.'/i',$container)))
if (! is_null($container) && ($regexp = $template->getRegExp()) && (! @preg_match('/'.$regexp.'/i',$container))) {
$template->setInvalid(_('This template is not valid in this container'),true);
if ($_SESSION[APPCONFIG]->getValue('appearance','hide_template_regexp'))
$template->setInvisible();
}
if ($template->isVisible() && (! $disabled || ! $template->isAdminDisabled()))
if (is_null($type) || (! is_null($type) && $template->isType($type)))
array_push($result,$template);