public function clearSeoSitemap()
 {
     global $TYPO3_DB;
     $ret = true;
     // Call hook
     tx_tqseo_tools::callHook('sitemap-clear', $this, $ret);
     $query = 'TRUNCATE tx_tqseo_sitemap';
     $TYPO3_DB->sql_query($query);
     return $ret;
 }
Beispiel #2
0
 /**
  * Output sitemap
  *
  * @return	string
  */
 public function main()
 {
     global $TSFE, $TYPO3_DB, $TYPO3_CONF_VARS;
     // INIT
     $this->tsSetup = $TSFE->tmpl->setup['plugin.']['tq_seo.']['sitemap.'];
     // check if sitemap is enabled in root
     if (!tx_tqseo_tools::getRootSettingValue('is_sitemap', true)) {
         $this->showError('Sitemap is not available, please check your configuration [control-center]');
     }
     $ret .= $this->_build();
     return $ret;
 }
Beispiel #3
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);
 }
Beispiel #4
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;
 }
Beispiel #5
0
 /**
  * Execute task
  */
 public function execute()
 {
     // Build sitemap
     $rootPageList = $this->_getRootPages();
     $this->_cleanupDirectory();
     $this->_initLanguages();
     foreach ($rootPageList as $uid => $page) {
         $this->_initRootPage($uid);
         if (tx_tqseo_tools::getRootSettingValue('is_sitemap_language_lock', false, $uid)) {
             foreach ($this->_languageIdList as $languageId) {
                 $this->_setRootPageLanguage($languageId);
                 $this->_buildSitemap($uid, $languageId);
             }
         } else {
             $this->_buildSitemap($uid, null);
         }
     }
     return true;
 }
Beispiel #6
0
    /**
     * Clear outdated and invalid pages from sitemap table
     */
    public static function expire()
    {
        global $TYPO3_DB, $TSFE, $TYPO3_CONF_VARS;
        #####################
        # Expired pages
        #####################
        $expireDays = (int) tx_tqseo_tools::getExtConf('sitemap_pageSitemapExpireDays', 60);
        $tstamp = time() - $expireDays * 24 * 60 * 60;
        $query = 'DELETE FROM tx_tqseo_sitemap WHERE tstamp <= ' . (int) $tstamp;
        $res = $TYPO3_DB->sql_query($query);
        #####################
        # Deleted or
        # excluded pages
        #####################
        $deletedSitemapPages = array();
        $query = 'SELECT
						ts.uid
					FROM
						tx_tqseo_sitemap ts
						LEFT JOIN pages p
							ON		p.uid = ts.page_uid
								AND	p.deleted = 0
								AND p.hidden = 0
					WHERE
						p.uid IS NULL';
        $res = $TYPO3_DB->sql_query($query);
        while ($row = $TYPO3_DB->sql_fetch_assoc($res)) {
            $deletedSitemapPages[$row['uid']] = $row['uid'];
        }
        // delete pages
        if (!empty($deletedSitemapPages)) {
            $query = 'DELETE FROM tx_tqseo_sitemap WHERE uid IN (' . implode(',', $deletedSitemapPages) . ')';
            $TYPO3_DB->sql_query($query);
        }
    }
Beispiel #7
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;
 }
Beispiel #8
0
 /**
  * Return page count
  *
  * @return	integer
  */
 public function pageCount()
 {
     $pageLimit = tx_tqseo_tools::getRootSettingValue('sitemap_page_limit', null);
     if (empty($pageLimit)) {
         $pageLimit = 1000;
     }
     $pageItems = count($this->sitemapPages);
     $pageCount = ceil($pageItems / $pageLimit);
     return $pageCount;
 }
