projects
/
Pman.Core
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
DataObjects/Images.php
[Pman.Core]
/
DataObjects
/
Images.php
diff --git
a/DataObjects/Images.php
b/DataObjects/Images.php
index
0e4341d
..
6e4c4ae
100644
(file)
--- a/
DataObjects/Images.php
+++ b/
DataObjects/Images.php
@@
-131,7
+131,9
@@
class Pman_Core_DataObjects_Images extends DB_DataObject
}
}
}
}
- $this->getNumberOfPages($file);
+ if($this->mimetype == 'application/pdf'){
+ $this->no_of_pages = $this->getPdfPages($file);
+ }
$this->filesize = filesize($file);
$this->created = date('Y-m-d H:i:s');
$this->filesize = filesize($file);
$this->created = date('Y-m-d H:i:s');
@@
-183,6
+185,9
@@
class Pman_Core_DataObjects_Images extends DB_DataObject
{
$opts = HTML_FlexyFramework::get()->Pman;
$fn = preg_replace('/[^a-z0-9\.]+/i', '_', $this->filename);
{
$opts = HTML_FlexyFramework::get()->Pman;
$fn = preg_replace('/[^a-z0-9\.]+/i', '_', $this->filename);
+ print_r(implode( '/', array(
+ $opts['storedir'], '_images_', date('Y/m', strtotime($this->created)), $this->id . '-'. $fn
+ )));exit;
return implode( '/', array(
$opts['storedir'], '_images_', date('Y/m', strtotime($this->created)), $this->id . '-'. $fn
));
return implode( '/', array(
$opts['storedir'], '_images_', date('Y/m', strtotime($this->created)), $this->id . '-'. $fn
));
@@
-767,6
+772,10
@@
class Pman_Core_DataObjects_Images extends DB_DataObject
$this->filesize = filesize($f);
$this->filesize = filesize($f);
+ if($this->mimetype == 'application/pdf'){
+ $this->no_of_pages = $this->getPdfPages($f);
+ }
+
$this->update($o);
return true;
$this->update($o);
return true;
@@
-792,48
+801,34
@@
class Pman_Core_DataObjects_Images extends DB_DataObject
return $base64;
}
return $base64;
}
- function get
NumberO
fPages($file)
+ function get
Pd
fPages($file)
{
require_once 'System.php';
{
require_once 'System.php';
- $this->no_of_pages = 0;
-
- if(!file_exists($file)){
- return;
+ $page = 0;
+
+ $pdfinfo = System::which('pdfinfo');
+
+ if (!file_exists($file) || empty($pdfinfo)) {
+ return $page;
}
}
-
- switch ($this->mimetype) {
-
- case 'application/pdf' :
-
- $pdftk = System::which('pdftk');
-
- if (empty($pdftk)) {
- return false;
- }
-
- $cmd = "{$pdftk} {$file} dump_data";
-
- $info = `$cmd`;
-
- $infos = explode("\n", $info);
+
+ $cmd = "{$pdfinfo} {$file}";
- foreach ($infos as $i){
-
- if(!preg_match('/^NumberOfPages: ([0-9]+)/', $i, $matches)){
- continue;
- }
-
- $ret = (empty($matches[1])) ? false : $matches[1];
- break;
- }
-
- break;
- default :
- break;
+ $ret = `$cmd`;
+
+ $info = explode("\n", $ret);
+
+ foreach ($info as $i){
+
+ if(!preg_match('/^Pages:[\s]*([0-9]+)/', $i, $matches)){
+ continue;
+ }
+
+ $page = (empty($matches[1])) ? 0 : $matches[1];
}
}
- return $
ret
;
+ return $
page
;
}
}
}
}