本文整理汇总了PHP中Utilities::titleMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP Utilities::titleMimeType方法的具体用法?PHP Utilities::titleMimeType怎么用?PHP Utilities::titleMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utilities
的用法示例。
在下文中一共展示了Utilities::titleMimeType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTitleMimeType
function testTitleMimeType()
{
$this->assertEqual('application/epub+zip', Utilities::titleMimeType('x/y/test.epub'));
$this->assertEqual('application/vnd.amazon.ebook', Utilities::titleMimeType('test.azw'));
$this->assertEqual('application/x-mobipocket-ebook', Utilities::titleMimeType('test.mobi'));
$this->assertEqual('text/plain', Utilities::titleMimeType(self::FIXT . '/test.unknown-format'));
$this->assertEqual('application/xml', Utilities::titleMimeType(self::FIXT . '/atom.rng'));
}
示例2: partialAcquisitionEntry
/**
* Write a catalog entry for a book title with acquisition links
* @param array $entry the book and its details
* @param boolean $protected true = use an indirect acquisition link,
* else a direct one
*/
function partialAcquisitionEntry($entry, $protected)
{
$titleLink = $this->bbs_root . '/opds/titles/' . $entry['book']->id;
$this->xmlw->startElement('entry');
$this->xmlw->writeElement('id', 'urn:bicbucstriim:' . $titleLink);
$this->xmlw->writeElement('title', $entry['book']->title);
$this->xmlw->writeElement('dc:issued', date("Y", strtotime($entry['book']->pubdate)));
$this->xmlw->writeElement('updated', $this->updated);
$this->xmlw->startElement('author');
$this->xmlw->writeElement('name', $entry['book']->author_sort);
$this->xmlw->endElement();
$this->xmlw->startElement('content');
$this->xmlw->writeAttribute('type', 'text/html');
$this->xmlw->text($entry['comment']);
$this->xmlw->endElement();
$this->xmlw->startElement("dc:language");
$this->xmlw->text($entry['language']);
$this->xmlw->endElement();
if (isset($entry['book']->thumbnail) && $entry['book']->thumbnail) {
$tlink = $this->bbs_root . '/data/titles/thumb_' . $entry['book']->id . '.png';
} else {
$tlink = $titleLink . '/thumbnail/';
}
$this->thumbnailLink($tlink);
$this->imageLink($titleLink . '/cover/');
#$this->detailsLink($titleLink.'/thumbnail/');
foreach ($entry['formats'] as $format) {
$fname = $format->name;
$ext = strtolower($format->format);
$bp = Utilities::bookPath($this->calibre_dir, $entry['book']->path, $fname . '.' . $ext);
$mt = Utilities::titleMimeType($bp);
if ($protected) {
$this->indirectDownloadLink($titleLink . '/showaccess/', $mt);
} else {
$this->directDownloadLink($titleLink . '/file/' . urlencode($fname) . '.' . $ext, $mt);
}
}
foreach ($entry['tags'] as $category) {
$this->xmlw->startElement('category');
$this->xmlw->writeAttribute('term', $category->name);
$this->xmlw->writeAttribute('label', $category->name);
$this->xmlw->endElement();
}
$this->xmlw->endElement();
}
示例3: book
function book($id, $file)
{
global $app, $globalSettings;
// parameter checking
if (!is_numeric($id)) {
$app->getLog()->warn('book: invalid title id ' . $id);
$app->halt(400, "Bad parameter");
}
// TODO check file parameter?
$details = $app->calibre->titleDetails($globalSettings['lang'], $id);
if (is_null($details)) {
$app->getLog()->warn("book: no book found for " . $id);
$app->notFound();
}
// for people trying to circumvent filtering by direct access
if (title_forbidden($details)) {
$app->getLog()->warn("book: requested book not allowed for user: " . $id);
$app->notFound();
return;
}
$real_bookpath = $app->calibre->titleFile($id, $file);
$contentType = Utilities::titleMimeType($real_bookpath);
$app->getLog()->info("book download by " . $app->auth->getUserName() . " for " . $real_bookpath . " with metadata update = " . $globalSettings[METADATA_UPDATE]);
if ($contentType == Utilities::MIME_EPUB && $globalSettings[METADATA_UPDATE]) {
if ($details['book']->has_cover == 1) {
$cover = $app->calibre->titleCover($id);
} else {
$cover = null;
}
// If an EPUB update the metadata
$mdep = new MetadataEpub($real_bookpath);
$mdep->updateMetadata($details, $cover);
$bookpath = $mdep->getUpdatedFile();
$app->getLog()->debug("book(e): file " . $bookpath);
$app->getLog()->debug("book(e): type " . $contentType);
$booksize = filesize($bookpath);
$app->getLog()->debug("book(e): size " . $booksize);
if ($booksize > 0) {
header("Content-Length: " . $booksize);
}
header("Content-Type: " . $contentType);
header("Content-Disposition: attachment; filename=\"" . $file . "\"");
header("Content-Description: File Transfer");
header("Content-Transfer-Encoding: binary");
readfile_chunked($bookpath);
} else {
// Else send the file as is
$bookpath = $real_bookpath;
$app->getLog()->debug("book: file " . $bookpath);
$app->getLog()->debug("book: type " . $contentType);
$booksize = filesize($bookpath);
$app->getLog()->debug("book: size " . $booksize);
header("Content-Length: " . $booksize);
header("Content-Type: " . $contentType);
header("Content-Disposition: attachment; filename=\"" . $file . "\"");
header("Content-Description: File Transfer");
header("Content-Transfer-Encoding: binary");
readfile_chunked($bookpath);
}
}