Info
* @internal This class is a specific Backend controller implementation and is not part of the TYPO3's Core API.
*/
class TranslationStatusController
{
use PublicPropertyDeprecationTrait;
use PublicMethodDeprecationTrait;
/**
* @var array
*/
private $deprecatedPublicProperties = [
'pObj' => 'Using TranslationStatusController::$pObj is deprecated and will not be possible anymore in TYPO3 v10.0.',
'function_key' => 'Using TranslationStatusController::function_key$ is deprecated, property will be removed in TYPO3 v10.0.',
'extClassConf' => 'Using TranslationStatusController::$extClassConf is deprecated, property will be removed in TYPO3 v10.0.',
'localLangFile' => 'Using TranslationStatusController::$localLangFile is deprecated, property will be removed in TYPO3 v10.0.',
'extObj' => 'Using TranslationStatusController::$extObj is deprecated, property will be removed in TYPO3 v10.0.',
];
/**
* @var array
*/
private $deprecatedPublicMethods = [
'getContentElementCount' => 'Using TranslationStatusController::getContentElementCount() is deprecated and will not be possible anymore in TYPO3 v10.0.',
'getLangStatus' => 'Using TranslationStatusController::getLangStatus() is deprecated and will not be possible anymore in TYPO3 v10.0.',
'renderL10nTable' => 'Using TranslationStatusController::renderL10nTable() is deprecated and will not be possible anymore in TYPO3 v10.0.',
'modMenu' => 'Using TranslationStatusController::modMenu() is deprecated and will not be possible anymore in TYPO3 v10.0.',
'extObjContent' => 'Using TranslationStatusController::extObjContent() is deprecated, method will be removed in TYPO3 v10.0.',
];
/**
* @var IconFactory
*/
protected $iconFactory;
/**
* @var SiteLanguage[]
*/
protected $siteLanguages;
/**
* @var InfoModuleController Contains a reference to the parent calling object
*/
protected $pObj;
/**
* @var int Value of the GET/POST var 'id'
*/
protected $id;
/**
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0.
*/
protected $extObj;
/**
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0.
*/
protected $localLangFile = '';
/**
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0.
*/
protected $extClassConf;
/**
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0.
*/
protected $function_key = '';
/**
* Init, called from parent object
*
* @param InfoModuleController $pObj A reference to the parent (calling) object
*/
public function init($pObj)
{
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$this->id = (int)GeneralUtility::_GP('id');
$this->initializeSiteLanguages();
$this->pObj = $pObj;
// Local lang:
if (!empty($this->localLangFile)) {
// @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0.
$this->getLanguageService()->includeLLFile($this->localLangFile);
}
// Setting MOD_MENU items as we need them for logging:
$this->pObj->MOD_MENU = array_merge($this->pObj->MOD_MENU, $this->modMenu());
}
/**
* Main, called from parent object
*
* @return string Output HTML for the module.
*/
public function main()
{
$theOutput = '
';
return $output;
}
/**
* Selects all system languages (from sys_language)
*
* @return array System language records in an array.
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0
*/
public function getSystemLanguages()
{
trigger_error('This method will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);
if (!$this->getBackendUser()->isAdmin() && $this->getBackendUser()->groupData['allowed_languages'] !== '') {
$allowed_languages = array_flip(explode(',', $this->getBackendUser()->groupData['allowed_languages']));
}
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('sys_language')
->select('*')
->from('sys_language')
->orderBy('sorting');
$res = $queryBuilder->execute();
$outputArray = [];
if (is_array($allowed_languages) && !empty($allowed_languages)) {
while ($output = $res->fetch()) {
if (isset($allowed_languages[$output['uid']])) {
$outputArray[] = $output;
}
}
} else {
$outputArray = $res->fetchAll();
}
return $outputArray;
}
/**
* Get an alternative language record for a specific page / language
*
* @param int $pageId Page ID to look up for.
* @param int $langId Language UID to select for.
* @return array translated pages record
*/
protected function getLangStatus($pageId, $langId)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('pages');
$queryBuilder
->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class))
->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$result = $queryBuilder
->select('*')
->from('pages')
->where(
$queryBuilder->expr()->eq(
$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT)
)
)
->andWhere(
$queryBuilder->expr()->eq(
$GLOBALS['TCA']['pages']['ctrl']['languageField'],
$queryBuilder->createNamedParameter($langId, \PDO::PARAM_INT)
)
)
->execute();
$row = $result->fetch();
BackendUtility::workspaceOL('pages', $row);
if (is_array($row)) {
$row['_COUNT'] = $queryBuilder->count('uid')->execute()->fetchColumn(0);
$row['_HIDDEN'] = $row['hidden'] || (int)$row['endtime'] > 0 && (int)$row['endtime'] < $GLOBALS['EXEC_TIME'] || $GLOBALS['EXEC_TIME'] < (int)$row['starttime'];
}
$result->closeCursor();
return $row;
}
/**
* Counting content elements for a single language on a page.
*
* @param int $pageId Page id to select for.
* @param int $sysLang Sys language uid
* @return int Number of content elements from the PID where the language is set to a certain value.
*/
protected function getContentElementCount($pageId, $sysLang)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tt_content');
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class))
->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
$count = $queryBuilder
->count('uid')
->from('tt_content')
->where(
$queryBuilder->expr()->eq(
'pid',
$queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT)
)
)
->andWhere(
$queryBuilder->expr()->eq(
'sys_language_uid',
$queryBuilder->createNamedParameter($sysLang, \PDO::PARAM_INT)
)
)
->execute()
->fetchColumn(0);
return $count ?: '-';
}
/**
* Since the AbstractFunctionModule cannot access the current request yet, we'll do it "old school"
* to fetch the Site based on the current ID.
*/
protected function initializeSiteLanguages()
{
/** @var SiteInterface $currentSite */
$currentSite = $GLOBALS['TYPO3_REQUEST']->getAttribute('site');
$this->siteLanguages = $currentSite->getAvailableLanguages($this->getBackendUser(), false, (int)$this->id);
}
/**
* Called from InfoModuleController until deprecation removal in TYPO3 v10.0
*
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0.
*/
public function checkExtObj()
{
if (is_array($this->extClassConf) && $this->extClassConf['name']) {
$this->extObj = GeneralUtility::makeInstance($this->extClassConf['name']);
$this->extObj->init($this->pObj, $this->extClassConf);
// Re-write:
$this->pObj->MOD_SETTINGS = BackendUtility::getModuleData($this->pObj->MOD_MENU, GeneralUtility::_GP('SET'), 'web_info');
}
}
/**
* Calls the main function inside ANOTHER sub-submodule which might exist.
*
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0.
*/
protected function extObjContent()
{
if (is_object($this->extObj)) {
return $this->extObj->main();
}
}
/**
* @return LanguageService
*/
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
/**
* Returns the current BE user.
*
* @return BackendUserAuthentication
*/
protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
}
/**
* @return PageRenderer
*/
protected function getPageRenderer(): PageRenderer
{
return GeneralUtility::makeInstance(PageRenderer::class);
}
}