bookPath() static public method

Works around a strange feature of Calibre where middle components of names are capitalized, eg "Aliette de Bodard" -> "Aliette De Bodard". The directory name uses the capitalized form, the book path stored in the DB uses the original form.
static public bookPath ( string $cd, string $bp, string $file ) : string
$cd string Calibre library directory
$bp string book path, as stored in the DB
$file string file name
return string the filesystem path to the book file
示例#1
0
 function testBookPath()
 {
     $this->assertEqual('tests/fixtures/lib2/Gotthold Ephraim Lessing/Lob der Faulheit (1)/Lob der Faulheit - Gotthold Ephraim Lessing.epub', Utilities::bookPath('tests/fixtures/lib2', 'Gotthold Ephraim Lessing/Lob der Faulheit (1)', 'Lob der Faulheit - Gotthold Ephraim Lessing.epub'));
 }
 /**
  * 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
0
 /**
  * Returns the path to the file of a book or NULL.
  * @param  int $id book id
  * @param  string $file file name
  * @return string       full path to image file or NULL
  */
 function titleFile($id, $file)
 {
     $book = $this->title($id);
     if (is_null($book)) {
         return NULL;
     } else {
         return Utilities::bookPath($this->calibre_dir, $book->path, $file);
     }
 }