@@ -348,6 +348,31 @@ public static function iframe($url, $name, $attribs = null, $noFrames = '')
348348 return '<iframe src=" ' . $ url . '" ' . $ attribs . ' name=" ' . $ name . '"> ' . $ noFrames . '</iframe> ' ;
349349 }
350350
351+ /**
352+ * Look for path relatively to media folder.
353+ *
354+ * @param string $folder Folder name to search in (i.e. images, css, js).
355+ * @param string $file Path to file to check.
356+ * @param array $options Array with additional options:
357+ * relative: Flag if the path to the file is relative to the /media folder (and searches in template);
358+ * detectBrowser: Flag if the browser should be detected to include specific browser file;
359+ * detectDebug: Flag if debug mode is enabled to include uncompressed files (for css, js)
360+ * (boolean) - will enable debugging depends on site configuration, (1) - force debug On, (-1) - force debug Off;
361+ *
362+ * @return string
363+ * @since __DEPLOY_VERSION__
364+ */
365+ final public static function mediaPath (string $ folder , string $ file , array $ options = []): string
366+ {
367+ $ relative = $ options ['relative ' ] ?? false ;
368+ $ detectBrowser = $ options ['detectBrowser ' ] ?? false ;
369+ $ detectDebug = $ options ['detectDebug ' ] ?? true ;
370+
371+ $ includes = static ::includeRelativeFiles ($ folder , $ file , $ relative , $ detectBrowser , $ detectDebug );
372+
373+ return $ includes [0 ] ?? '' ;
374+ }
375+
351376 /**
352377 * Compute the files to be included
353378 *
@@ -356,6 +381,7 @@ public static function iframe($url, $name, $attribs = null, $noFrames = '')
356381 * @param boolean $relative Flag if the path to the file is relative to the /media folder (and searches in template).
357382 * @param boolean $detectBrowser Flag if the browser should be detected to include specific browser files.
358383 * @param boolean $detectDebug Flag if debug mode is enabled to include uncompressed files if debug is on.
384+ * (boolean) - will enable debugging depends on site configuration, (1) - force debug On, (-1) - force debug Off;
359385 *
360386 * @return array files to be included.
361387 *
@@ -364,12 +390,17 @@ public static function iframe($url, $name, $attribs = null, $noFrames = '')
364390 */
365391 protected static function includeRelativeFiles ($ folder , $ file , $ relative , $ detectBrowser , $ detectDebug )
366392 {
367- // Set debug flag
368- $ debugMode = false ;
369-
370393 // Detect debug mode
371- if ($ detectDebug && JDEBUG ) {
372- $ debugMode = true ;
394+ switch (true ) {
395+ case \is_bool ($ detectDebug ):
396+ $ debugMode = $ detectDebug && JDEBUG ;
397+ break ;
398+ case $ detectDebug === 1 :
399+ $ debugMode = true ;
400+ break ;
401+ case $ detectDebug === -1 :
402+ default :
403+ $ debugMode = false ;
373404 }
374405
375406 // If http is present in filename
@@ -757,9 +788,14 @@ public static function image($file, $alt, $attribs = null, $relative = false, $r
757788 *
758789 * @see Browser
759790 * @since 1.5
791+ *
792+ * @deprecated __DEPLOY_VERSION__ will be removed in 7.0
793+ * Use WebAssetManager::useStyle() or WebAssetManager::registerAndUseStyle() instead.
760794 */
761795 public static function stylesheet ($ file , $ options = [], $ attribs = [])
762796 {
797+ @trigger_error ('Method HTMLHelper::stylesheet() is deprecated, and will be removed in 7.0 ' , \E_USER_DEPRECATED );
798+
763799 $ options ['relative ' ] = $ options ['relative ' ] ?? false ;
764800 $ options ['pathOnly ' ] = $ options ['pathOnly ' ] ?? false ;
765801 $ options ['detectBrowser ' ] = $ options ['detectBrowser ' ] ?? false ;
@@ -804,9 +840,14 @@ public static function stylesheet($file, $options = [], $attribs = [])
804840 *
805841 * @see HTMLHelper::stylesheet()
806842 * @since 1.5
843+ *
844+ * @deprecated __DEPLOY_VERSION__ will be removed in 7.0
845+ * Use WebAssetManager::useScript() or WebAssetManager::registerAndUseScript() instead.
807846 */
808847 public static function script ($ file , $ options = [], $ attribs = [])
809848 {
849+ @trigger_error ('Method HTMLHelper::script() is deprecated, and will be removed in 7.0 ' , \E_USER_DEPRECATED );
850+
810851 $ options ['relative ' ] = $ options ['relative ' ] ?? false ;
811852 $ options ['pathOnly ' ] = $ options ['pathOnly ' ] ?? false ;
812853 $ options ['detectBrowser ' ] = $ options ['detectBrowser ' ] ?? false ;
0 commit comments