diff --git a/installtest.php b/installtest.php
index 6e98dde1b..5c5bc2db4 100755
--- a/installtest.php
+++ b/installtest.php
@@ -33,6 +33,24 @@
include_once(LEGACY_ROOT . '/constants.php');
include_once(LEGACY_ROOT . '/lib/InstallationTests.php');
+/* Version check before including TemplateUtility for asset URL versioning. */
+$phpVersion = phpversion();
+$phpVersionParts = explode('.', $phpVersion);
+if ($phpVersionParts[0] >= 5)
+{
+ include_once(LEGACY_ROOT . '/lib/TemplateUtility.php');
+}
+else
+{
+ $php4 = true;
+}
+
+$mainCSSURL = 'main.css';
+if (!isset($php4))
+{
+ $mainCSSURL = call_user_func(array('TemplateUtility', 'getVersionedAssetURL'), $mainCSSURL);
+}
+
define('REQUIRED_SCHEMA_VERSION', '1200');
@@ -45,7 +63,7 @@
CATS - Installation Test Script
-
+
+
+
+
+
diff --git a/js/submodal/loading.html b/js/submodal/loading.html
index 5871fbce4..7d6deb93d 100755
--- a/js/submodal/loading.html
+++ b/js/submodal/loading.html
@@ -4,6 +4,7 @@
Loading...
+
diff --git a/lib/Display.php b/lib/Display.php
index 6cea272db..b58ad4094 100755
--- a/lib/Display.php
+++ b/lib/Display.php
@@ -108,7 +108,10 @@ public function startTable()
$sheet = $this->_profileLib->getProfileStylesheet();
if ($profileStylesheet === false || strcmp($profileStylesheet, $sheet))
{
- echo sprintf('', $sheet);
+ echo sprintf(
+ '',
+ TemplateUtility::getVersionedAssetURL($sheet)
+ );
$profileStylesheet = $sheet;
}
diff --git a/lib/TemplateUtility.php b/lib/TemplateUtility.php
index 1db34f95b..adfad455e 100755
--- a/lib/TemplateUtility.php
+++ b/lib/TemplateUtility.php
@@ -1170,6 +1170,76 @@ public static function _printQuickActionMenuHolder()
echo '';
}
+ /**
+ * Returns an asset URL with a file-based version query parameter.
+ *
+ * @param string Relative asset path
+ * @return string
+ */
+ public static function getVersionedAssetURL($assetPath)
+ {
+ $assetPath = (string) $assetPath;
+ if ($assetPath == '')
+ {
+ return $assetPath;
+ }
+
+ $parsedURL = parse_url($assetPath);
+ if ($parsedURL === false || isset($parsedURL['scheme']) || isset($parsedURL['host']))
+ {
+ return $assetPath;
+ }
+
+ $path = isset($parsedURL['path']) ? $parsedURL['path'] : '';
+ if ($path == '')
+ {
+ return $assetPath;
+ }
+
+ $legacyRootPath = realpath(LEGACY_ROOT);
+ if ($legacyRootPath === false)
+ {
+ return $assetPath;
+ }
+
+ $normalizedPath = ltrim(str_replace('\\', '/', $path), '/');
+ if ($normalizedPath == '')
+ {
+ return $assetPath;
+ }
+
+ $assetFilePath = realpath(
+ $legacyRootPath . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $normalizedPath)
+ );
+ if ($assetFilePath === false)
+ {
+ return $assetPath;
+ }
+
+ $legacyRootPrefix = rtrim($legacyRootPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
+ if ($assetFilePath !== $legacyRootPath && strpos($assetFilePath, $legacyRootPrefix) !== 0)
+ {
+ return $assetPath;
+ }
+
+ $fileMTime = @filemtime($assetFilePath);
+ if ($fileMTime === false)
+ {
+ return $assetPath;
+ }
+
+ $queryString = isset($parsedURL['query']) ? $parsedURL['query'] . '&' : '';
+ $queryString .= 'v=' . (int) $fileMTime;
+
+ $versionedAssetURL = $path . '?' . $queryString;
+ if (isset($parsedURL['fragment']))
+ {
+ $versionedAssetURL .= '#' . $parsedURL['fragment'];
+ }
+
+ return $versionedAssetURL;
+ }
+
/**
* Prints template header HTML.
*
@@ -1186,16 +1256,6 @@ private static function _printCommonHeader($pageTitle, $headIncludes = array())
$siteID = $_SESSION['CATS']->getSiteID();
- /* This prevents caching problems when SVN updates are preformed. */
- if ($_SESSION['CATS']->getCachedBuild() > 0)
- {
- $javascriptAntiCache = '?b=' . $_SESSION['CATS']->getCachedBuild();
- }
- else
- {
- $javascriptAntiCache = '?v=' . CATSUtility::getVersionAsInteger();
- }
-
echo '', "\n";
echo '', "\n";
@@ -1208,11 +1268,18 @@ private static function _printCommonHeader($pageTitle, $headIncludes = array())
CATSUtility::getIndexName(), '?m=rss" />', "\n";
/* Core JS files */
- echo '', "\n";
- echo '', "\n";
- echo '', "\n";
- echo '', "\n";
- echo '', "\n";
+ $coreJavaScriptFiles = array(
+ 'js/lib.js',
+ 'js/quickAction.js',
+ 'js/calendarDateInput.js',
+ 'js/submodal/subModal.js',
+ 'js/jquery-1.3.2.min.js'
+ );
+ foreach ($coreJavaScriptFiles as $coreJavaScriptFile)
+ {
+ $versionedFilename = self::getVersionedAssetURL($coreJavaScriptFile);
+ echo '', "\n";
+ }
echo '', "\n";
if (isset($_SESSION['CATS']) && $_SESSION['CATS']->isLoggedIn())
{
@@ -1284,22 +1351,31 @@ private static function _printCommonHeader($pageTitle, $headIncludes = array())
foreach ($headIncludes as $key => $filename)
{
- $extension = substr($filename, strrpos($filename, '.') + 1);
+ $path = parse_url($filename, PHP_URL_PATH);
+ if ($path === false || $path === null)
+ {
+ $path = $filename;
+ }
+ $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
- $filename .= $javascriptAntiCache;
+ $versionedFilename = self::getVersionedAssetURL($filename);
if ($extension == 'js')
{
- echo '', "\n";
+ echo '', "\n";
}
else if ($extension == 'css')
{
- echo '', "\n";
+ echo '', "\n";
}
}
- echo '', "\n";
- echo '', "\n";
+ echo '', "\n";
+ echo '', "\n";
echo '', "\n\n";
}
diff --git a/modules/careers/Blank.tpl b/modules/careers/Blank.tpl
index 906e27f0c..07ddbb5a5 100755
--- a/modules/careers/Blank.tpl
+++ b/modules/careers/Blank.tpl
@@ -4,16 +4,16 @@
_($this->siteName); ?> - Careers
-
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
+
+
+
diff --git a/modules/install/phpVersion.php b/modules/install/phpVersion.php
index 7c17273ca..c877d5bd4 100755
--- a/modules/install/phpVersion.php
+++ b/modules/install/phpVersion.php
@@ -1,12 +1,14 @@
+
+
CATS - Installation Wizard Script
-
-
-
+
+
+
diff --git a/modules/login/ForgotPassword.tpl b/modules/login/ForgotPassword.tpl
index 72ab65706..6351a50cb 100755
--- a/modules/login/ForgotPassword.tpl
+++ b/modules/login/ForgotPassword.tpl
@@ -5,9 +5,9 @@
OpenCATS - Login
-
-
-
+
+
+
diff --git a/modules/login/Login.tpl b/modules/login/Login.tpl
index 370b6c438..ea480f598 100755
--- a/modules/login/Login.tpl
+++ b/modules/login/Login.tpl
@@ -5,10 +5,10 @@
opencats - Login
-
-
-
-
+
+
+
+
diff --git a/modules/reports/GraphView.tpl b/modules/reports/GraphView.tpl
index ce785b323..1b62170f3 100755
--- a/modules/reports/GraphView.tpl
+++ b/modules/reports/GraphView.tpl
@@ -8,8 +8,8 @@
-
-
+
+
-
-
+
+
+
diff --git a/modules/settings/PreviewPageTop.tpl b/modules/settings/PreviewPageTop.tpl
index c7c6e6a0d..9de351659 100755
--- a/modules/settings/PreviewPageTop.tpl
+++ b/modules/settings/PreviewPageTop.tpl
@@ -3,7 +3,7 @@
-
+
', "\n";
+ echo ' ', "\n";
foreach ($headIncludes as $key => $value)
{
- echo ' ', "\n";
+ echo ' ', "\n";
}
echo ' ', "\n";
diff --git a/modules/wizard/Show.tpl b/modules/wizard/Show.tpl
index 068521df5..ea799d8df 100755
--- a/modules/wizard/Show.tpl
+++ b/modules/wizard/Show.tpl
@@ -6,10 +6,10 @@
-
-
+
+
jsInclude != ''): ?>
-
+