From b34aeff7e1b3271cbb72b0e56a7359f5599a7975 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 21 Dec 2010 00:25:30 -0700 Subject: [PATCH] Bug #9456: External JS should be loaded before our JS --- framework/Core/lib/Horde.php | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/framework/Core/lib/Horde.php b/framework/Core/lib/Horde.php index cd0a20287..2a24da768 100644 --- a/framework/Core/lib/Horde.php +++ b/framework/Core/lib/Horde.php @@ -225,7 +225,15 @@ HTML; return; } - $js_tocache = $js_force = $js_external = array(); + $js = array( + 'force' => array(), + 'external' => array(), + 'tocache' => array() + ); + $mtime = array( + 'force' => array(), + 'tocache' => array() + ); $s_list = $hsf->listFiles(); if (empty($s_list)) { @@ -260,39 +268,39 @@ HTML; } /* Output prototype.js separately from the other files. */ - $js_force[] = array( - $s_list['horde'][0]['p'] . $s_list['horde'][0]['f'], - 'mtime' => array(filemtime($s_list['horde'][0]['p'] . $s_list['horde'][0]['f'])) - ); + $js['force'][] = $s_list['horde'][0]['p'] . $s_list['horde'][0]['f']; + $mtime['force'][] = filemtime($s_list['horde'][0]['p'] . $s_list['horde'][0]['f']); unset($s_list['horde'][0]); foreach ($s_list as $files) { foreach ($files as $file) { if ($file['d'] && ($file['f'][0] != '/') && empty($file['e'])) { - $js_tocache[] = $file['p'] . $file['f']; - $js_tocache['mtime'][] = filemtime($file['p'] . $file['f']); + $js['tocache'][] = $file['p'] . $file['f']; + $mtime['tocache'][] = filemtime($file['p'] . $file['f']); } elseif (!empty($file['e'])) { - $js_external[] = $file['u']; + $js['external'][] = $file['u']; } else { - $js_force[] = array( - $file['p'] . $file['f'], - 'mtime' => array(filemtime($file['p'] . $file['f'])) - ); + $js['force'][] = $file['p'] . $file['f']; + $mtime['force'][] = filemtime($file['p'] . $file['f']); } } } - foreach (array_merge($js_force, array($js_tocache)) as $files) { + foreach ($js as $key => $files) { if (!count($files)) { continue; } - $mtime = max($files['mtime']); - unset($files['mtime']); + if ($key == 'external') { + foreach ($files as $val) { + $hsf->outputTag($val); + } + continue; + } $sig_files = $files; sort($sig_files); - $sig = hash('md5', serialize($sig_files) . $mtime); + $sig = hash('md5', serialize($sig_files) . max($mtime[$key])); switch ($driver) { case 'filesystem': @@ -344,10 +352,6 @@ HTML; } $hsf->clear(); - - foreach ($js_external as $val) { - $hsf->outputTag($val); - } } /** -- 2.11.0