SF Feature #2837687 - Automatic template selection from one of one valid templates
This commit is contained in:
@@ -553,6 +553,24 @@ class TemplateRender extends PageRender {
|
||||
debug_dump_backtrace(sprintf('Unknown mode for %s',__METHOD__),1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the container for this mode
|
||||
*/
|
||||
protected function getModeContainer() {
|
||||
switch ($this->getMode()) {
|
||||
case 'creation':
|
||||
return $this->container;
|
||||
break;
|
||||
|
||||
case 'modification':
|
||||
return $this->dn;
|
||||
break;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the default template enabled?
|
||||
*/
|
||||
@@ -584,7 +602,7 @@ class TemplateRender extends PageRender {
|
||||
}
|
||||
|
||||
$avail_templates = $this->getTemplates();
|
||||
$templates = $avail_templates->getTemplates($this->getMode());
|
||||
$templates = $avail_templates->getTemplates($this->getMode(),$this->getModeContainer());
|
||||
printf('<center><h3>%s</h3></center>',$msg);
|
||||
|
||||
$href_parms = array_to_query_string($_GET,array('meth'));
|
||||
@@ -612,11 +630,6 @@ class TemplateRender extends PageRender {
|
||||
|
||||
$isInValid = $details->isInValid();
|
||||
|
||||
if (($regexp = $details->getRegExp())
|
||||
&& (($this->getMode() == 'creation' && ! @preg_match('/'.$regexp.'/i',$this->container))
|
||||
|| ($this->getMode() == 'modification' && ! @preg_match('/'.$regexp.'/i',$this->dn))))
|
||||
$isInValid = _('This template is not valid in this container');
|
||||
|
||||
# Balance the columns properly
|
||||
if (($nb_templates % 2 == 0 && $i == intval($nb_templates / 2)) ||
|
||||
($nb_templates % 2 == 1 && $i == intval($nb_templates / 2) + 1)) {
|
||||
|
Reference in New Issue
Block a user