Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
authorDan
Tue, 10 Jul 2007 03:38:19 -0400
changeset 59 7c4a851fb5c5
parent 58 8f532d8ab5f5
child 60 71b50f8c8f85
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
includes/clientside/static/enano-lib-basic.js
includes/template.php
--- a/includes/clientside/static/enano-lib-basic.js	Tue Jul 10 00:40:52 2007 -0400
+++ b/includes/clientside/static/enano-lib-basic.js	Tue Jul 10 03:38:19 2007 -0400
@@ -275,11 +275,11 @@
 {
   if ( typeof ( func ) == 'function' )
   {
-    try
+    if ( typeof(onload_hooks.push) == 'function' )
     {
       onload_hooks.push(func);
     }
-    catch(e)
+    else
     {
       onload_hooks[onload_hooks.length] = func;
     }
--- a/includes/template.php	Tue Jul 10 00:40:52 2007 -0400
+++ b/includes/template.php	Tue Jul 10 03:38:19 2007 -0400
@@ -1125,7 +1125,7 @@
     for($i=0;$i<sizeof($il[1]);$i++)
     {
       $href = makeUrl(str_replace(' ', '_', $il[1][$i]), null, true);
-      $text_parser->assign_vars(Array(
+      $text_parser->assign_vars(Array(  
           'HREF'  => $href,
           'FLAGS' => '',
           'TEXT'  => $il[1][$i]
@@ -1146,8 +1146,32 @@
     }
     
     // External links
-    $message = preg_replace('#\[(http|ftp|irc):\/\/([a-z0-9\/:_\.\?&%\#@_\\\\-]+?)\\ ([^\]]+)]#', '<a href="\\1://\\2">\\3</a><br style="display: none;" />', $message);
-    $message = preg_replace('#\[(http|ftp|irc):\/\/([a-z0-9\/:_\.\?&%\#@_\\\\-]+?)\\]#', '<a href="\\1://\\2">\\1://\\2</a><br style="display: none;" />', $message);
+    // $message = preg_replace('#\[(http|ftp|irc):\/\/([a-z0-9\/:_\.\?&%\#@_\\\\-]+?) ([^\]]+)\\]#', '<a href="\\1://\\2">\\3</a><br style="display: none;" />', $message);
+    // $message = preg_replace('#\[(http|ftp|irc):\/\/([a-z0-9\/:_\.\?&%\#@_\\\\-]+?)\\]#', '<a href="\\1://\\2">\\1://\\2</a><br style="display: none;" />', $message);
+    
+    preg_match_all('#\[(http|ftp|irc):\/\/([a-z0-9\/:_\.\?&%\#@_\\\\-]+?)\\ ([^\]]+)]#', $message, $ext_link);
+    
+    for ( $i = 0; $i < count($ext_link[0]); $i++ )
+    {
+      $text_parser->assign_vars(Array(  
+          'HREF'  => "{$ext_link[1][$i]}://{$ext_link[2][$i]}",
+          'FLAGS' => '',
+          'TEXT'  => $ext_link[3][$i]
+        ));
+      $message = str_replace($ext_link[0][$i], $text_parser->run(), $message);
+    }
+    
+    preg_match_all('#\[(http|ftp|irc):\/\/([a-z0-9\/:_\.\?&%\#@_\\\\-]+?)\\]#', $message, $ext_link);
+    
+    for ( $i = 0; $i < count($ext_link[0]); $i++ )
+    {
+      $text_parser->assign_vars(Array(  
+          'HREF'  => "{$ext_link[1][$i]}://{$ext_link[2][$i]}",
+          'FLAGS' => '',
+          'TEXT'  => htmlspecialchars("{$ext_link[1][$i]}://{$ext_link[2][$i]}")
+        ));
+      $message = str_replace($ext_link[0][$i], $text_parser->run(), $message);
+    }
     
     $parser1 = $this->makeParserText($tplvars['sidebar_section']);
     $parser2 = $this->makeParserText($tplvars['sidebar_section_raw']);