Initial commit

This commit is contained in:
2018-04-02 08:07:38 +02:00
commit 7330c1ed3e
2054 changed files with 405203 additions and 0 deletions

View File

@@ -0,0 +1,182 @@
<?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\Controller\Ajax\PageSeo;
use Metaseo\Metaseo\Controller\Ajax\AbstractPageSeoController;
use Metaseo\Metaseo\DependencyInjection\Utility\HttpUtility;
use Metaseo\Metaseo\Exception\Ajax\AjaxException;
use Metaseo\Metaseo\Utility\DatabaseUtility;
class AdvancedController extends AbstractPageSeoController
{
const LIST_TYPE = 'advanced';
/**
* @inheritDoc
*/
protected function initFieldList()
{
$this->fieldList = array();
}
/**
* @inheritDoc
*/
public function executeIndex()
{
if (empty($this->postVar['pid'])) {
throw new AjaxException(
'message.error.typo3_page_not_found',
'[0x4FBF3C0E]',
HttpUtility::HTTP_STATUS_BAD_REQUEST
);
}
$ret = array();
$pid = (int)$this->postVar['pid'];
$sysLanguage = (int)$this->postVar['sysLanguage'];
// check uid of pages language overlay
$query = 'SELECT tag_name,
tag_value
FROM tx_metaseo_metatag
WHERE pid = ' . (int)$pid . '
AND sys_language_uid = ' . (int)$sysLanguage;
$rowList = DatabaseUtility::getAll($query);
foreach ($rowList as $row) {
$ret[$row['tag_name']] = $row['tag_value'];
}
return array(
'results' => count($ret),
'rows' => array_values($ret),
);
}
/**
* @inheritDoc
*/
protected function executeUpdate()
{
if (empty($this->postVar['pid']) || empty($this->postVar['metaTags'])) {
throw new AjaxException(
'message.error.typo3_page_not_found',
'[0x4FBF3C0F]',
HttpUtility::HTTP_STATUS_BAD_REQUEST
);
}
$pid = (int)$this->postVar['pid'];
$metaTagList = (array)$this->postVar['metaTags'];
$sysLanguage = (int)$this->postVar['sysLanguage'];
$this->clearMetaTags($pid, $sysLanguage);
$metaTagGroup = 2;
foreach ($metaTagList as $metaTagName => $metaTagValue) {
if (is_scalar($metaTagValue)) {
$metaTagValue = trim($metaTagValue);
if (strlen($metaTagValue) > 0) {
$this->updateMetaTag($pid, $sysLanguage, $metaTagName, $metaTagValue);
}
} elseif (is_array($metaTagValue)) {
foreach ($metaTagValue as $subTagName => $subTagValue) {
$this->updateMetaTag(
$pid,
$sysLanguage,
array($metaTagName, $subTagName),
$subTagValue,
$metaTagGroup++
);
}
}
}
return array();
}
/**
* Clear all meta tags for one page
*
* @param integer $pid PID
* @param integer|null $sysLanguage system language id
*/
protected function clearMetaTags($pid, $sysLanguage)
{
$query = 'DELETE FROM tx_metaseo_metatag
WHERE pid = ' . (int)$pid . '
AND sys_language_uid = ' . (int)$sysLanguage;
DatabaseUtility::exec($query);
}
/**
* @param integer $pid PID
* @param integer|NULL $sysLanguage System language id
* @param string|array $metaTag MetaTag name
* @param string $value MetaTag value
* @param integer $tagGroup MetaTag group
*/
protected function updateMetaTag($pid, $sysLanguage, $metaTag, $value, $tagGroup = null)
{
$tstamp = time();
$crdate = time();
$cruserId = $this->getBackendUserAuthentication()->user['uid'];
$subTagName = '';
if (is_array($metaTag)) {
list($metaTag, $subTagName) = $metaTag;
}
if ($tagGroup === null) {
$tagGroup = 1;
}
$query = 'INSERT INTO tx_metaseo_metatag
(pid, tstamp, crdate, cruser_id, sys_language_uid,
tag_name, tag_subname, tag_value, tag_group)
VALUES (
' . (int)$pid . ',
' . (int)$tstamp . ',
' . (int)$crdate . ',
' . (int)$cruserId . ',
' . (int)$sysLanguage . ',
' . DatabaseUtility::quote($metaTag) . ',
' . DatabaseUtility::quote($subTagName) . ',
' . DatabaseUtility::quote($value) . ',
' . (int)$tagGroup . '
) ON DUPLICATE KEY UPDATE
tstamp = VALUES(tstamp),
tag_value = VALUES(tag_value)';
DatabaseUtility::execInsert($query);
}
}

