Пример #1
0
 /**
  * Create sitemap (for page)
  *
  * @param   integer $page   Page
  * @return  string
  */
 public function sitemap($page = NULL)
 {
     $ret = array();
     foreach ($this->sitemapPages as $sitemapPage) {
         if (empty($this->pages[$sitemapPage['page_uid']])) {
             // invalid page
             continue;
         }
         //$page = $this->pages[ $sitemapPage['page_uid'] ];
         $ret[] = \Metaseo\Metaseo\Utility\GeneralUtility::fullUrl($sitemapPage['page_url']);
     }
     // Call hook
     \Metaseo\Metaseo\Utility\GeneralUtility::callHook('sitemap-text-output', $this, $ret);
     return implode("\n", $ret);
 }
 /**
  * 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);
     }
 }
Пример #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;
 }
Пример #4
0
 /**
  * Generate a link via TYPO3-Api
  *
  * @param    integer|string $url    URL (id or string)
  * @param    array|NULL     $conf   URL configuration
  * @return   string                 URL
  */
 protected function _generateLink($url, $conf = NULL)
 {
     if ($conf === NULL) {
         $conf = array();
     }
     $conf['parameter'] = $url;
     $ret = $GLOBALS['TSFE']->cObj->typoLink_URL($conf);
     // maybe baseUrlWrap is better? but breaks with realurl currently?
     $ret = \Metaseo\Metaseo\Utility\GeneralUtility::fullUrl($ret);
     return $ret;
 }
Пример #5
0
 /**
  * Generate simulated title for one page
  *
  * @return    string
  */
 protected function _executeGenerateSimulatedUrl()
 {
     // Init
     $ret = '';
     $pid = (int) $this->_postVar['pid'];
     if (!empty($pid)) {
         $page = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $pid);
         if (!empty($page)) {
             if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl')) {
                 // Disable caching for url
                 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']['enableUrlDecodeCache'] = 0;
                 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']['enableUrlEncodeCache'] = 0;
                 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']['disablePathCache'] = 1;
             }
             $this->_initTsfe($page, NULL, $page, NULL);
             $ret = $GLOBALS['TSFE']->cObj->typolink_URL(array('parameter' => $page['uid']));
             if (!empty($ret)) {
                 $ret = \Metaseo\Metaseo\Utility\GeneralUtility::fullUrl($ret);
             }
         }
     }
     if (!empty($ret)) {
         $ret = array('url' => $ret);
     } else {
         $ret = array('error' => $GLOBALS['LANG']->getLL('error.url_generation_failed'));
     }
     return $ret;
 }
Пример #6
0
 /**
  * Create Sitemap Page
  *
  * @return string
  */
 protected function createSitemapPage()
 {
     $ret = '<?xml version="1.0" encoding="UTF-8"?>';
     $ret .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"';
     $ret .= ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"';
     $ret .= ' xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9';
     $ret .= ' http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';
     $pagePriorityDefaultValue = (double) \Metaseo\Metaseo\Utility\GeneralUtility::getRootSettingValue('sitemap_priorty', 0);
     $pagePriorityDepthMultiplier = (double) \Metaseo\Metaseo\Utility\GeneralUtility::getRootSettingValue('sitemap_priorty_depth_multiplier', 0);
     $pagePriorityDepthModificator = (double) \Metaseo\Metaseo\Utility\GeneralUtility::getRootSettingValue('sitemap_priorty_depth_modificator', 0);
     if ($pagePriorityDefaultValue == 0) {
         $pagePriorityDefaultValue = 1;
     }
     if ($pagePriorityDepthMultiplier == 0) {
         $pagePriorityDepthMultiplier = 1;
     }
     if ($pagePriorityDepthModificator == 0) {
         $pagePriorityDepthModificator = 1;
     }
     // #####################
     // SetupTS conf
     // #####################
     foreach ($this->sitemapPages as $sitemapPage) {
         if (empty($this->pages[$sitemapPage['page_uid']])) {
             // invalid page
             continue;
         }
         $page = $this->pages[$sitemapPage['page_uid']];
         // #####################################
         // Page priority
         // #####################################
         $pageDepth = $sitemapPage['page_depth'];
         $pageDepthBase = 1;
         if (!empty($sitemapPage['page_hash'])) {
             // page has module-content - trade as subpage
             ++$pageDepth;
         }
         $pageDepth -= $pagePriorityDepthModificator;
         if ($pageDepth > 0.1) {
             $pageDepthBase = 1 / $pageDepth;
         }
         $pagePriority = $pagePriorityDefaultValue * ($pageDepthBase * $pagePriorityDepthMultiplier);
         if (!empty($page['tx_metaseo_priority'])) {
             $pagePriority = $page['tx_metaseo_priority'] / 100;
         }
         $pagePriority = number_format($pagePriority, 2);
         if ($pagePriority > 1) {
             $pagePriority = '1.00';
         } elseif ($pagePriority <= 0) {
             $pagePriority = '0.00';
         }
         // #####################################
         // Page informations
         // #####################################
         // page Url
         $pageUrl = \Metaseo\Metaseo\Utility\GeneralUtility::fullUrl($sitemapPage['page_url']);
         // Page modification date
         $pageModifictionDate = date('c', $sitemapPage['tstamp']);
         // Page change frequency
         $pageChangeFrequency = NULL;
         if (!empty($page['tx_metaseo_change_frequency'])) {
             $pageChangeFrequency = (int) $page['tx_metaseo_change_frequency'];
         } elseif (!empty($sitemapPage['page_change_frequency'])) {
             $pageChangeFrequency = (int) $sitemapPage['page_change_frequency'];
         }
         if (!empty($pageChangeFrequency) && !empty($this->pageChangeFrequency[$pageChangeFrequency])) {
             $pageChangeFrequency = $this->pageChangeFrequency[$pageChangeFrequency];
         } else {
             $pageChangeFrequency = NULL;
         }
         // #####################################
         // Sitemal page output
         // #####################################
         $ret .= '<url>';
         $ret .= '<loc>' . htmlspecialchars($pageUrl) . '</loc>';
         $ret .= '<lastmod>' . $pageModifictionDate . '</lastmod>';
         if (!empty($pageChangeFrequency)) {
             $ret .= '<changefreq>' . htmlspecialchars($pageChangeFrequency) . '</changefreq>';
         }
         $ret .= '<priority>' . $pagePriority . '</priority>';
         $ret .= '</url>';
     }
     $ret .= '</urlset>';
     // Call hook
     \Metaseo\Metaseo\Utility\GeneralUtility::callHook('sitemap-xml-page-output', $this, $ret);
     return $ret;
 }