DataObjects/Images.php
authoredward <edward@roojs.com>
Fri, 10 Nov 2017 04:00:51 +0000 (12:00 +0800)
committeredward <edward@roojs.com>
Fri, 10 Nov 2017 04:00:51 +0000 (12:00 +0800)
DataObjects/Images.php

index 4b75cca..3db1921 100644 (file)
@@ -131,7 +131,33 @@ class Pman_Core_DataObjects_Images extends DB_DataObject
             }
         }
         
-        $this->getNumberOfPages($file);
+        if($this->mimetype == 'application/pdf'){
+            require_once 'System.php';
+        
+            $this->no_of_pages = 0;
+            
+            $pdfinfo = System::which('pdfinfo');
+
+            if (!empty($pdfinfo)) {
+                
+                $cmd = "{$pdfinfo} {$file}";
+
+                $ret = `$cmd`;
+
+                $info = explode("\n", $ret);
+
+                foreach ($info as $i){
+
+                    if(!preg_match('/^Pages:[\s]?([0-9]+)/', $i, $matches)){
+                        continue;
+                    }
+                    print_R($matches);exit;
+                    $ret = (empty($matches[1])) ? false : $matches[1];
+                    break;
+                }
+            }
+            
+        }
         
         $this->filesize = filesize($file);
         $this->created = date('Y-m-d H:i:s');