1 | <?php |
||
39 | class Site |
||
40 | { |
||
41 | |||
42 | /** |
||
43 | * @var TypoScriptConfiguration |
||
44 | */ |
||
45 | protected $configuration; |
||
46 | |||
47 | /** |
||
48 | * Cache for ApacheSolrForTypo3\Solr\Site objects |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | protected static $sitesCache = []; |
||
53 | |||
54 | /** |
||
55 | * Small cache for the list of pages in a site, so that the results of this |
||
56 | * rather expensive operation can be used by all initializers without having |
||
57 | * each initializer do it again. |
||
58 | * |
||
59 | * TODO Move to caching framework once TYPO3 4.6 is the minimum required |
||
60 | * version. |
||
61 | * |
||
62 | * @var array |
||
63 | */ |
||
64 | protected static $sitePagesCache = []; |
||
65 | |||
66 | /** |
||
67 | * Root page record. |
||
68 | * |
||
69 | * @var array |
||
70 | */ |
||
71 | protected $rootPage = []; |
||
72 | |||
73 | /** |
||
74 | * The site's sys_language_mode |
||
75 | * |
||
76 | * @var string |
||
77 | */ |
||
78 | protected $sysLanguageMode = null; |
||
79 | |||
80 | /** |
||
81 | 124 | * @var string |
|
82 | */ |
||
83 | 124 | protected $domain; |
|
84 | |||
85 | 124 | /** |
|
86 | 4 | * @var string |
|
87 | 4 | */ |
|
88 | 4 | protected $siteHash; |
|
89 | 4 | ||
90 | /** |
||
91 | * @var PagesRepository |
||
92 | */ |
||
93 | 120 | protected $pagesRepository; |
|
94 | 1 | ||
95 | 1 | /** |
|
96 | 1 | * Constructor. |
|
97 | 1 | * |
|
98 | * @param TypoScriptConfiguration $configuration |
||
99 | * @param array $page Site root page ID (uid). The page must be marked as site root ("Use as Root Page" flag). |
||
100 | * @param string $domain The domain record used by this Site |
||
101 | 119 | * @param string $siteHash The site hash used by this site |
|
102 | 119 | * @param PagesRepository $pagesRepository |
|
103 | */ |
||
104 | public function __construct(TypoScriptConfiguration $configuration, array $page, $domain, $siteHash, PagesRepository $pagesRepository = null) |
||
112 | |||
113 | /** |
||
114 | * Clears the $sitePagesCache |
||
115 | * |
||
116 | */ |
||
117 | public static function clearSitePagesCache() |
||
121 | 138 | ||
122 | 137 | /** |
|
123 | * Takes an pagerecord and checks whether the page is marked as root page. |
||
124 | * |
||
125 | 71 | * @param array $page pagerecord |
|
126 | * @return bool true if the page is marked as root page, false otherwise |
||
127 | */ |
||
128 | public static function isRootPage($page) |
||
136 | |||
137 | /** |
||
138 | * Gets the site's root page ID (uid). |
||
139 | * |
||
140 | * @return int The site's root page ID. |
||
141 | */ |
||
142 | public function getRootPageId() |
||
146 | 14 | ||
147 | 14 | /** |
|
148 | * Gets the site's label. The label is build from the the site title and root |
||
149 | 14 | * page ID (uid). |
|
150 | 14 | * |
|
151 | 14 | * @return string The site's label. |
|
152 | 14 | */ |
|
153 | public function getLabel() |
||
165 | |||
166 | /** |
||
167 | * Gets the site's Solr TypoScript configuration (plugin.tx_solr.*) |
||
168 | * |
||
169 | * @return \ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration The Solr TypoScript configuration |
||
170 | */ |
||
171 | public function getSolrConfiguration() |
||
175 | |||
176 | 1 | /** |
|
177 | * Gets the site's default language as configured in |
||
178 | 1 | * config.sys_language_uid. If sys_language_uid is not set, 0 is assumed to |
|
179 | 1 | * be the default. |
|
180 | 1 | * |
|
181 | * @return int The site's default language. |
||
182 | */ |
||
183 | 1 | public function getDefaultLanguage() |
|
198 | 12 | ||
199 | /** |
||
200 | 12 | * Generates a list of page IDs in this site. Attention, this includes |
|
201 | 12 | * all page types! Deleted pages are not included. |
|
202 | * |
||
203 | 12 | * @param int|string $rootPageId Page ID from where to start collection sub pages |
|
204 | 12 | * @param int $maxDepth Maximum depth to descend into the site tree |
|
205 | 12 | * @return array Array of pages (IDs) in this site |
|
206 | */ |
||
207 | public function getPages($rootPageId = 'SITE_ROOT', $maxDepth = 999) |
||
223 | |||
224 | /** |
||
225 | 12 | * Generates the site's unique Site Hash. |
|
226 | 12 | * |
|
227 | * The Site Hash is build from the site's main domain, the system encryption |
||
228 | * key, and the extension "tx_solr". These components are concatenated and |
||
229 | * sha1-hashed. |
||
230 | * |
||
231 | * @return string Site Hash. |
||
232 | */ |
||
233 | public function getSiteHash() |
||
237 | |||
238 | 12 | /** |
|
239 | * Gets the site's main domain. More specifically the first domain record in |
||
240 | 12 | * the site tree. |
|
241 | * |
||
242 | * @return string The site's main domain. |
||
243 | 12 | */ |
|
244 | 12 | public function getDomain() |
|
248 | 12 | ||
249 | /** |
||
250 | * Gets the site's root page. |
||
251 | 12 | * |
|
252 | * @return array The site's root page. |
||
253 | 12 | */ |
|
254 | 10 | public function getRootPage() |
|
258 | |||
259 | /** |
||
260 | 12 | * Gets the site's root page's title. |
|
261 | 12 | * |
|
262 | * @return string The site's root page's title |
||
263 | */ |
||
264 | public function getTitle() |
||
268 | |||
269 | /** |
||
270 | * Gets the site's config.sys_language_mode setting |
||
271 | * |
||
272 | * @param int $languageUid |
||
273 | 71 | * |
|
274 | * @return string The site's config.sys_language_mode |
||
275 | */ |
||
276 | 71 | public function getSysLanguageMode($languageUid = 0) |
|
285 | } |
||
286 |