View File

@@ -0,0 +1,47 @@
<?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\Controller\Ajax\PageSeo;
use Metaseo\Metaseo\Controller\Ajax\AbstractPageSeoController;
class GeoController extends AbstractPageSeoController
{
const LIST_TYPE = 'geo';
/**
* @inheritDoc
*/
protected function initFieldList()
{
$this->fieldList = array(
'tx_metaseo_geo_lat',
'tx_metaseo_geo_long',
'tx_metaseo_geo_place',
'tx_metaseo_geo_region'
);
}
}

View File

@@ -0,0 +1,66 @@
<?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\Controller\Ajax\PageSeo;
use Metaseo\Metaseo\Controller\Ajax\AbstractPageSeoController;
class MetaDataController extends AbstractPageSeoController
{
const LIST_TYPE = 'metadata';
protected function initFieldList()
{
$this->fieldList = array(
'keywords',
'description',
'abstract',
'author',
'author_email',
'lastupdated',
);
}
/**
* @inheritDoc
*/
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']);
} else {
$row['lastupdated'] = '';
}
}
unset($row);
return $list;
}
}

View File

@@ -0,0 +1,89 @@
<?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\Controller\Ajax\PageSeo;
use Metaseo\Metaseo\Controller\Ajax\AbstractPageSeoSimController;
use Metaseo\Metaseo\DependencyInjection\Utility\HttpUtility;
use Metaseo\Metaseo\Exception\Ajax\AjaxException;
use TYPO3\CMS\Core\Utility\GeneralUtility as Typo3GeneralUtility;
class PageTitleController extends AbstractPageSeoSimController
{
const LIST_TYPE = 'pagetitle';
/**
* @inheritDoc
*/
protected function initFieldList()
{
$this->fieldList = array(
'tx_metaseo_pagetitle',
'tx_metaseo_pagetitle_rel',
'tx_metaseo_pagetitle_prefix',
'tx_metaseo_pagetitle_suffix',
);
}
/**
* @inheritDoc
*/
protected function executeSimulate()
{
$pid = (int)$this->postVar['pid'];
if (empty($pid)) {
throw new AjaxException(
'message.error.typo3_page_not_found',
'[0x4FBF3C08]',
HttpUtility::HTTP_STATUS_BAD_REQUEST
);
}
$page = $this->getPageSeoDao()->getPageById($pid);
if (empty($page)) {
throw new AjaxException(
'message.error.typo3_page_not_found',
'[0x4FBF3C09]',
HttpUtility::HTTP_STATUS_BAD_REQUEST
);
}
// Load TYPO3 classes
$this->getFrontendUtility()->initTsfe($page, null, $page, null);
$pagetitle = Typo3GeneralUtility::makeInstance(
'Metaseo\\Metaseo\\Page\\Part\\PagetitlePart'
);
return array(
'title' => $pagetitle->main($page['title']),
);
}
}

View File

@@ -0,0 +1,101 @@
<?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\Controller\Ajax\PageSeo;
use Metaseo\Metaseo\Controller\Ajax\AbstractPageSeoController;
class PageTitleSimController extends AbstractPageSeoController
{
const LIST_TYPE = 'pagetitlesim';
/**
* @inheritDoc
*/
protected function initFieldList()
{
$this->fieldList = array(
'title',
'tx_metaseo_pagetitle',
'tx_metaseo_pagetitle_rel',
'tx_metaseo_pagetitle_prefix',
'tx_metaseo_pagetitle_suffix',
);
}
/**
* @inheritDoc
*/
protected function getIndex(array $page, $depth, $sysLanguage)
{
$list = $this->getPageSeoDao()->index($page, $depth, $sysLanguage, $this->fieldList);
$uidList = array_keys($list);
if (!empty($uidList)) {
// Check which pages have templates (for caching and faster building)
$this->templatePidList = array();
$pidList = $this->getTemplateDao()->checkForTemplateByUidList($uidList);
foreach ($pidList as $pid) {
$this->templatePidList[$pid] = $pid;
}
// Build simulated title
foreach ($list as &$row) {
$row['title_simulated'] = $this->simulateTitle($row, $sysLanguage);
}
}
return $list;
}
/**
* Generate simulated page title
*
* @param array $page Page
* @param integer $sysLanguage System language
*
* @return string
*/
protected function simulateTitle(array $page, $sysLanguage)
{
$this->getFrontendUtility()->initTsfe($page, null, $page, null, $sysLanguage);
$pagetitle = $this->objectManager->get('Metaseo\\Metaseo\\Page\\Part\\PagetitlePart');
$ret = $pagetitle->main($page['title']);
return $ret;
}
/**
* @return \Metaseo\Metaseo\Dao\TemplateDao
*/
protected function getTemplateDao()
{
return $this->objectManager->get('Metaseo\\Metaseo\\Dao\\TemplateDao');
}
}

View File

@@ -0,0 +1,46 @@
<?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\Controller\Ajax\PageSeo;
use Metaseo\Metaseo\Controller\Ajax\AbstractPageSeoController;
class SearchEnginesController extends AbstractPageSeoController
{
const LIST_TYPE = 'searchengines';
/**
* @inheritDoc
*/
protected function initFieldList()
{
$this->fieldList = array(
'tx_metaseo_canonicalurl',
'tx_metaseo_is_exclude',
'tx_metaseo_priority',
);
}
}

View File

@@ -0,0 +1,109 @@
<?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\Controller\Ajax\PageSeo;
use Metaseo\Metaseo\Controller\Ajax\AbstractPageSeoSimController;
use Metaseo\Metaseo\DependencyInjection\Utility\HttpUtility;
use Metaseo\Metaseo\Exception\Ajax\AjaxException;
use Metaseo\Metaseo\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
class UrlController extends AbstractPageSeoSimController
{
const LIST_TYPE = 'url';
/**
* @inheritDoc
*/
protected function initFieldList()
{
$this->fieldList = array(
'title',
'url_scheme',
'alias',
'tx_realurl_pathsegment',
'tx_realurl_pathoverride',
'tx_realurl_exclude',
);
}
/**
* @inheritDoc
*/
protected function executeSimulate()
{
$pid = (int)$this->postVar['pid'];
if (empty($pid)) {
throw new AjaxException(
'message.error.typo3_page_not_found',
'[0x4FBF3C0A]',
HttpUtility::HTTP_STATUS_BAD_REQUEST
);
}
$page = $this->getPageSeoDao()->getPageById($pid);
if (empty($page)) {
throw new AjaxException(
'message.error.typo3_page_not_found',
'[0x4FBF3C0B]',
HttpUtility::HTTP_STATUS_BAD_REQUEST
);
}
if (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->getFrontendUtility()->initTsfe($page, null, $page, null);
$ret = $this->getFrontendUtility()->getTypoLinkUrl(array('parameter' => $page['uid']));
if (!empty($ret)) {
$ret = GeneralUtility::fullUrl($ret);
}
if (empty($ret)) {
throw new AjaxException(
'message.error.url_generation_failed',
'[0x4FBF3C01]',
HttpUtility::HTTP_STATUS_BAD_REQUEST
);
}
return array(
'url' => $ret,
);
}
}