Beispiel #9
0
 /**
  * Add SEO-Page Title
  *
  * @param	string	$title	Default page title (rendered by TYPO3)
  * @return	string			Modified page title
  */
 public function main($title)
 {
     global $TSFE;
     // INIT
     $ret = $title;
     $rawTitel = $TSFE->page['title'];
     $tsSetup = $TSFE->tmpl->setup;
     $tsSeoSetup = array();
     $rootLine = $TSFE->rootLine;
     $currentPid = $TSFE->id;
     $skipPrefixSuffix = false;
     $applySitetitle = false;
     $stdWrapList = array();
     // get configuration
     if (!empty($tsSetup['plugin.']['tq_seo.'])) {
         $tsSeoSetup = $tsSetup['plugin.']['tq_seo.'];
     }
     // Use browsertitle if available
     if (!empty($TSFE->page['tx_tqseo_pagetitle_rel'])) {
         $rawTitel = $TSFE->page['tx_tqseo_pagetitle_rel'];
     }
     // Call hook
     tx_tqseo_tools::callHook('pagetitle-setup', $this, $tsSeoSetup);
     // get stdwrap list
     if (!empty($tsSeoSetup['pageTitle.']['stdWrap.'])) {
         $stdWrapList = $tsSeoSetup['pageTitle.']['stdWrap.'];
     }
     // Apply stdWrap before
     if (!empty($stdWrapList['before.'])) {
         $rawTitel = $this->cObj->stdWrap($rawTitel, $stdWrapList['before.']);
     }
     #######################################################################
     # RAW PAGE TITEL
     #######################################################################
     if (!empty($TSFE->page['tx_tqseo_pagetitle'])) {
         $ret = $TSFE->page['tx_tqseo_pagetitle'];
         // Add template prefix/suffix
         if (!empty($tsSeoSetup['pageTitle.']['applySitetitleToPagetitle'])) {
             $applySitetitle = true;
         }
         $skipPrefixSuffix = true;
     }
     #######################################################################
     # PAGE TITEL PREFIX/SUFFIX
     #######################################################################
     if (!$skipPrefixSuffix) {
         $pageTitelPrefix = false;
         $pageTitelSuffix = false;
         foreach ($rootLine as $page) {
             switch ((int) $page['tx_tqseo_inheritance']) {
                 case 0:
                     ###################################
                     # Normal
                     ###################################
                     if (!empty($page['tx_tqseo_pagetitle_prefix'])) {
                         $pageTitelPrefix = $page['tx_tqseo_pagetitle_prefix'];
                     }
                     if (!empty($page['tx_tqseo_pagetitle_suffix'])) {
                         $pageTitelSuffix = $page['tx_tqseo_pagetitle_suffix'];
                     }
                     if ($pageTitelPrefix !== FALSE || $pageTitelSuffix !== FALSE) {
                         // pagetitle found - break foreach
                         break 2;
                     }
                     break;
                 case 1:
                     ###################################
                     # Skip
                     # (don't herit from this page)
                     ###################################
                     if ((int) $page['uid'] != $currentPid) {
                         continue 2;
                     }
                     if (!empty($page['tx_tqseo_pagetitle_prefix'])) {
                         $pageTitelPrefix = $page['tx_tqseo_pagetitle_prefix'];
                     }
                     if (!empty($page['tx_tqseo_pagetitle_suffix'])) {
                         $pageTitelSuffix = $page['tx_tqseo_pagetitle_suffix'];
                     }
                     break 2;
                     break;
             }
         }
         // Apply prefix and suffix
         if ($pageTitelPrefix !== FALSE || $pageTitelSuffix !== FALSE) {
             $ret = $rawTitel;
             if ($pageTitelPrefix !== FALSE) {
                 $ret = $pageTitelPrefix . ' ' . $ret;
             }
             if ($pageTitelSuffix !== FALSE) {
                 $ret .= ' ' . $pageTitelSuffix;
             }
             if (!empty($tsSeoSetup['pageTitle.']['applySitetitleToPrefixSuffix'])) {
                 $applySitetitle = true;
             }
         } else {
             $ret = $rawTitel;
             $applySitetitle = true;
         }
     }
     #######################################################################
     # APPLY SITETITLE (from setup)
     #######################################################################
     if ($applySitetitle) {
         $pageTitleGlue = ':';
         $glueSpacerBefore = '';
         $glueSpacerAfter = '';
         $sitetitle = $tsSetup['sitetitle'];
         // Overwrite sitetitle with the one from ts-setup (if available)
         if (!empty($tsSeoSetup['pageTitle.']['sitetitle'])) {
             $sitetitle = $tsSeoSetup['pageTitle.']['sitetitle'];
         }
         // Apply stdWrap after
         if (!empty($stdWrapList['sitetitle.'])) {
             $sitetitle = $this->cObj->stdWrap($sitetitle, $stdWrapList['sitetitle.']);
         }
         if (isset($tsSeoSetup['pageTitle.']['sitetitleGlue'])) {
             $pageTitleGlue = $tsSeoSetup['pageTitle.']['sitetitleGlue'];
         }
         if (!empty($tsSeoSetup['pageTitle.']['sitetitleGlueSpaceBefore'])) {
             $glueSpacerBefore = ' ';
         }
         if (!empty($tsSeoSetup['pageTitle.']['sitetitleGlueSpaceAfter'])) {
             $glueSpacerAfter = ' ';
         }
         $sitetitlePosition = 0;
         if (isset($tsSeoSetup['pageTitle.']['sitetitlePosition'])) {
             $sitetitlePosition = (int) $tsSeoSetup['pageTitle.']['sitetitlePosition'];
         } elseif (isset($tsSetup['config.']['pageTitleFirst'])) {
             $sitetitlePosition = (int) $tsSetup['config.']['pageTitleFirst'];
         }
         // add overall pagetitel from template/ts-setup
         if ($sitetitlePosition) {
             // suffix
             $ret .= $glueSpacerBefore . $pageTitleGlue . $glueSpacerAfter . $sitetitle;
         } else {
             // prefix (default)
             $ret = $sitetitle . $glueSpacerBefore . $pageTitleGlue . $glueSpacerAfter . $ret;
         }
     }
     // Apply stdWrap after
     if (!empty($stdWrapList['after.'])) {
         $ret = $this->cObj->stdWrap($ret, $stdWrapList['after.']);
     }
     // Call hook
     tx_tqseo_tools::callHook('pagetitle-output', $this, $ret);
     return $ret;
 }
