Skip to content
This repository has been archived by the owner on Aug 8, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/2.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mblaschke committed Oct 9, 2016
2 parents be0ac59 + 3c2ac00 commit e5a16c1
Show file tree
Hide file tree
Showing 19 changed files with 193 additions and 82 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# MetaSEO - Changelog

## MetaSEO 2.0.1

- Bugfixes

## MetaSEO 2.0

- Added TYPO3 7.x support
Expand Down
3 changes: 2 additions & 1 deletion Classes/Backend/Module/AbstractModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

namespace Metaseo\Metaseo\Backend\Module;

use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;

Expand Down Expand Up @@ -60,7 +61,7 @@ abstract class AbstractModule extends ActionController
*/
protected function initializeAction()
{
$this->formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
$this->formProtection = FormProtectionFactory::get();
}

/**
Expand Down
16 changes: 16 additions & 0 deletions Classes/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Connector implements SingletonInterface
'meta' => array(),
'meta:og' => array(),
'custom' => array(),
'custom:og' => array(),
'pagetitle' => array(),
'sitemap' => array(),
);
Expand Down Expand Up @@ -171,6 +172,21 @@ public static function setCustomMetaTag($key, $value)
self::$store['custom'][$key] = $value;
}

/**
* Set custom opengraph tag
*
* @param string $key Metatag name
* @param string $value Metatag value
*/
public static function setCustomOpenGraphTag($key, $value)
{
$key = (string)$key;
$value = (string)$value;

self::$store['flag']['custom:og:external'] = true;
self::$store['custom:og'][$key] = $value;
}

/**
* Disable meta tag
*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Controller/AbstractAjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*/
abstract class AbstractAjaxController
{
const CONTENT_FORMAT_JSON = 'json';
const CONTENT_FORMAT_JSON = 'jsonbody';

/**
* Json status indicators
Expand Down
3 changes: 2 additions & 1 deletion Classes/Hook/HttpHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

use Metaseo\Metaseo\Utility\FrontendUtility;
use Metaseo\Metaseo\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility as Typo3GeneralUtility;

/**
* Http Header generator
Expand Down Expand Up @@ -57,7 +58,7 @@ public function main()
);

/** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
$objectManager = Typo3GeneralUtility::makeInstance(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManager'
);
$cacheManager = $objectManager->get('TYPO3\\CMS\\Core\\Cache\\CacheManager');
Expand Down
5 changes: 3 additions & 2 deletions Classes/Hook/SitemapIndexHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Metaseo\Metaseo\Utility\GeneralUtility;
use Metaseo\Metaseo\Utility\SitemapUtility;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility as Typo3GeneralUtility;

/**
* Sitemap Indexer
Expand Down Expand Up @@ -109,7 +110,7 @@ abstract class SitemapIndexHook implements SingletonInterface
public function __construct()
{
/** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */
$this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
$this->objectManager = Typo3GeneralUtility::makeInstance(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManager'
);

Expand All @@ -135,7 +136,7 @@ protected function initConfiguration()
if (!empty($this->conf['sitemap.']['index.']['fileExtension.'])) {
# File extensions can be a comma separated list
foreach ($this->conf['sitemap.']['index.']['fileExtension.'] as $fileExtListRaw) {
$fileExtList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $fileExtListRaw);
$fileExtList = Typo3GeneralUtility::trimExplode(',', $fileExtListRaw);
$this->fileExtList = array_merge($this->fileExtList, $fileExtList);
};
}
Expand Down
10 changes: 5 additions & 5 deletions Classes/Page/Part/FooterPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

namespace Metaseo\Metaseo\Page\Part;

use Metaseo\Metaseo\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility as Typo3GeneralUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Page Footer
Expand Down Expand Up @@ -67,7 +67,7 @@ public function main($title)
}

// Call hook
\Metaseo\Metaseo\Utility\GeneralUtility::callHookAndSignal(__CLASS__, 'pageFooterSetup', $this, $tsServices);
GeneralUtility::callHookAndSignal(__CLASS__, 'pageFooterSetup', $this, $tsServices);

// #########################################
// GOOGLE ANALYTICS
Expand Down Expand Up @@ -128,7 +128,7 @@ public function main($title)
}

// Call hook
\Metaseo\Metaseo\Utility\GeneralUtility::callHookAndSignal(__CLASS__, 'pageFooterOutput', $this, $ret);
GeneralUtility::callHookAndSignal(__CLASS__, 'pageFooterOutput', $this, $ret);

return implode("\n", $ret);
}
Expand All @@ -144,7 +144,7 @@ public function main($title)
public function buildGoogleAnalyticsCode(array $tsServices, array $gaConf)
{
$ret = array();
$gaCodeList = GeneralUtility::trimExplode(',', $tsServices['googleAnalytics']);
$gaCodeList = Typo3GeneralUtility::trimExplode(',', $tsServices['googleAnalytics']);

foreach ($gaCodeList as $gaCode) {
$customCode = '';
Expand Down Expand Up @@ -201,7 +201,7 @@ public function serviceGoogleAnalyticsTrackDownloads(array $tsServices, array $g
public function buildPiwikCode(array $tsServices, array $piwikConf)
{
$ret = array();
$piwikCodeList = GeneralUtility::trimExplode(',', $piwikConf['id']);
$piwikCodeList = Typo3GeneralUtility::trimExplode(',', $piwikConf['id']);

foreach ($piwikCodeList as $piwikCode) {
$customCode = '';
Expand Down
121 changes: 96 additions & 25 deletions Classes/Page/Part/MetatagPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public function main()
}

$this->processMetaTags($this->metaTagList);
//todo: type mismatch array->string for $this->metaTagList
$this->metaTagList = $this->renderMetaTags($this->metaTagList);

return $this->metaTagList;
Expand All @@ -242,7 +243,6 @@ public function main()
*/
protected function initExtensionSupport()
{

// Extension: news
if (ExtensionManagementUtility::isLoaded('news')) {
$this->initExtensionSupportNews();
Expand Down Expand Up @@ -508,26 +508,51 @@ protected function detectCanonicalPage(array $tsConfig = array())
protected function advMetaTags(array &$metaTags, array $pageRecord, $sysLanguageId, array $customMetaTagList)
{
$pageRecordId = $pageRecord['uid'];

$connector = $this->objectManager->get('Metaseo\\Metaseo\\Connector');
$storeMeta = $connector->getStore();
$storeMeta = $this->getStoreMeta();
$advMetaTagCondition = array();

// #################
// Adv meta tags (from editor)
// External Og tags (from connector)
// #################
$advMetaTagList = array();
$advMetaTagCondition = array();

if (!empty($storeMeta['flag']['meta:og:external'])) {
if ($this->isAvailableExternalOgTags()) {
// External OpenGraph support
$advMetaTagCondition[] = 'tag_name NOT LIKE \'og:%\'';

// Add external og-tags to adv meta tag list
if (!empty($storeMeta['meta:og'])) {
//todo: $advMetaTagList not in use
$advMetaTagList = array_merge($advMetaTagList, $storeMeta['meta:og']);
if (!empty($storeMeta['meta:og'])) { //overwrite known og tags
$externalOgTags = $storeMeta['meta:og'];
foreach ($externalOgTags as $tagName => $tagValue) {
if (array_key_exists('og.' . $tagName, $metaTags)) { //_only_ known og tags
$metaTags['og.' . $tagName] = array(
'tag' => 'meta',
'attributes' => array(
'property' => 'og:' . $tagName,
'content' => $tagValue,
),
);
}
}
}
}
if ($this->isAvailableExternalOgCustomTags()) {
$ogTagKeys = array();
if (!empty($storeMeta['custom:og'])) {
$externalCustomOgTags = $storeMeta['custom:og'];
foreach ($externalCustomOgTags as $tagName => $tagValue) { //take all tags
$metaTags['og.' . $tagName] = array(
'tag' => 'meta',
'attributes' => array(
'property' => 'og:' . $tagName,
'content' => $tagValue,
),
);
$ogTagKeys[] = 'og:' . $tagName;
}
}
$advMetaTagCondition[] = DatabaseUtility::conditionNotIn('tag_name', $ogTagKeys, true);
}

// #################
// Adv meta tags (from editor)
// #################

if (!empty($advMetaTagCondition)) {
$advMetaTagCondition = '( ' . implode(') AND (', $advMetaTagCondition) . ' )';
Expand All @@ -546,13 +571,23 @@ protected function advMetaTags(array &$metaTags, array $pageRecord, $sysLanguage

// Add metadata to tag list
foreach ($advMetaTagList as $tagName => $tagValue) {
$metaTags['adv.' . $tagName] = array(
'tag' => 'meta',
'attributes' => array(
'rel' => $tagName,
'href' => $tagValue,
),
);
if (substr($tagName, 0, 3) === 'og:') {
$metaTags['og.' . $tagName] = array(
'tag' => 'meta',
'attributes' => array(
'property' => $tagName,
'content' => $tagValue,
),
);
} else {
$metaTags['adv.' . $tagName] = array(
'tag' => 'meta',
'attributes' => array(
'rel' => $tagName, //todo: rel and href might not be suitable in every case
'href' => $tagValue,
),
);
}
}

// #################
Expand All @@ -562,7 +597,7 @@ protected function advMetaTags(array &$metaTags, array $pageRecord, $sysLanguage
$metaTags['adv.' . $tagName] = array(
'tag' => 'meta',
'attributes' => array(
'rel' => $tagName,
'rel' => $tagName, //todo: rel and href might not be suitable in every case
'href' => $tagValue,
),
);
Expand Down Expand Up @@ -772,9 +807,7 @@ protected function collectMetaDataFromConnector()
{
$ret = array();

/** @var \Metaseo\Metaseo\Connector $connector */
$connector = $this->objectManager->get('Metaseo\\Metaseo\\Connector');
$storeMeta = $connector->getStore();
$storeMeta = $this->getStoreMeta();

// Std meta tags
foreach ($storeMeta['meta'] as $metaKey => $metaValue) {
Expand Down Expand Up @@ -1426,4 +1459,42 @@ function ($item) {
}
}
}

/**
* @return bool true if external OpenGraph tags are available via the Connector, false otherwise
*/
protected function isAvailableExternalOgTags()
{
$storeMeta = $this->getStoreMeta();

return !empty($storeMeta['flag']['meta:og:external']);
}

/**
* @return bool true if external custom OpenGraph tags are available via the Connector, false otherwise
*/
protected function isAvailableExternalOgCustomTags()
{
$storeMeta = $this->getStoreMeta();

return !empty($storeMeta['flag']['custom:og:external']);
}

/**
* @return array with the meta tags from the connector
*/
protected function getStoreMeta()
{
return $this->getConnector()->getStore();
}

/**
* @return \Metaseo\Metaseo\Connector
*/
protected function getConnector()
{
/** @var \Metaseo\Metaseo\Connector $connector */
$connector = $this->objectManager->get('Metaseo\\Metaseo\\Connector');
return $connector;
}
}
3 changes: 2 additions & 1 deletion Classes/Scheduler/Task/AbstractTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
use Metaseo\Metaseo\Utility\DatabaseUtility;
use Metaseo\Metaseo\Utility\FrontendUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Scheduler\Task\AbstractTask as T3AbstractTask;

/**
* Scheduler Task Sitemap Base
*/
abstract class AbstractTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask
abstract class AbstractTask extends T3AbstractTask
{

// ########################################################################
Expand Down
Loading

0 comments on commit e5a16c1

Please sign in to comment.