function printview_GET(Web &$w) { $p = $w->pathMatch("table", "id"); $attachments = $w->service("File")->getAttachments($p['table'], $p['$id']); $w->ctx("attachments", $attachments); $w->setLayout(null); }
function atfile_GET(Web &$w) { $p = $w->pathMatch("id"); $id = str_replace(".jpg", "", $p['id']); $attachment = $w->service("File")->getAttachment($id); $w->sendFile(FILE_ROOT . $attachment->fullpath); }
function attach_POST(Web &$w) { $table = $w->request('table'); $id = $w->request('id'); $title = $w->request('title'); $description = $w->request('description'); $type_code = $w->request('type_code'); $url = str_replace(" ", "/", $w->request('url')); $object = $w->Auth->getObject($table, $id); if (!$object) { $w->error("Nothing to attach to.", $url); } $aid = $w->service("File")->uploadAttachment("file", $object, $title, $description, $type_code); if ($aid) { $w->ctx('attach_id', $aid); $w->ctx('attach_table', $table); $w->ctx('attach_table_id', $id); $w->ctx('attach_title', $title); $w->ctx('attach_description', $description); $w->ctx('attach_type_code', $type_code); $w->msg("File attached.", $url); } else { $w->error("There was an error. Attachment could not be saved.", $url); } }
function atthumb_GET(Web &$w) { $p = $w->pathMatch("id", array("w", 150), array("h", 150)); $id = str_replace(".jpg", "", $p['id']); $attachment = $w->service("File")->getAttachment($id); require_once 'phpthumb/ThumbLib.inc.php'; $thumb = PhpThumbFactory::create(FILE_ROOT . $attachment->fullpath); $thumb->resize($p['w'], $p['h']); //$thumb->adaptiveResize($p['w'], $p['h']); $thumb->show(); exit; }
function atdel_GET(Web &$w) { $p = $w->pathMatch("id", "url"); $att = $w->service("File")->getAttachment($p['id']); if ($att) { $w->ctx('attach_id', $att->id); $w->ctx('attach_table', $att->parent_table); $w->ctx('attach_table_id', $att->parent_id); $w->ctx('attach_title', $att->title); $w->ctx('attach_description', $att->description); $att->delete(); $w->msg("Attachment deleted.", "/" . str_replace(" ", "/", $p['url'])); } else { $w->error("Attachment does not exist.", "/" . str_replace(" ", "/", $p['url'])); } }