|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ApacheSolrForTypo3\Solr\System\Page; |
|
4
|
|
|
|
|
5
|
|
|
/*************************************************************** |
|
6
|
|
|
* Copyright notice |
|
7
|
|
|
* |
|
8
|
|
|
* (c) 2010-2016 Timo Hund <[email protected] |
|
9
|
|
|
* All rights reserved |
|
10
|
|
|
* |
|
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
|
12
|
|
|
* free software; you can redistribute it and/or modify |
|
13
|
|
|
* it under the terms of the GNU General Public License as published by |
|
14
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
|
15
|
|
|
* (at your option) any later version. |
|
16
|
|
|
* |
|
17
|
|
|
* The GNU General Public License can be found at |
|
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
|
19
|
|
|
* |
|
20
|
|
|
* This script is distributed in the hope that it will be useful, |
|
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23
|
|
|
* GNU General Public License for more details. |
|
24
|
|
|
* |
|
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
|
26
|
|
|
***************************************************************/ |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Rootline class. This class is used to perform operations on a rootline array. |
|
31
|
|
|
* The constructor requires an rootline array as an arguments (as you get it from |
|
32
|
|
|
* PageRepository::getRootline or TSFE->rootline. |
|
33
|
|
|
* |
|
34
|
|
|
* @author Timo Hund <[email protected]> |
|
35
|
|
|
*/ |
|
36
|
|
|
class Rootline |
|
37
|
|
|
{ |
|
38
|
|
|
/** |
|
39
|
|
|
* @var array |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $rootLineArray = []; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Rootline constructor. |
|
45
|
|
|
* @param array $rootLineArray |
|
46
|
|
|
*/ |
|
47
|
65 |
|
public function __construct(array $rootLineArray = []) |
|
48
|
|
|
{ |
|
49
|
65 |
|
$this->rootLineArray = $rootLineArray; |
|
50
|
65 |
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @return array |
|
54
|
|
|
*/ |
|
55
|
|
|
public function getRootLineArray() |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->rootLineArray; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param array $rootLineArray |
|
62
|
|
|
*/ |
|
63
|
57 |
|
public function setRootLineArray($rootLineArray) |
|
64
|
|
|
{ |
|
65
|
57 |
|
$this->rootLineArray = $rootLineArray; |
|
66
|
57 |
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Returns true if the rooline contains a root page. |
|
70
|
|
|
* |
|
71
|
|
|
* @return boolean |
|
72
|
|
|
*/ |
|
73
|
58 |
|
public function getHasRootPage() |
|
74
|
|
|
{ |
|
75
|
58 |
|
return $this->getRootPageId() !== 0; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Returns the rootPageId as integer if a rootpage is given, |
|
80
|
|
|
* if non is given 0 will be returned |
|
81
|
|
|
* |
|
82
|
|
|
* @return integer |
|
83
|
|
|
*/ |
|
84
|
62 |
|
public function getRootPageId() |
|
85
|
|
|
{ |
|
86
|
62 |
|
$rootPageId = 0; |
|
87
|
|
|
|
|
88
|
62 |
|
if (empty($this->rootLineArray)) { |
|
89
|
17 |
|
return $rootPageId; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
60 |
|
foreach ($this->rootLineArray as $page) { |
|
93
|
60 |
|
if ($page['is_siteroot']) { |
|
94
|
60 |
|
$rootPageId = $page['uid']; |
|
95
|
60 |
|
} |
|
96
|
60 |
|
} |
|
97
|
|
|
|
|
98
|
60 |
|
return $rootPageId; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Returns an array of the pageUids in the rootline. |
|
103
|
|
|
* |
|
104
|
|
|
* @return array |
|
105
|
|
|
*/ |
|
106
|
11 |
|
public function getParentPageIds() |
|
107
|
|
|
{ |
|
108
|
11 |
|
$rootLineParentPageIds = []; |
|
109
|
11 |
|
if (empty($this->rootLineArray)) { |
|
110
|
|
|
// no rootline given |
|
111
|
9 |
|
return $rootLineParentPageIds; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
2 |
|
foreach ($this->rootLineArray as $pageRecord) { |
|
115
|
2 |
|
$rootLineParentPageIds[] = $pageRecord['uid']; |
|
116
|
2 |
|
if ($pageRecord['is_siteroot']) { |
|
117
|
2 |
|
break; |
|
118
|
|
|
} |
|
119
|
2 |
|
} |
|
120
|
|
|
|
|
121
|
2 |
|
return $rootLineParentPageIds; |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|