Initial commit
This commit is contained in:
@@ -0,0 +1,227 @@
|
||||
<?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;
|
||||
|
||||
use Exception;
|
||||
use Metaseo\Metaseo\DependencyInjection\Utility\HttpUtility;
|
||||
use Metaseo\Metaseo\Exception\Ajax\AjaxException;
|
||||
use TYPO3\CMS\Core\Http\AjaxRequestHandler;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
|
||||
/**
|
||||
* TYPO3 Backend ajax module base
|
||||
*/
|
||||
abstract class AbstractAjaxController
|
||||
{
|
||||
const CONTENT_FORMAT_JSON = 'json';
|
||||
|
||||
/**
|
||||
* Json status indicators
|
||||
*/
|
||||
const JSON_ERROR = 'error';
|
||||
const JSON_ERROR_NUMBER = 'errorNumber';
|
||||
|
||||
// ########################################################################
|
||||
// Attributes
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* POST vars (transformed from json)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $postVar;
|
||||
|
||||
/**
|
||||
* Sorting field
|
||||
*/
|
||||
protected $sortField;
|
||||
|
||||
/**
|
||||
* Sorting dir
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $sortDir;
|
||||
|
||||
/**
|
||||
* TYPO3 Object manager
|
||||
*
|
||||
* @var \TYPO3\CMS\Extbase\Object\ObjectManager
|
||||
*/
|
||||
protected $objectManager;
|
||||
|
||||
// ########################################################################
|
||||
// Methods
|
||||
// ########################################################################
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->postVar = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect and process POST vars and stores them into $this->postVars
|
||||
*/
|
||||
protected function fetchParams()
|
||||
{
|
||||
$rawPostVarList = GeneralUtility::_POST();
|
||||
foreach ($rawPostVarList as $key => $value) {
|
||||
$this->postVar[$key] = json_decode($value);
|
||||
}
|
||||
|
||||
// Sorting data
|
||||
if (!empty($rawPostVarList['sort'])) {
|
||||
$this->sortField = $this->escapeSortField((string)$rawPostVarList['sort']);
|
||||
}
|
||||
|
||||
if (!empty($rawPostVarList['dir'])) {
|
||||
switch (strtoupper($rawPostVarList['dir'])) {
|
||||
case 'ASC':
|
||||
$this->sortDir = 'ASC';
|
||||
break;
|
||||
case 'DESC':
|
||||
$this->sortDir = 'DESC';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape for sql sort fields
|
||||
*
|
||||
* @param string $value Sort value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function escapeSortField($value)
|
||||
{
|
||||
return preg_replace('[^_a-zA-Z]', '', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Init
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
$this->fetchParams();
|
||||
|
||||
// Include ajax local lang
|
||||
$this->getLanguageService()->includeLLFile('EXT:metaseo/Resources/Private/Language/locallang.xlf');
|
||||
|
||||
if (!isset($this->objectManager)) {
|
||||
$this->objectManager = GeneralUtility::makeInstance(
|
||||
'TYPO3\\CMS\\Extbase\\Object\\ObjectManager'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getAjaxPrefix();
|
||||
|
||||
/**
|
||||
* Returns a json formatted error response with http error status specified in the Exception
|
||||
* The message is created with $ajaxObj->setContent instead of setError because $ajaxObj->setError
|
||||
* always sets http status 500 and does not respect content format.
|
||||
*
|
||||
* @param Exception $exception
|
||||
* @param AjaxRequestHandler $ajaxObj
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function ajaxExceptionHandler(Exception $exception, AjaxRequestHandler &$ajaxObj)
|
||||
{
|
||||
$responseArray = array();
|
||||
if ($exception instanceof AjaxException) {
|
||||
$responseArray[self::JSON_ERROR] = $this->translate($exception->getMessage());
|
||||
$this->getHttpUtility()->sendHttpHeader($exception->getHttpStatus());
|
||||
$errorCode = $exception->getCode();
|
||||
if (!empty($errorCode)) {
|
||||
$responseArray[self::JSON_ERROR_NUMBER] = $exception->getCode();
|
||||
}
|
||||
} else {
|
||||
$responseArray[self::JSON_ERROR] = $exception->getMessage();
|
||||
$this->getHttpUtility()->sendHttpHeader(HttpUtility::HTTP_STATUS_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
$ajaxObj->setContent($responseArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a key to the current chosen language
|
||||
*
|
||||
* @param $messageKey string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function translate($messageKey)
|
||||
{
|
||||
return $this
|
||||
->getLanguageService()
|
||||
->getLL($messageKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the TYPO3 CMS LanguageService
|
||||
*
|
||||
* @return \TYPO3\CMS\Lang\LanguageService
|
||||
*/
|
||||
protected function getLanguageService()
|
||||
{
|
||||
return $GLOBALS['LANG'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
|
||||
*/
|
||||
protected function getBackendUserAuthentication()
|
||||
{
|
||||
return $GLOBALS['BE_USER'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HttpUtility
|
||||
*/
|
||||
protected function getHttpUtility()
|
||||
{
|
||||
return $this->objectManager->get('Metaseo\\Metaseo\\DependencyInjection\\Utility\\HttpUtility');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ObjectManager $objectManager
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setObjectManager(ObjectManager $objectManager)
|
||||
{
|
||||
$this->objectManager = $objectManager;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
<?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;
|
||||
|
||||
use Metaseo\Metaseo\Backend\Module\AbstractStandardModule;
|
||||
use Metaseo\Metaseo\Utility\BackendUtility;
|
||||
use Metaseo\Metaseo\Utility\DatabaseUtility;
|
||||
use Metaseo\Metaseo\Utility\RootPageUtility;
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility as Typo3BackendUtility;
|
||||
use TYPO3\CMS\Core\Messaging\FlashMessage;
|
||||
|
||||
/**
|
||||
* TYPO3 Backend module root settings
|
||||
*/
|
||||
class BackendControlCenterController extends AbstractStandardModule
|
||||
{
|
||||
// ########################################################################
|
||||
// Attributes
|
||||
// ########################################################################
|
||||
|
||||
// ########################################################################
|
||||
// Methods
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* Main action
|
||||
*/
|
||||
public function mainAction()
|
||||
{
|
||||
// #################
|
||||
// Root page list
|
||||
// #################
|
||||
|
||||
$rootPageList = BackendUtility::getRootPageList();
|
||||
$rootIdList = array_keys($rootPageList);
|
||||
|
||||
$rootPidCondition = null;
|
||||
if (!empty($rootIdList)) {
|
||||
$rootPidCondition = 'p.uid IN (' . implode(',', $rootIdList) . ')';
|
||||
} else {
|
||||
$rootPidCondition = '1=0';
|
||||
}
|
||||
|
||||
// #################
|
||||
// Root setting list (w/ automatic creation)
|
||||
// #################
|
||||
|
||||
// check which root pages have no root settings
|
||||
$query = 'SELECT p.uid
|
||||
FROM pages p
|
||||
LEFT JOIN tx_metaseo_setting_root seosr
|
||||
ON seosr.pid = p.uid
|
||||
AND seosr.deleted = 0
|
||||
WHERE ' . $rootPidCondition . '
|
||||
AND seosr.uid IS NULL';
|
||||
$rowList = DatabaseUtility::getAll($query);
|
||||
foreach ($rowList as $row) {
|
||||
$tmpUid = $row['uid'];
|
||||
$query = 'INSERT INTO tx_metaseo_setting_root (pid, tstamp, crdate, cruser_id)
|
||||
VALUES (' . (int)$tmpUid . ',
|
||||
' . (int)time() . ',
|
||||
' . (int)time() . ',
|
||||
' . (int)$GLOBALS['BE_USER']->user['uid'] . ')';
|
||||
DatabaseUtility::execInsert($query);
|
||||
}
|
||||
|
||||
$rootSettingList = BackendUtility::getRootPageSettingList();
|
||||
|
||||
// #################
|
||||
// Domain list
|
||||
// ##################
|
||||
|
||||
// Fetch domain name
|
||||
$query = 'SELECT uid,
|
||||
pid,
|
||||
domainName,
|
||||
forced
|
||||
FROM sys_domain
|
||||
WHERE hidden = 0
|
||||
ORDER BY forced DESC,
|
||||
sorting';
|
||||
$rowList = DatabaseUtility::getAll($query);
|
||||
|
||||
$domainList = array();
|
||||
foreach ($rowList as $row) {
|
||||
$domainList[$row['pid']][$row['uid']] = $row;
|
||||
}
|
||||
|
||||
// #################
|
||||
// Build root page list
|
||||
// #################
|
||||
|
||||
unset($page);
|
||||
foreach ($rootPageList as $pageId => &$page) {
|
||||
// Domain list
|
||||
$page['domainList'] = '';
|
||||
if (!empty($domainList[$pageId])) {
|
||||
$page['domainList'] = $domainList[$pageId];
|
||||
}
|
||||
|
||||
// Settings
|
||||
$page['rootSettings'] = array();
|
||||
if (!empty($rootSettingList[$pageId])) {
|
||||
$page['rootSettings'] = $rootSettingList[$pageId];
|
||||
}
|
||||
|
||||
// Settings available
|
||||
$page['settingsLink'] = Typo3BackendUtility::editOnClick(
|
||||
'&edit[tx_metaseo_setting_root][' . $rootSettingList[$pageId]['uid'] . ']=edit'
|
||||
);
|
||||
|
||||
$page['sitemapLink'] = RootPageUtility::getSitemapIndexUrl($pageId);
|
||||
$page['robotsTxtLink'] = RootPageUtility::getRobotsTxtUrl($pageId);
|
||||
}
|
||||
unset($page);
|
||||
|
||||
// check if there is any root page
|
||||
if (empty($rootPageList)) {
|
||||
$this->addFlashMessage(
|
||||
$this->translate('message.warning.noRootPage.message'),
|
||||
$this->translate('message.warning.noRootPage.title'),
|
||||
FlashMessage::WARNING
|
||||
);
|
||||
}
|
||||
|
||||
$this->view->assign('RootPageList', $rootPageList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
<?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;
|
||||
|
||||
use Metaseo\Metaseo\Backend\Module\AbstractStandardModule;
|
||||
use Metaseo\Metaseo\Controller\Ajax\AbstractPageSeoController;
|
||||
use Metaseo\Metaseo\Controller\Ajax\PageSeo\GeoController;
|
||||
use Metaseo\Metaseo\Controller\Ajax\PageSeo\MetaDataController;
|
||||
use Metaseo\Metaseo\Controller\Ajax\PageSeo\PageTitleController;
|
||||
use Metaseo\Metaseo\Controller\Ajax\PageSeo\PageTitleSimController;
|
||||
use Metaseo\Metaseo\Controller\Ajax\PageSeo\SearchEnginesController;
|
||||
use Metaseo\Metaseo\Controller\Ajax\PageSeo\UrlController;
|
||||
use Metaseo\Metaseo\Utility\DatabaseUtility;
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
use TYPO3\CMS\Backend\Utility\IconUtility;
|
||||
use TYPO3\CMS\Core\Messaging\FlashMessage;
|
||||
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* TYPO3 Backend module page seo
|
||||
*/
|
||||
class BackendPageSeoController extends AbstractStandardModule
|
||||
{
|
||||
// ########################################################################
|
||||
// Attributes
|
||||
// ########################################################################
|
||||
|
||||
// ########################################################################
|
||||
// Methods
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* Main action
|
||||
*/
|
||||
public function mainAction()
|
||||
{
|
||||
$this->handleSubAction(MetaDataController::LIST_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Geo action
|
||||
*/
|
||||
public function geoAction()
|
||||
{
|
||||
$this->handleSubAction(GeoController::LIST_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* searchengines action
|
||||
*/
|
||||
public function searchenginesAction()
|
||||
{
|
||||
$this->handleSubAction(SearchEnginesController::LIST_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* url action
|
||||
*/
|
||||
public function urlAction()
|
||||
{
|
||||
$this->handleSubAction(UrlController::LIST_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* pagetitle action
|
||||
*/
|
||||
public function pagetitleAction()
|
||||
{
|
||||
$this->handleSubAction(PageTitleController::LIST_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* pagetitlesim action
|
||||
*/
|
||||
public function pagetitlesimAction()
|
||||
{
|
||||
$this->handleSubAction(PageTitleSimController::LIST_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $listType
|
||||
*/
|
||||
protected function handleSubAction($listType)
|
||||
{
|
||||
$pageId = (int) GeneralUtility::_GP('id');
|
||||
|
||||
if (empty($pageId)) {
|
||||
$this->addFlashMessage(
|
||||
$this->translate('message.warning.no_valid_page.message'),
|
||||
$this->translate('message.warning.no_valid_page.title'),
|
||||
FlashMessage::WARNING
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Load PageTS
|
||||
$pageTsConf = BackendUtility::getPagesTSconfig($pageId);
|
||||
|
||||
// Build language list
|
||||
$defaultLanguageText = $this->translate('default.language');
|
||||
|
||||
$languageFullList = array(
|
||||
0 => array(
|
||||
'label' => $this->translate('default.language'),
|
||||
'flag' => '',
|
||||
),
|
||||
);
|
||||
|
||||
if (!empty($pageTsConf['mod.']['SHARED.']['defaultLanguageFlag'])) {
|
||||
$languageFullList[0]['flag'] = $pageTsConf['mod.']['SHARED.']['defaultLanguageFlag'];
|
||||
}
|
||||
|
||||
if (!empty($pageTsConf['mod.']['SHARED.']['defaultLanguageLabel'])) {
|
||||
$label = $pageTsConf['mod.']['SHARED.']['defaultLanguageLabel'];
|
||||
|
||||
$languageFullList[0]['label'] = $this->translate('default.language.named', array($label));
|
||||
|
||||
$defaultLanguageText = $pageTsConf['mod.']['SHARED.']['defaultLanguageLabel'];
|
||||
}
|
||||
|
||||
// Fetch other flags
|
||||
$query = 'SELECT uid,
|
||||
title,
|
||||
flag
|
||||
FROM sys_language
|
||||
WHERE hidden = 0';
|
||||
$rowList = DatabaseUtility::getAll($query);
|
||||
foreach ($rowList as $row) {
|
||||
$languageFullList[$row['uid']] = array(
|
||||
'label' => htmlspecialchars($row['title']),
|
||||
'flag' => htmlspecialchars($row['flag']),
|
||||
);
|
||||
}
|
||||
|
||||
// Languages
|
||||
$languageList = array();
|
||||
|
||||
foreach ($languageFullList as $langId => $langRow) {
|
||||
$flag = '';
|
||||
|
||||
// Flag (if available)
|
||||
if (!empty($langRow['flag'])) {
|
||||
$flag .= '<span class="t3-icon t3-icon-flags t3-icon-flags-' . $langRow['flag']
|
||||
. ' t3-icon-' . $langRow['flag'] . '"></span>';
|
||||
$flag .= ' ';
|
||||
}
|
||||
|
||||
// label
|
||||
$label = $langRow['label'];
|
||||
|
||||
$languageList[] = array(
|
||||
$langId,
|
||||
$label,
|
||||
$flag
|
||||
);
|
||||
}
|
||||
|
||||
$sysLanguageDefault = (int)$GLOBALS['BE_USER']->getSessionData('MetaSEO.sysLanguage');
|
||||
|
||||
if (empty($sysLanguageDefault)) {
|
||||
$sysLanguageDefault = 0;
|
||||
}
|
||||
|
||||
// ############################
|
||||
// HTML
|
||||
// ############################
|
||||
|
||||
$realUrlAvailable = ExtensionManagementUtility::isLoaded('realurl');
|
||||
|
||||
$ajaxController = AbstractPageSeoController::AJAX_PREFIX . $listType;
|
||||
|
||||
if (!array_key_exists($ajaxController, AbstractPageSeoController::getBackendAjaxClassNames())) {
|
||||
throw new \RuntimeException('Ajax controller with this name was not registered by MetaSEO.');
|
||||
}
|
||||
|
||||
$metaSeoConf = array(
|
||||
'ajaxController' => $ajaxController,
|
||||
'pid' => (int)$pageId,
|
||||
'renderTo' => 'tx-metaseo-sitemap-grid',
|
||||
'pagingSize' => 50,
|
||||
'depth' => 2,
|
||||
'sortField' => 'crdate',
|
||||
'sortDir' => 'DESC',
|
||||
'filterIcon' => IconUtility::getSpriteIcon(
|
||||
'actions-system-tree-search-open'
|
||||
),
|
||||
'dataLanguage' => $languageList,
|
||||
'sysLanguage' => $sysLanguageDefault,
|
||||
'listType' => $listType,
|
||||
'criteriaFulltext' => '',
|
||||
'realurlAvailable' => $realUrlAvailable,
|
||||
'sprite' => array(
|
||||
'edit' => IconUtility::getSpriteIcon('actions-document-open'),
|
||||
'info' => IconUtility::getSpriteIcon('actions-document-info'),
|
||||
'editor' => IconUtility::getSpriteIcon('actions-system-options-view'),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
$metaSeoLang = array(
|
||||
'pagingMessage' => 'pager.results',
|
||||
'pagingEmpty' => 'pager.noresults',
|
||||
'boolean_yes' => 'boolean.yes',
|
||||
'boolean_no' => 'boolean.no',
|
||||
'button_save' => 'button.save',
|
||||
'button_saverecursively' => 'button.saverecursively',
|
||||
'button_saverecursively_tooltip' => 'button.saverecursively.tooltip',
|
||||
'button_cancel' => 'button.cancel',
|
||||
'labelDepth' => 'label.depth',
|
||||
'labelSearchFulltext' => 'label.search.fulltext',
|
||||
'emptySearchFulltext' => 'empty.search.fulltext',
|
||||
'labelSearchPageLanguage' => 'label.search.page_language',
|
||||
'emptySearchPageLanguage' => '',
|
||||
'page_uid' => 'header.sitemap.page_uid',
|
||||
'page_title' => 'header.sitemap.page_title',
|
||||
'page_keywords' => 'header.sitemap.page_keywords',
|
||||
'page_description' => 'header.sitemap.page_description',
|
||||
'page_abstract' => 'header.sitemap.page_abstract',
|
||||
'page_author' => 'header.sitemap.page_author',
|
||||
'page_author_email' => 'header.sitemap.page_author_email',
|
||||
'page_lastupdated' => 'header.sitemap.page_lastupdated',
|
||||
'page_geo_lat' => 'header.sitemap.page_geo_lat',
|
||||
'page_geo_long' => 'header.sitemap.page_geo_long',
|
||||
'page_geo_place' => 'header.sitemap.page_geo_place',
|
||||
'page_geo_region' => 'header.sitemap.page_geo_region',
|
||||
'page_tx_metaseo_pagetitle' => 'header.sitemap.page_tx_metaseo_pagetitle',
|
||||
'page_tx_metaseo_pagetitle_rel' => 'header.sitemap.page_tx_metaseo_pagetitle_rel',
|
||||
'page_tx_metaseo_pagetitle_prefix' => 'header.sitemap.page_tx_metaseo_pagetitle_prefix',
|
||||
'page_tx_metaseo_pagetitle_suffix' => 'header.sitemap.page_tx_metaseo_pagetitle_suffix',
|
||||
'page_title_simulated' => 'header.pagetitlesim.title_simulated',
|
||||
'page_searchengine_canonicalurl' => 'header.searchengine_canonicalurl',
|
||||
'page_searchengine_is_exclude' => 'header.searchengine_is_excluded',
|
||||
'searchengine_is_exclude_disabled' => 'searchengine.is_exclude_disabled',
|
||||
'searchengine_is_exclude_enabled' => 'searchengine.is_exclude_enabled',
|
||||
'page_sitemap_priority' => 'header.sitemap.priority',
|
||||
'page_url_scheme' => 'header.url_scheme',
|
||||
'page_url_scheme_default' => 'page.url_scheme_default',
|
||||
'page_url_scheme_http' => 'page.url_scheme_http',
|
||||
'page_url_scheme_https' => 'page.url_scheme_https',
|
||||
'page_url_alias' => 'header.url_alias',
|
||||
'page_url_realurl_pathsegment' => 'header.url_realurl_pathsegment',
|
||||
'page_url_realurl_pathoverride' => 'header.url_realurl_pathoverride',
|
||||
'page_url_realurl_exclude' => 'header.url_realurl_exclude',
|
||||
'qtip_pagetitle_simulate' => 'qtip.pagetitle_simulate',
|
||||
'qtip_url_simulate' => 'qtip.url_simulate',
|
||||
'metaeditor_title' => 'metaeditor.title',
|
||||
'metaeditor_tab_opengraph' => 'metaeditor.tab.opengraph',
|
||||
'metaeditor_button_hin' => 'metaeditor.button.hint',
|
||||
'value_from_base' => 'value.from_base',
|
||||
'value_from_overlay' => 'value.from_overlay',
|
||||
'value_only_base' => 'value.only_base',
|
||||
'value_default' => 'value_default',
|
||||
);
|
||||
|
||||
// translate list
|
||||
$metaSeoLang = $this->translateList($metaSeoLang);
|
||||
$metaSeoLang['emptySearchPageLanguage'] = $defaultLanguageText;
|
||||
|
||||
$this->view->assign(
|
||||
'JavaScript',
|
||||
'Ext.namespace("MetaSeo.overview");
|
||||
MetaSeo.overview.conf = ' . json_encode($metaSeoConf) . ';
|
||||
MetaSeo.overview.conf.lang = ' . json_encode($metaSeoLang) . ';
|
||||
'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
<?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;
|
||||
|
||||
use Metaseo\Metaseo\Backend\Module\AbstractStandardModule;
|
||||
use Metaseo\Metaseo\Utility\BackendUtility;
|
||||
use Metaseo\Metaseo\Utility\DatabaseUtility;
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility as Typo3BackendUtility;
|
||||
use TYPO3\CMS\Core\Messaging\FlashMessage;
|
||||
|
||||
/**
|
||||
* TYPO3 Backend module root settings
|
||||
*/
|
||||
class BackendRootSettingsController extends AbstractStandardModule
|
||||
{
|
||||
// ########################################################################
|
||||
// Attributes
|
||||
// ########################################################################
|
||||
|
||||
// ########################################################################
|
||||
// Methods
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* Main action
|
||||
*/
|
||||
public function mainAction()
|
||||
{
|
||||
// #################
|
||||
// Root page list
|
||||
// #################
|
||||
|
||||
$rootPageList = BackendUtility::getRootPageList();
|
||||
$rootIdList = array_keys($rootPageList);
|
||||
|
||||
$rootPidCondition = null;
|
||||
if (!empty($rootIdList)) {
|
||||
$rootPidCondition = 'p.uid IN (' . implode(',', $rootIdList) . ')';
|
||||
} else {
|
||||
$rootPidCondition = '1=0';
|
||||
}
|
||||
|
||||
// #################
|
||||
// Root setting list (w/ automatic creation)
|
||||
// #################
|
||||
|
||||
// check which root pages have no root settings
|
||||
$query = 'SELECT p.uid
|
||||
FROM pages p
|
||||
LEFT JOIN tx_metaseo_setting_root seosr
|
||||
ON seosr.pid = p.uid
|
||||
AND seosr.deleted = 0
|
||||
WHERE ' . $rootPidCondition . '
|
||||
AND seosr.uid IS NULL';
|
||||
$uidList = DatabaseUtility::getCol($query);
|
||||
foreach ($uidList as $tmpUid) {
|
||||
$query = 'INSERT INTO tx_metaseo_setting_root (pid, tstamp, crdate, cruser_id)
|
||||
VALUES (' . (int)$tmpUid . ',
|
||||
' . (int)time() . ',
|
||||
' . (int)time() . ',
|
||||
' . (int)$GLOBALS['BE_USER']->user['uid'] . ')';
|
||||
DatabaseUtility::execInsert($query);
|
||||
}
|
||||
|
||||
$rootSettingList = BackendUtility::getRootPageSettingList();
|
||||
|
||||
// #################
|
||||
// Domain list
|
||||
// ##################
|
||||
|
||||
// Fetch domain name
|
||||
$query = 'SELECT uid,
|
||||
pid,
|
||||
domainName,
|
||||
forced
|
||||
FROM sys_domain
|
||||
WHERE hidden = 0
|
||||
ORDER BY forced DESC,
|
||||
sorting';
|
||||
$rowList = DatabaseUtility::getAll($query);
|
||||
|
||||
$domainList = array();
|
||||
foreach ($rowList as $row) {
|
||||
$domainList[$row['pid']][$row['uid']] = $row;
|
||||
}
|
||||
|
||||
// #################
|
||||
// Build root page list
|
||||
// #################
|
||||
|
||||
unset($page);
|
||||
foreach ($rootPageList as $pageId => &$page) {
|
||||
// Domain list
|
||||
$page['domainList'] = '';
|
||||
if (!empty($domainList[$pageId])) {
|
||||
$page['domainList'] = $domainList[$pageId];
|
||||
}
|
||||
|
||||
// Settings
|
||||
$page['rootSettings'] = array();
|
||||
if (!empty($rootSettingList[$pageId])) {
|
||||
$page['rootSettings'] = $rootSettingList[$pageId];
|
||||
}
|
||||
|
||||
// Settings available
|
||||
$page['settingsLink'] = Typo3BackendUtility::editOnClick(
|
||||
'&edit[tx_metaseo_setting_root][' . $rootSettingList[$pageId]['uid'] . ']=edit'
|
||||
);
|
||||
}
|
||||
unset($page);
|
||||
|
||||
// check if there is any root page
|
||||
if (empty($rootPageList)) {
|
||||
$this->addFlashMessage(
|
||||
$this->translate('message.warning.noRootPage.message'),
|
||||
$this->translate('message.warning.noRootPage.title'),
|
||||
FlashMessage::WARNING
|
||||
);
|
||||
}
|
||||
|
||||
$this->view->assign('RootPageList', $rootPageList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
<?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;
|
||||
|
||||
use Metaseo\Metaseo\Backend\Module\AbstractStandardModule;
|
||||
use Metaseo\Metaseo\Controller\Ajax\SitemapController;
|
||||
use Metaseo\Metaseo\Utility\BackendUtility;
|
||||
use Metaseo\Metaseo\Utility\DatabaseUtility;
|
||||
use Metaseo\Metaseo\Utility\SitemapUtility;
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility as Typo3BackendUtility;
|
||||
use TYPO3\CMS\Backend\Utility\IconUtility;
|
||||
use TYPO3\CMS\Core\Messaging\FlashMessage;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* TYPO3 Backend module sitemap
|
||||
*/
|
||||
class BackendSitemapController extends AbstractStandardModule
|
||||
{
|
||||
// ########################################################################
|
||||
// Attributes
|
||||
// ########################################################################
|
||||
|
||||
// ########################################################################
|
||||
// Methods
|
||||
// ########################################################################
|
||||
|
||||
/**
|
||||
* Main action
|
||||
*/
|
||||
public function mainAction()
|
||||
{
|
||||
// Init
|
||||
$rootPageList = BackendUtility::getRootPageList();
|
||||
$rootSettingList = BackendUtility::getRootPageSettingList();
|
||||
|
||||
// ############################
|
||||
// Fetch
|
||||
// ############################
|
||||
|
||||
// Get statistics
|
||||
$query = 'SELECT s.page_rootpid,
|
||||
COUNT(*) AS sum_total,
|
||||
COUNT(s.page_uid) AS sum_pages
|
||||
FROM tx_metaseo_sitemap s
|
||||
INNER JOIN pages p
|
||||
ON p.uid = s.page_uid
|
||||
AND p.deleted = 0
|
||||
AND ' . DatabaseUtility::conditionNotIn(
|
||||
'p.doktype',
|
||||
SitemapUtility::getDoktypeBlacklist()
|
||||
) . '
|
||||
GROUP BY page_rootpid';
|
||||
$statsList = DatabaseUtility::getAllWithIndex($query, 'page_rootpid');
|
||||
|
||||
// Fetch domain name
|
||||
$query = 'SELECT uid,
|
||||
pid,
|
||||
domainName,
|
||||
forced
|
||||
FROM sys_domain
|
||||
WHERE hidden = 0
|
||||
ORDER BY forced DESC,
|
||||
sorting';
|
||||
$rowList = DatabaseUtility::getAll($query);
|
||||
|
||||
$domainList = array();
|
||||
foreach ($rowList as $row) {
|
||||
$pid = $row['pid'];
|
||||
|
||||
if (!empty($row['forced'])) {
|
||||
$domainList[$pid] = $row['domainName'];
|
||||
} elseif (empty($domainList[$pid])) {
|
||||
$domainList[$pid] = $row['domainName'];
|
||||
}
|
||||
}
|
||||
|
||||
// #################
|
||||
// Build root page list
|
||||
// #################
|
||||
|
||||
|
||||
unset($page);
|
||||
foreach ($rootPageList as $pageId => &$page) {
|
||||
$stats = array(
|
||||
'sum_pages' => 0,
|
||||
'sum_total' => 0,
|
||||
'sum_xml_pages' => 0,
|
||||
);
|
||||
|
||||
// Setting row
|
||||
$settingRow = array();
|
||||
if (!empty($rootSettingList[$pageId])) {
|
||||
$settingRow = $rootSettingList[$pageId];
|
||||
}
|
||||
|
||||
|
||||
// Calc stats
|
||||
if (!empty($statsList[$pageId])) {
|
||||
foreach ($statsList[$pageId] as $statsKey => $statsValue) {
|
||||
$stats[$statsKey] = $statsValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$joinWhere = DatabaseUtility::conditionNotIn(
|
||||
'p.doktype',
|
||||
SitemapUtility::getDoktypeBlacklist()
|
||||
);
|
||||
|
||||
// Root statistics
|
||||
$query = 'SELECT COUNT(s.page_uid)
|
||||
FROM tx_metaseo_sitemap s
|
||||
INNER JOIN pages p
|
||||
ON p.uid = s.page_uid
|
||||
AND ' . $joinWhere . '
|
||||
WHERE s.page_rootpid = ' . (int)$pageId;
|
||||
$stats['sum_pages'] = DatabaseUtility::getOne($query);
|
||||
|
||||
$pagesPerXmlSitemap = 1000;
|
||||
if (!empty($settingRow['sitemap_page_limit'])) {
|
||||
$pagesPerXmlSitemap = $settingRow['sitemap_page_limit'];
|
||||
}
|
||||
$sumXmlPages = ceil($stats['sum_total'] / $pagesPerXmlSitemap);
|
||||
$stats['sum_xml_pages'] = sprintf($this->translate('sitemap.xml.pages.total'), $sumXmlPages);
|
||||
|
||||
|
||||
$page['stats'] = $stats;
|
||||
}
|
||||
unset($page);
|
||||
|
||||
// check if there is any root page
|
||||
if (empty($rootPageList)) {
|
||||
$this->addFlashMessage(
|
||||
$this->translate('message.warning.noRootPage.message'),
|
||||
$this->translate('message.warning.noRootPage.title'),
|
||||
FlashMessage::WARNING
|
||||
);
|
||||
}
|
||||
|
||||
$this->view->assign('RootPageList', $rootPageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sitemap action
|
||||
*/
|
||||
public function sitemapAction()
|
||||
{
|
||||
$params = GeneralUtility::_GP('tx_metaseo_metaseometaseo_metaseositemap');
|
||||
$rootPid = $params['pageId'];
|
||||
|
||||
if (empty($rootPid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rootPageList = BackendUtility::getRootPageList();
|
||||
$rootPage = $rootPageList[$rootPid];
|
||||
|
||||
// ###############################
|
||||
// Fetch
|
||||
// ###############################
|
||||
$pageTsConf = Typo3BackendUtility::getPagesTSconfig($rootPid);
|
||||
|
||||
$languageFullList = array(
|
||||
0 => array(
|
||||
'label' => $this->translate('default.language'),
|
||||
'flag' => '',
|
||||
),
|
||||
);
|
||||
|
||||
if (!empty($pageTsConf['mod.']['SHARED.']['defaultLanguageFlag'])) {
|
||||
$languageFullList[0]['flag'] = $pageTsConf['mod.']['SHARED.']['defaultLanguageFlag'];
|
||||
}
|
||||
|
||||
if (!empty($pageTsConf['mod.']['SHARED.']['defaultLanguageLabel'])) {
|
||||
$languageFullList[0]['label'] = $pageTsConf['mod.']['SHARED.']['defaultLanguageLabel'];
|
||||
}
|
||||
|
||||
// Fetch domain name
|
||||
$query = 'SELECT uid,
|
||||
title,
|
||||
flag
|
||||
FROM sys_language
|
||||
WHERE hidden = 0';
|
||||
$rowList = DatabaseUtility::getAll($query);
|
||||
|
||||
foreach ($rowList as $row) {
|
||||
$languageFullList[$row['uid']] = array(
|
||||
'label' => htmlspecialchars($row['title']),
|
||||
'flag' => htmlspecialchars($row['flag']),
|
||||
);
|
||||
}
|
||||
|
||||
// Languages
|
||||
$languageList = array();
|
||||
$languageList[] = array(
|
||||
-1,
|
||||
$this->translate('empty.search.page_language'),
|
||||
);
|
||||
|
||||
foreach ($languageFullList as $langId => $langRow) {
|
||||
$flag = '';
|
||||
|
||||
// Flag (if available)
|
||||
if (!empty($langRow['flag'])) {
|
||||
$flag .= '<span class="t3-icon t3-icon-flags t3-icon-flags-' . $langRow['flag']
|
||||
. ' t3-icon-' . $langRow['flag'] . '"></span>';
|
||||
$flag .= ' ';
|
||||
}
|
||||
|
||||
// label
|
||||
$label = $langRow['label'];
|
||||
|
||||
$languageList[] = array(
|
||||
$langId,
|
||||
$label,
|
||||
$flag
|
||||
);
|
||||
}
|
||||
|
||||
// Depth
|
||||
$depthList = array();
|
||||
$depthList[] = array(
|
||||
-1,
|
||||
$this->translate('empty.search.page_depth'),
|
||||
);
|
||||
|
||||
$query = 'SELECT DISTINCT page_depth
|
||||
FROM tx_metaseo_sitemap
|
||||
WHERE page_rootpid = ' . (int)$rootPid;
|
||||
foreach (DatabaseUtility::getCol($query) as $depth) {
|
||||
$depthList[] = array(
|
||||
$depth,
|
||||
$depth,
|
||||
);
|
||||
}
|
||||
|
||||
// ###############################
|
||||
// Page/JS
|
||||
// ###############################
|
||||
|
||||
$metaSeoConf = array(
|
||||
'ajaxController' => SitemapController::AJAX_PREFIX,
|
||||
'pid' => (int)$rootPid,
|
||||
'renderTo' => 'tx-metaseo-sitemap-grid',
|
||||
'pagingSize' => 50,
|
||||
'sortField' => 'crdate',
|
||||
'sortDir' => 'DESC',
|
||||
'filterIcon' => IconUtility::getSpriteIcon(
|
||||
'actions-system-tree-search-open'
|
||||
),
|
||||
'dataLanguage' => $languageList,
|
||||
'dataDepth' => $depthList,
|
||||
'criteriaFulltext' => '',
|
||||
'criteriaPageUid' => '',
|
||||
'criteriaPageLanguage' => '',
|
||||
'criteriaPageDepth' => '',
|
||||
'criteriaIsBlacklisted' => 0,
|
||||
'languageFullList' => $languageFullList,
|
||||
);
|
||||
|
||||
$metaSeoLang = array(
|
||||
'title' => 'title.sitemap.list',
|
||||
'pagingMessage' => 'pager.results',
|
||||
'pagingEmpty' => 'pager.noresults',
|
||||
'sitemap_page_uid' => 'header.sitemap.page_uid',
|
||||
'sitemap_page_url' => 'header.sitemap.page_url',
|
||||
'sitemap_page_type' => 'header.sitemap.page_type',
|
||||
'sitemap_page_depth' => 'header.sitemap.page_depth',
|
||||
'sitemap_page_language' => 'header.sitemap.page_language',
|
||||
'sitemap_page_is_blacklisted' => 'header.sitemap.page_is_blacklisted',
|
||||
'page_tx_metaseo_is_exclude' => 'header.sitemap.page_tx_metaseo_is_exclude',
|
||||
'sitemap_tstamp' => 'header.sitemap.tstamp',
|
||||
'sitemap_crdate' => 'header.sitemap.crdate',
|
||||
'labelSearchFulltext' => 'label.search.fulltext',
|
||||
'emptySearchFulltext' => 'empty.search.fulltext',
|
||||
'labelSearchPageUid' => 'label.search.page_uid',
|
||||
'emptySearchPageUid' => 'empty.search.page_uid',
|
||||
'labelSearchPageLanguage' => 'label.search.page_language',
|
||||
'emptySearchPageLanguage' => 'empty.search.page_language',
|
||||
'labelSearchPageDepth' => 'label.search.page_depth',
|
||||
'emptySearchPageDepth' => 'empty.search.page_depth',
|
||||
'labelSearchIsBlacklisted' => 'label.search.is_blacklisted',
|
||||
'labelYes' => 'label.yes',
|
||||
'labelNo' => 'label.no',
|
||||
'buttonYes' => 'button.yes',
|
||||
'buttonNo' => 'button.no',
|
||||
'buttonDelete' => 'button.delete',
|
||||
'buttonDeleteHint' => 'button.delete.hint',
|
||||
'buttonBlacklist' => 'button.blacklist',
|
||||
'buttonBlacklistHint' => 'button.blacklist.hint',
|
||||
'buttonWhitelist' => 'button.whitelist',
|
||||
'buttonWhitelistHint' => 'button.whitelist.hint',
|
||||
'buttonDeleteAll' => 'button.delete_all',
|
||||
'messageDeleteTitle' => 'message.delete.title',
|
||||
'messageDeleteQuestion' => 'message.delete.question',
|
||||
'messageDeleteAllTitle' => 'message.delete_all.title',
|
||||
'messageDeleteAllQuestion' => 'message.delete_all.question',
|
||||
'messageBlacklistTitle' => 'message.blacklist.title',
|
||||
'messageBlacklistQuestion' => 'message.blacklist.question',
|
||||
'messageWhitelistTitle' => 'message.whitelist.title',
|
||||
'messageWhitelistQuestion' => 'message.whitelist.question',
|
||||
'errorDeleteFailedMessage' => 'message.delete.failed_body',
|
||||
'errorNoSelectedItemsBody' => 'message.no_selected_items',
|
||||
'today' => 'today',
|
||||
'yesterday' => 'yesterday',
|
||||
'sitemapPageType' => array(
|
||||
0 => 'sitemap.pagetype.0',
|
||||
1 => 'sitemap.pagetype.1',
|
||||
),
|
||||
);
|
||||
|
||||
// translate list
|
||||
$metaSeoLang = $this->translateList($metaSeoLang);
|
||||
$metaSeoLang['title'] = sprintf($metaSeoLang['title'], $rootPage['title'], $rootPid);
|
||||
|
||||
$this->view->assign(
|
||||
'JavaScript',
|
||||
'Ext.namespace("MetaSeo.sitemap");
|
||||
MetaSeo.sitemap.conf = ' . json_encode($metaSeoConf) . ';
|
||||
MetaSeo.sitemap.conf.lang = ' . json_encode($metaSeoLang) . ';
|
||||
'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user