rename VCS-related classes
[diogenes.git] / include / diogenes.spool.inc.php
index 69fc184..6afa6e2 100644 (file)
@@ -21,7 +21,7 @@
 
 /** This class handles Diogenes spool operations.
  */
-class DiogenesSpool {
+class Diogenes_VCS_Spool {
   /** The barrel we are running on */
   var $alias;
   /** Absolute directory location for the barrel's spool. */
@@ -47,7 +47,7 @@ class DiogenesSpool {
    * @param caller the caller
    * @param alias the alias to work on
    */
-  function DiogenesSpool(&$caller,$alias) {
+  function Diogenes_VCS_Spool(&$caller,$alias) {
     global $globals;
     $this->datadir = "{$globals->spoolroot}/$alias";
     $this->caller =& $caller;
@@ -154,6 +154,33 @@ class DiogenesSpool {
    */
   function importHtmlString($html)
   {
+    // If available, run tidy to clean sources
+    if (function_exists('tidy_repair_string')) {
+        $tidy_config = array('drop-empty-paras' => true,
+                             'drop-proprietary-attributes' => true,
+                             'hide-comments' => true,
+                             'logical-emphasis' => true,
+                             'output-xhtml' => true,
+                             'replace-color' => true,
+                             'join-classes'  => true,
+                             'join-style' => true, 
+                             'clean' => true,
+                             'show-body-only' => true,
+                             'alt-text' => '[ inserted by TIDY ]',
+                             'break-before-br' => true,
+                             'indent' => true,
+                             'vertical-space' => true,
+                             'wrap' => 120);
+        if (function_exists('tidy_setopt')) { // Tidy 1.0
+            foreach ($tidy_config as $field=>$value) {
+                tidy_setopt($field, $value);
+            }
+            $html = tidy_repair_string($html);
+        } else { // Tidy 2.0
+            $html = tidy_repair_string($html, $tidy_config);
+        }
+    }
     // if we cannot find the body open & close tags, return raw file
     if (!preg_match("/<body(\s[^>]*|)>(.*)<\/body>/si",$html,$matches))
       return $html;