/** * Main action */ public function mainAction() { // ################# // Root page list // ################# $rootPageList = \Metaseo\Metaseo\Utility\BackendUtility::getRootPageList(); $rootIdList = array_keys($rootPageList); $rootPidCondition = NULL; if (!empty($rootIdList)) { $rootPidCondition = 'p.uid IN (' . implode(',', $rootIdList) . ')'; } else { $rootPidCondition = '1=0'; } // ################# // Root setting list (w/ automatic creation) // ################# // check which root lages have no root settings $query = 'SELECT p.uid FROM pages p LEFT JOIN tx_metaseo_setting_root seosr ON seosr.pid = p.uid AND seosr.deleted = 0 WHERE ' . $rootPidCondition . ' AND seosr.uid IS NULL'; $uidList = DatabaseUtility::getCol($query); foreach ($uidList as $tmpUid) { $query = 'INSERT INTO tx_metaseo_setting_root (pid, tstamp, crdate, cruser_id) VALUES (' . (int) $tmpUid . ', ' . (int) time() . ', ' . (int) time() . ', ' . (int) $GLOBALS['BE_USER']->user['uid'] . ')'; DatabaseUtility::execInsert($query); } $rootSettingList = \Metaseo\Metaseo\Utility\BackendUtility::getRootPageSettingList(); // ################# // Domain list // ################## // Fetch domain name $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid, pid, domainName, forced', 'sys_domain', 'hidden = 0', '', 'forced DESC, sorting'); $domainList = array(); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $domainList[$row['pid']][$row['uid']] = $row; } // ################# // Build root page list // ################# unset($page); foreach ($rootPageList as $pageId => &$page) { // Domain list $page['domainList'] = ''; if (!empty($domainList[$pageId])) { $page['domainList'] = $domainList[$pageId]; } // Settings $page['rootSettings'] = array(); if (!empty($rootSettingList[$pageId])) { $page['rootSettings'] = $rootSettingList[$pageId]; } // Settings available $page['settingsLink'] = \TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick('&edit[tx_metaseo_setting_root][' . $rootSettingList[$pageId]['uid'] . ']=edit', $this->doc->backPath); } unset($page); // check if there is any root page if (empty($rootPageList)) { $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $this->_translate('message.warning.noRootPage.message'), $this->_translate('message.warning.noRootPage.title'), \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING); \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($message); } // ############################ // Page/JS // ############################ // FIXME: do we really need a template engine here? $this->template = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate'); $pageRenderer = $this->template->getPageRenderer(); $basePathJs = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('metaseo') . 'Resources/Public/Backend/JavaScript'; $basePathCss = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('metaseo') . 'Resources/Public/Backend/Css'; $pageRenderer->addCssFile($basePathCss . '/Default.css'); $this->view->assign('RootPageList', $rootPageList); }
/** * Main action */ public function mainAction() { // Init $rootPageList = \Metaseo\Metaseo\Utility\BackendUtility::getRootPageList(); $rootSettingList = \Metaseo\Metaseo\Utility\BackendUtility::getRootPageSettingList(); // ############################ // Fetch // ############################ $statsList['sum_total'] = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('page_rootpid, COUNT(*) as count', 'tx_metaseo_sitemap', '', 'page_rootpid', '', '', 'page_rootpid'); // Fetch domain name $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pid, domainName, forced', 'sys_domain', 'hidden = 0', '', 'forced DESC, sorting'); $domainList = array(); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $pid = $row['pid']; if (!empty($row['forced'])) { $domainList[$pid] = $row['domainName']; } elseif (empty($domainList[$pid])) { $domainList[$pid] = $row['domainName']; } } // ################# // Build root page list // ################# unset($page); foreach ($rootPageList as $pageId => &$page) { $stats = array('sum_pages' => 0, 'sum_total' => 0, 'sum_xml_pages' => 0); // Get domain $domain = NULL; if (!empty($domainList[$pageId])) { $domain = $domainList[$pageId]; } // Setting row $settingRow = array(); if (!empty($rootSettingList[$pageId])) { $settingRow = $rootSettingList[$pageId]; } // Calc stats foreach ($statsList as $statsKey => $statsTmpList) { if (!empty($statsTmpList[$pageId])) { $stats[$statsKey] = $statsTmpList[$pageId]['count']; } } // Root statistics $tmp = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('DISTINCT page_uid', 'tx_metaseo_sitemap', 'page_rootpid = ' . (int) $pageId); if (!empty($tmp)) { $stats['sum_pages'] = count($tmp); } // FIXME: fix link //$args = array( // 'rootPid' => $pageId //); //$listLink = $this->_moduleLinkOnClick('sitemapList', $args); $pagesPerXmlSitemap = 1000; if (!empty($settingRow['sitemap_page_limit'])) { $pagesPerXmlSitemap = $settingRow['sitemap_page_limit']; } $sumXmlPages = ceil($stats['sum_total'] / $pagesPerXmlSitemap); $stats['sum_xml_pages'] = sprintf($this->_translate('sitemap.xml.pages.total'), $sumXmlPages); $page['stats'] = $stats; } unset($page); // check if there is any root page if (empty($rootPageList)) { $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $this->_translate('message.warning.noRootPage.message'), $this->_translate('message.warning.noRootPage.title'), \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING); \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($message); } $this->view->assign('RootPageList', $rootPageList); }