]> git.mjollnir.org Git - s9y.git/commitdiff
* Trackback transcoding
authorgarvinhicking <garvinhicking>
Wed, 1 Feb 2006 13:24:20 +0000 (13:24 +0000)
committergarvinhicking <garvinhicking>
Wed, 1 Feb 2006 13:24:20 +0000 (13:24 +0000)
* Spartacus debugging reloaded
* Categories plugin HTML fixes
* Document changes

docs/NEWS
include/functions_trackbacks.inc.php
include/plugin_internal.inc.php
plugins/serendipity_event_spartacus/serendipity_event_spartacus.php

index a39de9bc6b5ac87a706e8a4a3e0107135a70ffdc..aeb70e9596be6764144a045709cb991e7a4a8696 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,15 @@
 Version 1.0-beta2 ()
 ------------------------------------------------------------------------
 
+   * Made categories plugin default HTML output more XHTML compliant.
+     (garvinhicking)
+
+   * Added option "stronger captchas" in spamblock plugin.
+   
+   * Transcode incoming trackbacks from the given charset to your blog's
+     charset. Reliably only works with the two most common formats,
+     ISO-8859-1 <-> UTF-8. (garvinhicking)
+
    * Change karma plugin and search results to output more HTML span
      classes for better styling (garvinhicking)
 
