Пример #1
0
 /**
  * Add Page to sitemap table
  */
 public function addPageToSitemapIndex()
 {
     // check if sitemap is enabled in root
     if (!\Metaseo\Metaseo\Utility\GeneralUtility::getRootSettingValue('is_sitemap', TRUE) || !\Metaseo\Metaseo\Utility\GeneralUtility::getRootSettingValue('is_sitemap_page_indexer', TRUE)) {
         return TRUE;
     }
     // check current page
     if (!self::_checkIfCurrentPageIsIndexable()) {
         return;
     }
     // Fetch chash
     $pageHash = NULL;
     if (!empty($GLOBALS['TSFE']->cHash)) {
         $pageHash = $GLOBALS['TSFE']->cHash;
     }
     // Fetch sysLanguage
     $pageLanguage = \Metaseo\Metaseo\Utility\GeneralUtility::getLanguageId();
     // Fetch page changeFrequency
     $pageChangeFrequency = 0;
     if (!empty($GLOBALS['TSFE']->page['tx_metaseo_change_frequency'])) {
         $pageChangeFrequency = (int) $GLOBALS['TSFE']->page['tx_metaseo_change_frequency'];
     } elseif (!empty($GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['sitemap.']['changeFrequency'])) {
         $pageChangeFrequency = (int) $GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['sitemap.']['changeFrequency'];
     }
     if (empty($pageChangeFrequency)) {
         $pageChangeFrequency = 0;
     }
     // Fetch pageUrl
     if ($pageHash !== NULL) {
         $pageUrl = $GLOBALS['TSFE']->anchorPrefix;
     } else {
         $linkConf = array('parameter' => $GLOBALS['TSFE']->id);
         $pageUrl = $GLOBALS['TSFE']->cObj->typoLink_URL($linkConf);
         $pageUrl = self::_processLinkUrl($pageUrl);
     }
     $tstamp = $_SERVER['REQUEST_TIME'];
     $pageData = array('tstamp' => $tstamp, 'crdate' => $tstamp, 'page_rootpid' => \Metaseo\Metaseo\Utility\GeneralUtility::getRootPid(), 'page_uid' => $GLOBALS['TSFE']->id, 'page_language' => $pageLanguage, 'page_url' => $pageUrl, 'page_depth' => count($GLOBALS['TSFE']->rootLine), 'page_change_frequency' => $pageChangeFrequency);
     // Call hook
     \Metaseo\Metaseo\Utility\GeneralUtility::callHook('sitemap-index-page', NULL, $pageData);
     if (!empty($pageData)) {
         \Metaseo\Metaseo\Utility\SitemapUtility::index($pageData, 'page');
     }
     return TRUE;
 }
Пример #2
0
 /**
  * Fetch sitemap information and generate sitemap
  */
 public function __construct()
 {
     // INIT
     $this->rootPid = \Metaseo\Metaseo\Utility\GeneralUtility::getRootPid();
     $sysLanguageId = NULL;
     $this->tsSetup = $GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['sitemap.'];
     // Language limit via setupTS
     if (\Metaseo\Metaseo\Utility\GeneralUtility::getRootSettingValue('is_sitemap_language_lock', FALSE)) {
         $sysLanguageId = \Metaseo\Metaseo\Utility\GeneralUtility::getLanguageId();
     }
     // Fetch sitemap list/pages
     $list = \Metaseo\Metaseo\Utility\SitemapUtility::getList($this->rootPid, $sysLanguageId);
     $this->sitemapPages = $list['tx_metaseo_sitemap'];
     $this->pages = $list['pages'];
     // Call hook
     \Metaseo\Metaseo\Utility\GeneralUtility::callHook('sitemap-setup', $this);
 }
