*/ public function collectPageStatistics(): array { $databaseIntegrityCheck = GeneralUtility::makeInstance(DatabaseIntegrityCheck::class); $databaseIntegrityCheck->genTree(0); return [ 'total_pages' => [ 'icon' => $this->iconFactory->getIconForRecord('pages', [], IconSize::SMALL)->render(), 'count' => count($databaseIntegrityCheck->getPageIdArray()), ], 'translated_pages' => [ 'icon' => $this->iconFactory->getIconForRecord('pages', [], IconSize::SMALL)->render(), 'count' => count($databaseIntegrityCheck->getPageTranslatedPageIDArray()), ], 'hidden_pages' => [ 'icon' => $this->iconFactory->getIconForRecord('pages', ['hidden' => 1], IconSize::SMALL)->render(), 'count' => $databaseIntegrityCheck->getRecStats()['hidden'] ?? 0, ], 'deleted_pages' => [ 'icon' => $this->iconFactory->getIconForRecord('pages', ['deleted' => 1], IconSize::SMALL)->render(), 'count' => isset($databaseIntegrityCheck->getRecStats()['deleted']['pages']) ? count($databaseIntegrityCheck->getRecStats()['deleted']['pages']) : 0, ], ]; } /** * Collects statistics for different page doktypes * * @return array */ public function collectDoktypeStatistics(): array { $languageService = $this->getLanguageService(); $databaseIntegrityCheck = GeneralUtility::makeInstance(DatabaseIntegrityCheck::class); $databaseIntegrityCheck->genTree(0); $doktypes = []; foreach ($this->pageDoktypeRegistry->getAllDoktypes() as $doktype) { if ($doktype->isDivider()) { continue; } $doktypes[] = [ 'icon' => $this->iconFactory->getIconForRecord('pages', ['doktype' => $doktype->getValue()], IconSize::SMALL)->render(), 'title' => $languageService->sL($doktype->getLabel()) . ' (' . $doktype->getValue() . ')', 'count' => (int)($databaseIntegrityCheck->getRecStats()['doktype'][$doktype->getValue()] ?? 0), ]; } return $doktypes; } /** * Collects statistics for all TCA tables including lost records * * @return array */ public function collectTableStatistics(): array { $languageService = $this->getLanguageService(); $databaseIntegrityCheck = GeneralUtility::makeInstance(DatabaseIntegrityCheck::class); $databaseIntegrityCheck->genTree(0); // Tables and lost records $pageIds = array_merge([0], array_keys($databaseIntegrityCheck->getPageIdArray())); $lostRecords = $databaseIntegrityCheck->lostRecords($pageIds); $tableStatistic = []; $countArr = $databaseIntegrityCheck->countRecords($pageIds); $lostPageIds = isset($lostRecords['pages']) ? array_keys($lostRecords['pages']) : []; /** @var TcaSchema $schema */ foreach ($this->tcaSchemaFactory->all() as $table => $schema) { if ($schema->hasCapability(TcaSchemaCapability::HideInUi)) { continue; } $lostRecordCount = isset($lostRecords[$table]) ? count($lostRecords[$table]) : 0; $recordCount = 0; if ($countArr['all'][$table] ?? false) { $recordCount = (int)($countArr['non_deleted'][$table] ?? 0) . '/' . $lostRecordCount; } $lostRecordList = []; foreach ($lostRecords[$table] ?? [] as $data) { if (!in_array((int)$data['pid'], $lostPageIds, true)) { $lostRecordList[] = '
' . $this->iconFactory->getIcon('status-dialog-error', IconSize::SMALL)->render() . 'uid:' . $data['uid'] . ', pid:' . $data['pid'] . ', ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(strip_tags($data['title']), 20)) . '
'; } else { $lostRecordList[] = '
' . 'uid:' . $data['uid'] . ', pid:' . $data['pid'] . ', ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(strip_tags($data['title']), 20)) . '
'; } } $tableStatistic[$table] = [ 'icon' => $this->iconFactory->getIconForRecord($table, [], IconSize::SMALL)->render(), 'title' => $schema->getTitle($languageService->sL(...)), 'count' => $recordCount, 'lostRecords' => implode(LF, $lostRecordList), ]; } ksort($tableStatistic); return $tableStatistic; } private function getLanguageService(): LanguageService { return $GLOBALS['LANG']; } }