public function queue_dirs($dirs)
{
$dirs = Utils::single_array($dirs);
$alltemplates = array();
// If multiple directories are passed, the earlier ones should override the later ones
$dirs = array_reverse($dirs);
foreach ($dirs as $dir) {
$templates = Utils::glob(Utils::end_in_slash($dir) . '*.*');
$alltemplates = array_merge($alltemplates, $templates);
}
// Convert the template files into template names and produce a map from name => file
$available_templates = array_map('basename', $alltemplates, array_fill(1, count($alltemplates), '.php'));
$template_map = array_combine($available_templates, $alltemplates);
$this->template_map = array_merge($this->template_map, $template_map);
// Workaround for the 404 template key being merged into the 0 integer index
unset($this->template_map[0]);
if (isset($template_map[404])) {
$this->template_map['404'] = $template_map[404];
}
// The templates in the list should be uniquely identified
array_unique($available_templates);
// Filter the templates that are available
$available_templates = Plugins::filter('available_templates', $available_templates, __CLASS__);
$this->available_templates = array_merge($available_templates, $this->available_templates);
}