@@ -120,7 +120,7 @@ public function header($buffer=false) {
120120 }
121121 if ( isset ($ this ->lessons ->headers ) && is_array ($ this ->lessons ->headers ) ) {
122122 foreach ($ this ->lessons ->headers as $ header ) {
123- $ header = self :: expandLink ($ header );
123+ $ header = $ this -> expandLink ($ header );
124124 echo ($ header );
125125 echo ("\n" );
126126 }
@@ -411,26 +411,6 @@ public static function absolute_url_ref(&$url) {
411411 */
412412 public static function expandLink ($ url ) {
413413 global $ CFG ;
414- // Skip expansion if URL already starts with http:// or https://
415- if (strpos ($ url , 'http:// ' ) === 0 || strpos ($ url , 'https:// ' ) === 0 ) {
416- return $ url ;
417- }
418-
419- // Clean up duplicate placeholders first (e.g., {apphome}/{apphome} -> {apphome})
420- $ url = preg_replace ('#\{apphome\}/+\{apphome\}# ' , '{apphome} ' , $ url );
421- $ url = preg_replace ('#\{wwwroot\}/+\{wwwroot\}# ' , '{wwwroot} ' , $ url );
422-
423- // Check if URL already contains expanded apphome or wwwroot (prevent double expansion)
424- $ has_expanded_apphome = isset ($ CFG ->apphome ) && strpos ($ url , $ CFG ->apphome ) !== false ;
425- $ has_expanded_wwwroot = isset ($ CFG ->wwwroot ) && strpos ($ url , $ CFG ->wwwroot ) !== false ;
426-
427- if ($ has_expanded_apphome || $ has_expanded_wwwroot ) {
428- // URL already contains expanded values, just remove any remaining placeholders
429- $ url = str_replace (array ('{apphome} ' , '{wwwroot} ' ), '' , $ url );
430- // Clean up any double slashes that might result
431- $ url = preg_replace ('#([^:])//+# ' , '$1/ ' , $ url );
432- return $ url ;
433- }
434414
435415 $ search = array (
436416 "{apphome} " ,
@@ -442,20 +422,6 @@ public static function expandLink($url) {
442422 );
443423 $ url = str_replace ($ search , $ replace , $ url );
444424
445- // Hopefully, the URL starts with http:// or https://
446- if (strpos ($ url , 'http:// ' ) === 0 || strpos ($ url , 'https:// ' ) === 0 ) {
447- return $ url ;
448- }
449-
450- // If we still don't have http:// or https://, and apphome is set, assume apphome, adding a / is the url sode not start with a slash
451- if ( $ url !== '' && isset ($ CFG ->apphome ) ) {
452- if ( strpos ($ url , '/ ' ) !== 0 ) {
453- $ url = $ CFG ->apphome . '/ ' . $ url ;
454- } else {
455- $ url = $ CFG ->apphome . $ url ;
456- }
457- }
458-
459425 return $ url ;
460426 }
461427
0 commit comments