/**
  * Get whole list of sitemap entries
  *
  * @param   string $rootPageId Site root page id or domain
  * @return  string
  */
 public function sitemapCommand($rootPageId)
 {
     $rootPageId = $this->_getRootPageIdFromId($rootPageId);
     if ($rootPageId !== NULL) {
         $domain = RootPageUtility::getDomain($rootPageId);
         $query = 'SELECT page_url
                     FROM tx_metaseo_sitemap
                    WHERE page_rootpid = ' . DatabaseUtility::quote($rootPageId, 'tx_metaseo_sitemap') . '
                      AND is_blacklisted = 0';
         $urlList = DatabaseUtility::getCol($query);
         foreach ($urlList as $url) {
             if ($domain) {
                 $url = \Metaseo\Metaseo\Utility\GeneralUtility::fullUrl($url, $domain);
             }
             ConsoleUtility::writeLine($url);
         }
     } else {
         ConsoleUtility::writeErrorLine('No such root page found');
         ConsoleUtility::teminate(1);
     }
 }
 /**
  * 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);
 }
Ejemplo n.º 3
0
 /**
  * Return simulated page title
  *
  * @param   array   $page         Root page
  * @param   integer $depth        Depth
  * @param   integer $sysLanguage  Sys language
  * @return  array
  */
 protected function _listPageTitleSim($page, $depth, $sysLanguage)
 {
     // Init
     $list = array();
     $pid = $page['uid'];
     $fieldList = array('title', 'tx_metaseo_pagetitle', 'tx_metaseo_pagetitle_rel', 'tx_metaseo_pagetitle_prefix', 'tx_metaseo_pagetitle_suffix');
     $list = $this->_listDefaultTree($page, $depth, $sysLanguage, $fieldList);
     $uidList = array_keys($list);
     if (!empty($uidList)) {
         // Check which pages have templates (for caching and faster building)
         $this->_templatePidList = array();
         $query = 'SELECT pid
                     FROM sys_template
                    WHERE pid IN (' . implode(',', $uidList) . ')
                      AND deleted = 0
                      AND hidden = 0';
         $pidList = DatabaseUtility::getCol($query);
         foreach ($pidList as $pid) {
             $this->_templatePidList[$pid] = $pid;
         }
         // Build simulated title
         foreach ($list as &$row) {
             $row['title_simulated'] = $this->_simulateTitle($row, $sysLanguage);
         }
     }
     return $list;
 }