/** * Add Page to sitemap table */ public function addPageToSitemapIndex() { global $TYPO3_DB, $TSFE, $TYPO3_CONF_VARS; // check if sitemap is enabled in root if (!tx_tqseo_tools::getRootSettingValue('is_sitemap', true) || !tx_tqseo_tools::getRootSettingValue('is_sitemap_page_indexer', true)) { return true; } // Skip non-seo-pages if ($_SERVER['REQUEST_METHOD'] !== 'GET' || !empty($TSFE->fe_user->user['uid'])) { return true; } // Skip own sitemap tools if ($TSFE->type == 841131 || $TSFE->type == 841132) { return true; } // Skip no_cache-pages if (!empty($TSFE->no_cache)) { return true; } // Fetch chash $pageHash = NULL; if (!empty($TSFE->cHash)) { $pageHash = $TSFE->cHash; } // Fetch sysLanguage $pageLanguage = tx_tqseo_tools::getLanguageId(); // Fetch page changeFrequency $pageChangeFrequency = 0; if (!empty($TSFE->page['tx_tqseo_change_frequency'])) { $pageChangeFrequency = (int) $TSFE->page['tx_tqseo_change_frequency']; } elseif (!empty($TSFE->tmpl->setup['plugin.']['tq_seo.']['sitemap.']['changeFrequency'])) { $pageChangeFrequency = (int) $TSFE->tmpl->setup['plugin.']['tq_seo.']['sitemap.']['changeFrequency']; } if (empty($pageChangeFrequency)) { $pageChangeFrequency = 0; } // Fetch pageUrl if ($pageHash !== NULL) { $pageUrl = $TSFE->anchorPrefix; } else { $linkConf = array('parameter' => $TSFE->id); $pageUrl = $TSFE->cObj->typoLink_URL($linkConf); $pageUrl = self::_processLinkUrl($pageUrl); } $tstamp = $_SERVER['REQUEST_TIME']; $pageData = array('tstamp' => $tstamp, 'crdate' => $tstamp, 'page_rootpid' => tx_tqseo_tools::getRootPid(), 'page_uid' => $TSFE->id, 'page_language' => $pageLanguage, 'page_url' => $pageUrl, 'page_hash' => md5($pageUrl), 'page_depth' => count($TSFE->rootLine), 'page_change_frequency' => $pageChangeFrequency); // Call hook tx_tqseo_tools::callHook('sitemap-index-page', null, $pageData); if (!empty($pageData)) { tx_tqseo_sitemap::index($pageData, 'page'); } return true; }
/** * Fetch and build robots.txt */ public function main() { global $TSFE, $TYPO3_DB, $TYPO3_CONF_VARS; $settings = tx_tqseo_tools::getRootSetting(); // INIT $tsSetup = $TSFE->tmpl->setup; $cObj = $TSFE->cObj; $tsfePage = $TSFE->page; $rootPid = tx_tqseo_tools::getRootPid(); $ret = ''; $tsSetupSeo = null; if (!empty($tsSetup['plugin.']['tq_seo.']['robotsTxt.'])) { $tsSetupSeo = $tsSetup['plugin.']['tq_seo.']['robotsTxt.']; } if (!empty($tsSetup['plugin.']['tq_seo.']['sitemap.'])) { $tsSetupSeoSitemap = $tsSetup['plugin.']['tq_seo.']['sitemap.']; } // check if sitemap is enabled in root if (!tx_tqseo_tools::getRootSettingValue('is_robotstxt', true)) { return true; } $linkToStaticSitemap = tx_tqseo_tools::getRootSettingValue('is_robotstxt_sitemap_static', false); // Language lock $sitemapLanguageLock = tx_tqseo_tools::getRootSettingValue('is_sitemap_language_lock', false); $languageId = tx_tqseo_tools::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_tqseo/sitemap_xml/index-r' . (int) $rootPid . '-l' . (int) $languageId . '.xml.gz'; } else { $path = 'uploads/tx_tqseo/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%'] = tx_tqseo_tools::fullUrl($markerList['%sitemap%']); // Call hook tx_tqseo_tools::callHook('robotstxt-marker', $this, $markerList); // Apply marker list if (!empty($markerList)) { $ret = strtr($ret, $markerList); } } // Call hook tx_tqseo_tools::callHook('robotstxt-output', $this, $ret); return $ret; }
/** * Fetch sitemap information and generate sitemap */ public function __construct() { global $TSFE, $TYPO3_DB, $TYPO3_CONF_VARS; // INIT $this->rootPid = tx_tqseo_tools::getRootPid(); $sysLanguageId = null; $this->tsSetup = $TSFE->tmpl->setup['plugin.']['tq_seo.']['sitemap.']; // Language limit via setupTS if (tx_tqseo_tools::getRootSettingValue('is_sitemap_language_lock', false)) { $sysLanguageId = tx_tqseo_tools::getLanguageId(); } // Fetch sitemap list/pages $list = tx_tqseo_sitemap::getList($this->rootPid, $sysLanguageId); $this->sitemapPages = $list['tx_tqseo_sitemap']; $this->pages = $list['pages']; // Call hook tx_tqseo_tools::callHook('sitemap-setup', $this, $foo); }