Beispiel #10
0
 /**
  * Add Page Footer
  *
  * @param	string	$title	Default page title (rendered by TYPO3)
  * @return	string			Modified page title
  */
 public function main($title)
 {
     global $TSFE;
     // INIT
     $ret = array();
     $tsSetup = $TSFE->tmpl->setup;
     $tsServices = array();
     $beLoggedIn = isset($GLOBALS['BE_USER']->user['username']);
     $disabledHeaderCode = false;
     if (!empty($tsSetup['config.']['disableAllHeaderCode'])) {
         $disabledHeaderCode = true;
     }
     if (!empty($tsSetup['plugin.']['tq_seo.']['services.'])) {
         $tsServices = $tsSetup['plugin.']['tq_seo.']['services.'];
     }
     // Call hook
     tx_tqseo_tools::callHook('pagefooter-setup', $this, $tsServices);
     #########################################
     # GOOGLE ANALYTICS
     #########################################
     if (!empty($tsServices['googleAnalytics'])) {
         $gaConf = $tsServices['googleAnalytics.'];
         $gaEnabled = true;
         if ($disabledHeaderCode && empty($gaConf['enableIfHeaderIsDisabled'])) {
             $gaEnabled = false;
         }
         if ($gaEnabled && !(empty($gaConf['showIfBeLogin']) && $beLoggedIn)) {
             $tmp = '';
             $customCode = '';
             if (!empty($gaConf['customizationCode'])) {
                 $customCode .= "\n" . $this->cObj->cObjGetSingle($gaConf['customizationCode'], $gaConf['customizationCode.']);
             }
             $this->cObj->data['gaCode'] = $tsServices['googleAnalytics'];
             $this->cObj->data['gaIsAnonymize'] = (int) (!empty($gaConf['anonymizeIp']));
             $this->cObj->data['gaDomainName'] = $gaConf['domainName'];
             $this->cObj->data['gaCustomizationCode'] = $customCode;
             // Build code
             $ret['ga'] = $this->cObj->cObjGetSingle($gaConf['template'], $gaConf['template.']);
             if (!empty($gaConf['trackDownloads']) && !empty($gaConf['trackDownloadsScript'])) {
                 $jsFile = t3lib_div::getFileAbsFileName($gaConf['trackDownloadsScript']);
                 $jsfile = preg_replace('/^' . preg_quote(PATH_site, '/') . '/i', '', $jsFile);
                 $ret['ga.trackdownload'] = '<script type="text/javascript" src="' . htmlspecialchars($jsfile) . '"></script>';
             }
         } elseif ($gaEnabled && $beLoggedIn) {
             // Backend login detected, disable cache because this page is viewed by BE-users
             $ret['ga.disabled'] = '<!-- Google Analytics disabled - Backend-Login detected -->';
         }
     }
     #########################################
     # PIWIK
     #########################################
     if (!empty($tsServices['piwik.']) && !empty($tsServices['piwik.']['url']) && !empty($tsServices['piwik.']['id'])) {
         $piwikConf = $tsServices['piwik.'];
         $piwikEnabled = true;
         if ($disabledHeaderCode && empty($piwikConf['enableIfHeaderIsDisabled'])) {
             $piwikEnabled = false;
         }
         if ($piwikEnabled && !(empty($piwikConf['showIfBeLogin']) && $beLoggedIn)) {
             $tmp = '';
             $customCode = '';
             if (!empty($piwikConf['customizationCode'])) {
                 $customCode .= "\n" . $this->cObj->cObjGetSingle($piwikConf['customizationCode'], $piwikConf['customizationCode.']);
             }
             // remove last slash
             $piwikConf['url'] = rtrim($piwikConf['url'], '/');
             $this->cObj->data['piwikUrl'] = $piwikConf['url'];
             $this->cObj->data['piwikId'] = $piwikConf['id'];
             $this->cObj->data['piwikDomainName'] = $piwikConf['domainName'];
             $this->cObj->data['piwikCookieDomainName'] = $piwikConf['cookieDomainName'];
             $this->cObj->data['piwikDoNotTrack'] = $piwikConf['doNotTrack'];
             $this->cObj->data['piwikCustomizationCode'] = $customCode;
             // Build code
             $ret['piwik'] = $this->cObj->cObjGetSingle($piwikConf['template'], $piwikConf['template.']);
         } elseif ($piwikEnabled && $beLoggedIn) {
             // Backend login detected, disable cache because this page is viewed by BE-users
             $ret['piwik.disabled'] = '<!-- Piwik disabled - Backend-Login detected -->';
         }
     }
     // Call hook
     tx_tqseo_tools::callHook('pagefooter-output', $this, $ret);
     return implode("\n", $ret);
 }
