Skip to content

Commit

Permalink
Merge branch 'develop' into dev/tmp-merge
Browse files Browse the repository at this point in the history
# Conflicts:
#	Classes/Controller/Ajax/AbstractPageSeoController.php
  • Loading branch information
thomaszbz committed Jun 10, 2017
2 parents b08796e + 0f4e108 commit ca8ae1f
Show file tree
Hide file tree
Showing 34 changed files with 376 additions and 60 deletions.
1 change: 0 additions & 1 deletion Classes/Backend/Module/AbstractModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ protected function initializeAction()
*/
protected function translateList(array $list)
{
unset($token);
foreach ($list as &$token) {
if (!empty($token)) {
if (is_array($token)) {
Expand Down
16 changes: 15 additions & 1 deletion Classes/Controller/Ajax/AbstractPageSeoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Metaseo\Metaseo\Controller\Ajax\PageSeo as PageSeo;
use Metaseo\Metaseo\DependencyInjection\Utility\HttpUtility;
use Metaseo\Metaseo\Exception\Ajax\AjaxException;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

Expand Down Expand Up @@ -353,10 +354,23 @@ protected function getPageSeoDao()
->objectManager
->get('Metaseo\\Metaseo\\Dao\\PageSeoDao')
->setPageTreeView($this->getPageTreeView())
->setDataHandler($this->getDataHandler());
->setDataHandler($this->getDataHandler())
->setExtensibilityOptions($this->getExtensibilityOptions());
}

/**
* return array
*/
protected function getExtensibilityOptions()
{
$config = $this
->objectManager
->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager')
->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
return $config['plugin.']['metaseo.']['extensibility.'];
}

/**
* @return \TYPO3\CMS\Core\DataHandling\DataHandler
*/
protected function getDataHandler()
Expand Down
1 change: 0 additions & 1 deletion Classes/Controller/Ajax/PageSeo/MetaDataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ protected function getIndex(array $page, $depth, $sysLanguage)
{
$list = $this->getPageSeoDao()->index($page, $depth, $sysLanguage, $this->fieldList);

unset($row);
foreach ($list as &$row) {
if (!empty($row['lastUpdated'])) {
$row['lastUpdated'] = date('Y-m-d', $row['lastUpdated']);
Expand Down
1 change: 0 additions & 1 deletion Classes/Controller/BackendControlCenterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ public function mainAction()
// Build root page list
// #################

unset($page);
foreach ($rootPageList as $pageId => &$page) {
// Domain list
$page['domainList'] = '';
Expand Down
1 change: 0 additions & 1 deletion Classes/Controller/BackendRootSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public function mainAction()
// Build root page list
// #################

unset($page);
foreach ($rootPageList as $pageId => &$page) {
// Domain list
$page['domainList'] = '';
Expand Down
1 change: 0 additions & 1 deletion Classes/Controller/BackendSitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public function mainAction()
// #################


unset($page);
foreach ($rootPageList as $pageId => &$page) {
$stats = array(
'sum_pages' => 0,
Expand Down
41 changes: 38 additions & 3 deletions Classes/Dao/PageSeoDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class PageSeoDao extends Dao
*/
protected $pageTreeView;

/**
* Extended options set via plugin.metaseo.extensibility
* @var array
*/
protected $extensibilityOptions;

/**
* Return default tree
*
Expand Down Expand Up @@ -68,8 +74,10 @@ public function index(array $page, $depth, $sysLanguage, $fieldList = array())
foreach ($fieldList as $field) {
$tree->addField($field, true);
}

$tree->init(
'AND doktype IN (1,4) AND ' . $this->getBackendUserAuthentication()->getPagePermsClause(1)
'AND doktype IN (' . $this->getDocTypeList() . ') AND '
. $this->getBackendUserAuthentication()->getPagePermsClause(1)
);

$tree->tree[] = array(
Expand Down Expand Up @@ -102,7 +110,6 @@ public function index(array $page, $depth, $sysLanguage, $fieldList = array())
$defaultOverlayStatus = 2;
}

unset($row);
foreach ($list as &$row) {
// Set field as main fields
foreach ($fieldList as $fieldName) {
Expand Down Expand Up @@ -143,7 +150,6 @@ public function index(array $page, $depth, $sysLanguage, $fieldList = array())
);

// update all overlay status field to "from base"
unset($row);
foreach ($list as &$row) {
foreach ($overlayFieldList as $fieldName) {
$row['_overlay'][$fieldName] = 0;
Expand Down Expand Up @@ -178,6 +184,23 @@ public function index(array $page, $depth, $sysLanguage, $fieldList = array())
return $list;
}

protected function getDocTypeList()
{
if (!isset($this->extensibilityOptions['allowedDoktypes'])
|| empty($this->extensibilityOptions['allowedDoktypes'])
) {
return '1,4'; //default
}

// validate input
$allowedDoktypes = explode(',', $this->extensibilityOptions['allowedDoktypes']);
foreach ($allowedDoktypes as &$allowedDoktype) {
$allowedDoktype = (int)trim($allowedDoktype);
}

return implode(',', $allowedDoktypes);
}

/**
* Calculate the depth of a page
*
Expand Down Expand Up @@ -325,4 +348,16 @@ public function setPageTreeView($pageTreeView)

return $this;
}

/**
* @param array $extensibilityOptions
*
* @return $this
*/
public function setExtensibilityOptions(array $extensibilityOptions)
{
$this->extensibilityOptions = $extensibilityOptions;

return $this;
}
}
23 changes: 20 additions & 3 deletions Classes/Page/Part/MetatagPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,6 @@ protected function processMetaTags(array &$tags)
foreach ($keyList as $key) {
if (!empty($tags[$key]['attributes'])) {
foreach ($markerList as $marker => $value) {
unset($metaTagAttribute);
foreach ($tags[$key]['attributes'] as &$metaTagAttribute) {
// only replace markers if they are present
if (strpos($metaTagAttribute, $marker) !== false) {
Expand Down Expand Up @@ -1419,8 +1418,19 @@ protected function getProtocolLength($url)
*/
protected function generateOpenGraphMetaTags()
{
$prefixes = array('og');
$tsSetupSeoOg = $this->tsSetupSeo['opengraph.'];
$this->convertOpenGraphTypoScriptToMetaTags($prefixes, $tsSetupSeoOg);
}

/**
* Convert nested TypoScript to OpenGraph MetaTags
*
* @param array $prefixes
* @param array $tsSetupSeoOg
*/
protected function convertOpenGraphTypoScriptToMetaTags(array $prefixes, array $tsSetupSeoOg)
{
// Get list of tags (filtered array)
$ogTagNameList = array_keys($tsSetupSeoOg);
$ogTagNameList = array_unique(
Expand All @@ -1446,13 +1456,20 @@ function ($item) {
$tsSetupSeoOg[$ogTagName],
$tsSetupSeoOg[$ogTagName . '.']
);
} elseif (!array_key_exists($ogTagName, $tsSetupSeoOg) && array_key_exists($ogTagName . '.', $tsSetupSeoOg)) {
// Nested object (e.g. image)
array_push($prefixes, $ogTagName);
$this->convertOpenGraphTypoScriptToMetaTags($prefixes, $tsSetupSeoOg[$ogTagName . '.']);
array_pop($prefixes);
}

if ($ogTagValue !== null && strlen($ogTagValue) >= 1) {
$this->metaTagList['og.' . $ogTagName] = array(
$path = $prefixes;
$path[] = $ogTagName;
$this->metaTagList[implode('.', $path)] = array(
'tag' => 'meta',
'attributes' => array(
'property' => 'og:' . $ogTagName,
'property' => implode(':', $path),
'content' => $ogTagValue,
),
);
Expand Down
1 change: 0 additions & 1 deletion Classes/Utility/SitemapUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public static function index(array $pageData)
}

// Escape/Quote data
unset($pageDataValue);
foreach ($pageData as &$pageDataValue) {
if ($pageDataValue === null) {
$pageDataValue = 'NULL';
Expand Down
14 changes: 14 additions & 0 deletions Configuration/TCA/Overrides/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
'maxitems' => 1
)
),
'tx_metaseo_opengraph_image' => array(
'exclude' => 1,
'label' => 'LLL:EXT:metaseo/Resources/Private/Language/TCA/locallang.xlf:pages.tx_metaseo_opengraph_image',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('tx_metaseo_opengraph_image', array(
'maxitems' => 1
)
)
),
'tx_metaseo_is_exclude' => array(
'label' => 'LLL:EXT:metaseo/Resources/Private/Language/TCA/locallang.xlf:pages.tx_metaseo_is_exclude',
'exclude' => 1,
Expand Down Expand Up @@ -212,6 +220,11 @@
'canNotCollapse' => 1
);

$GLOBALS['TCA']['pages']['palettes']['tx_metaseo_opengraph'] = array(
'showitem' => 'tx_metaseo_opengraph_image',
'canNotCollapse' => 1
);

$GLOBALS['TCA']['pages']['palettes']['tx_metaseo_crawler'] = array(
'showitem' => 'tx_metaseo_is_exclude,--linebreak--,tx_metaseo_canonicalurl',
'canNotCollapse' => 1
Expand Down Expand Up @@ -241,6 +254,7 @@
'pages',
'--div--;LLL:EXT:metaseo/Resources/Private/Language/TCA/locallang.xlf:pages.tab.seo;,--palette--;'
. 'LLL:EXT:metaseo/Resources/Private/Language/TCA/locallang.xlf:pages.palette.pagetitle;tx_metaseo_pagetitle,'
. '--palette--;LLL:EXT:metaseo/Resources/Private/Language/TCA/locallang.xlf:pages.palette.opengraph;tx_metaseo_opengraph,'
. '--palette--;LLL:EXT:metaseo/Resources/Private/Language/TCA/locallang.xlf:pages.palette.geo;tx_metaseo_geo,'
. '--palette--;LLL:EXT:metaseo/Resources/Private/Language/TCA/locallang.xlf:pages.palette.crawler;'
. 'tx_metaseo_crawler,--palette--;LLL:EXT:metaseo/Resources/Private/Language/TCA/locallang.xlf:'
Expand Down
15 changes: 15 additions & 0 deletions Configuration/TCA/Overrides/pages_language_overlay.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
'eval' => 'trim',
)
),
'tx_metaseo_opengraph_image' => array(
'exclude' => 1,
'label' => 'LLL:EXT:metaseo/Resources/Private/Language/TCA/locallang.xlf:'
. 'pages.tx_metaseo_opengraph_image',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('tx_metaseo_opengraph_image', array(
'maxitems' => 1
)
)
),
'tx_metaseo_pagetitle_prefix' => array(
'label' => 'LLL:EXT:metaseo/Resources/Private/Language/TCA/locallang.xlf:'
. 'pages.tx_metaseo_pagetitle_prefix',
Expand Down Expand Up @@ -80,6 +89,11 @@
'canNotCollapse' => 1
);

$GLOBALS['TCA']['pages_language_overlay']['palettes']['tx_metaseo_opengraph'] = array(
'showitem' => 'tx_metaseo_opengraph_image',
'canNotCollapse' => 1
);

$GLOBALS['TCA']['pages_language_overlay']['palettes']['tx_metaseo_crawler'] = array(
'showitem' => 'tx_metaseo_canonicalurl',
'canNotCollapse' => 1
Expand All @@ -97,6 +111,7 @@
'pages_language_overlay',
'--div--;LLL:EXT:metaseo/Resources/Private/Language/TCA/locallang.xlf:pages.tab.seo;,--palette--;'
. 'LLL:EXT:metaseo/Resources/Private/Language/TCA/locallang.xlf:pages.palette.pagetitle;tx_metaseo_pagetitle,'
. '--palette--;LLL:EXT:metaseo/Resources/Private/Language/TCA/locallang.xlf:pages.palette.opengraph;tx_metaseo_opengraph,'
. '--palette--;LLL:EXT:metaseo/Resources/Private/Language/TCA/locallang.xlf:pages.palette.crawler;'
. 'tx_metaseo_crawler',
'',
Expand Down
10 changes: 10 additions & 0 deletions Configuration/TypoScript/constants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# This are the default TS-constants for metaseo
##
plugin.metaseo {

# cat=plugin.metaseo.metaTags/page/01; type=string; label= Meta Description: Short description of your webpage.
metaTags.description =

Expand Down Expand Up @@ -62,6 +63,12 @@ plugin.metaseo {
# cat=plugin.metaseo.metaTags/enable/26; type=boolean; label= OpenGraph Tags: Enable generation of OpenGraph Tags
metaTags.opengraph = 1

# cat=plugin.metaseo.metaTags/page/20; type=string; label= Open Graph image width
metaTags.opengraphImageWidth = 1200c

# cat=plugin.metaseo.metaTags/page/21; type=string; label= Open Graph image height
metaTags.opengraphImageHeight = 630c

# cat=plugin.metaseo.metaTags/enable/27; type=boolean; label= Publish Page Expire Time: Anounce Expire Tag (TYPO3's enddate in content elements).
metaTags.useExpire = 1

Expand Down Expand Up @@ -181,4 +188,7 @@ plugin.metaseo {

# cat=plugin.metaseo.sitemap/index/01; type=boolean; label= Lastmod tag in sitemap: Include lastmod tag in sitemap
sitemap.enableLastMod = 1

# cat=plugin.metaseo.extensibility/page/01; type=string; label= Doktypes list for backend page tree
extensibility.allowedDoktypes = 1,4
}
53 changes: 53 additions & 0 deletions Configuration/TypoScript/setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ page {
# TypoScript added by extension "metaseo"
plugin.metaseo =
plugin.metaseo {

# extensibility options
extensibility =
extensibility {
allowedDoktypes = {$plugin.metaseo.extensibility.allowedDoktypes}
}

# Page title generator
pageTitle =
pageTitle {
Expand Down Expand Up @@ -145,6 +152,52 @@ plugin.metaseo {
field = title
}

image {
url = FILES
url {
references {
table = pages
uid.data = page:uid
fieldName = tx_metaseo_opengraph_image
}
renderObj = TEXT
renderObj {
typolink {
parameter {
stdWrap.cObject = IMG_RESOURCE
stdWrap.cObject {
file {
import.data = file:current:uid
treatIdAsReference = 1
width = {$plugin.metaseo.metaTags.opengraphImageWidth}
height = {$plugin.metaseo.metaTags.opengraphImageHeight}
}
}
}
returnLast = url
forceAbsoluteUrl = 1
}
}
}

width = TEXT
width {
data = TSFE:lastImgResourceInfo|0
}

height = TEXT
height {
data = TSFE:lastImgResourceInfo|1
}

type = TEXT
type {
wrap = image/|
data = TSFE:lastImgResourceInfo|2
required = 1
}
}

type = article
admins =
email = {$plugin.metaseo.metaTags.email}
Expand Down
8 changes: 7 additions & 1 deletion Documentation/ChangeLog/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ Changelog
+=============+====================================================================================================+
| **2.1.0** | **New feature and Bugfix release** |
| | |
| | - Added support for OpenGraph images |
| | - Display custom page doktypes in SEO/Metatags section |
| | |
| | **Migration to 2.1.0:** |
| | |
| | `Milestone 2.1.0 <https://github.com/mblaschke/TYPO3-metaseo/milestone/17?closed=1>`_ |
| | - Compare and update the database schema in the install tool. |
| | - Page title prefix/suffix inheritance has changed. Please check your titles. |
| | |
| | `Milestone 2.1.0 <https://github.com/mblaschke/TYPO3-metaseo/milestone/5?closed=1>`_ |
| | `Changes in 2.1.0 <https://github.com/mblaschke/TYPO3-metaseo/compare/2.0.4...2.1.0>`_ |
+-------------+----------------------------------------------------------------------------------------------------+
| **2.0.4** | **New feature and Bugfix release** |
Expand Down
Loading

0 comments on commit ca8ae1f

Please sign in to comment.