$roo->jerr("File upload failed : error = ". (!empty($this->err) ? $this->err : ''));
}
- $roo->addEvent("ADD", $this, $this->toEventString());
-
- if(method_exists($this, 'addEventLog')){
- $this->addEventLog($ar, $roo);
- }
+ $this->addEvent($ar, $roo);
$r = DB_DataObject::factory($this->tableName());
$r->id = $this->id;
}
+ function addEvent($ar, $roo)
+ {
+ $roo->addEvent("ADD", $this, $this->toEventString());
+ }
+
function toEventString()
{
return $base64;
}
+ function getNumberOfPages()
+ {
+ $ret = false;
+
+ require_once 'System.php';
+
+ switch ($this->mimetype) {
+
+ case 'application/pdf' :
+
+ $file = $this->getStoreName();
+
+ if(!file_exists($file)){
+ return false;
+ }
+
+ $pdftk = System::which('pdftk');
+
+ if (empty($pdftk)) {
+ return false;
+ }
+
+ $cmd = "{$pdftk} {$file} dump_data";
+
+ $info = `$cmd`;
+
+ $infos = explode("\n", $info);
+
+ foreach ($infos as $i){
+
+ if(!preg_match('/^NumberOfPages: ([0-9]+)/', $i, $matches)){
+ continue;
+ }
+
+ $ret = (empty($matches[1])) ? false : $matches[1];
+ break;
+ }
+
+ break;
+ default :
+ break;
+ }
+
+ return $ret;
+ }
+
}