Initial commit
This commit is contained in:
@@ -0,0 +1,412 @@
|
||||
<?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;
|
||||
|
||||
use Exception;
|
||||
use Metaseo\Metaseo\Controller\AbstractAjaxController;
|
||||
use Metaseo\Metaseo\Controller\Ajax\PageSeo as PageSeo;
|
||||
use Metaseo\Metaseo\DependencyInjection\Utility\HttpUtility;
|
||||
use Metaseo\Metaseo\Exception\Ajax\AjaxException;
|
||||
use TYPO3\CMS\Core\Http\AjaxRequestHandler;
|
||||
|
||||
/**
|
||||
* TYPO3 Backend ajax module page
|
||||
*/
|
||||
abstract class AbstractPageSeoController extends AbstractAjaxController implements PageSeoInterface
|
||||
{
|
||||
const LIST_TYPE = 'undefined';
|
||||
const AJAX_PREFIX = 'tx_metaseo_controller_ajax_pageseo_';
|
||||
|
||||
// ########################################################################
|
||||
// Attributes
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* List of page uids which have templates
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $templatePidList;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $fieldList;
|
||||
|
||||
// ########################################################################
|
||||
// Methods
|
||||
// ########################################################################
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->templatePidList = array();
|
||||
$this->initFieldList();
|
||||
}
|
||||
|
||||
abstract protected function initFieldList();
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function indexAction($params = array(), AjaxRequestHandler &$ajaxObj = null)
|
||||
{
|
||||
try {
|
||||
$this->init();
|
||||
$ajaxObj->setContent($this->executeIndex());
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxExceptionHandler($exception, $ajaxObj);
|
||||
}
|
||||
|
||||
$ajaxObj->setContentFormat(self::CONTENT_FORMAT_JSON);
|
||||
$ajaxObj->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws AjaxException
|
||||
*/
|
||||
protected function executeIndex()
|
||||
{
|
||||
$pid = (int)$this->postVar['pid'];
|
||||
$depth = (int)$this->postVar['depth'];
|
||||
$sysLanguage = (int)$this->postVar['sysLanguage'];
|
||||
|
||||
// Store last selected language
|
||||
$this->getBackendUserAuthentication()
|
||||
->setAndSaveSessionData('MetaSEO.sysLanguage', $sysLanguage);
|
||||
|
||||
if (empty($pid)) {
|
||||
|
||||
throw new AjaxException(
|
||||
'message.error.typo3_page_not_found',
|
||||
'[0x4FBF3C0C]',
|
||||
HttpUtility::HTTP_STATUS_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
$page = $this->getPageSeoDao()->getPageById($pid);
|
||||
|
||||
$list = $this->getIndex($page, $depth, $sysLanguage);
|
||||
|
||||
return array(
|
||||
'results' => count($list),
|
||||
'rows' => array_values($list),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return default tree
|
||||
*
|
||||
* This function is made for list manipulation in subclasses (method template design pattern)
|
||||
*
|
||||
* @param array $page Root page
|
||||
* @param integer $depth Depth
|
||||
* @param integer $sysLanguage System language
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getIndex(array $page, $depth, $sysLanguage)
|
||||
{
|
||||
return $this->getPageSeoDao()->index($page, $depth, $sysLanguage, $this->fieldList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function updateAction($params = array(), AjaxRequestHandler &$ajaxObj = null)
|
||||
{
|
||||
try {
|
||||
$this->init();
|
||||
$ajaxObj->setContent($this->executeUpdate());
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxExceptionHandler($exception, $ajaxObj);
|
||||
}
|
||||
|
||||
$ajaxObj->setContentFormat(self::CONTENT_FORMAT_JSON);
|
||||
$ajaxObj->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws AjaxException
|
||||
*/
|
||||
protected function executeUpdate()
|
||||
{
|
||||
if (empty($this->postVar['pid']) || empty($this->postVar['field'])) {
|
||||
|
||||
throw new AjaxException(
|
||||
'message.warning.incomplete_data_received.message',
|
||||
'[0x4FBF3C02]',
|
||||
HttpUtility::HTTP_STATUS_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
$pid = (int)$this->postVar['pid'];
|
||||
$fieldName = strtolower((string)$this->postVar['field']);
|
||||
$fieldValue = (string)$this->postVar['value'];
|
||||
$sysLanguage = (int)$this->postVar['sysLanguage'];
|
||||
|
||||
// validate field name: must match exactly to list of known field names
|
||||
if (!in_array($fieldName, array_merge($this->fieldList, array('title')))) {
|
||||
throw new AjaxException(
|
||||
'message.warning.incomplete_data_received.message',
|
||||
'[0x4FBF3C23]',
|
||||
HttpUtility::HTTP_STATUS_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($fieldName)) {
|
||||
|
||||
throw new AjaxException(
|
||||
'message.warning.incomplete_data_received.message',
|
||||
'[0x4FBF3C03]',
|
||||
HttpUtility::HTTP_STATUS_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
// ############################
|
||||
// Security checks
|
||||
// ############################
|
||||
|
||||
|
||||
// check if user is able to modify pages
|
||||
if (!$this->getBackendUserAuthentication()->check('tables_modify', 'pages')) {
|
||||
// No access
|
||||
|
||||
throw new AjaxException(
|
||||
'message.error.access_denied',
|
||||
'[0x4FBF3BE2]',
|
||||
HttpUtility::HTTP_STATUS_UNAUTHORIZED
|
||||
);
|
||||
}
|
||||
|
||||
$page = $this->getPageSeoDao()->getPageById($pid);
|
||||
|
||||
// check if page exists and user can edit this specific record
|
||||
if (empty($page) || !$this->getBackendUserAuthentication()->doesUserHaveAccess($page, 2)) {
|
||||
// No access
|
||||
|
||||
throw new AjaxException(
|
||||
'message.error.access_denied',
|
||||
'[0x4FBF3BCF]',
|
||||
HttpUtility::HTTP_STATUS_UNAUTHORIZED
|
||||
);
|
||||
}
|
||||
|
||||
// check if user is able to modify the field of pages
|
||||
if (!$this->getBackendUserAuthentication()
|
||||
->check('non_exclude_fields', 'pages:' . $fieldName)
|
||||
) {
|
||||
// No access
|
||||
|
||||
throw new AjaxException(
|
||||
'message.error.access_denied',
|
||||
'[0x4FBF3BD9]',
|
||||
HttpUtility::HTTP_STATUS_UNAUTHORIZED
|
||||
);
|
||||
}
|
||||
|
||||
// also check for sys language
|
||||
if (!empty($sysLanguage)) {
|
||||
// check if user is able to modify pages
|
||||
if (!$this->getBackendUserAuthentication()
|
||||
->check('tables_modify', 'pages_language_overlay')
|
||||
) {
|
||||
// No access
|
||||
|
||||
throw new AjaxException(
|
||||
'message.error.access_denied',
|
||||
'[0x4FBF3BE2]',
|
||||
HttpUtility::HTTP_STATUS_UNAUTHORIZED
|
||||
);
|
||||
}
|
||||
|
||||
// check if user is able to modify the field of pages
|
||||
if (!$this->getBackendUserAuthentication()
|
||||
->check('non_exclude_fields', 'pages_language_overlay:' . $fieldName)
|
||||
) {
|
||||
// No access
|
||||
|
||||
throw new AjaxException(
|
||||
'message.error.access_denied',
|
||||
'[0x4FBF3BD9]',
|
||||
HttpUtility::HTTP_STATUS_UNAUTHORIZED
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ############################
|
||||
// Transformations
|
||||
// ############################
|
||||
|
||||
switch ($fieldName) {
|
||||
case 'lastupdated':
|
||||
// transform to unix timestamp
|
||||
$fieldValue = strtotime($fieldValue);
|
||||
break;
|
||||
}
|
||||
|
||||
// ############################
|
||||
// Update
|
||||
// ############################
|
||||
|
||||
return $this->getPageSeoDao()->updatePageTableField($pid, $sysLanguage, $fieldName, $fieldValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function updateRecursiveAction($params = array(), AjaxRequestHandler &$ajaxObj = null)
|
||||
{
|
||||
try {
|
||||
$this->init();
|
||||
$ajaxObj->setContent($this->executeUpdateRecursive());
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxExceptionHandler($exception, $ajaxObj);
|
||||
}
|
||||
|
||||
$ajaxObj->setContentFormat(self::CONTENT_FORMAT_JSON);
|
||||
$ajaxObj->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws AjaxException
|
||||
*/
|
||||
protected function executeUpdateRecursive()
|
||||
{
|
||||
if (empty($this->postVar['pid']) || empty($this->postVar['field'])) {
|
||||
|
||||
throw new AjaxException(
|
||||
'message.warning.incomplete_data_received.message',
|
||||
'[0x4FBF3C04]',
|
||||
HttpUtility::HTTP_STATUS_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
$pid = $this->postVar['pid'];
|
||||
$sysLanguage = (int)$this->postVar['sysLanguage'];
|
||||
|
||||
$page = $this->getPageSeoDao()->getPageById($pid);
|
||||
|
||||
$list = $this->getPageSeoDao()->index($page, 999, $sysLanguage, array());
|
||||
|
||||
$count = 0;
|
||||
foreach ($list as $key => $page) {
|
||||
$this->postVar['pid'] = $key;
|
||||
$this->executeUpdate();
|
||||
$count++;
|
||||
}
|
||||
|
||||
return array(
|
||||
'updateCount' => $count, //not in use yet
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getAjaxPrefix()
|
||||
{
|
||||
return self::AJAX_PREFIX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Metaseo\Metaseo\Dao\PageSeoDao
|
||||
*/
|
||||
protected function getPageSeoDao()
|
||||
{
|
||||
return $this
|
||||
->objectManager
|
||||
->get('Metaseo\\Metaseo\\Dao\\PageSeoDao')
|
||||
->setPageTreeView($this->getPageTreeView())
|
||||
->setDataHandler($this->getDataHandler());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \TYPO3\CMS\Core\DataHandling\DataHandler
|
||||
*/
|
||||
protected function getDataHandler()
|
||||
{
|
||||
return $this->objectManager->get('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \TYPO3\CMS\Backend\Tree\View\PageTreeView
|
||||
*/
|
||||
protected function getPageTreeView()
|
||||
{
|
||||
return $this->objectManager->get('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Metaseo\Metaseo\DependencyInjection\Utility\FrontendUtility
|
||||
*/
|
||||
protected function getFrontendUtility()
|
||||
{
|
||||
return $this
|
||||
->objectManager
|
||||
->get('Metaseo\\Metaseo\\DependencyInjection\\Utility\\FrontendUtility')
|
||||
->setPageRepository($this->getPageRepository());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \TYPO3\CMS\Frontend\Page\PageRepository
|
||||
*/
|
||||
protected function getPageRepository()
|
||||
{
|
||||
return $this->objectManager->get('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of classes which contain Ajax controllers with <ajaxPrefix> => <className)
|
||||
*
|
||||
* @todo replace class concatenation with e.g. 'UrlController::class' as of PHP 5.5 (renders $namespace obsolete)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getBackendAjaxClassNames()
|
||||
{
|
||||
$nameSpace = __NAMESPACE__ . '\\PageSeo';
|
||||
$ajaxPrefix = self::AJAX_PREFIX;
|
||||
|
||||
return array(
|
||||
//$ajaxPrefix . PageSeo\AdvancedController::LIST_TYPE
|
||||
// => $nameSpace . '\\' . 'AdvancedController',//unused
|
||||
$ajaxPrefix . PageSeo\GeoController::LIST_TYPE => $nameSpace . '\\' . 'GeoController',
|
||||
$ajaxPrefix . PageSeo\MetaDataController::LIST_TYPE => $nameSpace . '\\' . 'MetaDataController',
|
||||
$ajaxPrefix . PageSeo\PageTitleController::LIST_TYPE => $nameSpace . '\\' . 'PageTitleController',
|
||||
$ajaxPrefix . PageSeo\PageTitleSimController::LIST_TYPE => $nameSpace . '\\' . 'PageTitleSimController',
|
||||
$ajaxPrefix . PageSeo\SearchEnginesController::LIST_TYPE => $nameSpace . '\\' . 'SearchEnginesController',
|
||||
$ajaxPrefix . PageSeo\UrlController::LIST_TYPE => $nameSpace . '\\' . 'UrlController',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?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;
|
||||
|
||||
use TYPO3\CMS\Core\Http\AjaxRequestHandler;
|
||||
|
||||
abstract class AbstractPageSeoSimController extends AbstractPageSeoController implements PageSeoSimulateInterface
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function simulateAction($params = array(), AjaxRequestHandler &$ajaxObj = null)
|
||||
{
|
||||
try {
|
||||
$this->init();
|
||||
$ajaxObj->setContent($this->executeSimulate());
|
||||
} catch (\Exception $exception) {
|
||||
$this->ajaxExceptionHandler($exception, $ajaxObj);
|
||||
}
|
||||
|
||||
$ajaxObj->setContentFormat(self::CONTENT_FORMAT_JSON);
|
||||
$ajaxObj->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws \Metaseo\Metaseo\Exception\Ajax\AjaxException
|
||||
*/
|
||||
abstract protected function executeSimulate();
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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']),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?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;
|
||||
|
||||
use TYPO3\CMS\Core\Http\AjaxRequestHandler;
|
||||
|
||||
interface PageSeoInterface
|
||||
{
|
||||
/**
|
||||
* Executes an AJAX request which displays the data (usually as a list)
|
||||
*
|
||||
* @param array $params Array of parameters from the AJAX interface, currently unused (as of 6.2.14)
|
||||
* becomes available starting with 7.4.0 (c048cede,
|
||||
* https://forge.typo3.org/issues/68186)
|
||||
* @param AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function indexAction($params = array(), AjaxRequestHandler &$ajaxObj = null);
|
||||
|
||||
/**
|
||||
* Executes an AJAX request which updates the data in the database
|
||||
*
|
||||
* @param array $params Array of parameters from the AJAX interface, currently unused (as of 6.2.14)
|
||||
* becomes available starting with 7.4.0 (c048cede,
|
||||
* https://forge.typo3.org/issues/68186)
|
||||
* @param AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateAction($params = array(), AjaxRequestHandler &$ajaxObj = null);
|
||||
|
||||
|
||||
/**
|
||||
* Executes an AJAX request which updates the data in the database recursively
|
||||
*
|
||||
* @param array $params Array of parameters from the AJAX interface, currently unused (as of 6.2.14)
|
||||
* becomes available starting with 7.4.0 (c048cede,
|
||||
* https://forge.typo3.org/issues/68186)
|
||||
* @param AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateRecursiveAction($params = array(), AjaxRequestHandler &$ajaxObj = null);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?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;
|
||||
|
||||
use TYPO3\CMS\Core\Http\AjaxRequestHandler;
|
||||
|
||||
interface PageSeoSimulateInterface extends PageSeoInterface
|
||||
{
|
||||
/**
|
||||
* Executes an AJAX request which simulates field values
|
||||
*
|
||||
* @param array $params Array of parameters from the AJAX interface, currently unused (as of 6.2.14)
|
||||
* becomes available starting with 7.4.0 (c048cede,
|
||||
* https://forge.typo3.org/issues/68186)
|
||||
* @param AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function simulateAction($params = array(), AjaxRequestHandler &$ajaxObj = null);
|
||||
}
|
||||
@@ -0,0 +1,389 @@
|
||||
<?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;
|
||||
|
||||
use Exception;
|
||||
use Metaseo\Metaseo\Controller\AbstractAjaxController;
|
||||
use Metaseo\Metaseo\DependencyInjection\Utility\HttpUtility;
|
||||
use Metaseo\Metaseo\Exception\Ajax\AjaxException;
|
||||
use Metaseo\Metaseo\Utility\DatabaseUtility;
|
||||
use Metaseo\Metaseo\Utility\SitemapUtility;
|
||||
use TYPO3\CMS\Core\Http\AjaxRequestHandler;
|
||||
|
||||
/**
|
||||
* TYPO3 Backend ajax module sitemap
|
||||
*/
|
||||
class SitemapController extends AbstractAjaxController implements SitemapInterface
|
||||
{
|
||||
const AJAX_PREFIX = 'tx_metaseo_controller_ajax_sitemap';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function indexAction($params = array(), AjaxRequestHandler &$ajaxObj = null)
|
||||
{
|
||||
try {
|
||||
$this->init();
|
||||
$ajaxObj->setContent($this->executeIndex());
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxExceptionHandler($exception, $ajaxObj);
|
||||
}
|
||||
|
||||
$ajaxObj->setContentFormat(self::CONTENT_FORMAT_JSON);
|
||||
$ajaxObj->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return sitemap entry list for root tree
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function executeIndex()
|
||||
{
|
||||
// Init
|
||||
$rootPid = (int)$this->postVar['pid'];
|
||||
$offset = (int)$this->postVar['start'];
|
||||
$itemsPerPage = (int)$this->postVar['pagingSize'];
|
||||
|
||||
$searchFulltext = trim((string)$this->postVar['criteriaFulltext']);
|
||||
$searchPageUid = trim((int)$this->postVar['criteriaPageUid']);
|
||||
$searchPageLanguage = trim((string)$this->postVar['criteriaPageLanguage']);
|
||||
$searchPageDepth = trim((string)$this->postVar['criteriaPageDepth']);
|
||||
$searchIsBlacklisted = (bool)trim((string)$this->postVar['criteriaIsBlacklisted']);
|
||||
|
||||
// ############################
|
||||
// Criteria
|
||||
// ############################
|
||||
$where = array();
|
||||
|
||||
// Root pid limit
|
||||
$where[] = 's.page_rootpid = ' . (int)$rootPid;
|
||||
|
||||
// Fulltext
|
||||
if (!empty($searchFulltext)) {
|
||||
$where[] = 's.page_url LIKE ' . DatabaseUtility::quote('%' . $searchFulltext . '%', 'tx_metaseo_sitemap');
|
||||
}
|
||||
|
||||
// Page id
|
||||
if (!empty($searchPageUid)) {
|
||||
$where[] = 's.page_uid = ' . (int)$searchPageUid;
|
||||
}
|
||||
|
||||
// Language
|
||||
if ($searchPageLanguage != -1 && strlen($searchPageLanguage) >= 1) {
|
||||
$where[] = 's.page_language = ' . (int)$searchPageLanguage;
|
||||
}
|
||||
|
||||
// Depth
|
||||
if ($searchPageDepth != -1 && strlen($searchPageDepth) >= 1) {
|
||||
$where[] = 's.page_depth = ' . (int)$searchPageDepth;
|
||||
}
|
||||
|
||||
if ($searchIsBlacklisted) {
|
||||
$where[] = 's.is_blacklisted = 1';
|
||||
}
|
||||
|
||||
// Filter blacklisted page types
|
||||
$where[] = DatabaseUtility::conditionNotIn(
|
||||
'p.doktype',
|
||||
SitemapUtility::getDoktypeBlacklist()
|
||||
);
|
||||
|
||||
// Build where
|
||||
$where = DatabaseUtility::buildCondition($where);
|
||||
|
||||
// ############################
|
||||
// Pager
|
||||
// ############################
|
||||
|
||||
// Fetch total count of items with this filter settings
|
||||
$query = 'SELECT COUNT(*) AS count
|
||||
FROM tx_metaseo_sitemap s
|
||||
INNER JOIN pages p ON p.uid = s.page_uid
|
||||
WHERE ' . $where;
|
||||
$itemCount = DatabaseUtility::getOne($query);
|
||||
|
||||
// ############################
|
||||
// Sort
|
||||
// ############################
|
||||
// default sort
|
||||
$sort = 's.page_depth ASC, s.page_uid ASC';
|
||||
|
||||
if (!empty($this->sortField) && !empty($this->sortDir)) {
|
||||
// already filtered
|
||||
$sort = $this->sortField . ' ' . $this->sortDir;
|
||||
}
|
||||
|
||||
// ############################
|
||||
// Fetch sitemap
|
||||
// ############################
|
||||
$query = 'SELECT s.uid,
|
||||
s.page_rootpid,
|
||||
s.page_uid,
|
||||
s.page_language,
|
||||
s.page_url,
|
||||
s.page_depth,
|
||||
s.page_type,
|
||||
s.is_blacklisted,
|
||||
p.tx_metaseo_is_exclude,
|
||||
FROM_UNIXTIME(s.tstamp) as tstamp,
|
||||
FROM_UNIXTIME(s.crdate) as crdate
|
||||
FROM tx_metaseo_sitemap s
|
||||
INNER JOIN pages p ON p.uid = s.page_uid
|
||||
WHERE ' . $where . '
|
||||
ORDER BY ' . $sort . '
|
||||
LIMIT ' . (int)$offset . ', ' . (int)$itemsPerPage;
|
||||
$list = DatabaseUtility::getAll($query);
|
||||
|
||||
return array(
|
||||
'results' => $itemCount,
|
||||
'rows' => $list,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function blacklistAction($params = array(), AjaxRequestHandler &$ajaxObj = null)
|
||||
{
|
||||
try {
|
||||
$this->init();
|
||||
$ajaxObj->setContent($this->executeBlacklist());
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxExceptionHandler($exception, $ajaxObj);
|
||||
}
|
||||
|
||||
$ajaxObj->setContentFormat(self::CONTENT_FORMAT_JSON);
|
||||
$ajaxObj->render();
|
||||
}
|
||||
|
||||
/*
|
||||
* Blacklist sitemap entries
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws AjaxException
|
||||
*/
|
||||
protected function executeBlacklist()
|
||||
{
|
||||
$uidList = $this->postVar['uidList'];
|
||||
$rootPid = (int)$this->postVar['pid'];
|
||||
|
||||
$uidList = DatabaseUtility::connection()->cleanIntArray($uidList);
|
||||
|
||||
if (empty($uidList) || empty($rootPid)) {
|
||||
|
||||
throw new AjaxException(
|
||||
'message.warning.incomplete_data_received.message',
|
||||
'[0x4FBF3C10]',
|
||||
HttpUtility::HTTP_STATUS_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
$where = array();
|
||||
$where[] = 'page_rootpid = ' . (int)$rootPid;
|
||||
$where[] = DatabaseUtility::conditionIn('uid', $uidList);
|
||||
$where = DatabaseUtility::buildCondition($where);
|
||||
|
||||
$query = 'UPDATE tx_metaseo_sitemap
|
||||
SET is_blacklisted = 1
|
||||
WHERE ' . $where;
|
||||
DatabaseUtility::exec($query);
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function whitelistAction($params = array(), AjaxRequestHandler &$ajaxObj = null)
|
||||
{
|
||||
try {
|
||||
$this->init();
|
||||
$ajaxObj->setContent($this->executeWhitelist());
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxExceptionHandler($exception, $ajaxObj);
|
||||
}
|
||||
|
||||
$ajaxObj->setContentFormat(self::CONTENT_FORMAT_JSON);
|
||||
$ajaxObj->render();
|
||||
}
|
||||
|
||||
/*
|
||||
* Whitelist sitemap entries
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws AjaxException
|
||||
*/
|
||||
protected function executeWhitelist()
|
||||
{
|
||||
$uidList = $this->postVar['uidList'];
|
||||
$rootPid = (int)$this->postVar['pid'];
|
||||
|
||||
$uidList = DatabaseUtility::connection()->cleanIntArray($uidList);
|
||||
|
||||
if (empty($uidList) || empty($rootPid)) {
|
||||
|
||||
throw new AjaxException(
|
||||
'message.warning.incomplete_data_received.message',
|
||||
'[0x4FBF3C12]',
|
||||
HttpUtility::HTTP_STATUS_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
$where = array();
|
||||
$where[] = 'page_rootpid = ' . (int)$rootPid;
|
||||
$where[] = DatabaseUtility::conditionIn('uid', $uidList);
|
||||
$where = DatabaseUtility::buildCondition($where);
|
||||
|
||||
$query = 'UPDATE tx_metaseo_sitemap
|
||||
SET is_blacklisted = 0
|
||||
WHERE ' . $where;
|
||||
DatabaseUtility::exec($query);
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function deleteAction($params = array(), AjaxRequestHandler &$ajaxObj = null)
|
||||
{
|
||||
try {
|
||||
$this->init();
|
||||
$ajaxObj->setContent($this->executeDelete());
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxExceptionHandler($exception, $ajaxObj);
|
||||
}
|
||||
|
||||
$ajaxObj->setContentFormat(self::CONTENT_FORMAT_JSON);
|
||||
$ajaxObj->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete sitemap entries
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws AjaxException
|
||||
*/
|
||||
protected function executeDelete()
|
||||
{
|
||||
$uidList = $this->postVar['uidList'];
|
||||
$rootPid = (int)$this->postVar['pid'];
|
||||
|
||||
$uidList = DatabaseUtility::connection()->cleanIntArray($uidList);
|
||||
|
||||
if (empty($uidList) || empty($rootPid)) {
|
||||
|
||||
throw new AjaxException(
|
||||
'message.warning.incomplete_data_received.message',
|
||||
'[0x4FBF3C11]',
|
||||
HttpUtility::HTTP_STATUS_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
$where = array();
|
||||
$where[] = 'page_rootpid = ' . (int)$rootPid;
|
||||
$where[] = DatabaseUtility::conditionIn('uid', $uidList);
|
||||
$where = DatabaseUtility::buildCondition($where);
|
||||
|
||||
$query = 'DELETE FROM tx_metaseo_sitemap
|
||||
WHERE ' . $where;
|
||||
DatabaseUtility::exec($query);
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function deleteAllAction($params = array(), AjaxRequestHandler &$ajaxObj = null)
|
||||
{
|
||||
try {
|
||||
$this->init();
|
||||
$ajaxObj->setContent($this->executeDeleteAll());
|
||||
} catch (Exception $exception) {
|
||||
$this->ajaxExceptionHandler($exception, $ajaxObj);
|
||||
}
|
||||
|
||||
$ajaxObj->setContentFormat(self::CONTENT_FORMAT_JSON);
|
||||
$ajaxObj->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all sitemap entries
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws AjaxException
|
||||
*/
|
||||
protected function executeDeleteAll()
|
||||
{
|
||||
$rootPid = (int)$this->postVar['pid'];
|
||||
|
||||
if (empty($rootPid)) {
|
||||
|
||||
throw new AjaxException(
|
||||
'message.warning.incomplete_data_received.message',
|
||||
'[0x4FBF3C12]',
|
||||
HttpUtility::HTTP_STATUS_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
$where = array();
|
||||
$where[] = 'page_rootpid = ' . (int)$rootPid;
|
||||
$where = DatabaseUtility::buildCondition($where);
|
||||
|
||||
$query = 'DELETE FROM tx_metaseo_sitemap
|
||||
WHERE ' . $where;
|
||||
DatabaseUtility::exec($query);
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getAjaxPrefix()
|
||||
{
|
||||
return self::AJAX_PREFIX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of classes which contain Ajax controllers with <ajaxPrefix> => <className)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getBackendAjaxClassNames()
|
||||
{
|
||||
return array(
|
||||
self::AJAX_PREFIX => __CLASS__,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?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;
|
||||
|
||||
use TYPO3\CMS\Core\Http\AjaxRequestHandler;
|
||||
|
||||
interface SitemapInterface
|
||||
{
|
||||
/**
|
||||
* Executes an AJAX request which displays the data (usually as a list)
|
||||
*
|
||||
* @param array $params Array of parameters from the AJAX interface, currently unused (as of 6.2.14)
|
||||
* becomes available starting with 7.4.0 (c048cede,
|
||||
* https://forge.typo3.org/issues/68186)
|
||||
* @param AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function indexAction($params = array(), AjaxRequestHandler &$ajaxObj = null);
|
||||
|
||||
/**
|
||||
* Blacklists a sitemap entry so that it does not appear in the sitemap presented to search engines
|
||||
*
|
||||
* @param array $params Array of parameters from the AJAX interface, currently unused (as of 6.2.14)
|
||||
* becomes available starting with 7.4.0 (c048cede,
|
||||
* https://forge.typo3.org/issues/68186)
|
||||
* @param AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function blacklistAction($params = array(), AjaxRequestHandler &$ajaxObj = null);
|
||||
|
||||
/**
|
||||
* Undoes the blacklist operation
|
||||
*
|
||||
* @param array $params Array of parameters from the AJAX interface, currently unused (as of 6.2.14)
|
||||
* becomes available starting with 7.4.0 (c048cede,
|
||||
* https://forge.typo3.org/issues/68186)
|
||||
* @param AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function whitelistAction($params = array(), AjaxRequestHandler &$ajaxObj = null);
|
||||
|
||||
/**
|
||||
* Deletes an entry from the sitemap. Entry will reappear as soon as it's indexed again
|
||||
*
|
||||
* @param array $params Array of parameters from the AJAX interface, currently unused (as of 6.2.14)
|
||||
* becomes available starting with 7.4.0 (c048cede,
|
||||
* https://forge.typo3.org/issues/68186)
|
||||
* @param AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteAction($params = array(), AjaxRequestHandler &$ajaxObj = null);
|
||||
|
||||
/**
|
||||
* Performs delete operation for all the entries in the sitemap
|
||||
*
|
||||
* @param array $params Array of parameters from the AJAX interface, currently unused (as of 6.2.14)
|
||||
* becomes available starting with 7.4.0 (c048cede,
|
||||
* https://forge.typo3.org/issues/68186)
|
||||
* @param AjaxRequestHandler $ajaxObj Object of type AjaxRequestHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteAllAction($params = array(), AjaxRequestHandler &$ajaxObj = null);
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user