Пример #1
0
 /**
  * Build sitemap xml
  *
  * @return  string
  */
 public function main()
 {
     // INIT
     $this->tsSetup = $GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['sitemap.'];
     // check if sitemap is enabled in root
     if (!\Metaseo\Metaseo\Utility\GeneralUtility::getRootSettingValue('is_sitemap', TRUE)) {
         $this->showError('Sitemap is not available, please check your configuration [control-center]');
     }
     $ret = $this->_build();
     return $ret;
 }
Пример #2
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);
 }
 /**
  * Execute task
  */
 public function execute()
 {
     // Build sitemap
     $rootPageList = $this->_getRootPages();
     $this->_cleanupDirectory();
     $this->_initLanguages();
     foreach ($rootPageList as $uid => $page) {
         $this->_initRootPage($uid);
         if (\Metaseo\Metaseo\Utility\GeneralUtility::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;
 }
Пример #4
0
 /**
  * Add HTTP Headers
  */
 public function main()
 {
     // INIT
     $tsSetup = $GLOBALS['TSFE']->tmpl->setup;
     $headers = array();
     // dont send any headers if headers are already sent
     if (headers_sent()) {
         return;
     }
     if (!empty($GLOBALS['TSFE']->tmpl->loaded)) {
         // ##################################
         // Non-Cached page
         // ##################################
         if (!empty($tsSetup['plugin.']['metaseo.']['metaTags.'])) {
             $tsSetupSeo = $tsSetup['plugin.']['metaseo.']['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($GLOBALS['TSFE']->tmpl->hierarchyInfo);
                 $currentTemplatePid = $curentTemplate['pid'];
                 \Metaseo\Metaseo\Utility\CacheUtility::set($currentTemplatePid, 'http', 'p3p', $headers['P3P']);
             }
         }
     } else {
         // #####################################
         // Cached page
         // #####################################
         // build root pid list
         $rootPidList = array();
         foreach ($GLOBALS['TSFE']->rootLine as $pageRow) {
             $rootPidList[$pageRow['uid']] = $pageRow['uid'];
         }
         // fetch from cache
         $cacheList = \Metaseo\Metaseo\Utility\CacheUtility::getList('http', 'p3p');
         foreach ($rootPidList as $pageId) {
             if (!empty($cacheList[$pageId])) {
                 $headers['P3P'] = $cacheList[$pageId];
                 break;
             }
         }
     }
     // Call hook
     \Metaseo\Metaseo\Utility\GeneralUtility::callHook('httpheader-output', $this, $headers);
     // #####################################
     // Sender headers
     // #####################################
     if (!empty($headers['P3P'])) {
         header('P3P: ' . $headers['P3P']);
     }
 }
 /**
  * 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);
     }
 }
Пример #6
0
 /**
  * Hook: Link Parser
  *
  * @param   object          $pObj    Object
  * @return  boolean|null
  */
 public static function hook_linkParse(&$pObj)
 {
     // check if sitemap is enabled in root
     if (!\Metaseo\Metaseo\Utility\GeneralUtility::getRootSettingValue('is_sitemap', TRUE) || !\Metaseo\Metaseo\Utility\GeneralUtility::getRootSettingValue('is_sitemap_typolink_indexer', TRUE)) {
         return TRUE;
     }
     // check current page
     if (!self::_checkIfCurrentPageIsIndexable()) {
         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;
     }
     if (empty($linkUrl)) {
         // invalid url? should be never empty!
         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 = \Metaseo\Metaseo\Utility\GeneralUtility::getRootLine($uid);
     if (empty($rootline)) {
         return;
     }
     $page = reset($rootline);
     // #####################################
     // Build relative url
     // #####################################
     $linkParts = parse_url($linkUrl);
     // Remove left / (but only if not root page)
     if ($linkParts['path'] === '/') {
         // Link points to root page
         $pageUrl = '/';
     } else {
         // Link points to another page, strip left /
         $pageUrl = ltrim($linkParts['path'], '/');
     }
     // Add query
     if (!empty($linkParts['query'])) {
         $pageUrl .= '?' . $linkParts['query'];
     }
     // #####################################
     // Page settings
     // #####################################
     // Fetch page changeFrequency
     $pageChangeFrequency = 0;
     if (!empty($page['tx_metaseo_change_frequency'])) {
         $pageChangeFrequency = (int) $page['tx_metaseo_change_frequency'];
     } elseif (!empty($GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['sitemap.']['changeFrequency'])) {
         $pageChangeFrequency = (int) $GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['sitemap.']['changeFrequency'];
     }
     // Fetch sysLanguage
     $pageLanguage = 0;
     if (isset($addParameters['L'])) {
         $pageLanguage = (int) $addParameters['L'];
     } elseif (!empty($GLOBALS['TSFE']->tmpl->setup['config.']['sys_language_uid'])) {
         $pageLanguage = (int) $GLOBALS['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_depth' => count($rootline), 'page_change_frequency' => $pageChangeFrequency);
     // Call hook
     \Metaseo\Metaseo\Utility\GeneralUtility::callHook('sitemap-index-link', NULL, $pageData);
     if (!empty($pageData)) {
         \Metaseo\Metaseo\Utility\SitemapUtility::index($pageData, 'link');
     }
     return TRUE;
 }
Пример #7
0
 /**
  * Return page count
  *
  * @return integer
  */
 public function pageCount()
 {
     $pageLimit = \Metaseo\Metaseo\Utility\GeneralUtility::getRootSettingValue('sitemap_page_limit', NULL);
     if (empty($pageLimit)) {
         $pageLimit = 1000;
     }
     $pageItems = count($this->sitemapPages);
     $pageCount = ceil($pageItems / $pageLimit);
     return $pageCount;
 }
Пример #8
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;
 }
Пример #9
0
 /**
  * Process meta tags
  */
 protected function _processMetaTags(&$tags)
 {
     // Call hook
     \Metaseo\Metaseo\Utility\GeneralUtility::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]);
                 }
             }
         }
     }
 }
