Пример #1
0
 /**
  * Create Sitemap Index
  *
  * @return string 		XML Sitemap
  */
 protected function createSitemapIndex($pageCount)
 {
     global $TSFE;
     $sitemaps = array();
     // TODO: pages?
     $linkConf = array('parameter' => tx_tqseo_tools::getRootPid(), 'additionalParams' => '', 'useCacheHash' => 1);
     for ($i = 0; $i < $pageCount; $i++) {
         $linkConf['additionalParams'] = '&type=' . $TSFE->type . '&page=' . ($i + 1);
         $sitemaps[] = t3lib_div::locationHeaderUrl($TSFE->cObj->typoLink_URL($linkConf));
     }
     $ret = '<?xml version="1.0" encoding="UTF-8"?><sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     foreach ($sitemaps as $sitemapPage) {
         $ret .= '<sitemap><loc>' . htmlspecialchars($sitemapPage) . '</loc></sitemap>';
     }
     $ret .= '</sitemapindex>';
     return $ret;
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 /**
  * 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);
 }
Пример #4
0
    /**
     * Fetch sitemap information and generate sitemap
     */
    public function main()
    {
        global $TSFE, $TYPO3_DB, $TYPO3_CONF_VARS;
        // INIT
        $this->rootPid = tx_tqseo_tools::getRootPid();
        $limitToFeLanguage = false;
        $this->tsSetup = $TSFE->tmpl->setup['plugin.']['tq_seo.']['sitemap.'];
        // check if sitemap is enabled
        if (empty($this->tsSetup['enable'])) {
            $this->showError();
        }
        // Load ext conf
        $this->extConf = unserialize($TYPO3_CONF_VARS['EXT']['extConf']['tq_seo']);
        if (!is_array($this->extConf)) {
            $this->extConf = array();
        }
        $typo3Pids = array();
        // Language limit via ext conf [DEPRECATED]
        if ($this->getExtConf('sitemap_ObeySysLanguage', false)) {
            $limitToFeLanguage = true;
        }
        // Language limit via setupTS [DEPRECATED]
        if (!empty($this->tsSetup['limitToCurrentLanguage'])) {
            $limitToFeLanguage = true;
        }
        #########################################
        # Fetch sitemap pages
        #########################################
        $query = 'SELECT ts.*
					FROM tx_tqseo_sitemap ts
							INNER JOIN pages p
							  ON	p.uid = ts.page_uid
								AND	p.deleted = 0
								AND p.hidden = 0
								AND p.tx_tqseo_is_exclude = 0
				   WHERE ts.page_rootpid = ' . (int) $this->rootPid;
        if ($limitToFeLanguage) {
            $sysLanguageId = 0;
            if (!empty($TSFE->tmpl->setup['config.']['sys_language_uid'])) {
                $sysLanguageId = (int) $TSFE->tmpl->setup['config.']['sys_language_uid'];
            }
            $query .= ' AND ts.page_language = ' . (int) $sysLanguageId;
        }
        $query .= ' ORDER BY
						ts.page_depth ASC,
						p.pid ASC,
						p.sorting ASC';
        $res = $TYPO3_DB->sql_query($query);
        if (!$res) {
            $this->showError();
        }
        while ($row = $TYPO3_DB->sql_fetch_assoc($res)) {
            $this->sitemapPages[] = $row;
            $sitemapPageId = $row['page_uid'];
            $typo3Pids[$sitemapPageId] = (int) $sitemapPageId;
        }
        #########################################
        # Fetch pages
        #########################################
        if (!empty($typo3Pids)) {
            $query = 'SELECT *
						FROM pages
					   WHERE uid IN (' . implode(',', $typo3Pids) . ')';
            $res = $TYPO3_DB->sql_query($query);
            if (!$res) {
                $this->showError();
            }
            while ($row = $TYPO3_DB->sql_fetch_assoc($res)) {
                $this->pages[$row['uid']] = $row;
            }
        }
        $ret = $this->createSitemap();
        return $ret;
    }
Пример #5
0
 /**
  * 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;
 }