if (!$message->seen) { // Get the metadata $author = $message->from; $author = trim(preg_replace('/\\<.*\\>/', '', $author)); echo " - Author: {$author}\n"; $title = trim($message->subject); echo " - Title: {$title}\n"; $abstract = trim(strip_tags(imap_fetchbody($inbox, $message->msgno, 1))); echo " - Message: {$abstract}\n"; $info = imap_fetchstructure($inbox, $message->msgno); // Create the package $uid = imap_uid($inbox, $message->msgno); $packagefilename = 'packages/packager-' . $uid . '.zip'; @mkdir('tmp/attachments/' . $uid); $package = new PackagerMetsSwap('tmp', 'attachments/' . $uid, 'tmp', $packagefilename); $package->addCreator($author); $package->setTitle($title); $package->setAbstract($abstract); // Get the attachments / files $type = array("TEXT", "MULTIPART", "MESSAGE", "APPLICATION", "AUDIO", "IMAGE", "VIDEO", "OTHER"); $counter = 1; while (count($info->parts) > 1 && count($info->parts) > $counter) { if ($info->parts[$counter]->ifparameters == 1) { $filename = $info->parts[$counter]->parameters[0]->value; } else { if ($info->parts[$counter]->ifdparameters == 1) { $filename = $info->parts[$counter]->dparameters[0]->value; } } $mimetype = $type[(int) $info->parts[$counter]->type] . '/' . $info->parts[$counter]->subtype; $mimetype = strtolower($mimetype);
// Citation $test_citation = 'Allinson, J., Francois, S., Lewis, S. SWORD: Simple Web-service Offering Repository Deposit, Ariadne, Issue 54, January 2008. Online at http://www.ariadne.ac.uk/issue54/'; // Identifier $test_identifier = 'http://www.ariadne.ac.uk/issue54/allinson-et-al/'; // Date made available $test_dateavailable = '2008-01'; // Copyright holder $test_copyrightholder = 'Julie Allinson, Sebastien Francois, Stuart Lewis'; // Custodian $test_custodian = 'Julie Allinson, Sebastien Francois, Stuart Lewis'; // Status statement $test_statusstatement = 'http://purl.org/eprint/status/PeerReviewed'; // File name $test_file = 'SWORD Ariadne Jan 2008.pdf'; // MIME type of file $test_mimetype = 'application/pdf'; $test_packager = new PackagerMetsSwap($test_rootin, $test_dirin, $test_rootout, $test_fileout); $test_packager->setCustodian($test_custodian); $test_packager->setType($test_type); $test_packager->setTitle($test_title); $test_packager->setAbstract($test_abstract); foreach ($test_creators as $test_creator) { $test_packager->addCreator($test_creator); } $test_packager->setIdentifier($test_identifier); $test_packager->setDateAvailable($test_dateavailable); $test_packager->setStatusStatement($test_statusstatement); $test_packager->setCopyrightHolder($test_copyrightholder); $test_packager->setCitation($test_citation); $test_packager->addFile($test_file, $test_mimetype); $test_packager->create();