Add get / set methods for Uuid and Uri

This commit is contained in:
Didier Corbière 2013-09-11 00:36:57 +01:00
parent dd242052f7
commit 8e16d68f26

View file

@ -3,7 +3,7 @@
* PHP EPub Meta library
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Sébastien Lucas <sebastien@slucas.fr>
* @author Sébastien Lucas <sebastien@slucas.fr>
*/
require_once(realpath( dirname( __FILE__ ) ) . '/tbszip.php');
@ -302,6 +302,37 @@ class EPub {
return $this->getset('dc:description',$description);
}
/**
* Set or get the book's Unique Identifier
*
* @param string Unique identifier
*/
public function Uuid($uuid = false)
{
$nodes = $this->xpath->query('/opf:package');
if ($nodes->length !== 1) {
$error = sprintf('Cannot find ebook identifier');
throw new Exception($error);
}
$identifier = $nodes->item(0)->attr('unique-identifier');
$res = $this->getset('dc:identifier', $uuid, 'id', $identifier);
return $res;
}
/**
* Set or get the book's URI
*
* @param string URI
*/
public function Uri($uri = false)
{
$res = $this->getset('dc:identifier', $uri, 'opf:scheme', 'URI');
return $res;
}
/**
* Set or get the book's ISBN number
*