components does not contain / anymore.

--HG--
extra : rebase_source : 0a4eea43929b87c4455cba8c4343586733ae3ffe
This commit is contained in:
Sébastien Lucas 2013-08-28 14:45:37 +02:00
parent f368795542
commit a51a276805

View file

@ -145,7 +145,7 @@ class EPub {
$nodes = $this->xpath->query('//opf:spine/opf:itemref'); $nodes = $this->xpath->query('//opf:spine/opf:itemref');
foreach($nodes as $node){ foreach($nodes as $node){
$idref = $node->getAttribute('idref'); $idref = $node->getAttribute('idref');
$spine[] = $this->xpath->query("//opf:manifest/opf:item[@id='$idref']")->item(0)->getAttribute('href'); $spine[] = str_replace ("/", "-SLASH-", $this->xpath->query("//opf:manifest/opf:item[@id='$idref']")->item(0)->getAttribute('href'));
} }
return $spine; return $spine;
} }
@ -153,8 +153,9 @@ class EPub {
/** /**
* Get the component content * Get the component content
*/ */
public function component($comp) { public function component($comp, $elementPath) {
$path = dirname($this->meta).'/'.$comp; $path = str_replace ("-SLASH-", "/", $comp);
$path = $this->getFullPath ($path, $elementPath);
if (!$this->zip->FileExists($path)) { if (!$this->zip->FileExists($path)) {
throw new Exception ("Unable to find " . $path); throw new Exception ("Unable to find " . $path);
} }
@ -167,6 +168,7 @@ class EPub {
* Get the component content type * Get the component content type
*/ */
public function componentContentType($comp) { public function componentContentType($comp) {
$comp = str_replace ("-SLASH-", "/", $comp);
return $this->xpath->query("//opf:manifest/opf:item[@href='$comp']")->item(0)->getAttribute('media-type'); return $this->xpath->query("//opf:manifest/opf:item[@href='$comp']")->item(0)->getAttribute('media-type');
} }
@ -181,6 +183,7 @@ class EPub {
foreach($nodes as $node){ foreach($nodes as $node){
$title = $this->toc_xpath->query('x:navLabel/x:text', $node)->item(0)->nodeValue; $title = $this->toc_xpath->query('x:navLabel/x:text', $node)->item(0)->nodeValue;
$src = $this->toc_xpath->query('x:content', $node)->item(0)->attr('src'); $src = $this->toc_xpath->query('x:content', $node)->item(0)->attr('src');
$src = str_replace ("/", "-SLASH-", $src);
$contents[] = array("title" => $title, "src" => $src); $contents[] = array("title" => $title, "src" => $src);
} }
return $contents; return $contents;