index 96138270cfb55f1e1a875b17c2b3f25b49d80480..8f2d4dedae0b2e69704e0434cd4156e465063c77 100644 (file)
@@ -229,19 +229,55 @@ function add_trackback ($id, $title, $url, $name, $excerpt) {
 
     // We can't accept a trackback if we don't get any URL
     // This is a protocol rule.
-    if ( empty($url) ) {
+    if (empty($url)) {
         return 0;
     }
 
     // If title is not provided, the value for url will be set as the title
     // This is a protocol rule.
-    if ( empty($title) ) {
+    if (empty($title)) {
         $title = $url;
     }
-    $comment['title']   = $title;
-    $comment['url']     = $url;
-    $comment['name']    = $name;
-    $comment['comment'] = $excerpt;
+    
+    $comment = array(
+        'title'   => $title,
+        'url'     => $url,
+        'name'    => $name,
+        'comment' => $excerpt
+    );
+    
+    $is_utf8 = strtolower(LANG_CHARSET) == 'utf-8';
+
+    if ($GLOBALS['tb_logging']) {
+        $fp = fopen('trackback2.log', 'a');
+        fwrite($fp, '[' . date('d.m.Y H:i') . '] TRACKBACK TRANSCODING CHECK' . "\n");
+    }
+
+    foreach($comment AS $idx => $field) {
+        if (is_utf8($field)) {
+            // Trackback is in UTF-8. Check if our blog also is UTF-8.
+            if (!$is_utf8) {
+                if ($GLOBALS['tb_logging']) {
+                    fwrite($fp, '[' . date('d.m.Y H:i') . '] Transcoding ' . $idx . ' from UTF-8 to ISO' . "\n");
+                }
+                $comment[$idx] = utf8_decode($field);
+            }
+        } else {
+            // Trackback is in some native format. We assume ISO-8859-1. Check if our blog is also ISO.
+            if ($is_utf8) {
+                if ($GLOBALS['tb_logging']) {
+                    fwrite($fp, '[' . date('d.m.Y H:i') . '] Transcoding ' . $idx . ' from ISO to UTF-8' . "\n");
+                }
+                $comment[$idx] = utf8_encode($field);
+            }
+        }
+    }
+    
+    if ($GLOBALS['tb_logging']) {
+        fwrite($fp, '[' . date('d.m.Y H:i') . '] TRACKBACK DATA: ' . print_r($comment, true) . '...' . "\n");
+        fwrite($fp, '[' . date('d.m.Y H:i') . '] TRACKBACK STORING...' . "\n");
+        fclose($fp);
+    }
 
     serendipity_saveComment($id, $comment, 'TRACKBACK');
 
@@ -434,3 +470,24 @@ function serendipity_handle_references($id, $author, $title, $text) {
         serendipity_db_query($query);
     }
 }
+
+/**
+ * Check if a string is in UTF-8 format.
+ *
+ * @access public
+ * @param   string  The string to check
+ * @return  bool
+ */
+function is_utf8($string) {
+   // From http://w3.org/International/questions/qa-forms-utf-8.html
+   return preg_match('%^(?:'
+         . '[\x09\x0A\x0D\x20-\x7E]'             # ASCII
+         . '|[\xC2-\xDF][\x80-\xBF]'             # non-overlong 2-byte
+         . '|\xE0[\xA0-\xBF][\x80-\xBF]'         # excluding overlongs
+         . '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'  # straight 3-byte
+         . '|\xED[\x80-\x9F][\x80-\xBF]'         # excluding surrogates
+         . '|\xF0[\x90-\xBF][\x80-\xBF]{2}'      # planes 1-3
+         . '|[\xF1-\xF3][\x80-\xBF]{3}'          # planes 4-15
+         . '|\xF4[\x80-\x8F][\x80-\xBF]{2}'      # plane 16
+         . ')*$%xs', $string);
+}
\ No newline at end of file
index 66f861e4897e0a06a8945a81fc0881f72777e02b..ed4a41aabd4ac6f0d309f0322afbe245a8e9506f 100644 (file)
@@ -1402,7 +1402,9 @@ class serendipity_categories_plugin extends serendipity_plugin {
         $html       = '';
 
         if (!$smarty && $is_form) {
-            $html .= '<form action="' . $serendipity['baseURL'] . $serendipity['indexFile'] . '" method="post"><div>';
+            $html .= '<form action="' . $serendipity['baseURL'] . $serendipity['indexFile'] . '" method="post">
+              <div id="serendipity_category_form_content">
+              <ul id="serendipity_categories_list" style="list-style: none; margin: 0px; padding: 0px">';
         }
 
         $image = $this->get_config('image', serendipity_getTemplateFile('img/xml.gif'));
@@ -1464,28 +1466,32 @@ class serendipity_categories_plugin extends serendipity_plugin {
                 }
 
                 if (!$smarty) {
-                    $html .= '<div style="padding-bottom: 2px;">';
+                    $html .= '<li style="display: block;">';
 
                     if ($is_form) {
                         $html .= '<input style="width: 15px" type="checkbox" name="serendipity[multiCat][]" value="' . $cat['categoryid'] . '" />';
                     }
 
                     if ( !empty($image) ) {
-                        $html .= '<a href="'. $categories[$cid]['feedCategoryURL'] .'"><img src="'. $image .'" alt="XML" style="border: 0px" /></a> ';
+                        $html .= '<a class="serendipity_xml_icon" href="'. $categories[$cid]['feedCategoryURL'] .'"><img src="'. $image .'" alt="XML" style="border: 0px" /></a> ';
                     }
                     $html .= '<a href="'. $categories[$cid]['categoryURL'] .'" title="'. htmlspecialchars($cat['category_description']) .'" style="padding-left: '. $categories[$cid]['paddingPx'] .'px">'. htmlspecialchars($categories[$cid]['category_name']) .'</a>';
-                    $html .= '</div>' . "\n";
+                    $html .= '</li>' . "\n";
                 }
             }
         }
 
+        if (!$smarty) {
+            $html .= '</ul>';
+        }
+        
         if (!$smarty && $is_form) {
-            $html .= '<br /><input type="submit" name="serendipity[isMultiCat]" value="' . GO . '" /><br />';
+            $html .= '<div class="category_submit"><br /><input type="submit" name="serendipity[isMultiCat]" value="' . GO . '" /></div>';
         }
 
         if (!$smarty) {
             $html .= sprintf(
-                '<br /><a href="%s" title="%s">%s</a>',
+                '<div class="category_link_all"><br /><a href="%s" title="%s">%s</a></div>',
 
                 $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'],
                 ALL_CATEGORIES,
index fb0930433e4a9c44f40eea262b0d9cb10ac982ae..f077f01da23134176a6f0cb79344006dc06ef78f 100644 (file)
@@ -570,7 +570,7 @@ class serendipity_event_spartacus extends serendipity_event
 
     function checkArray(&$tree) {
         if (!is_array($tree) || !is_array($tree[0]['children'])) {
-           echo "DEBUG: Tree not an array, but: " . print_r($tree, true) . ". Please report this bug. This might be an error with the downloaded XML file. You can try to go to the plugin configuration of the Spartacus Plugin and simply click on 'Save' - this will purge all cached XML files and try to download it again.<br />\n";
+           echo "DEBUG: The XML file could not be successfully parsed. Download or caching error. Please try again later or switch your XML/File mirror location. You can also try to go to the plugin configuration of the Spartacus Plugin and simply click on 'Save' - this will purge all cached XML files and try to download it again.<div style='display: none'>" . print_r($tree, true) . "</div><br />\n";
         }
     }