-
Notifications
You must be signed in to change notification settings - Fork 22
/
Metas.php
63 lines (55 loc) · 1.42 KB
/
Metas.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
56
57
58
59
60
61
62
63
<?php
namespace Gregwar\RST;
class Metas
{
protected $entries = array();
protected $parents = array();
public function __construct($entries)
{
if ($entries) {
$this->entries = $entries;
}
}
public function getAll()
{
return $this->entries;
}
/**
* Sets the meta for url, giving the title, the modification time and
* the dependencies list
*/
public function set($file, $url, $title, $titles, $tocs, $ctime, array $depends)
{
foreach ($tocs as $toc) {
foreach ($toc as $child) {
$this->parents[$child] = $file;
if (isset($this->entries[$child])) {
$this->entries[$child]['parent'] = $file;
}
}
}
$this->entries[$file] = array(
'file' => $file,
'url' => $url,
'title' => $title,
'titles' => $titles,
'tocs' => $tocs,
'ctime' => $ctime,
'depends' => $depends
);
if (isset($this->parents[$file])) {
$this->entries[$file]['parent'] = $this->parents[$file];
}
}
/**
* Gets the meta for a given document reference url
*/
public function get($url)
{
if (isset($this->entries[$url])) {
return $this->entries[$url];
} else {
return null;
}
}
}