/**
* Table Definition for Images
*/
-require_once 'DB/DataObject.php';
+class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
class Pman_Core_DataObjects_Images extends DB_DataObject
{
function beforeInsert($q, $roo)
{
- print_r('beforeInsert');exit;
-
if (isset($q['_remote_upload'])) {
require_once 'System.php';
*/
function createFrom($file, $filename=false)
{
- print_r('createFrom');exit;
// copy the file into the storage area..
if (!file_exists($file) || !filesize($file)) {
$this->err = "File $file did not exist or is 0 size";
return false;
}
if ($tbl->$fld) {
+ HTML_FlexyFramework::get()->page->jerr("updating images is disabled");
+ exit;
$image = DB_DataObject::factory('Images');
$image->get($tbl->$fld);
$image->beforeDelete();
}
if ($this->id) {
+ HTML_FlexyFramework::get()->page->jerr("updating images is disabled");
+ exit;
$this->beforeDelete();
}
if ( empty($this->ontable)) {
$img->find();
while ($img->fetch()) {
+ HTML_FlexyFramework::get()->page->jerr("updating images is disabled");
+ exit;
$img->beforeDelete();
$img->delete();
}
function setFromRoo($ar, $roo)
{
- print_r('setFromRoo');exit;
// not sure why we do this..
// if imgtype starts with '-' ? then we set the 'old' (probably to delete later)
$roo->jerr("File upload failed : error = ". (!empty($this->err) ? $this->err : ''));
}
- $roo->addEvent("ADD", $this, $this->toEventString());
+ $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()
{
}
if ($this->id) {
+ HTML_FlexyFramework::get()->page->jerr("updating images is disabled");
+ exit;
$this->beforeDelete();
}
$img->find();
while ($img->fetch()) {
+ HTML_FlexyFramework::get()->page->jerr("updating images is disabled");
+ exit;
$img->beforeDelete();
$img->delete();
}
}
+ function toBase64()
+ {
+ if(!preg_match('/^image\//', $this->mimetype)){
+ return false;
+ }
+
+ $file = $this->getStoreName();
+
+ if(!file_exists($file)){
+ return false;
+ }
+
+ $data = file_get_contents($file);
+
+ $base64 = 'data:' . $this->mimetype . ';base64,' . base64_encode($data);
+
+ 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} dump_data";
+
+ $test = `$cmd`;
+
+ print_R($test);exit;
+
+ break;
+ default :
+ break;
+ }
+
+ return $ret;
+ }
+
}