Merge with current github, fix trailing spaces, and tab->space.

--HG--
extra : rebase_source : ad44a915f7c4880ee8f4ffc406e97c8fc142ac82
This commit is contained in:
Sébastien Lucas 2013-10-23 16:39:02 +02:00
parent 3ca4996a41
commit 62941ccb4b

View file

@ -328,6 +328,61 @@ class EPub {
return $this->getset('dc:description',$description); 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 creation date
*
* @param string Date eg: 2012-05-19T12:54:25Z
*/
public function CreationDate($date = false)
{
$res = $this->getset('dc:date', $date, 'opf:event', 'creation');
return $res;
}
/**
* Set or get the book's modification date
*
* @param string Date eg: 2012-05-19T12:54:25Z
*/
public function ModificationDate($date = false)
{
$res = $this->getset('dc:date', $date, 'opf:event', 'modification');
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 * Set or get the book's ISBN number
* *
@ -517,40 +572,40 @@ class EPub {
} }
public function Combine($a, $b) public function Combine($a, $b)
{ {
$isAbsolute = false; $isAbsolute = false;
if ($a[0] == "/") if ($a[0] == "/")
$isAbsolute = true; $isAbsolute = true;
if ($b[0] == "/") if ($b[0] == "/")
throw new InvalidArgumentException("Second path part must not stwar with " . $m_Separator); throw new InvalidArgumentException("Second path part must not start with " . $m_Separator);
$splittedA = split("/", $a); $splittedA = split("/", $a);
$splittedB = split("/", $b); $splittedB = split("/", $b);
$pathParts = array(); $pathParts = array();
$mergedPath = array_merge($splittedA, $splittedB); $mergedPath = array_merge($splittedA, $splittedB);
foreach($mergedPath as $item) foreach($mergedPath as $item)
{ {
if ($item == null || $item == "" || $item == ".") if ($item == null || $item == "" || $item == ".")
continue; continue;
if ($item == "..") if ($item == "..")
{ {
array_pop($pathParts); array_pop($pathParts);
continue; continue;
} }
array_push($pathParts, $item); array_push($pathParts, $item);
} }
$path = implode("/", $pathParts); $path = implode("/", $pathParts);
if ($isAbsolute) if ($isAbsolute)
return("/" . $path); return("/" . $path);
else else
return($path); return($path);
} }
private function getFullPath ($file, $context = NULL) { private function getFullPath ($file, $context = NULL) {
$path = dirname('/'.$this->meta).'/'.$file; $path = dirname('/'.$this->meta).'/'.$file;