You are here

function epub_get_nav in Epub 8

Same name and namespace in other branches
  1. 7 epub.module \epub_get_nav()
1 call to epub_get_nav()
epub_get_toc in ./epub.module

File

./epub.module, line 188

Code

function epub_get_nav($dir) {
  $file = epub_get_opf($dir);
  if ($file == FALSE) {
    return false;
  }
  $opfXML = simplexml_load_file($file);
  $opfXML
    ->registerXPathNamespace('opf', 'http://www.idpf.org/2007/opf');
  $nav = $opfXML
    ->xpath('//opf:item[@properties="nav"]');
  if ($nav) {
    $attributes = $nav[0]
      ->attributes();
    return dirname($file) . '/' . (string) $attributes['href'];
  }
  else {
    return FALSE;
  }
}