More image tag parser fixes
authorDan
Sun, 01 Jul 2007 17:12:42 -0400
changeset 37 7267c2a67a93
parent 36 425261984266
child 38 ed06961e54dd
More image tag parser fixes
includes/pageprocess.php
includes/render.php
plugins/SpecialAdmin.php
themes/stpatty/css/shamrock.css
--- a/includes/pageprocess.php	Sun Jul 01 15:00:32 2007 -0400
+++ b/includes/pageprocess.php	Sun Jul 01 17:12:42 2007 -0400
@@ -723,13 +723,13 @@
     if ( !empty($userdata['user_aim']) )
     {
       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
-      echo '<tr><td class="'.$class.'">AIM: ' . htmlspecialchars($userdata['user_aim']) . '</td></tr>';
+      echo '<tr><td class="'.$class.'">AIM: ' . $userdata['user_aim'] . '</td></tr>';
     }
     
     if ( !empty($userdata['user_yahoo']) )
     {
       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
-      echo '<tr><td class="'.$class.'">Yahoo! IM: ' . htmlspecialchars($userdata['user_yahoo']) . '</td></tr>';
+      echo '<tr><td class="'.$class.'">Yahoo! IM: ' . $userdata['user_yahoo'] . '</td></tr>';
     }
     
     if ( !empty($userdata['user_msn']) )
@@ -753,19 +753,19 @@
     if ( !empty($userdata['user_location']) )
     {
       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
-      echo '<tr><td class="'.$class.'">Location: ' . htmlspecialchars($userdata['user_location']) . '</td></tr>';
+      echo '<tr><td class="'.$class.'">Location: ' . $userdata['user_location'] . '</td></tr>';
     }
     
     if ( !empty($userdata['user_job']) )
     {
       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
-      echo '<tr><td class="'.$class.'">Job/occupation: ' . htmlspecialchars($userdata['user_job']) . '</td></tr>';
+      echo '<tr><td class="'.$class.'">Job/occupation: ' . $userdata['user_job'] . '</td></tr>';
     }
     
     if ( !empty($userdata['user_hobbies']) )
     {
       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
-      echo '<tr><td class="'.$class.'">Enjoys: ' . htmlspecialchars($userdata['user_hobbies']) . '</td></tr>';
+      echo '<tr><td class="'.$class.'">Enjoys: ' . $userdata['user_hobbies'] . '</td></tr>';
     }
     
     if ( empty($userdata['user_location']) && empty($userdata['user_job']) && empty($userdata['user_hobbies']) )
--- a/includes/render.php	Sun Jul 01 15:00:32 2007 -0400
+++ b/includes/render.php	Sun Jul 01 17:12:42 2007 -0400
@@ -243,7 +243,7 @@
     if ( !$plaintext )
     {
       // Process images
-      $text = RenderMan::process_image_tags($text);
+      $text = RenderMan::process_image_tags($text, $taglist);
     }
     
     if($do_params)
@@ -272,6 +272,11 @@
       $result = $wiki->transform($text, 'Xhtml');
     }
     
+    if ( !$plaintext )
+    {
+      $result = RenderMan::process_imgtags_stage2($result, $taglist);
+    }
+    
     // Reinsert <nowiki> sections
     for($i=0;$i<$nw;$i++)
     {
@@ -747,13 +752,18 @@
   /**
    * Changes wikitext image tags to HTML.
    * @param string The wikitext to process
+   * @param array Will be overwritten with the list of HTML tags (the system uses tokens for TextWiki compatibility)
    * @return string
    */
   
-  function process_image_tags($text)
+  function process_image_tags($text, &$taglist)
   {
     global $db, $session, $paths, $template, $plugins; // Common objects
     
+    $s_delim = "\xFF";
+    $f_delim = "\xFF";
+    $taglist = array();
+    
     // Wicked huh?
     $regex = '/\[\[:' . $paths->nslist['File'] . '([\w\s0-9_\(\)!@%\^\+\|\.-]+?)((\|thumb)|(\|([0-9]+)x([0-9]+)))?(\|left|\|right)?(\|(.+))?\]\]/i';
     
@@ -801,11 +811,6 @@
         $img_tag .= 'width="' . $r_width . '" height="' . $r_height . '" ';
       }
       
-      if ( empty($clear) && $scale_type == '|thumb' )
-      {
-        $clear = 'right';
-      }
-      
       $img_tag .= 'style="border-width: 0px; background-color: white;" ';
       
       $img_tag .= '/>';
@@ -820,7 +825,7 @@
         {
           $side = ( $clear == '|left' ) ? 'left' : 'right';
           $opposite = ( $clear == '|left' ) ? 'right' : 'left';
-          $clear_text .= "clear: $side; float: $side; margin-$opposite: 20px;";
+          $clear_text .= "float: $side; margin-$opposite: 20px;";
           $complete_tag .= 'style="' . $clear_text . '" ';
         }
         $complete_tag .= '>';
@@ -846,9 +851,10 @@
         $complete_tag .= '</a>';
       }
       
-      $complete_tag = "<nowiki>$complete_tag</nowiki>\n\n";
+      $complete_tag .= "\n\n";
+      $taglist[$i] = $complete_tag;
       
-      $pos = strpos($text, $full_tag) - 3;
+      $pos = strpos($text, $full_tag);
       
       while(true)
       {
@@ -862,7 +868,8 @@
         $pos--;
       }
       
-      $text = substr($text, 0, $pos) . $complete_tag . substr($text, $pos + 1);
+      $repl = "{$s_delim}e_img_{$i}{$f_delim}";
+      $text = substr($text, 0, $pos) . $repl . substr($text, $pos);
       
       $text = str_replace($full_tag, '', $text);
       
@@ -873,6 +880,24 @@
     return $text;
   }
   
+  /**
+   * Finalizes processing of image tags.
+   * @param string The preprocessed text
+   * @param array The list of image tags created by RenderMan::process_image_tags()
+   */
+   
+  function process_imgtags_stage2($text, $taglist)
+  {
+    $s_delim = "\xFF";
+    $f_delim = "\xFF";
+    foreach ( $taglist as $i => $tag )
+    {
+      $repl = "{$s_delim}e_img_{$i}{$f_delim}";
+      $text = str_replace($repl, $tag, $text);
+    }               
+    return $text;
+  }
+  
 }
  
 ?>
--- a/plugins/SpecialAdmin.php	Sun Jul 01 15:00:32 2007 -0400
+++ b/plugins/SpecialAdmin.php	Sun Jul 01 17:12:42 2007 -0400
@@ -49,7 +49,6 @@
     return;
   }
   
-  
   // Basic information
   echo RenderMan::render(
 '== Welcome to Runt, the Enano administration panel. ==
--- a/themes/stpatty/css/shamrock.css	Sun Jul 01 15:00:32 2007 -0400
+++ b/themes/stpatty/css/shamrock.css	Sun Jul 01 17:12:42 2007 -0400
@@ -79,6 +79,7 @@
 div#maincontent {
   padding: 10px;
   padding-right: 150px;
+  clear: left;
 }
 img#ajaxloadicon {
   margin-top: 10px;
@@ -118,6 +119,7 @@
 /* Sidebar */
 div#sidebar, div.dbx-box {
   float: right;
+  clear: right;
   width: 135px;
 }
 div#sidebar h4, div.dbx-handle {