aboutsummaryrefslogtreecommitdiffstats
path: root/include/template.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/template.class.php')
-rw-r--r--include/template.class.php57
1 files changed, 24 insertions, 33 deletions
diff --git a/include/template.class.php b/include/template.class.php
index c27f39d74..b91d34b2a 100644
--- a/include/template.class.php
+++ b/include/template.class.php
@@ -1046,7 +1046,8 @@ class CssLoader
function get_css()
{
uasort($this->registered_css, array('CssLoader', 'cmp_by_order'));
- return self::do_combine($this->registered_css);
+ $combiner = new FileCombiner('css', $this->registered_css);
+ return $combiner->combine();
}
private static function cmp_by_order($a, $b)
@@ -1054,16 +1055,6 @@ class CssLoader
return $a->order - $b->order;
}
- private static function do_combine($files)
- {
- $combiner = new FileCombiner('css');
- foreach ($files as $css)
- {
- $combiner->add( $css);
- }
- return $combiner->combine();
- }
-
function add($id, $path, $version=0, $order=0, $is_template=false)
{
if (!isset($this->registered_css[$id]))
@@ -1252,11 +1243,7 @@ class ScriptLoader
private static function do_combine($scripts, $load_mode)
{
- $combiner = new FileCombiner('js');
- foreach ($scripts as $script)
- {
- $combiner->add( $script);
- }
+ $combiner = new FileCombiner('js', $scripts);
return $combiner->combine();
}
@@ -1377,12 +1364,13 @@ final class FileCombiner
{
private $type; // js or css
private $is_css;
- private $combinables = array();
+ private $combinables;
- function FileCombiner($type)
+ function FileCombiner($type, $combinables)
{
$this->type = $type;
$this->is_css = $type=='css';
+ $this->combinables = $combinables;
}
static function clear_combined_files()
@@ -1396,9 +1384,10 @@ final class FileCombiner
closedir($dir);
}
- function add($combinable)
+ function add($combinables)
{
- $this->combinables[] = $combinable;
+ foreach($combinables as $combinable)
+ $this->combinables[] = $combinable;
}
function combine()
@@ -1413,27 +1402,29 @@ final class FileCombiner
$result = array();
$pending = array();
- $key = $this->is_css ? array(get_absolute_root_url(false)): array(); //because for css we modify bg url
+ $ini_key = $this->is_css ? array(get_absolute_root_url(false)): array(); //because for css we modify bg url;
+ $key = $ini_key;
foreach ($this->combinables as $combinable)
{
- if ($conf['template_combine_files'] && !$combinable->is_remote())
+ if ($combinable->is_remote())
{
- $key[] = $combinable->path;
- $key[] = $combinable->version;
- if ($conf['template_compile_check'])
- $key[] = filemtime( PHPWG_ROOT_PATH . $combinable->path );
- $pending[] = $combinable;
+ $this->flush_pending($result, $pending, $key, $force);
+ $key = $ini_key;
+ $result[] = $combinable;
+ continue;
}
- else
+ elseif (!$conf['template_combine_files'])
{
$this->flush_pending($result, $pending, $key, $force);
- $key = $this->is_css ? array(get_absolute_root_url(false)): array(); //because for css we modify bg url
- if ($combinable->is_remote())
- $result[] = $combinable;
- else
- $pending = array($combinable);
+ $key = $ini_key;
}
+
+ $key[] = $combinable->path;
+ $key[] = $combinable->version;
+ if ($conf['template_compile_check'])
+ $key[] = filemtime( PHPWG_ROOT_PATH . $combinable->path );
+ $pending[] = $combinable;
}
$this->flush_pending($result, $pending, $key, $force);
return $result;