Initial commit
This commit is contained in:
59
typo3conf/ext/metaseo/Classes/Page/Part/AbstractPart.php
Normal file
59
typo3conf/ext/metaseo/Classes/Page/Part/AbstractPart.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2015 Markus Blaschke <typo3@markus-blaschke.de> (metaseo)
|
||||
* (c) 2013 Markus Blaschke (TEQneers GmbH & Co. KG) <blaschke@teqneers.de> (tq_seo)
|
||||
* All rights reserved
|
||||
*
|
||||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||||
* free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
*/
|
||||
|
||||
namespace Metaseo\Metaseo\Page\Part;
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* Abstract part
|
||||
*/
|
||||
abstract class AbstractPart
|
||||
{
|
||||
// ########################################################################
|
||||
// Attributes
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* @var \TYPO3\CMS\Extbase\Object\ObjectManager
|
||||
* @inject
|
||||
*/
|
||||
protected $objectManager;
|
||||
|
||||
|
||||
// ########################################################################
|
||||
// Methods
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Init object manager
|
||||
$this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
|
||||
}
|
||||
}
|
||||
235
typo3conf/ext/metaseo/Classes/Page/Part/FooterPart.php
Normal file
235
typo3conf/ext/metaseo/Classes/Page/Part/FooterPart.php
Normal file
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2015 Markus Blaschke <typo3@markus-blaschke.de> (metaseo)
|
||||
* (c) 2013 Markus Blaschke (TEQneers GmbH & Co. KG) <blaschke@teqneers.de> (tq_seo)
|
||||
* All rights reserved
|
||||
*
|
||||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||||
* free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
*/
|
||||
|
||||
namespace Metaseo\Metaseo\Page\Part;
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility as Typo3GeneralUtility;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* Page Footer
|
||||
*/
|
||||
class FooterPart extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Content object renderer
|
||||
*
|
||||
* @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
|
||||
*/
|
||||
public $cObj;
|
||||
|
||||
/**
|
||||
* 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::callHookAndSignal(__CLASS__, 'pageFooterSetup', $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)) {
|
||||
// Build Google Analytics service
|
||||
$ret['ga'] = $this->buildGoogleAnalyticsCode($tsServices, $gaConf);
|
||||
|
||||
if (!empty($gaConf['trackDownloads']) && !empty($gaConf['trackDownloadsScript'])) {
|
||||
$ret['ga.trackdownload'] = $this->serviceGoogleAnalyticsTrackDownloads($tsServices, $gaConf);
|
||||
}
|
||||
} elseif ($gaEnabled && $beLoggedIn) {
|
||||
// Disable caching
|
||||
$GLOBALS['TSFE']->set_no_cache('MetaSEO: Google Analytics code disabled, backend login detected');
|
||||
|
||||
// Backend login detected, disable cache because this page is viewed by BE-users
|
||||
$ret['ga.disabled'] = '<!-- Google Analytics disabled, '
|
||||
. 'Page cache 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)) {
|
||||
// Build Piwik service
|
||||
$ret['piwik'] = $this->buildPiwikCode($tsServices, $piwikConf);
|
||||
} elseif ($piwikEnabled && $beLoggedIn) {
|
||||
// Disable caching
|
||||
$GLOBALS['TSFE']->set_no_cache('MetaSEO: Piwik code disabled, backend login detected');
|
||||
|
||||
// Backend login detected, disable cache because this page is viewed by BE-users
|
||||
$ret['piwik.disabled'] = '<!-- Piwik disabled, Page cache disabled - Backend-Login detected -->';
|
||||
}
|
||||
}
|
||||
|
||||
// Call hook
|
||||
\Metaseo\Metaseo\Utility\GeneralUtility::callHookAndSignal(__CLASS__, 'pageFooterOutput', $this, $ret);
|
||||
|
||||
return implode("\n", $ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Google analytics
|
||||
*
|
||||
* @param array $tsServices SetupTS of services
|
||||
* @param array $gaConf Google Analytics configuration
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function buildGoogleAnalyticsCode(array $tsServices, array $gaConf)
|
||||
{
|
||||
$ret = array();
|
||||
$gaCodeList = GeneralUtility::trimExplode(',', $tsServices['googleAnalytics']);
|
||||
|
||||
foreach ($gaCodeList as $gaCode) {
|
||||
$customCode = '';
|
||||
if (!empty($gaConf['customizationCode'])) {
|
||||
$customCode .= "\n" . $this->cObj->cObjGetSingle(
|
||||
$gaConf['customizationCode'],
|
||||
$gaConf['customizationCode.']
|
||||
);
|
||||
}
|
||||
|
||||
$this->cObj->data['gaCode'] = $gaCode;
|
||||
$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[] = $this->cObj->cObjGetSingle($gaConf['template'], $gaConf['template.']);
|
||||
}
|
||||
|
||||
// Build all GA codes
|
||||
$ret = implode("\n", $ret);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Google analytics
|
||||
*
|
||||
* @param array $tsServices SetupTS of services
|
||||
* @param array $gaConf Google Analytics configuration
|
||||
*
|
||||
* @return string
|
||||
* @todo $tsServices is never used
|
||||
*/
|
||||
public function serviceGoogleAnalyticsTrackDownloads(array $tsServices, array $gaConf)
|
||||
{
|
||||
$jsFile = Typo3GeneralUtility::getFileAbsFileName($gaConf['trackDownloadsScript']);
|
||||
$jsfile = preg_replace('/^' . preg_quote(PATH_site, '/') . '/i', '', $jsFile);
|
||||
|
||||
$ret = '<script type="text/javascript" src="' . htmlspecialchars($jsfile) . '"></script>';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Piwik
|
||||
*
|
||||
* @param array $tsServices SetupTS of services
|
||||
* @param array $piwikConf Piwik configuration
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function buildPiwikCode(array $tsServices, array $piwikConf)
|
||||
{
|
||||
$ret = array();
|
||||
$piwikCodeList = GeneralUtility::trimExplode(',', $piwikConf['id']);
|
||||
|
||||
foreach ($piwikCodeList as $piwikCode) {
|
||||
$customCode = '';
|
||||
if (!empty($piwikConf['customizationCode'])) {
|
||||
$customCode .= "\n";
|
||||
$customCode .= $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'] = $piwikCode;
|
||||
$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[] = $this->cObj->cObjGetSingle($piwikConf['template'], $piwikConf['template.']);
|
||||
}
|
||||
|
||||
// Build all piwik codes
|
||||
$ret = implode("\n", $ret);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
1353
typo3conf/ext/metaseo/Classes/Page/Part/MetatagPart.php
Normal file
1353
typo3conf/ext/metaseo/Classes/Page/Part/MetatagPart.php
Normal file
File diff suppressed because it is too large
Load Diff
417
typo3conf/ext/metaseo/Classes/Page/Part/PagetitlePart.php
Normal file
417
typo3conf/ext/metaseo/Classes/Page/Part/PagetitlePart.php
Normal file
@@ -0,0 +1,417 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2015 Markus Blaschke <typo3@markus-blaschke.de> (metaseo)
|
||||
* (c) 2013 Markus Blaschke (TEQneers GmbH & Co. KG) <blaschke@teqneers.de> (tq_seo)
|
||||
* All rights reserved
|
||||
*
|
||||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||||
* free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
*/
|
||||
|
||||
namespace Metaseo\Metaseo\Page\Part;
|
||||
|
||||
use Metaseo\Metaseo\Utility\FrontendUtility;
|
||||
use Metaseo\Metaseo\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility as Typo3GeneralUtility;
|
||||
|
||||
/**
|
||||
* Page Title Changer
|
||||
*/
|
||||
class PagetitlePart extends AbstractPart
|
||||
{
|
||||
|
||||
/**
|
||||
* List of stdWrap manipulations
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $stdWrapList = array();
|
||||
|
||||
/**
|
||||
* Content object renderer
|
||||
*
|
||||
* @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
|
||||
*/
|
||||
public $cObj;
|
||||
|
||||
/**
|
||||
* TypoScript Setup
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $tsSetup = array();
|
||||
|
||||
/**
|
||||
* TypoScript Setup (subtree of plugin.metaseo)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $tsSetupSeo = array();
|
||||
|
||||
/**
|
||||
* Page rootline
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rootLine = array();
|
||||
|
||||
/**
|
||||
* Add SEO-Page Title
|
||||
*
|
||||
* @param string $title Default page title (rendered by TYPO3)
|
||||
*
|
||||
* @return string Modified page title
|
||||
*/
|
||||
public function main($title)
|
||||
{
|
||||
$ret = null;
|
||||
|
||||
// ############################
|
||||
// Fetch from cache
|
||||
// ############################
|
||||
|
||||
$pageTitleCachingEnabled = $this->checkIfPageTitleCachingEnabled();
|
||||
if ($pageTitleCachingEnabled === true) {
|
||||
$cacheIdentification = sprintf(
|
||||
'%s_%s_title',
|
||||
$GLOBALS['TSFE']->id,
|
||||
substr(sha1(FrontendUtility::getCurrentUrl()), 10, 30)
|
||||
);
|
||||
|
||||
/** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */
|
||||
$objectManager = Typo3GeneralUtility::makeInstance(
|
||||
'TYPO3\\CMS\\Extbase\\Object\\ObjectManager'
|
||||
);
|
||||
$cacheManager = $objectManager->get('TYPO3\\CMS\\Core\\Cache\\CacheManager');
|
||||
$cache = $cacheManager->getCache('cache_pagesection');
|
||||
|
||||
$cacheTitle = $cache->get($cacheIdentification);
|
||||
if (!empty($cacheTitle)) {
|
||||
$ret = $cacheTitle;
|
||||
}
|
||||
}
|
||||
|
||||
// ############################
|
||||
// Generate page title
|
||||
// ############################
|
||||
|
||||
// Generate page title if not set
|
||||
// also fallback
|
||||
if (empty($ret)) {
|
||||
$this->initialize();
|
||||
$ret = $this->generatePageTitle($title);
|
||||
|
||||
// Cache page title (if page is not cacheable)
|
||||
if ($pageTitleCachingEnabled === true && isset($cache) && isset($cacheIdentification)) {
|
||||
$cache->set($cacheIdentification, $ret, array('pageId_' . $GLOBALS['TSFE']->id));
|
||||
}
|
||||
}
|
||||
|
||||
// ############################
|
||||
// Output
|
||||
// ############################
|
||||
|
||||
// Call hook
|
||||
GeneralUtility::callHookAndSignal(__CLASS__, 'pageTitleOutput', $this, $ret);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
$this->cObj = $GLOBALS['TSFE']->cObj;
|
||||
$this->tsSetup = $GLOBALS['TSFE']->tmpl->setup;
|
||||
$this->rootLine = GeneralUtility::getRootLine();
|
||||
|
||||
if (!empty($this->tsSetup['plugin.']['metaseo.'])) {
|
||||
$this->tsSetupSeo = $this->tsSetup['plugin.']['metaseo.'];
|
||||
|
||||
// get stdwrap list
|
||||
if (!empty($this->tsSetupSeo['stdWrap.'])) {
|
||||
$this->stdWrapList = $this->tsSetupSeo['pageTitle.']['stdWrap.'];
|
||||
}
|
||||
} else {
|
||||
$this->tsSetupSeo = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if page title caching is enabled
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkIfPageTitleCachingEnabled()
|
||||
{
|
||||
$cachingEnabled = !empty($GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['pageTitle.']['caching']);
|
||||
|
||||
// Enable caching only if caching is enabled in SetupTS
|
||||
// And if there is any USER_INT on the current page
|
||||
//
|
||||
// -> USER_INT will break Connector pagetitle setting
|
||||
// because the plugin output is cached but not the whole
|
||||
// page. so the Connector will not be called again
|
||||
// and the default page title will be shown
|
||||
// which is wrong
|
||||
// -> if the page is fully cacheable we don't have anything
|
||||
// to do
|
||||
return $cachingEnabled && !FrontendUtility::isCacheable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add SEO-Page Title
|
||||
*
|
||||
* @param string $title Default page title (rendered by TYPO3)
|
||||
*
|
||||
* @return string Modified page title
|
||||
* @todo: split up function (too long)
|
||||
*/
|
||||
public function generatePageTitle($title)
|
||||
{
|
||||
// INIT
|
||||
$ret = $title;
|
||||
$rawTitle = !empty($GLOBALS['TSFE']->altPageTitle) ?
|
||||
$GLOBALS['TSFE']->altPageTitle : $GLOBALS['TSFE']->page['title'];
|
||||
$currentPid = $GLOBALS['TSFE']->id;
|
||||
$skipPrefixSuffix = false;
|
||||
$applySitetitle = true;
|
||||
|
||||
$pageTitlePrefix = false;
|
||||
$pageTitleSuffix = false;
|
||||
|
||||
$this->stdWrapList = array();
|
||||
|
||||
$sitetitle = $this->tsSetup['sitetitle'];
|
||||
|
||||
// Use browsertitle if available
|
||||
if (!empty($GLOBALS['TSFE']->page['tx_metaseo_pagetitle_rel'])) {
|
||||
$rawTitle = $GLOBALS['TSFE']->page['tx_metaseo_pagetitle_rel'];
|
||||
}
|
||||
|
||||
// Call hook
|
||||
GeneralUtility::callHookAndSignal(
|
||||
__CLASS__,
|
||||
'pageTitleSetup',
|
||||
$this,
|
||||
$this->tsSetupSeo
|
||||
);
|
||||
|
||||
// get stdwrap list
|
||||
if (!empty($this->tsSetupSeo['pageTitle.']['stdWrap.'])) {
|
||||
$this->stdWrapList = $this->tsSetupSeo['pageTitle.']['stdWrap.'];
|
||||
}
|
||||
|
||||
// Apply stdWrap before
|
||||
if (!empty($this->stdWrapList['before.'])) {
|
||||
$rawTitle = $this->cObj->stdWrap($rawTitle, $this->stdWrapList['before.']);
|
||||
}
|
||||
|
||||
// #######################################################################
|
||||
// RAW PAGE TITLE
|
||||
// #######################################################################
|
||||
if (!empty($GLOBALS['TSFE']->page['tx_metaseo_pagetitle'])) {
|
||||
$ret = $GLOBALS['TSFE']->page['tx_metaseo_pagetitle'];
|
||||
|
||||
// Add template prefix/suffix
|
||||
if (empty($this->tsSetupSeo['pageTitle.']['applySitetitleToPagetitle'])) {
|
||||
$applySitetitle = false;
|
||||
}
|
||||
|
||||
$skipPrefixSuffix = true;
|
||||
}
|
||||
|
||||
|
||||
// #######################################################################
|
||||
// PAGE TITLE PREFIX/SUFFIX
|
||||
// #######################################################################
|
||||
if (!$skipPrefixSuffix) {
|
||||
foreach ($this->rootLine as $page) {
|
||||
switch ((int)$page['tx_metaseo_inheritance']) {
|
||||
case 0:
|
||||
// ###################################
|
||||
// Normal
|
||||
// ###################################
|
||||
if (!empty($page['tx_metaseo_pagetitle_prefix'])) {
|
||||
$pageTitlePrefix = $page['tx_metaseo_pagetitle_prefix'];
|
||||
}
|
||||
|
||||
if (!empty($page['tx_metaseo_pagetitle_suffix'])) {
|
||||
$pageTitleSuffix = $page['tx_metaseo_pagetitle_suffix'];
|
||||
}
|
||||
|
||||
if ($pageTitlePrefix !== false || $pageTitleSuffix !== false) {
|
||||
// pagetitle found - break foreach
|
||||
break 2;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// ###################################
|
||||
// Skip
|
||||
// (don't inherit from this page)
|
||||
// ###################################
|
||||
if ((int)$page['uid'] != $currentPid) {
|
||||
continue 2;
|
||||
}
|
||||
|
||||
if (!empty($page['tx_metaseo_pagetitle_prefix'])) {
|
||||
$pageTitlePrefix = $page['tx_metaseo_pagetitle_prefix'];
|
||||
}
|
||||
|
||||
if (!empty($page['tx_metaseo_pagetitle_suffix'])) {
|
||||
$pageTitleSuffix = $page['tx_metaseo_pagetitle_suffix'];
|
||||
}
|
||||
|
||||
break 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// #################
|
||||
// Process settings from access point
|
||||
// #################
|
||||
$connector = $this->objectManager->get('Metaseo\\Metaseo\\Connector');
|
||||
$store = $connector->getStore('pagetitle');
|
||||
|
||||
if (!empty($store)) {
|
||||
if (isset($store['pagetitle.title'])) {
|
||||
$rawTitle = $store['pagetitle.title'];
|
||||
}
|
||||
|
||||
if (isset($store['pagetitle.prefix'])) {
|
||||
$pageTitlePrefix = $store['pagetitle.prefix'];
|
||||
}
|
||||
|
||||
if (isset($store['pagetitle.suffix'])) {
|
||||
$pageTitleSuffix = $store['pagetitle.suffix'];
|
||||
}
|
||||
|
||||
if (isset($store['pagetitle.absolute'])) {
|
||||
$ret = $store['pagetitle.absolute'];
|
||||
$rawTitle = $store['pagetitle.absolute'];
|
||||
|
||||
$pageTitlePrefix = false;
|
||||
$pageTitleSuffix = false;
|
||||
|
||||
if (empty($this->tsSetupSeo['pageTitle.']['applySitetitleToPagetitle'])) {
|
||||
$applySitetitle = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($store['pagetitle.sitetitle'])) {
|
||||
$sitetitle = $store['pagetitle.sitetitle'];
|
||||
}
|
||||
}
|
||||
|
||||
// Apply prefix and suffix
|
||||
if ($pageTitlePrefix !== false || $pageTitleSuffix !== false) {
|
||||
$ret = $rawTitle;
|
||||
|
||||
if ($pageTitlePrefix !== false) {
|
||||
$ret = $pageTitlePrefix . ' ' . $ret;
|
||||
}
|
||||
|
||||
if ($pageTitleSuffix !== false) {
|
||||
$ret .= ' ' . $pageTitleSuffix;
|
||||
}
|
||||
|
||||
if (!empty($this->tsSetupSeo['pageTitle.']['applySitetitleToPrefixSuffix'])) {
|
||||
$applySitetitle = true;
|
||||
}
|
||||
} else {
|
||||
$ret = $rawTitle;
|
||||
}
|
||||
}
|
||||
|
||||
// #######################################################################
|
||||
// APPLY SITETITLE (from setup)
|
||||
// #######################################################################
|
||||
if ($applySitetitle) {
|
||||
$ret = $this->applySitetitleToPagetitle($sitetitle, $ret);
|
||||
}
|
||||
|
||||
// Apply stdWrap after
|
||||
if (!empty($this->stdWrapList['after.'])) {
|
||||
$ret = $this->cObj->stdWrap($ret, $this->stdWrapList['after.']);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply sitetitle (from sys_template) to pagetitle
|
||||
*
|
||||
* @param string $sitetitle Sitetitle
|
||||
* @param string $title Page title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function applySitetitleToPagetitle($sitetitle, $title)
|
||||
{
|
||||
$pageTitleGlue = ':';
|
||||
$glueSpacerBefore = '';
|
||||
$glueSpacerAfter = '';
|
||||
|
||||
$ret = $title;
|
||||
|
||||
// Overwrite sitetitle with the one from ts-setup (if available)
|
||||
if (!empty($this->tsSetupSeo['pageTitle.']['sitetitle'])) {
|
||||
$sitetitle = $this->tsSetupSeo['pageTitle.']['sitetitle'];
|
||||
}
|
||||
|
||||
// Apply stdWrap after
|
||||
if (!empty($this->stdWrapList['sitetitle.'])) {
|
||||
$sitetitle = $this->cObj->stdWrap($sitetitle, $this->stdWrapList['sitetitle.']);
|
||||
}
|
||||
|
||||
|
||||
if (isset($this->tsSetupSeo['pageTitle.']['sitetitleGlue'])) {
|
||||
$pageTitleGlue = $this->tsSetupSeo['pageTitle.']['sitetitleGlue'];
|
||||
}
|
||||
|
||||
if (!empty($this->tsSetupSeo['pageTitle.']['sitetitleGlueSpaceBefore'])) {
|
||||
$glueSpacerBefore = ' ';
|
||||
}
|
||||
|
||||
if (!empty($this->tsSetupSeo['pageTitle.']['sitetitleGlueSpaceAfter'])) {
|
||||
$glueSpacerAfter = ' ';
|
||||
}
|
||||
|
||||
$sitetitlePosition = 0;
|
||||
if (isset($this->tsSetupSeo['pageTitle.']['sitetitlePosition'])) {
|
||||
$sitetitlePosition = (int)$this->tsSetupSeo['pageTitle.']['sitetitlePosition'];
|
||||
} elseif (isset($this->tsSetup['config.']['pageTitleFirst'])) {
|
||||
$sitetitlePosition = (int)$this->tsSetup['config.']['pageTitleFirst'];
|
||||
}
|
||||
|
||||
// add overall pagetitle from template/ts-setup
|
||||
if ($sitetitlePosition) {
|
||||
// suffix
|
||||
$ret .= $glueSpacerBefore . $pageTitleGlue . $glueSpacerAfter . $sitetitle;
|
||||
|
||||
return $ret;
|
||||
} else {
|
||||
// prefix (default)
|
||||
$ret = $sitetitle . $glueSpacerBefore . $pageTitleGlue . $glueSpacerAfter . $ret;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user