Author: david
Date: Fri Aug 24 10:31:01 2012
New Revision: 12201

Log:
Add extractText() method to compound digital object logic. Fixes issue 1252.

Modified:
   trunk/lib/model/QubitDigitalObject.php

Modified: trunk/lib/model/QubitDigitalObject.php
==============================================================================
--- trunk/lib/model/QubitDigitalObject.php      Fri Aug 24 00:03:05 2012        
(r12200)
+++ trunk/lib/model/QubitDigitalObject.php      Fri Aug 24 10:31:01 2012        
(r12201)
@@ -323,6 +323,9 @@
         // We don't need reference image because a compound will be displayed 
instead of it
         // But thumbnails are necessary for image flow
         $this->createThumbnail($connection);
+
+        // Extract text and attach to parent digital object
+        $this->extractText($connection);
       }
       else
       {
@@ -964,11 +967,8 @@
             $this->createThumbnail($connection);
           }
 
-          // Extract text if possible
-          if (self::canExtractText($this->mimeType))
-          {
-            $this->extractText($connection);
-          }
+          // Extract text
+          $this->extractText($connection);
         }
 
         break;
@@ -1530,22 +1530,6 @@
   }
 
   /**
-   * Test if current mimeType allows text extraction
-   *
-   * @param string mime-type
-   * @return boolean true if extraction is supported
-   */
-  public static function canExtractText($mimeType)
-  {
-    if ('application/pdf' == $mimeType)
-    {
-      return true;
-    }
-
-    return false;
-  }
-
-  /**
    * Return true if derived mimeType is "image/*"
    *
    * @param string $filename
@@ -1903,14 +1887,36 @@
   }
 
   /**
+   * Test if text extraction is possible
+   *
+   * @param string mime-type
+   * @return boolean true if extraction is supported
+   */
+  public static function canExtractText($mimeType)
+  {
+    // Only works for PDFs
+    if ('application/pdf' != $mimeType)
+    {
+      return false;
+    }
+
+    // Requires pdftotext binary
+    if (!self::hasPdfToText())
+    {
+      return false;
+    }
+
+    return true;
+  }
+
+  /**
    * Create a thumbnail derivative for the current digital object
    *
    * @return QubitDigitalObject
    */
   public function extractText($connection = null)
   {
-    // Test for FFmpeg library
-    if (!self::hasPdfToText())
+    if (!self::canExtractText($this->mimeType))
     {
       return;
     }

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to