/**
  * 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);
 }
Example #2
0
 /**
  * @param integer        $pid               PID
  * @param integer|NULL   $sysLanguage       System language id
  * @param string|array   $metaTag           MetaTag name
  * @param string         $value             MetaTag value
  * @param integer        $tagGroup          MetaTag group
  */
 protected function _updateMetaTag($pid, $sysLanguage, $metaTag, $value, $tagGroup = NULL)
 {
     $tstamp = time();
     $crdate = time();
     $cruserId = $GLOBALS['BE_USER']->user['uid'];
     $subTagName = '';
     if (is_array($metaTag)) {
         list($metaTag, $subTagName) = $metaTag;
     }
     if ($tagGroup === NULL) {
         $tagGroup = 1;
     }
     $query = 'INSERT INTO tx_metaseo_metatag
                           (pid, tstamp, crdate, cruser_id, sys_language_uid, tag_name, tag_subname, tag_value, tag_group)
                     VALUES (
                           ' . (int) $pid . ',
                           ' . (int) $tstamp . ',
                           ' . (int) $crdate . ',
                           ' . (int) $cruserId . ',
                           ' . (int) $sysLanguage . ',
                           ' . DatabaseUtility::quote($metaTag) . ',
                           ' . DatabaseUtility::quote($subTagName) . ',
                           ' . DatabaseUtility::quote($value) . ',
                           ' . (int) $tagGroup . '
                     ) ON DUPLICATE KEY UPDATE
                             tstamp    = VALUES(tstamp),
                             tag_value = VALUES(tag_value)';
     DatabaseUtility::execInsert($query);
 }