diff --git a/lib/Template.php b/lib/Template.php index 8b5c721..455baa1 100644 --- a/lib/Template.php +++ b/lib/Template.php @@ -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); diff --git a/lib/config_default.php b/lib/config_default.php index 2eb494a..b963374 100644 --- a/lib/config_default.php +++ b/lib/config_default.php @@ -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); diff --git a/lib/xmlTemplates.php b/lib/xmlTemplates.php index 926271c..08389de 100644 --- a/lib/xmlTemplates.php +++ b/lib/xmlTemplates.php @@ -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);