-
Notifications
You must be signed in to change notification settings - Fork 0
/
guide.php
55 lines (43 loc) · 1.4 KB
/
guide.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
require_once("reference.php");
class guide {
private $epub = null;
private $references = null;
//costruttore
function __construct($epub) {
$this->epub = $epub;
$this->references = array();
$this->import();
}
public function import() {
$xml = $this->epub->getOpf()->guide;
$manifest = $this->epub->getManifest();
if(empty($xml)) return;
foreach($xml->reference as $reference){
$attr = $reference->attributes();
$reference = new reference((string)$attr["type"], (string)$attr["title"], (string)$attr["href"]);
$this->addReference($reference);
}
}
public function addReference($reference) {
array_push($this->references, $reference);
}
public function getReferences() {
return $this->references;
}
public function getReferenceByType($type) {
foreach($this->references as $reference) {
if($reference->getType() == $type) return $reference;
}
return null;
}
public function asXml($guide) {
foreach($this->references as $reference) {
$nodo = $guide->addChild("reference");
$nodo->addAttribute("href", $reference->getHref());
$nodo->addAttribute("type", $reference->getType());
$nodo->addAttribute("title", $reference->getTitle());
}
}
}
?>