mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/11768] Updated merge_templates(). No functional change intended
PHPBB3-11768
This commit is contained in:
parent
37106bae7a
commit
4398da234e
1 changed files with 10 additions and 5 deletions
|
@ -471,11 +471,21 @@ class factory implements \phpbb\textformatter\cache_interface
|
||||||
/**
|
/**
|
||||||
* Merge the templates from any number of styles into one BBCode template
|
* Merge the templates from any number of styles into one BBCode template
|
||||||
*
|
*
|
||||||
|
* When multiple templates are available for the same BBCode (because of multiple styles) we
|
||||||
|
* merge them into a single template that uses an xsl:choose construct that determines which
|
||||||
|
* style to use at rendering time.
|
||||||
|
*
|
||||||
* @param array $style_templates Associative array matching style_ids to their template
|
* @param array $style_templates Associative array matching style_ids to their template
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function merge_templates(array $style_templates)
|
protected function merge_templates(array $style_templates)
|
||||||
{
|
{
|
||||||
|
// Return the template as-is if there's only one style or all styles share the same template
|
||||||
|
if (count(array_unique($style_templates)) === 1)
|
||||||
|
{
|
||||||
|
return end($style_templates);
|
||||||
|
}
|
||||||
|
|
||||||
// Group identical templates together
|
// Group identical templates together
|
||||||
$grouped_templates = array();
|
$grouped_templates = array();
|
||||||
foreach ($style_templates as $style_id => $style_template)
|
foreach ($style_templates as $style_id => $style_template)
|
||||||
|
@ -483,11 +493,6 @@ class factory implements \phpbb\textformatter\cache_interface
|
||||||
$grouped_templates[$style_template][] = '$STYLE_ID=' . $style_id;
|
$grouped_templates[$style_template][] = '$STYLE_ID=' . $style_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($grouped_templates) === 1)
|
|
||||||
{
|
|
||||||
return $style_template;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort templates by frequency descending
|
// Sort templates by frequency descending
|
||||||
$templates_cnt = array_map('sizeof', $grouped_templates);
|
$templates_cnt = array_map('sizeof', $grouped_templates);
|
||||||
array_multisort($grouped_templates, $templates_cnt);
|
array_multisort($grouped_templates, $templates_cnt);
|
||||||
|
|
Loading…
Add table
Reference in a new issue