예제 #1
0
 /**
  * Hook: Link Parser
  *
  * @param	object	$pObj	Object
  */
 public static function hook_linkParse(&$pObj)
 {
     global $TSFE;
     // check if sitemap is enabled in root
     if (!tx_tqseo_tools::getRootSettingValue('is_sitemap', true) || !tx_tqseo_tools::getRootSettingValue('is_sitemap_typolink_indexer', true)) {
         return true;
     }
     // skip POST-calls and feuser login
     if ($_SERVER['REQUEST_METHOD'] !== 'GET' || !empty($TSFE->fe_user->user['uid'])) {
         return;
     }
     // Skip own sitemap tools
     if ($TSFE->type == 841131 || $TSFE->type == 841132) {
         return true;
     }
     // dont parse if page is not cacheable
     if (!$TSFE->isStaticCacheble()) {
         return;
     }
     // Check
     if (empty($pObj['finalTagParts']) || empty($pObj['conf']) || empty($pObj['finalTagParts']['url'])) {
         // no valid link
         return;
     }
     // Init link informations
     $linkConf = $pObj['conf'];
     $linkUrl = $pObj['finalTagParts']['url'];
     $linkUrl = self::_processLinkUrl($linkUrl);
     if (!is_numeric($linkConf['parameter'])) {
         // not valid internal link
         return;
     }
     #####################################
     # Init
     #####################################
     $uid = $linkConf['parameter'];
     $addParameters = array();
     if (!empty($linkConf['additionalParams'])) {
         parse_str($linkConf['additionalParams'], $addParameters);
     }
     #####################################
     # Check if link is cacheable
     #####################################
     $isValid = false;
     // check if conf is valid
     if (!empty($linkConf['useCacheHash'])) {
         $isValid = true;
     }
     // check for typical typo3 params
     $addParamsCache = $addParameters;
     unset($addParamsCache['L']);
     unset($addParamsCache['type']);
     if (empty($addParamsCache)) {
         $isValid = true;
     }
     if (!$isValid) {
         // page is not cacheable, skip it
         return;
     }
     #####################################
     # Rootline
     #####################################
     $rootline = tx_tqseo_tools::getRootLine($uid);
     if (empty($rootline)) {
         return;
     }
     $page = reset($rootline);
     #####################################
     # Build relative url
     #####################################
     $linkParts = parse_url($linkUrl);
     $pageUrl = ltrim($linkParts['path'], '/');
     if (!empty($linkParts['query'])) {
         $pageUrl .= '?' . $linkParts['query'];
     }
     #####################################
     # Page settings
     #####################################
     // Fetch page changeFrequency
     $pageChangeFrequency = 0;
     if (!empty($page['tx_tqseo_change_frequency'])) {
         $pageChangeFrequency = (int) $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'];
     }
     // Fetch sysLanguage
     $pageLanguage = 0;
     if (isset($addParameters['L'])) {
         $pageLanguage = (int) $addParameters['L'];
     } elseif (!empty($TSFE->tmpl->setup['config.']['sys_language_uid'])) {
         $pageLanguage = (int) $TSFE->tmpl->setup['config.']['sys_language_uid'];
     }
     #####################################
     # Indexing
     #####################################
     $tstamp = $_SERVER['REQUEST_TIME'];
     $pageData = array('tstamp' => $tstamp, 'crdate' => $tstamp, 'page_rootpid' => $rootline[0]['uid'], 'page_uid' => $linkConf['parameter'], 'page_language' => $pageLanguage, 'page_url' => $pageUrl, 'page_hash' => md5($pageUrl), 'page_depth' => count($rootline), 'page_change_frequency' => $pageChangeFrequency);
     // Call hook
     tx_tqseo_tools::callHook('sitemap-index-link', null, $pageData);
     if (!empty($pageData)) {
         tx_tqseo_sitemap::index($pageData, 'link');
     }
     return true;
 }