Пример #10
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;
 }
Пример #11
0
 /**
  * Add Page Footer
  *
  * @param    string $title    Default page title (rendered by TYPO3)
  * @return    string            Modified page title
  */
 public function main($title)
 {
     // INIT
     $ret = array();
     $tsSetup = $GLOBALS['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.']['metaseo.']['services.'])) {
         $tsServices = $tsSetup['plugin.']['metaseo.']['services.'];
     }
     // Call hook
     \Metaseo\Metaseo\Utility\GeneralUtility::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;
             $this->cObj->data['gaUseUniversalAnalytics'] = (int) (!empty($gaConf['universalAnalytics']));
             // Build code
             $ret['ga'] = $this->cObj->cObjGetSingle($gaConf['template'], $gaConf['template.']);
             if (!empty($gaConf['trackDownloads']) && !empty($gaConf['trackDownloadsScript'])) {
                 $jsFile = \TYPO3\CMS\Core\Utility\GeneralUtility::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
     \Metaseo\Metaseo\Utility\GeneralUtility::callHook('pagefooter-output', $this, $ret);
     return implode("\n", $ret);
 }
Пример #12
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;
 }
Пример #13
0
 /**
  * Clear outdated and invalid pages from sitemap table
  */
 public static function expire()
 {
     // #####################
     // Expired pages
     // #####################
     $expireDays = (int) \Metaseo\Metaseo\Utility\GeneralUtility::getExtConf('sitemap_pageSitemapExpireDays', 60);
     if (empty($expireDays)) {
         $expireDays = 60;
     }
     // No negative days allowed
     $expireDays = abs($expireDays);
     $tstamp = time() - $expireDays * 24 * 60 * 60;
     $query = 'DELETE FROM tx_metaseo_sitemap
                     WHERE tstamp <= ' . (int) $tstamp . '
                       AND is_blacklisted = 0';
     DatabaseUtility::exec($query);
     // #####################
     //  Deleted or
     // excluded pages
     // #####################
     $query = 'SELECT
                     ts.uid
                 FROM
                     tx_metaseo_sitemap ts
                     LEFT JOIN pages p
                         ON p.uid = ts.page_uid
                        AND p.deleted = 0
                        AND p.hidden = 0
                        AND p.tx_metaseo_is_exclude = 0
                 WHERE
                     p.uid IS NULL';
     $deletedSitemapPages = DatabaseUtility::getColWithIndex($query);
     // delete pages
     if (!empty($deletedSitemapPages)) {
         $query = 'DELETE FROM tx_metaseo_sitemap
                         WHERE uid IN (' . implode(',', $deletedSitemapPages) . ')
                           AND is_blacklisted = 0';
         DatabaseUtility::exec($query);
     }
 }
