2 namespace TYPO3\CMS\Belog\Controller;
102 parent::initializeView($view);
103 $view->getModuleTemplate()->getPageRenderer()->loadExtJS();
104 $view->getModuleTemplate()->getPageRenderer()->loadRequireJsModule(
'TYPO3/CMS/Backend/DateTimePicker');
114 if ($this->isInPageContext ===
false) {
115 $this->defaultViewObjectName = BackendTemplateView::class;
132 if (empty($this->settings)) {
133 throw new \RuntimeException(
134 'No settings detected. This usually happens if there is no frontend TypoScript template with root flag set. Please create one.',
138 if (!isset($this->settings[
'dateFormat'])) {
139 $this->settings[
'dateFormat'] =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'USdateFormat'] ?
'm-d-Y' :
'd-m-Y';
141 if (!isset($this->settings[
'timeFormat'])) {
142 $this->settings[
'timeFormat'] =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'hhmm'];
156 if ($constraint === null) {
158 if ($constraint === null) {
159 $constraint = $this->objectManager->get(\TYPO3\CMS\Belog\Domain\Model\Constraint::class);
164 $constraint->setIsInPageContext($this->isInPageContext);
165 $constraint->setPageId($this->pageId);
168 $logEntries = $this->logEntryRepository->findByConstraint($constraint);
169 $groupedLogEntries = $this->groupLogEntriesByPageAndDay($logEntries, $constraint->getGroupByPage());
180 $serializedConstraint =
$GLOBALS[
'BE_USER']->getModuleData(get_class($this));
181 if (!is_string($serializedConstraint) || empty($serializedConstraint)) {
184 return @unserialize($serializedConstraint);
195 $GLOBALS[
'BE_USER']->pushModuleData(get_class($this), serialize($constraint));
212 protected function groupLogEntriesByPageAndDay(\TYPO3\CMS\Extbase\Persistence\QueryResultInterface $logEntries, $groupByPage =
false)
214 $targetStructure = array();
216 foreach ($logEntries as $entry) {
219 $pid = $entry->getEventPid();
224 if (!is_array($targetStructure[$pid])) {
225 $targetStructure[$pid] = array();
228 $timestampDay = strtotime(strftime(
'%d.%m.%Y', $entry->getTstamp()));
229 if (!is_array($targetStructure[$pid][$timestampDay])) {
230 $targetStructure[$pid][$timestampDay] = array();
233 $targetStructure[$pid][$timestampDay][] = $entry;
235 ksort($targetStructure);
236 return $targetStructure;
248 $userGroupArray = array();
250 $userGroupArray[0] = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
'allUsers',
'Belog');
251 $userGroupArray[-1] = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
'self',
'Belog');
253 $groups = \TYPO3\CMS\Backend\Utility\BackendUtility::getGroupNames();
254 foreach ($groups as $group) {
255 $userGroupArray[
'gr-' . $group[
'uid']] = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
'group',
'Belog') .
' ' . $group[
'title'];
258 $users = \TYPO3\CMS\Backend\Utility\BackendUtility::getUserNames();
259 foreach ($users as $user) {
260 $userGroupArray[
'us-' . $user[
'uid']] = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
'user',
'Belog') .
' ' . $user[
'username'];
262 return $userGroupArray;
270 protected function createWorkspaceListForSelectOptions()
272 if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'workspaces')) {
275 $workspaceArray = array();
277 $workspaceArray[-99] = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
'any',
'Belog');
278 $workspaceArray[0] = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
'live',
'Belog');
279 $workspaces = $this->objectManager->get(\TYPO3\CMS\Belog\Domain\Repository\WorkspaceRepository::class)->findAll();
281 foreach ($workspaces as $workspace) {
282 $workspaceArray[$workspace->getUid()] = $workspace->getUid() .
': ' . $workspace->getTitle();
284 return $workspaceArray;
297 if (
$GLOBALS[
'BE_USER']->workspace !== 0) {
298 $constraint->setWorkspaceUid(
$GLOBALS[
'BE_USER']->workspace);
299 $this->view->assign(
'showWorkspaceSelector',
false);
301 $this->view->assign(
'showWorkspaceSelector',
true);
335 switch ($constraint->getTimeFrame()) {
336 case self::TIMEFRAME_THISWEEK:
338 $week = (date(
'w') ?: 7) - 1;
339 $startTime = mktime(0, 0, 0) - $week * 3600 * 24;
341 case self::TIMEFRAME_LASTWEEK:
343 $week = (date(
'w') ?: 7) - 1;
344 $startTime = mktime(0, 0, 0) - ($week + 7) * 3600 * 24;
345 $endTime = mktime(0, 0, 0) - $week * 3600 * 24;
347 case self::TIMEFRAME_LASTSEVENDAYS:
349 $startTime = mktime(0, 0, 0) - 7 * 3600 * 24;
351 case self::TIMEFRAME_THISMONTH:
353 $startTime = mktime(0, 0, 0, date(
'm'), 1);
355 case self::TIMEFRAME_LASTMONTH:
357 $startTime = mktime(0, 0, 0, date(
'm') - 1, 1);
358 $endTime = mktime(0, 0, 0, date(
'm'), 1);
360 case self::TIMEFRAME_LAST31DAYS:
362 $startTime = mktime(0, 0, 0) - 31 * 3600 * 24;
364 case self::TIMEFRAME_CUSTOM:
365 $startTime = $constraint->getStartTimestamp();
366 if ($constraint->getEndTimestamp() > $constraint->getStartTimestamp()) {
367 $endTime = $constraint->getEndTimestamp();
374 $constraint->setStartTimestamp($startTime);
375 $constraint->setEndTimestamp($endTime);