當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Utilities::titleMimeType方法代碼示例

本文整理匯總了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'));
 }
開發者ID:rvolz,項目名稱:BicBucStriim,代碼行數:8,代碼來源:test_utilities.php

示例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();
 }
開發者ID:chrispoupart,項目名稱:BicBucStriim,代碼行數:51,代碼來源:opds_generator.php

示例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);
    }
}
開發者ID:Htut,項目名稱:BicBucStriim,代碼行數:60,代碼來源:index.php


注:本文中的Utilities::titleMimeType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。