|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright 2016 Vladimir Jimenez |
|
5
|
|
|
* @license https://github.com/allejo/stakx/blob/master/LICENSE.md MIT |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace allejo\stakx\Object; |
|
9
|
|
|
|
|
10
|
|
|
use allejo\stakx\FrontMatter\ExpandedValue; |
|
11
|
|
|
|
|
12
|
|
|
class RepeaterPageView extends PageView |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @var \ArrayIterator |
|
16
|
|
|
*/ |
|
17
|
|
|
private $permalinksIterator; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var \ArrayIterator |
|
21
|
|
|
*/ |
|
22
|
|
|
private $redirectsIterator; |
|
23
|
|
|
|
|
24
|
|
|
private $permalinks; |
|
25
|
|
|
private $redirects; |
|
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
private $configured; |
|
28
|
|
|
|
|
29
|
1 |
|
public function __construct($filePath) |
|
30
|
|
|
{ |
|
31
|
1 |
|
parent::__construct($filePath); |
|
32
|
|
|
|
|
33
|
1 |
|
$this->frontMatterBlacklist = array(); |
|
34
|
1 |
|
$this->type = PageView::REPEATER_TYPE; |
|
35
|
1 |
|
$this->configured = false; |
|
36
|
1 |
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @return ExpandedValue[] |
|
40
|
|
|
*/ |
|
41
|
1 |
|
public function getRepeaterPermalinks () |
|
42
|
|
|
{ |
|
43
|
1 |
|
$this->configureValues(); |
|
44
|
|
|
|
|
45
|
1 |
|
return $this->permalinks; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
1 |
|
public function getRepeaterRedirects () |
|
49
|
|
|
{ |
|
50
|
1 |
|
$this->configureValues(); |
|
51
|
|
|
|
|
52
|
1 |
|
return $this->redirects; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
1 |
|
public function bumpPermalink () |
|
56
|
|
|
{ |
|
57
|
1 |
|
$this->permalink = $this->permalinksIterator->current()->getEvaluated(); |
|
58
|
1 |
|
$this->permalinksIterator->next(); |
|
59
|
1 |
|
} |
|
60
|
|
|
|
|
61
|
1 |
|
private function configureValues () |
|
62
|
|
|
{ |
|
63
|
1 |
|
if ($this->configured) { return; } |
|
64
|
|
|
|
|
65
|
|
|
// Cause the Front Matter to be evaluated |
|
66
|
1 |
|
$this->getFrontMatter(); |
|
67
|
|
|
|
|
68
|
1 |
|
$evaluated = $this->frontMatter['permalink']; |
|
69
|
|
|
|
|
70
|
1 |
|
$this->permalinks = $evaluated[0]; |
|
71
|
1 |
|
array_shift($evaluated); |
|
72
|
1 |
|
$this->redirects = $evaluated; |
|
73
|
|
|
|
|
74
|
1 |
|
$this->permalinksIterator = new \ArrayIterator($this->permalinks); |
|
75
|
1 |
|
$this->redirectsIterator = new \ArrayIterator($this->redirects); |
|
76
|
|
|
|
|
77
|
1 |
|
$this->configured = true; |
|
78
|
|
|
} |
|
79
|
|
|
} |