Пример #3
0
 /**
  * Fetch and build robots.txt
  */
 public function main()
 {
     $settings = \Metaseo\Metaseo\Utility\GeneralUtility::getRootSetting();
     // INIT
     $tsSetup = $GLOBALS['TSFE']->tmpl->setup;
     $cObj = $GLOBALS['TSFE']->cObj;
     $tsfePage = $GLOBALS['TSFE']->page;
     $rootPid = \Metaseo\Metaseo\Utility\GeneralUtility::getRootPid();
     $ret = '';
     $tsSetupSeo = NULL;
     if (!empty($tsSetup['plugin.']['metaseo.']['robotsTxt.'])) {
         $tsSetupSeo = $tsSetup['plugin.']['metaseo.']['robotsTxt.'];
     }
     if (!empty($tsSetup['plugin.']['metaseo.']['sitemap.'])) {
         $tsSetupSeoSitemap = $tsSetup['plugin.']['metaseo.']['sitemap.'];
     }
     // check if sitemap is enabled in root
     if (!\Metaseo\Metaseo\Utility\GeneralUtility::getRootSettingValue('is_robotstxt', TRUE)) {
         return TRUE;
     }
     $linkToStaticSitemap = \Metaseo\Metaseo\Utility\GeneralUtility::getRootSettingValue('is_robotstxt_sitemap_static', FALSE);
     // Language lock
     $sitemapLanguageLock = \Metaseo\Metaseo\Utility\GeneralUtility::getRootSettingValue('is_sitemap_language_lock', FALSE);
     $languageId = \Metaseo\Metaseo\Utility\GeneralUtility::getLanguageId();
     // ###############################
     // Fetch robots.txt content
     // ###############################
     $settings['robotstxt'] = trim($settings['robotstxt']);
     if (!empty($settings['robotstxt'])) {
         // Custom Robots.txt
         $ret .= $settings['robotstxt'];
     } elseif ($tsSetupSeo) {
         // Default robots.txt
         $ret .= $cObj->cObjGetSingle($tsSetupSeo['default'], $tsSetupSeo['default.']);
     }
     // ###############################
     // Fetch extra robots.txt content
     // ###############################
     // User additional
     if (!empty($settings['robotstxt_additional'])) {
         $ret .= "\n\n" . $settings['robotstxt_additional'];
     }
     // Setup additional
     if ($tsSetupSeo) {
         // Default robots.txt
         $tmp = $cObj->cObjGetSingle($tsSetupSeo['extra'], $tsSetupSeo['extra.']);
         if (!empty($tmp)) {
             $ret .= "\n\n" . $tmp;
         }
     }
     // ###############################
     // Marker
     // ###############################
     if (!empty($tsSetupSeo['marker.'])) {
         // Init marker list
         $markerList = array();
         $markerConfList = array();
         foreach ($tsSetupSeo['marker.'] as $name => $data) {
             if (strpos($name, '.') === FALSE) {
                 $markerConfList[$name] = NULL;
             }
         }
         if ($linkToStaticSitemap) {
             // remove sitemap-marker because we link to static url
             unset($markerConfList['sitemap']);
         }
         // Fetch marker content
         foreach ($markerConfList as $name => $conf) {
             $markerList['%' . $name . '%'] = $cObj->cObjGetSingle($tsSetupSeo['marker.'][$name], $tsSetupSeo['marker.'][$name . '.']);
         }
         // generate sitemap-static marker
         if ($linkToStaticSitemap) {
             if ($sitemapLanguageLock) {
                 $path = 'uploads/tx_metaseo/sitemap_xml/index-r' . (int) $rootPid . '-l' . (int) $languageId . '.xml.gz';
             } else {
                 $path = 'uploads/tx_metaseo/sitemap_xml/index-r' . (int) $rootPid . '.xml.gz';
             }
             $conf = array('parameter' => $path);
             $markerList['%sitemap%'] = $cObj->typolink_URL($conf);
         }
         // Fix sitemap-marker url (add prefix if needed)
         $markerList['%sitemap%'] = \Metaseo\Metaseo\Utility\GeneralUtility::fullUrl($markerList['%sitemap%']);
         // Call hook
         \Metaseo\Metaseo\Utility\GeneralUtility::callHook('robotstxt-marker', $this, $markerList);
         // Apply marker list
         if (!empty($markerList)) {
             $ret = strtr($ret, $markerList);
         }
     }
     // Call hook
     \Metaseo\Metaseo\Utility\GeneralUtility::callHook('robotstxt-output', $this, $ret);
     return $ret;
 }