diff --git a/libraries/cms/html/html.php b/libraries/cms/html/html.php index d28274b13bf49..ecb7d1a0447d7 100644 --- a/libraries/cms/html/html.php +++ b/libraries/cms/html/html.php @@ -276,6 +276,31 @@ public static function iframe($url, $name, $attribs = null, $noFrames = '') return ''; } + /** + * Include version with MD5SUM file in path. + * + * @param string $path Folder name to search into (images, css, js, ...). + * + * @return string Query string to add. + * + * @since __DEPLOY_VERSION__ + * + * @deprecated 4.0 Usage of MD5SUM files is deprecated, use version instead. + */ + protected static function getMd5Version($path) + { + $md5 = dirname($path) . '/MD5SUM'; + + if (file_exists($md5)) + { + JLog::add('Usage of MD5SUM files is deprecated, use version instead.', JLog::WARNING, 'deprecated'); + + return '?' . file_get_contents($md5); + } + + return ''; + } + /** * Compute the files to be included * @@ -371,9 +396,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $md5 = dirname($path) . '/MD5SUM'; - $includes[] = JUri::base(true) . "/templates/$template/$folder/$file" . - (file_exists($md5) ? ('?' . file_get_contents($md5)) : ''); + $includes[] = JUri::base(true) . "/templates/$template/$folder/$file" . static::getMd5Version($path); break; } @@ -396,9 +419,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $md5 = dirname($path) . '/MD5SUM'; - $includes[] = JUri::root(true) . "/media/$extension/$element/$folder/$file" . - (file_exists($md5) ? ('?' . file_get_contents($md5)) : ''); + $includes[] = JUri::root(true) . "/media/$extension/$element/$folder/$file" . static::getMd5Version($path); break; } @@ -408,9 +429,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $md5 = dirname($path) . '/MD5SUM'; - $includes[] = JUri::root(true) . "/media/$extension/$folder/$element/$file" . - (file_exists($md5) ? ('?' . file_get_contents($md5)) : ''); + $includes[] = JUri::root(true) . "/media/$extension/$folder/$element/$file" . static::getMd5Version($path); break; } @@ -420,9 +439,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $md5 = dirname($path) . '/MD5SUM'; - $includes[] = JUri::root(true) . "/templates/$template/$folder/system/$element/$file" . - (file_exists($md5) ? ('?' . file_get_contents($md5)) : ''); + $includes[] = JUri::root(true) . "/templates/$template/$folder/system/$element/$file" . static::getMd5Version($path); break; } @@ -432,9 +449,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $md5 = dirname($path) . '/MD5SUM'; - $includes[] = JUri::root(true) . "/media/system/$folder/$element/$file" . - (file_exists($md5) ? ('?' . file_get_contents($md5)) : ''); + $includes[] = JUri::root(true) . "/media/system/$folder/$element/$file" . static::getMd5Version($path); break; } @@ -446,9 +461,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $md5 = dirname($path) . '/MD5SUM'; - $includes[] = JUri::root(true) . "/media/$extension/$folder/$file" . - (file_exists($md5) ? ('?' . file_get_contents($md5)) : ''); + $includes[] = JUri::root(true) . "/media/$extension/$folder/$file" . static::getMd5Version($path); break; } @@ -458,9 +471,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $md5 = dirname($path) . '/MD5SUM'; - $includes[] = JUri::root(true) . "/templates/$template/$folder/system/$file" . - (file_exists($md5) ? ('?' . file_get_contents($md5)) : ''); + $includes[] = JUri::root(true) . "/templates/$template/$folder/system/$file" . static::getMd5Version($path); break; } @@ -470,9 +481,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $md5 = dirname($path) . '/MD5SUM'; - $includes[] = JUri::root(true) . "/media/system/$folder/$file" . - (file_exists($md5) ? ('?' . file_get_contents($md5)) : ''); + $includes[] = JUri::root(true) . "/media/system/$folder/$file" . static::getMd5Version($path); break; } @@ -485,9 +494,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $md5 = dirname($path) . '/MD5SUM'; - $includes[] = JUri::root(true) . "/media/system/$folder/$file" . - (file_exists($md5) ? ('?' . file_get_contents($md5)) : ''); + $includes[] = JUri::root(true) . "/media/system/$folder/$file" . static::getMd5Version($path); break; } @@ -535,9 +542,7 @@ protected static function includeRelativeFiles($folder, $file, $relative, $detec if (file_exists($path)) { - $md5 = dirname($path) . '/MD5SUM'; - $includes[] = JUri::root(true) . "/$file" . - (file_exists($md5) ? ('?' . file_get_contents($md5)) : ''); + $includes[] = JUri::root(true) . "/$file" . static::getMd5Version($path); break; } @@ -653,50 +658,83 @@ public static function stylesheet($file, $attribs = array(), $relative = false, /** * Write a `' . $lnEnd; } - $defaultJsMimes = array('text/javascript', 'application/javascript', 'text/x-javascript', 'application/x-javascript'); + $defaultJsMimes = array('text/javascript', 'application/javascript', 'text/x-javascript', 'application/x-javascript'); + $html5NoValueAttributes = array('defer', 'async'); + $mediaVersion = $document->getMediaVersion(); // Generate script file links - foreach ($document->_scripts as $strSrc => $strAttr) + foreach ($document->_scripts as $src => $attribs) { - $buffer .= $tab . ''; + + // This is for IE conditional statements support. + if (!is_null($conditional)) + { + $buffer .= ''; + } + + $buffer .= $lnEnd; } // Generate script declarations diff --git a/tests/unit/suites/libraries/cms/html/JHtmlBehaviorTest.php b/tests/unit/suites/libraries/cms/html/JHtmlBehaviorTest.php index 987ab83c19c6a..7d272b5eaac6a 100644 --- a/tests/unit/suites/libraries/cms/html/JHtmlBehaviorTest.php +++ b/tests/unit/suites/libraries/cms/html/JHtmlBehaviorTest.php @@ -492,7 +492,6 @@ public function testKeepalive() array( 'JHtmlBehavior::keepalive' => true, 'JHtmlBehavior::core' => true, - 'JHtmlBehavior::framework' => array('core' => true), 'JHtmlBehavior::polyfill' => array(md5(serialize(array('event', 'lt IE 9'))) => true), ), JHtmlBehaviorInspector::getLoaded(),