|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* (c) Kitodo. Key to digital objects e.V. <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* This file is part of the Kitodo and TYPO3 projects. |
|
7
|
|
|
* |
|
8
|
|
|
* @license GNU General Public License version 3 or later. |
|
9
|
|
|
* For the full copyright and license information, please read the |
|
10
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Kitodo\Dlf\Controller; |
|
14
|
|
|
|
|
15
|
|
|
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; |
|
16
|
|
|
use \TYPO3\CMS\Extbase\Configuration\ConfigurationManager; |
|
|
|
|
|
|
17
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
18
|
|
|
use TYPO3\CMS\Core\Utility\MathUtility; |
|
19
|
|
|
use TYPO3\CMS\Core\Utility\PathUtility; |
|
20
|
|
|
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; |
|
21
|
|
|
use Kitodo\Dlf\Common\Document; |
|
22
|
|
|
use Kitodo\Dlf\Common\DocumentList; |
|
23
|
|
|
use Kitodo\Dlf\Common\Helper; |
|
24
|
|
|
use Kitodo\Dlf\Common\Indexer; |
|
25
|
|
|
use Kitodo\Dlf\Common\Solr; |
|
26
|
|
|
use TYPO3\CMS\Core\Database\Connection; |
|
27
|
|
|
use TYPO3\CMS\Core\Database\ConnectionPool; |
|
28
|
|
|
use \Kitodo\Dlf\Domain\Model\SearchForm; |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
class CalendarController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
|
|
public $prefixId = 'tx_dlf'; |
|
33
|
|
|
public $extKey = 'dlf'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var ConfigurationManager |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $configurationManager; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var \TYPO3\CMS\Core\Log\LogManager |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $logger; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* SearchController constructor. |
|
47
|
|
|
* @param $configurationManager |
|
48
|
|
|
*/ |
|
49
|
|
|
public function __construct(ConfigurationManager $configurationManager) |
|
50
|
|
|
{ |
|
51
|
|
|
$this->configurationManager = $configurationManager; |
|
52
|
|
|
$this->logger = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
// TODO: Needs to be placed in an abstract class |
|
56
|
|
|
/** |
|
57
|
|
|
* Loads the current document into $this->doc |
|
58
|
|
|
* |
|
59
|
|
|
* @access protected |
|
60
|
|
|
* |
|
61
|
|
|
* @return void |
|
62
|
|
|
*/ |
|
63
|
|
|
protected function loadDocument($requestData) |
|
64
|
|
|
{ |
|
65
|
|
|
// Check for required variable. |
|
66
|
|
|
if ( |
|
67
|
|
|
!empty($requestData['id']) |
|
68
|
|
|
&& !empty($this->settings['pages']) |
|
69
|
|
|
) { |
|
70
|
|
|
// Should we exclude documents from other pages than $this->settings['pages']? |
|
71
|
|
|
$pid = (!empty($this->settings['excludeOther']) ? intval($this->settings['pages']) : 0); |
|
72
|
|
|
// Get instance of \Kitodo\Dlf\Common\Document. |
|
73
|
|
|
$this->doc = Document::getInstance($requestData['id'], $pid); |
|
|
|
|
|
|
74
|
|
|
if (!$this->doc->ready) { |
|
75
|
|
|
// Destroy the incomplete object. |
|
76
|
|
|
$this->doc = null; |
|
77
|
|
|
$this->logger->error('Failed to load document with UID ' . $requestData['id']); |
|
|
|
|
|
|
78
|
|
|
} else { |
|
79
|
|
|
// Set configuration PID. |
|
80
|
|
|
$this->doc->cPid = $this->settings['pages']; |
|
81
|
|
|
} |
|
82
|
|
|
} elseif (!empty($requestData['recordId'])) { |
|
83
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
|
84
|
|
|
->getQueryBuilderForTable('tx_dlf_documents'); |
|
85
|
|
|
|
|
86
|
|
|
// Get UID of document with given record identifier. |
|
87
|
|
|
$result = $queryBuilder |
|
88
|
|
|
->select('tx_dlf_documents.uid AS uid') |
|
89
|
|
|
->from('tx_dlf_documents') |
|
90
|
|
|
->where( |
|
91
|
|
|
$queryBuilder->expr()->eq('tx_dlf_documents.record_id', $queryBuilder->expr()->literal($requestData['recordId'])), |
|
92
|
|
|
Helper::whereExpression('tx_dlf_documents') |
|
93
|
|
|
) |
|
94
|
|
|
->setMaxResults(1) |
|
95
|
|
|
->execute(); |
|
96
|
|
|
|
|
97
|
|
|
if ($resArray = $result->fetch()) { |
|
98
|
|
|
$requestData['id'] = $resArray['uid']; |
|
99
|
|
|
// Set superglobal $_GET array and unset variables to avoid infinite looping. |
|
100
|
|
|
$_GET[$this->prefixId]['id'] = $requestData['id']; |
|
101
|
|
|
unset($requestData['recordId'], $_GET[$this->prefixId]['recordId']); |
|
102
|
|
|
// Try to load document. |
|
103
|
|
|
$this->loadDocument(); |
|
|
|
|
|
|
104
|
|
|
} else { |
|
105
|
|
|
$this->logger->error('Failed to load document with record ID "' . $requestData['recordId'] . '"'); |
|
106
|
|
|
} |
|
107
|
|
|
} else { |
|
108
|
|
|
$this->logger->error('Invalid UID ' . $requestData['id'] . ' or PID ' . $this->settings['pages'] . ' for document loading'); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
|
|
113
|
|
|
public function mainAction() |
|
114
|
|
|
{ |
|
115
|
|
|
$requestData = GeneralUtility::_GPmerged('tx_dlf'); |
|
116
|
|
|
unset($requestData['__referrer'], $requestData['__trustedProperties']); |
|
117
|
|
|
|
|
118
|
|
|
// Set initial document (anchor or year file) if configured. |
|
119
|
|
|
if (empty($requestData['id']) && !empty($this->settings['initialDocument'])) { |
|
120
|
|
|
$requestData['id'] = $this->settings['initialDocument']; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
// Load current document. |
|
124
|
|
|
$this->loadDocument($requestData); |
|
125
|
|
|
if ($this->doc === null) { |
|
126
|
|
|
// Quit without doing anything if required variables are not set. |
|
127
|
|
|
return ''; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
$metadata = $this->doc->getTitledata(); |
|
131
|
|
|
if (!empty($metadata['type'][0])) { |
|
132
|
|
|
$type = $metadata['type'][0]; |
|
133
|
|
|
} else { |
|
134
|
|
|
return ''; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
switch ($type) { |
|
138
|
|
|
case 'newspaper': |
|
139
|
|
|
case 'ephemera': |
|
140
|
|
|
$this->forward('years', NULL, NULL, $requestData); |
|
|
|
|
|
|
141
|
|
|
case 'year': |
|
142
|
|
|
$this->forward('calendar', NULL, NULL, $requestData); |
|
143
|
|
|
case 'issue': |
|
144
|
|
|
default: |
|
145
|
|
|
break; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
// Nothing to do here. |
|
149
|
|
|
return ''; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* The Calendar Method |
|
154
|
|
|
* |
|
155
|
|
|
* @access public |
|
156
|
|
|
* |
|
157
|
|
|
* @param string $content: The PlugIn content |
|
158
|
|
|
* @param array $conf: The PlugIn configuration |
|
159
|
|
|
* |
|
160
|
|
|
* @return string The content that is displayed on the website |
|
161
|
|
|
*/ |
|
162
|
|
|
public function calendarAction() |
|
163
|
|
|
{ |
|
164
|
|
|
$requestData = GeneralUtility::_GPmerged('tx_dlf'); |
|
165
|
|
|
unset($requestData['__referrer'], $requestData['__trustedProperties']); |
|
166
|
|
|
|
|
167
|
|
|
// Load current document. |
|
168
|
|
|
$this->loadDocument($requestData); |
|
169
|
|
|
if ($this->doc === null) { |
|
170
|
|
|
// Quit without doing anything if required variables are not set. |
|
171
|
|
|
return ''; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
|
175
|
|
|
->getQueryBuilderForTable('tx_dlf_documents'); |
|
176
|
|
|
|
|
177
|
|
|
// Get all children of year anchor. |
|
178
|
|
|
$result = $queryBuilder |
|
179
|
|
|
->select( |
|
180
|
|
|
'tx_dlf_documents.uid AS uid', |
|
181
|
|
|
'tx_dlf_documents.title AS title', |
|
182
|
|
|
'tx_dlf_documents.year AS year', |
|
183
|
|
|
'tx_dlf_documents.mets_label AS label', |
|
184
|
|
|
'tx_dlf_documents.mets_orderlabel AS orderlabel' |
|
185
|
|
|
) |
|
186
|
|
|
->from('tx_dlf_documents') |
|
187
|
|
|
->where( |
|
188
|
|
|
$queryBuilder->expr()->eq('tx_dlf_documents.structure', Helper::getUidFromIndexName('issue', 'tx_dlf_structures', $this->doc->cPid)), |
|
189
|
|
|
$queryBuilder->expr()->eq('tx_dlf_documents.partof', intval($this->doc->uid)), |
|
190
|
|
|
Helper::whereExpression('tx_dlf_documents') |
|
191
|
|
|
) |
|
192
|
|
|
->orderBy('tx_dlf_documents.mets_orderlabel') |
|
193
|
|
|
->execute(); |
|
194
|
|
|
|
|
195
|
|
|
$issues = []; |
|
196
|
|
|
|
|
197
|
|
|
// Process results. |
|
198
|
|
|
while ($resArray = $result->fetch()) { |
|
199
|
|
|
// Set title for display in calendar view. |
|
200
|
|
|
if (!empty($resArray['title'])) { |
|
201
|
|
|
$title = $resArray['title']; |
|
202
|
|
|
} else { |
|
203
|
|
|
$title = !empty($resArray['label']) ? $resArray['label'] : $resArray['orderlabel']; |
|
204
|
|
|
if (strtotime($title) !== false) { |
|
205
|
|
|
$title = strftime('%x', strtotime($title)); |
|
206
|
|
|
} |
|
207
|
|
|
} |
|
208
|
|
|
$issues[] = [ |
|
209
|
|
|
'uid' => $resArray['uid'], |
|
210
|
|
|
'title' => $title, |
|
211
|
|
|
'year' => $resArray['year'] |
|
212
|
|
|
]; |
|
213
|
|
|
} |
|
214
|
|
|
// We need an array of issues with year => month => day number as key. |
|
215
|
|
|
$calendarIssuesByYear = []; |
|
216
|
|
|
foreach ($issues as $issue) { |
|
217
|
|
|
$dateTimestamp = strtotime($issue['year']); |
|
218
|
|
|
if ($dateTimestamp !== false) { |
|
219
|
|
|
$_year = date('Y', $dateTimestamp); |
|
220
|
|
|
$_month = date('n', $dateTimestamp); |
|
221
|
|
|
$_day = date('j', $dateTimestamp); |
|
222
|
|
|
$calendarIssuesByYear[$_year][$_month][$_day][] = $issue; |
|
223
|
|
|
} else { |
|
224
|
|
|
$this->logger->warning('Document with UID ' . $issue['uid'] . 'has no valid date of publication'); |
|
|
|
|
|
|
225
|
|
|
} |
|
226
|
|
|
} |
|
227
|
|
|
// Sort by years. |
|
228
|
|
|
ksort($calendarIssuesByYear); |
|
229
|
|
|
// Build calendar for year (default) or season. |
|
230
|
|
|
$iteration = 1; |
|
231
|
|
|
foreach ($calendarIssuesByYear as $year => $calendarIssuesByMonth) { |
|
232
|
|
|
// Sort by months. |
|
233
|
|
|
ksort($calendarIssuesByMonth); |
|
234
|
|
|
// Default: First month is January, last month is December. |
|
235
|
|
|
$firstMonth = 1; |
|
236
|
|
|
$lastMonth = 12; |
|
237
|
|
|
// Show calendar from first issue up to end of season if applicable. |
|
238
|
|
|
if ( |
|
239
|
|
|
empty($this->settings['showEmptyMonths']) |
|
240
|
|
|
&& count($calendarIssuesByYear) > 1 |
|
241
|
|
|
) { |
|
242
|
|
|
if ($iteration == 1) { |
|
243
|
|
|
$firstMonth = (int) key($calendarIssuesByMonth); |
|
244
|
|
|
} elseif ($iteration == count($calendarIssuesByYear)) { |
|
245
|
|
|
end($calendarIssuesByMonth); |
|
246
|
|
|
$lastMonth = (int) key($calendarIssuesByMonth); |
|
247
|
|
|
} |
|
248
|
|
|
} |
|
249
|
|
|
$this->getCalendarYear($calendarIssuesByMonth, $year, $firstMonth, $lastMonth); |
|
250
|
|
|
$iteration++; |
|
251
|
|
|
} |
|
252
|
|
|
// Prepare list as alternative view. |
|
253
|
|
|
$issueData = []; |
|
254
|
|
|
foreach ($this->allIssues as $dayTimestamp => $issues) { |
|
255
|
|
|
$issueData[$dayTimestamp]['dateString'] = strftime('%A, %x', $dayTimestamp); |
|
256
|
|
|
$issueData[$dayTimestamp]['items'] = []; |
|
257
|
|
|
foreach ($issues as $issue) { |
|
258
|
|
|
$issueData[$dayTimestamp]['items'][] = $issue; |
|
259
|
|
|
} |
|
260
|
|
|
} |
|
261
|
|
|
$this->view->assign('issueData', $issueData); |
|
262
|
|
|
|
|
263
|
|
|
// Link to current year. |
|
264
|
|
|
$uri = $this->uriBuilder->reset() |
|
265
|
|
|
->setTargetPageUid($GLOBALS['TSFE']->id) |
|
266
|
|
|
->setCreateAbsoluteUri(!empty($this->settings['forceAbsoluteUrl']) ? 1 : 0) |
|
267
|
|
|
->setArguments([$this->prefixId . '[id]' => urlencode($this->doc->uid)]) |
|
268
|
|
|
->build(); |
|
269
|
|
|
|
|
270
|
|
|
$linkTitleData = $this->doc->getTitledata(); |
|
271
|
|
|
$linkTitle = !empty($linkTitleData['mets_orderlabel'][0]) ? $linkTitleData['mets_orderlabel'][0] : $linkTitleData['mets_label'][0]; |
|
272
|
|
|
$yearLink = $uri; |
|
273
|
|
|
|
|
274
|
|
|
$this->view->assign('yearLink', $yearLink); |
|
275
|
|
|
$this->view->assign('yearLinkText', $linkTitle); |
|
276
|
|
|
|
|
277
|
|
|
// Link to years overview. |
|
278
|
|
|
$uri = $this->uriBuilder->reset() |
|
279
|
|
|
->setTargetPageUid($GLOBALS['TSFE']->id) |
|
280
|
|
|
->setCreateAbsoluteUri(!empty($this->settings['forceAbsoluteUrl']) ? 1 : 0) |
|
281
|
|
|
->setArguments([$this->prefixId . '[id]' => urlencode($this->doc->parentId)]) |
|
282
|
|
|
->build(); |
|
283
|
|
|
$allYearsLink = $uri; |
|
284
|
|
|
|
|
285
|
|
|
$this->view->assign('allYearsLink', $allYearsLink); |
|
286
|
|
|
$this->view->assign('allYearDocTitle', $this->doc->getTitle($this->doc->parentId)); |
|
287
|
|
|
$this->view->assign('calendarViewActive', count($this->allIssues) > 5 ? 'active' : ''); |
|
288
|
|
|
$this->view->assign('listViewActive', count($this->allIssues) < 6 ? 'active' : ''); |
|
289
|
|
|
|
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
|
|
/** |
|
293
|
|
|
* The Years Method |
|
294
|
|
|
* |
|
295
|
|
|
* @access public |
|
296
|
|
|
* |
|
297
|
|
|
* @param integer $id |
|
298
|
|
|
* |
|
299
|
|
|
* @return string The content that is displayed on the website |
|
300
|
|
|
*/ |
|
301
|
|
|
public function yearsAction($id = 0) |
|
302
|
|
|
{ |
|
303
|
|
|
$requestData = GeneralUtility::_GPmerged('tx_dlf'); |
|
304
|
|
|
unset($requestData['__referrer'], $requestData['__trustedProperties']); |
|
305
|
|
|
|
|
306
|
|
|
if (empty($requestData) && !empty($id)) { |
|
307
|
|
|
$requestData['id'] = $id; |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
// Load current document. |
|
311
|
|
|
$this->loadDocument($requestData); |
|
312
|
|
|
if ($this->doc === null) { |
|
313
|
|
|
// Quit without doing anything if required variables are not set. |
|
314
|
|
|
return ''; |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
// Get the title of the anchor file |
|
318
|
|
|
$titleAnchor = $this->doc->getTitle($this->doc->uid); |
|
319
|
|
|
|
|
320
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
|
321
|
|
|
->getQueryBuilderForTable('tx_dlf_documents'); |
|
322
|
|
|
|
|
323
|
|
|
// Get all children of anchor. This should be the year anchor documents |
|
324
|
|
|
$result = $queryBuilder |
|
325
|
|
|
->select( |
|
326
|
|
|
'tx_dlf_documents.uid AS uid', |
|
327
|
|
|
'tx_dlf_documents.title AS title', |
|
328
|
|
|
'tx_dlf_documents.mets_label AS label', |
|
329
|
|
|
'tx_dlf_documents.mets_orderlabel AS orderlabel' |
|
330
|
|
|
) |
|
331
|
|
|
->from('tx_dlf_documents') |
|
332
|
|
|
->where( |
|
333
|
|
|
$queryBuilder->expr()->eq('tx_dlf_documents.structure', Helper::getUidFromIndexName('year', 'tx_dlf_structures', $this->doc->cPid)), |
|
334
|
|
|
$queryBuilder->expr()->eq('tx_dlf_documents.partof', intval($this->doc->uid)), |
|
335
|
|
|
Helper::whereExpression('tx_dlf_documents') |
|
336
|
|
|
) |
|
337
|
|
|
->orderBy('tx_dlf_documents.mets_orderlabel') |
|
338
|
|
|
->execute(); |
|
339
|
|
|
|
|
340
|
|
|
$years = []; |
|
341
|
|
|
// Process results. |
|
342
|
|
|
while ($resArray = $result->fetch()) { |
|
343
|
|
|
$years[] = [ |
|
344
|
|
|
'title' => !empty($resArray['label']) ? $resArray['label'] : (!empty($resArray['orderlabel']) ? $resArray['orderlabel'] : $resArray['title']), |
|
345
|
|
|
'uid' => $resArray['uid'] |
|
346
|
|
|
]; |
|
347
|
|
|
} |
|
348
|
|
|
$yearArray = []; |
|
349
|
|
|
if (count($years) > 0) { |
|
350
|
|
|
foreach ($years as $year) { |
|
351
|
|
|
$uri = $this->uriBuilder->reset() |
|
352
|
|
|
->setTargetPageUid($GLOBALS['TSFE']->id) |
|
353
|
|
|
->setCreateAbsoluteUri(!empty($this->settings['forceAbsoluteUrl']) ? 1 : 0) |
|
354
|
|
|
->setArguments([$this->prefixId . '[id]' => urlencode($year['uid'])]) |
|
355
|
|
|
->build(); |
|
356
|
|
|
|
|
357
|
|
|
$yearArray[] = [ |
|
358
|
|
|
'yearNameLinkTitle' => $titleAnchor . ': ' . $year['title'], |
|
359
|
|
|
'yearNameLink' => $uri, |
|
360
|
|
|
'yearName' => $year['title'] |
|
361
|
|
|
]; |
|
362
|
|
|
} |
|
363
|
|
|
$this->view->assign('yearName', $yearArray); |
|
364
|
|
|
} |
|
365
|
|
|
// Link to years overview (should be itself here) |
|
366
|
|
|
$uri = $this->uriBuilder->reset() |
|
367
|
|
|
->setTargetPageUid($GLOBALS['TSFE']->id) |
|
368
|
|
|
->setCreateAbsoluteUri(!empty($this->settings['forceAbsoluteUrl']) ? 1 : 0) |
|
369
|
|
|
->setArguments(['tx_dlf[id]' => $this->doc->uid]) |
|
370
|
|
|
->build(); |
|
371
|
|
|
$allYearsLink = $uri; |
|
372
|
|
|
|
|
373
|
|
|
$this->view->assign('allYearsLink', $allYearsLink); |
|
374
|
|
|
$this->view->assign('allYearDocTitle', $this->doc->getTitle($this->doc->uid)); |
|
375
|
|
|
} |
|
376
|
|
|
|
|
377
|
|
|
/** |
|
378
|
|
|
* Build calendar for a certain year |
|
379
|
|
|
* |
|
380
|
|
|
* @access protected |
|
381
|
|
|
* |
|
382
|
|
|
* @param array $calendarIssuesByMonth All issues sorted by month => day |
|
383
|
|
|
* @param int $year Gregorian year |
|
384
|
|
|
* @param int $firstMonth 1 for January, 2 for February, ... 12 for December |
|
385
|
|
|
* @param int $lastMonth 1 for January, 2 for February, ... 12 for December |
|
386
|
|
|
* |
|
387
|
|
|
* @return string Content for template subpart |
|
388
|
|
|
*/ |
|
389
|
|
|
protected function getCalendarYear($calendarIssuesByMonth, $year, $firstMonth = 1, $lastMonth = 12) |
|
390
|
|
|
{ |
|
391
|
|
|
$calendarData = []; |
|
392
|
|
|
for ($i = $firstMonth; $i <= $lastMonth; $i++) { |
|
393
|
|
|
$calendarData[$i] = [ |
|
394
|
|
|
'DAYMON_NAME' => strftime('%a', strtotime('last Monday')), |
|
395
|
|
|
'DAYTUE_NAME' => strftime('%a', strtotime('last Tuesday')), |
|
396
|
|
|
'DAYWED_NAME' => strftime('%a', strtotime('last Wednesday')), |
|
397
|
|
|
'DAYTHU_NAME' => strftime('%a', strtotime('last Thursday')), |
|
398
|
|
|
'DAYFRI_NAME' => strftime('%a', strtotime('last Friday')), |
|
399
|
|
|
'DAYSAT_NAME' => strftime('%a', strtotime('last Saturday')), |
|
400
|
|
|
'DAYSUN_NAME' => strftime('%a', strtotime('last Sunday')), |
|
401
|
|
|
'MONTHNAME' => strftime('%B', strtotime($year . '-' . $i . '-1')) . ' ' . $year, |
|
402
|
|
|
'CALYEAR' => ($i == $firstMonth) ? $year : '' |
|
403
|
|
|
]; |
|
404
|
|
|
|
|
405
|
|
|
$firstOfMonth = strtotime($year . '-' . $i . '-1'); |
|
406
|
|
|
$lastOfMonth = strtotime('last day of', ($firstOfMonth)); |
|
407
|
|
|
$firstOfMonthStart = strtotime('last Monday', $firstOfMonth); |
|
408
|
|
|
// There are never more than 6 weeks in a month. |
|
409
|
|
|
for ($j = 0; $j <= 5; $j++) { |
|
410
|
|
|
$firstDayOfWeek = strtotime('+ ' . $j . ' Week', $firstOfMonthStart); |
|
411
|
|
|
|
|
412
|
|
|
$calendarData[$i]['week'][$j] = [ |
|
413
|
|
|
'DAYMON' => ['dayValue' => ' '], |
|
414
|
|
|
'DAYTUE' => ['dayValue' => ' '], |
|
415
|
|
|
'DAYWED' => ['dayValue' => ' '], |
|
416
|
|
|
'DAYTHU' => ['dayValue' => ' '], |
|
417
|
|
|
'DAYFRI' => ['dayValue' => ' '], |
|
418
|
|
|
'DAYSAT' => ['dayValue' => ' '], |
|
419
|
|
|
'DAYSUN' => ['dayValue' => ' '], |
|
420
|
|
|
]; |
|
421
|
|
|
// Every week has seven days. ;-) |
|
422
|
|
|
for ($k = 0; $k <= 6; $k++) { |
|
423
|
|
|
$currentDayTime = strtotime('+ ' . $k . ' Day', $firstDayOfWeek); |
|
424
|
|
|
if ( |
|
425
|
|
|
$currentDayTime >= $firstOfMonth |
|
426
|
|
|
&& $currentDayTime <= $lastOfMonth |
|
427
|
|
|
) { |
|
428
|
|
|
$dayLinks = ''; |
|
429
|
|
|
$dayLinksText = []; |
|
430
|
|
|
$currentMonth = date('n', $currentDayTime); |
|
431
|
|
|
if (is_array($calendarIssuesByMonth[$currentMonth])) { |
|
432
|
|
|
foreach ($calendarIssuesByMonth[$currentMonth] as $id => $day) { |
|
433
|
|
|
if ($id == date('j', $currentDayTime)) { |
|
434
|
|
|
$dayLinks = $id; |
|
435
|
|
|
foreach ($day as $issue) { |
|
436
|
|
|
$dayLinkLabel = empty($issue['title']) ? strftime('%x', $currentDayTime) : $issue['title']; |
|
437
|
|
|
|
|
438
|
|
|
$uri = $this->uriBuilder->reset() |
|
439
|
|
|
->setTargetPageUid($this->settings['targetPid']) |
|
440
|
|
|
->setCreateAbsoluteUri(!empty($this->settings['forceAbsoluteUrl']) ? 1 : 0) |
|
441
|
|
|
->setArguments([$this->prefixId . '[id]' => urlencode($issue['uid'])]) |
|
442
|
|
|
->build(); |
|
443
|
|
|
|
|
444
|
|
|
$dayLinksText[] = [ |
|
445
|
|
|
'url' => $uri, |
|
446
|
|
|
'text' => $dayLinkLabel |
|
447
|
|
|
]; |
|
448
|
|
|
|
|
449
|
|
|
// Save issue for list view. |
|
450
|
|
|
$this->allIssues[$currentDayTime][] = [ |
|
|
|
|
|
|
451
|
|
|
'url' => $uri, |
|
452
|
|
|
'text' => $dayLinkLabel |
|
453
|
|
|
]; |
|
454
|
|
|
} |
|
455
|
|
|
} |
|
456
|
|
|
} |
|
457
|
|
|
$dayLinkDiv = $dayLinksText; |
|
458
|
|
|
} |
|
459
|
|
|
switch (strftime('%w', strtotime('+ ' . $k . ' Day', $firstDayOfWeek))) { |
|
460
|
|
|
case '0': |
|
461
|
|
|
$calendarData[$i]['week'][$j]['DAYSUN']['dayValue'] = strftime('%d', $currentDayTime); |
|
462
|
|
|
if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
|
463
|
|
|
$calendarData[$i]['week'][$j]['DAYSUN']['issues'] = $dayLinkDiv; |
|
|
|
|
|
|
464
|
|
|
} |
|
465
|
|
|
break; |
|
466
|
|
|
case '1': |
|
467
|
|
|
$calendarData[$i]['week'][$j]['DAYMON']['dayValue'] = strftime('%d', $currentDayTime); |
|
468
|
|
|
if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
|
469
|
|
|
$calendarData[$i]['week'][$j]['DAYMON']['issues'] = $dayLinkDiv; |
|
470
|
|
|
} |
|
471
|
|
|
break; |
|
472
|
|
|
case '2': |
|
473
|
|
|
$calendarData[$i]['week'][$j]['DAYTUE']['dayValue'] = strftime('%d', $currentDayTime); |
|
474
|
|
|
if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
|
475
|
|
|
$calendarData[$i]['week'][$j]['DAYTUE']['issues'] = $dayLinkDiv; |
|
476
|
|
|
} |
|
477
|
|
|
break; |
|
478
|
|
|
case '3': |
|
479
|
|
|
$calendarData[$i]['week'][$j]['DAYWED']['dayValue'] = strftime('%d', $currentDayTime); |
|
480
|
|
|
if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
|
481
|
|
|
$calendarData[$i]['week'][$j]['DAYWED']['issues'] = $dayLinkDiv; |
|
482
|
|
|
} |
|
483
|
|
|
break; |
|
484
|
|
|
case '4': |
|
485
|
|
|
$calendarData[$i]['week'][$j]['DAYTHU']['dayValue'] = strftime('%d', $currentDayTime); |
|
486
|
|
|
if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
|
487
|
|
|
$calendarData[$i]['week'][$j]['DAYTHU']['issues'] = $dayLinkDiv; |
|
488
|
|
|
} |
|
489
|
|
|
break; |
|
490
|
|
|
case '5': |
|
491
|
|
|
$calendarData[$i]['week'][$j]['DAYFRI']['dayValue'] = strftime('%d', $currentDayTime); |
|
492
|
|
|
if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
|
493
|
|
|
$calendarData[$i]['week'][$j]['DAYFRI']['issues'] = $dayLinkDiv; |
|
494
|
|
|
} |
|
495
|
|
|
break; |
|
496
|
|
|
case '6': |
|
497
|
|
|
$calendarData[$i]['week'][$j]['DAYSAT']['dayValue'] = strftime('%d', $currentDayTime); |
|
498
|
|
|
if ((int) $dayLinks === (int) date('j', $currentDayTime)) { |
|
499
|
|
|
$calendarData[$i]['week'][$j]['DAYSAT']['issues'] = $dayLinkDiv; |
|
500
|
|
|
} |
|
501
|
|
|
break; |
|
502
|
|
|
} |
|
503
|
|
|
} |
|
504
|
|
|
} |
|
505
|
|
|
} |
|
506
|
|
|
} |
|
507
|
|
|
$this->view->assign('calendarData', $calendarData); |
|
508
|
|
|
} |
|
509
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths