Ejemplo n.º 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[] = tx_tqseo_tools::fullUrl($sitemapPage['page_url']);
     }
     // Call hook
     tx_tqseo_tools::callHook('sitemap-text-output', $this, $ret);
     return implode("\n", $ret);
 }
Ejemplo n.º 2
0
 /**
  * Create Sitemap Page
  *
  * @return string 		XML Sitemap
  */
 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) tx_tqseo_tools::getRootSettingValue('sitemap_priorty', 0);
     $pagePriorityDepthMultiplier = (double) tx_tqseo_tools::getRootSettingValue('sitemap_priorty_depth_multiplier', 0);
     $pagePriorityDepthModificator = (double) tx_tqseo_tools::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_tqseo_priority'])) {
             $pagePriority = $page['tx_tqseo_priority'] / 100;
         }
         $pagePriority = number_format($pagePriority, 2);
         if ($pagePriority > 1) {
             $pagePriority = '1.00';
         } elseif ($pagePriority <= 0) {
             $pagePriority = '0.00';
         }
         #####################################
         # Page informations
         #####################################
         // page Url
         $pageUrl = tx_tqseo_tools::fullUrl($sitemapPage['page_url']);
         // Page modification date
         $pageModifictionDate = date('c', $sitemapPage['tstamp']);
         // Page change frequency
         $pageChangeFrequency = NULL;
         if (!empty($page['tx_tqseo_change_frequency'])) {
             $pageChangeFrequency = (int) $page['tx_tqseo_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
     tx_tqseo_tools::callHook('sitemap-xml-page-output', $this, $ret);
     return $ret;
 }
Ejemplo n.º 3
0
 /**
  * Generate simulated title for one page
  *
  * @return	string
  */
 protected function _executeGenerateSimulatedUrl()
 {
     global $TYPO3_DB, $BE_USER, $TSFE, $TYPO3_CONF_VARS, $LANG;
     // Init
     $ret = '';
     $pid = (int) $this->_postVar['pid'];
     if (!empty($pid)) {
         $page = t3lib_BEfunc::getRecord('pages', $pid);
         if (!empty($page)) {
             if (t3lib_extMgm::isLoaded('realurl')) {
                 // Disable caching for url
                 $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT']['enableUrlDecodeCache'] = 0;
                 $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT']['enableUrlEncodeCache'] = 0;
                 $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT']['disablePathCache'] = 1;
             }
             // TODO: check if this is needed anymore with autoloading
             require_once PATH_t3lib . 'class.t3lib_page.php';
             require_once PATH_t3lib . 'class.t3lib_tstemplate.php';
             require_once PATH_t3lib . 'class.t3lib_tsparser_ext.php';
             $this->_initTsfe($page, null, $page, null);
             $ret = $TSFE->cObj->typolink_URL(array('parameter' => $page['uid']));
             if (!empty($ret)) {
                 $ret = tx_tqseo_tools::fullUrl($ret);
             }
         }
     }
     if (!empty($ret)) {
         $ret = array('url' => $ret);
     } else {
         $ret = array('error' => $LANG->getLL('error_url_generation_failed'));
     }
     return $ret;
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
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)
 {
     global $TSFE;
     if ($conf === null) {
         $conf = array();
     }
     $conf['parameter'] = $url;
     $ret = $TSFE->cObj->typoLink_URL($conf);
     // maybe baseUrlWrap is better? but breaks with realurl currently?
     $ret = tx_tqseo_tools::fullUrl($ret);
     return $ret;
 }