Пример #14
0
 /**
  * Add SEO-Page Title
  *
  * @param    string $title    Default page title (rendered by TYPO3)
  * @return    string            Modified page title
  */
 public function main($title)
 {
     // INIT
     $ret = $title;
     $rawTitel = !empty($GLOBALS['TSFE']->altPageTitle) ? $GLOBALS['TSFE']->altPageTitle : $GLOBALS['TSFE']->page['title'];
     $tsSetup = $GLOBALS['TSFE']->tmpl->setup;
     $tsSeoSetup = array();
     $rootLine = $GLOBALS['TSFE']->rootLine;
     $currentPid = $GLOBALS['TSFE']->id;
     $skipPrefixSuffix = FALSE;
     $applySitetitle = TRUE;
     $pageTitelPrefix = FALSE;
     $pageTitelSuffix = FALSE;
     $stdWrapList = array();
     $sitetitle = $tsSetup['sitetitle'];
     // get configuration
     if (!empty($tsSetup['plugin.']['metaseo.'])) {
         $tsSeoSetup = $tsSetup['plugin.']['metaseo.'];
     }
     // Use browsertitle if available
     if (!empty($GLOBALS['TSFE']->page['tx_metaseo_pagetitle_rel'])) {
         $rawTitel = $GLOBALS['TSFE']->page['tx_metaseo_pagetitle_rel'];
     }
     // Call hook
     \Metaseo\Metaseo\Utility\GeneralUtility::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($GLOBALS['TSFE']->page['tx_metaseo_pagetitle'])) {
         $ret = $GLOBALS['TSFE']->page['tx_metaseo_pagetitle'];
         // Add template prefix/suffix
         if (empty($tsSeoSetup['pageTitle.']['applySitetitleToPagetitle'])) {
             $applySitetitle = FALSE;
         }
         $skipPrefixSuffix = TRUE;
     }
     // #######################################################################
     // PAGE TITEL PREFIX/SUFFIX
     // #######################################################################
     if (!$skipPrefixSuffix) {
         foreach ($rootLine as $page) {
             switch ((int) $page['tx_metaseo_inheritance']) {
                 case 0:
                     // ###################################
                     // Normal
                     // ###################################
                     if (!empty($page['tx_metaseo_pagetitle_prefix'])) {
                         $pageTitelPrefix = $page['tx_metaseo_pagetitle_prefix'];
                     }
                     if (!empty($page['tx_metaseo_pagetitle_suffix'])) {
                         $pageTitelSuffix = $page['tx_metaseo_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_metaseo_pagetitle_prefix'])) {
                         $pageTitelPrefix = $page['tx_metaseo_pagetitle_prefix'];
                     }
                     if (!empty($page['tx_metaseo_pagetitle_suffix'])) {
                         $pageTitelSuffix = $page['tx_metaseo_pagetitle_suffix'];
                     }
                     break 2;
                     break;
             }
         }
         // #################
         // Process settings from access point
         // #################
         $connector = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Metaseo\\Metaseo\\Connector');
         $store = $connector->getStore('pagetitle');
         if (!empty($store)) {
             if (isset($store['pagetitle.title'])) {
                 $rawTitel = $store['pagetitle.title'];
             }
             if (isset($store['pagetitle.prefix'])) {
                 $pageTitelPrefix = $store['pagetitle.prefix'];
             }
             if (isset($store['pagetitle.suffix'])) {
                 $pageTitelSuffix = $store['pagetitle.suffix'];
             }
             if (isset($store['pagetitle.absolute'])) {
                 $ret = $store['pagetitle.absolute'];
                 $rawTitel = $store['pagetitle.absolute'];
                 $pageTitelPrefix = FALSE;
                 $pageTitelSuffix = FALSE;
                 if (empty($tsSeoSetup['pageTitle.']['applySitetitleToPagetitle'])) {
                     $applySitetitle = FALSE;
                 }
             }
             if (isset($store['pagetitle.sitetitle'])) {
                 $sitetitle = $store['pagetitle.sitetitle'];
             }
         }
         // 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;
         }
     }
     // #######################################################################
     // APPLY SITETITLE (from setup)
     // #######################################################################
     if ($applySitetitle) {
         $pageTitleGlue = ':';
         $glueSpacerBefore = '';
         $glueSpacerAfter = '';
         // 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
     \Metaseo\Metaseo\Utility\GeneralUtility::callHook('pagetitle-output', $this, $ret);
     return $ret;
 }