Beispiel #11
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;
    }
Beispiel #12
0
 /**
  * Get sys page object
  *
  * @return	t3lib_pageSelect
  */
 protected static function _getSysPageObj()
 {
     if (self::$sysPageObj === null) {
         self::$sysPageObj = t3lib_div::makeInstance('t3lib_pageSelect');
     }
     return self::$sysPageObj;
 }
Beispiel #13
0
 /**
  * Add HTTP Headers
  */
 public function main()
 {
     global $TSFE;
     // INIT
     $ret = array();
     $tsSetup = $TSFE->tmpl->setup;
     $cObj = $TSFE->cObj;
     $pageMeta = array();
     $tsfePage = $TSFE->page;
     $headers = array();
     // dont send any headers if headers are already sent
     if (headers_sent()) {
         return;
     }
     if (!empty($TSFE->tmpl->loaded)) {
         #####################################
         # Non-Cached page
         #####################################
         if (!empty($tsSetup['plugin.']['tq_seo.']['metaTags.'])) {
             $tsSetupSeo = $tsSetup['plugin.']['tq_seo.']['metaTags.'];
             #####################################
             # W3C P3P Tags
             #####################################
             $p3pCP = null;
             $p3pPolicyUrl = null;
             if (!empty($tsSetupSeo['p3pCP'])) {
                 $p3pCP = $tsSetupSeo['p3pCP'];
             }
             if (!empty($tsSetupSeo['p3pPolicyUrl'])) {
                 $p3pPolicyUrl = $tsSetupSeo['p3pPolicyUrl'];
             }
             if (!empty($p3pCP) || !empty($p3pPolicyUrl)) {
                 $p3pHeaders = array();
                 if (!empty($p3pCP)) {
                     $p3pHeader[] = 'CP="' . $p3pCP . '"';
                 }
                 if (!empty($p3pPolicyUrl)) {
                     $p3pHeader[] = 'policyref="' . $p3pPolicyUrl . '"';
                 }
                 $headers['P3P'] = implode(' ', $p3pHeader);
                 // cache informations
                 $curentTemplate = end($TSFE->tmpl->hierarchyInfo);
                 $currentTemplatePid = $curentTemplate['pid'];
                 tx_tqseo_cache::set($currentTemplatePid, 'http', 'p3p', $headers['P3P']);
             }
         }
     } else {
         #####################################
         # Cached page
         #####################################
         // build root pid list
         $rootPidList = array();
         foreach ($TSFE->rootLine as $pageRow) {
             $rootPidList[$pageRow['uid']] = $pageRow['uid'];
         }
         // fetch from cache
         $cacheList = tx_tqseo_cache::getList('http', 'p3p');
         foreach ($rootPidList as $pageId) {
             if (!empty($cacheList[$pageId])) {
                 $headers['P3P'] = $cacheList[$pageId];
                 break;
             }
         }
     }
     // Call hook
     tx_tqseo_tools::callHook('httpheader-output', $this, $headers);
     #####################################
     # Sender headers
     #####################################
     if (!empty($headers['P3P'])) {
         header('P3P: ' . $headers['P3P']);
     }
 }
 /**
  * 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;
 }
Beispiel #15
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;
 }
Beispiel #16
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;
 }
Beispiel #17
0
 /**
  * Process meta tags
  */
 protected function _processMetaTags(&$tags)
 {
     // Call hook
     tx_tqseo_tools::callHook('metatag-output', $this, $tags);
     // Add marker
     $markerList = array('%YEAR%' => date('Y'));
     $keyList = array('meta.title', 'meta.description', 'meta.description.dc', 'meta.keywords', 'meta.keywords.dc', 'meta.copyright', 'meta.copyright.dc', 'meta.publisher.dc');
     foreach ($keyList as $key) {
         if (!empty($tags[$key])) {
             foreach ($markerList as $marker => $value) {
                 if (strpos($tags[$key], $marker)) {
                     $tags[$key] = str_replace($marker, $value, $tags[$key]);
                 }
             }
         }
     }
 }