TYPO3 CMS  TYPO3_8-7
NewRecordController.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
32 
37 {
41  public $pageinfo;
42 
46  public $pidInfo;
47 
51  protected $newRecordSortList;
52 
56  public $newPagesInto;
57 
62 
67 
73  protected $newPagesSelectPosition = true;
74 
79 
84 
89 
94 
99 
104 
108  public $code;
109 
113  public $R_URI;
114 
118  public $id;
119 
123  public $returnUrl;
124 
130  public $pagesOnly;
131 
136 
142  public $content;
143 
147  public $tRows;
148 
152  public function __construct()
153  {
154  parent::__construct();
155  $GLOBALS['SOBE'] = $this;
156  $this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_misc.xlf');
157  $this->init();
158  }
159 
163  protected function init()
164  {
165  $beUser = $this->getBackendUserAuthentication();
166  // Page-selection permission clause (reading)
167  $this->perms_clause = $beUser->getPagePermsClause(1);
168  // This will hide records from display - it has nothing to do with user rights!!
169  if ($pidList = $beUser->getTSConfigVal('options.hideRecords.pages')) {
170  if (!empty($pidList)) {
171  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
172  ->getQueryBuilderForTable('pages');
173  $this->perms_clause .= ' AND ' . $queryBuilder->expr()->notIn(
174  'pages.uid',
175  GeneralUtility::intExplode(',', $pidList)
176  );
177  }
178  }
179  // Setting GPvars:
180  // The page id to operate from
181  $this->id = (int)GeneralUtility::_GP('id');
182  $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
183  $this->pagesOnly = GeneralUtility::_GP('pagesOnly');
184  // Setting up the context sensitive menu:
185  $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu');
186  $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Tooltip');
187  // Creating content
188  $this->content = '';
189  $this->content .= '<h1>'
190  . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:db_new.php.pagetitle')
191  . '</h1>';
192  // Id a positive id is supplied, ask for the page record with permission information contained:
193  if ($this->id > 0) {
194  $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
195  }
196  // If a page-record was returned, the user had read-access to the page.
197  if ($this->pageinfo['uid']) {
198  // Get record of parent page
199  $this->pidInfo = BackendUtility::getRecord('pages', $this->pageinfo['pid']);
200  // Checking the permissions for the user with regard to the parent page: Can he create new pages, new
201  // content record, new page after?
202  if ($beUser->doesUserHaveAccess($this->pageinfo, 8)) {
203  $this->newPagesInto = 1;
204  }
205  if ($beUser->doesUserHaveAccess($this->pageinfo, 16)) {
206  $this->newContentInto = 1;
207  }
208  if (($beUser->isAdmin() || is_array($this->pidInfo)) && $beUser->doesUserHaveAccess($this->pidInfo, 8)) {
209  $this->newPagesAfter = 1;
210  }
211  } elseif ($beUser->isAdmin()) {
212  // Admins can do it all
213  $this->newPagesInto = 1;
214  $this->newContentInto = 1;
215  $this->newPagesAfter = 0;
216  } else {
217  // People with no permission can do nothing
218  $this->newPagesInto = 0;
219  $this->newContentInto = 0;
220  $this->newPagesAfter = 0;
221  }
222  }
223 
232  public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
233  {
234  $this->main();
235 
236  $response->getBody()->write($this->moduleTemplate->renderContent());
237  return $response;
238  }
239 
243  public function main()
244  {
245  // If there was a page - or if the user is admin (admins has access to the root) we proceed:
246  if (!empty($this->pageinfo['uid']) || $this->getBackendUserAuthentication()->isAdmin()) {
247  if (empty($this->pageinfo)) {
248  // Explicitly pass an empty array to the docHeader
249  $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation([]);
250  } else {
251  $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
252  }
253  // Acquiring TSconfig for this module/current page:
254  $this->web_list_modTSconfig = BackendUtility::getModTSconfig($this->pageinfo['uid'], 'mod.web_list');
255  $this->allowedNewTables = GeneralUtility::trimExplode(
256  ',',
257  $this->web_list_modTSconfig['properties']['allowedNewTables'],
258  true
259  );
260  $this->deniedNewTables = GeneralUtility::trimExplode(
261  ',',
262  $this->web_list_modTSconfig['properties']['deniedNewTables'],
263  true
264  );
265  // Acquiring TSconfig for this module/parent page:
266  $this->web_list_modTSconfig_pid = BackendUtility::getModTSconfig($this->pageinfo['pid'], 'mod.web_list');
267  $this->allowedNewTables_pid = GeneralUtility::trimExplode(
268  ',',
269  $this->web_list_modTSconfig_pid['properties']['allowedNewTables'],
270  true
271  );
272  $this->deniedNewTables_pid = GeneralUtility::trimExplode(
273  ',',
274  $this->web_list_modTSconfig_pid['properties']['deniedNewTables'],
275  true
276  );
277  // More init:
278  if (!$this->showNewRecLink('pages')) {
279  $this->newPagesInto = 0;
280  }
281  if (!$this->showNewRecLink('pages', $this->allowedNewTables_pid, $this->deniedNewTables_pid)) {
282  $this->newPagesAfter = 0;
283  }
284  // Set header-HTML and return_url
285  if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
286  $title = strip_tags($this->pageinfo[$GLOBALS['TCA']['pages']['ctrl']['label']]);
287  } else {
288  $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
289  }
290  $this->moduleTemplate->setTitle($title);
291  // GENERATE the HTML-output depending on mode (pagesOnly is the page wizard)
292  // Regular new element:
293  if (!$this->pagesOnly) {
294  $this->regularNew();
295  } elseif ($this->showNewRecLink('pages')) {
296  // Pages only wizard
297  $this->pagesOnly();
298  }
299  // Add all the content to an output section
300  $this->content .= '<div>' . $this->code . '</div>';
301  // Setting up the buttons and markers for docheader
302  $this->getButtons();
303  // Build the <body> for the module
304  $this->moduleTemplate->setContent($this->content);
305  }
306  }
307 
311  protected function getButtons()
312  {
313  $lang = $this->getLanguageService();
314  $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
315  // Regular new element:
316  if (!$this->pagesOnly) {
317  // New page
318  if ($this->showNewRecLink('pages')) {
319  $newPageButton = $buttonBar->makeLinkButton()
320  ->setHref(GeneralUtility::linkThisScript(['pagesOnly' => '1']))
321  ->setTitle($lang->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:newPage'))
322  ->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-page-new', Icon::SIZE_SMALL));
323  $buttonBar->addButton($newPageButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
324  }
325  // CSH
326  $cshButton = $buttonBar->makeHelpButton()->setModuleName('xMOD_csh_corebe')->setFieldName('new_regular');
327  $buttonBar->addButton($cshButton);
328  } elseif ($this->showNewRecLink('pages')) {
329  // Pages only wizard
330  // CSH
331  $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'new_pages');
332  $cshButton = $buttonBar->makeHelpButton()->setModuleName('xMOD_csh_corebe')->setFieldName('new_pages');
333  $buttonBar->addButton($cshButton);
334  }
335  // Back
336  if ($this->returnUrl) {
337  $returnButton = $buttonBar->makeLinkButton()
338  ->setHref($this->returnUrl)
339  ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.goBack'))
340  ->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL));
341  $buttonBar->addButton($returnButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
342  }
343 
344  if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
345  // View
346  $pagesTSconfig = BackendUtility::getPagesTSconfig($this->pageinfo['uid']);
347  if (isset($pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'])) {
348  $excludeDokTypes = GeneralUtility::intExplode(
349  ',',
350  $pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'],
351  true
352  );
353  } else {
354  // exclude sysfolders and recycler by default
355  $excludeDokTypes = [
359  ];
360  }
361  if (!in_array((int)$this->pageinfo['doktype'], $excludeDokTypes, true)) {
362  $viewButton = $buttonBar->makeLinkButton()
363  ->setHref('#')
364  ->setOnClick(BackendUtility::viewOnClick(
365  $this->pageinfo['uid'],
366  '',
367  BackendUtility::BEgetRootLine($this->pageinfo['uid'])
368  ))
369  ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage'))
370  ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
371  'actions-document-view',
373  ));
374  $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 30);
375  }
376  }
377  }
378 
382  public function pagesOnly()
383  {
384  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
385  ->getQueryBuilderForTable('sys_language');
386  $queryBuilder->getRestrictions()
387  ->removeAll()
388  ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
389  $numberOfPages = $queryBuilder
390  ->count('*')
391  ->from('pages')
392  ->execute()
393  ->fetchColumn(0);
394 
395  if ($numberOfPages > 0) {
396  $this->code .= '
397  <h3>' . htmlspecialchars($this->getLanguageService()->getLL('selectPosition')) . ':</h3>
398  ';
399  $positionMap = GeneralUtility::makeInstance(PagePositionMap::class, NewRecordPageTreeView::class);
401  $this->code .= $positionMap->positionTree(
402  $this->id,
403  $this->pageinfo,
404  $this->perms_clause,
405  $this->returnUrl
406  );
407  } else {
408  // No pages yet, no need to prompt for position, redirect to page creation.
409  $urlParameters = [
410  'edit' => [
411  'pages' => [
412  0 => 'new'
413  ]
414  ],
415  'returnNewPageId' => 1,
416  'returnUrl' => BackendUtility::getModuleUrl('db_new', ['id' => $this->id, 'pagesOnly' => '1'])
417  ];
418  $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
419  @ob_end_clean();
420  HttpUtility::redirect($url);
421  }
422  }
423 
427  public function regularNew()
428  {
429  $lang = $this->getLanguageService();
430  // Initialize array for accumulating table rows:
431  $this->tRows = [];
432  // Get TSconfig for current page
433  $pageTS = BackendUtility::getPagesTSconfig($this->id);
434  // Finish initializing new pages options with TSconfig
435  // Each new page option may be hidden by TSconfig
436  // Enabled option for the position of a new page
437  $this->newPagesSelectPosition = !empty(
438  $pageTS['mod.']['wizards.']['newRecord.']['pages.']['show.']['pageSelectPosition']
439  );
440  // Pseudo-boolean (0/1) for backward compatibility
441  $displayNewPagesIntoLink = $this->newPagesInto && !empty($pageTS['mod.']['wizards.']['newRecord.']['pages.']['show.']['pageInside']) ? 1 : 0;
442  $displayNewPagesAfterLink = $this->newPagesAfter && !empty($pageTS['mod.']['wizards.']['newRecord.']['pages.']['show.']['pageAfter']) ? 1 : 0;
443  // Slight spacer from header:
444  $this->code .= '';
445  // New Page
446  $table = 'pages';
447  $v = $GLOBALS['TCA'][$table];
448  $pageIcon = $this->moduleTemplate->getIconFactory()->getIconForRecord(
449  $table,
450  [],
452  )->render();
453  $newPageIcon = $this->moduleTemplate->getIconFactory()->getIcon('actions-page-new', Icon::SIZE_SMALL)->render();
454  $rowContent = '';
455  // New pages INSIDE this pages
456  $newPageLinks = [];
457  if ($displayNewPagesIntoLink && $this->isTableAllowedForThisPage($this->pageinfo, 'pages') && $this->getBackendUserAuthentication()->check('tables_modify', 'pages') && $this->getBackendUserAuthentication()->workspaceCreateNewRecord(($this->pageinfo['_ORIG_uid'] ?: $this->id), 'pages')) {
458  // Create link to new page inside:
459  $newPageLinks[] = $this->linkWrap($this->moduleTemplate->getIconFactory()->getIconForRecord($table, [], Icon::SIZE_SMALL)->render() . htmlspecialchars($lang->sL($v['ctrl']['title'])) . ' (' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:db_new.php.inside')) . ')', $table, $this->id);
460  }
461  // New pages AFTER this pages
462  if ($displayNewPagesAfterLink && $this->isTableAllowedForThisPage($this->pidInfo, 'pages') && $this->getBackendUserAuthentication()->check('tables_modify', 'pages') && $this->getBackendUserAuthentication()->workspaceCreateNewRecord($this->pidInfo['uid'], 'pages')) {
463  $newPageLinks[] = $this->linkWrap($pageIcon . htmlspecialchars($lang->sL($v['ctrl']['title'])) . ' (' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:db_new.php.after')) . ')', 'pages', -$this->id);
464  }
465  // New pages at selection position
466  if ($this->newPagesSelectPosition && $this->showNewRecLink('pages')) {
467  // Link to page-wizard:
468  $newPageLinks[] = '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(['pagesOnly' => 1])) . '">' . $pageIcon . htmlspecialchars($lang->getLL('pageSelectPosition')) . '</a>';
469  }
470  // Assemble all new page links
471  $numPageLinks = count($newPageLinks);
472  for ($i = 0; $i < $numPageLinks; $i++) {
473  $rowContent .= '<li>' . $newPageLinks[$i] . '</li>';
474  }
475  if ($this->showNewRecLink('pages')) {
476  $rowContent = '<ul class="list-tree"><li>' . $newPageIcon . '<strong>' .
477  $lang->getLL('createNewPage') . '</strong><ul>' . $rowContent . '</ul></li>';
478  } else {
479  $rowContent = '<ul class="list-tree"><li><ul>' . $rowContent . '</li></ul>';
480  }
481  // Compile table row
482  $startRows = [$rowContent];
483  $iconFile = [];
484  // New tables (but not pages) INSIDE this pages
485  $isAdmin = $this->getBackendUserAuthentication()->isAdmin();
486  $newContentIcon = $this->moduleTemplate->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL)->render();
487  if ($this->newContentInto) {
488  if (is_array($GLOBALS['TCA'])) {
489  $groupName = '';
490  foreach ($GLOBALS['TCA'] as $table => $v) {
491  $rootLevelConfiguration = isset($v['ctrl']['rootLevel']) ? (int)$v['ctrl']['rootLevel'] : 0;
492  if ($table !== 'pages'
493  && $this->showNewRecLink($table)
494  && $this->isTableAllowedForThisPage($this->pageinfo, $table)
495  && $this->getBackendUserAuthentication()->check('tables_modify', $table)
496  && ($rootLevelConfiguration === -1 || ($this->id xor $rootLevelConfiguration))
497  && $this->getBackendUserAuthentication()->workspaceCreateNewRecord(($this->pageinfo['_ORIG_uid'] ? $this->pageinfo['_ORIG_uid'] : $this->id), $table)
498  ) {
499  $newRecordIcon = $this->moduleTemplate->getIconFactory()->getIconForRecord($table, [], Icon::SIZE_SMALL)->render();
500  $rowContent = '';
501  $thisTitle = '';
502  // Create new link for record:
503  $newLink = $this->linkWrap($newRecordIcon . htmlspecialchars($lang->sL($v['ctrl']['title'])), $table, $this->id);
504  // If the table is 'tt_content', create link to wizard
505  if ($table === 'tt_content') {
506  $groupName = $lang->getLL('createNewContent');
507  $rowContent = $newContentIcon . '<strong>' . $lang->getLL('createNewContent') . '</strong><ul>';
508  // If mod.newContentElementWizard.override is set, use that extension's wizard instead:
509  $tsConfig = BackendUtility::getModTSconfig($this->id, 'mod');
510  $moduleName = isset($tsConfig['properties']['newContentElementWizard.']['override'])
511  ? $tsConfig['properties']['newContentElementWizard.']['override']
512  : 'new_content_element';
513  $url = BackendUtility::getModuleUrl($moduleName, ['id' => $this->id, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]);
514  $rowContent .= '<li>' . $newLink . ' ' . BackendUtility::wrapInHelp($table, '') . '</li><li><a href="' . htmlspecialchars($url) . '">' . $newContentIcon . htmlspecialchars($lang->getLL('clickForWizard')) . '</a></li></ul>';
515  } else {
516  // Get the title
517  if ($v['ctrl']['readOnly'] || $v['ctrl']['hideTable'] || $v['ctrl']['is_static']) {
518  continue;
519  }
520  if ($v['ctrl']['adminOnly'] && !$isAdmin) {
521  continue;
522  }
523  $nameParts = explode('_', $table);
524  $thisTitle = '';
525  $_EXTKEY = '';
526  if ($nameParts[0] === 'tx' || $nameParts[0] === 'tt') {
527  // Try to extract extension name
528  if (substr($v['ctrl']['title'], 0, 8) === 'LLL:EXT:') {
529  $_EXTKEY = substr($v['ctrl']['title'], 8);
530  $_EXTKEY = substr($_EXTKEY, 0, strpos($_EXTKEY, '/'));
531  if ($_EXTKEY !== '') {
532  // First try to get localisation of extension title
533  $temp = explode(':', substr($v['ctrl']['title'], 9 + strlen($_EXTKEY)));
534  $langFile = $temp[0];
535  $thisTitle = $lang->sL('LLL:EXT:' . $_EXTKEY . '/' . $langFile . ':extension.title');
536  // If no localisation available, read title from ext_emconf.php
537  $extPath = ExtensionManagementUtility::extPath($_EXTKEY);
538  $extEmConfFile = $extPath . 'ext_emconf.php';
539  if (!$thisTitle && is_file($extEmConfFile)) {
540  $EM_CONF = [];
541  include $extEmConfFile;
542  $thisTitle = $EM_CONF[$_EXTKEY]['title'];
543  }
544  $iconFile[$_EXTKEY] = '<img src="' . PathUtility::getAbsoluteWebPath(ExtensionManagementUtility::getExtensionIcon($extPath, true)) . '" ' . 'width="16" height="16" ' . 'alt="' . $thisTitle . '" />';
545  }
546  }
547  if (empty($thisTitle)) {
548  $_EXTKEY = $nameParts[1];
549  $thisTitle = $nameParts[1];
550  $iconFile[$_EXTKEY] = '';
551  }
552  } else {
553  if ($table === 'pages_language_overlay' && !$this->checkIfLanguagesExist()) {
554  continue;
555  }
556  $_EXTKEY = 'system';
557  $thisTitle = $lang->getLL('system_records');
558  $iconFile['system'] = $this->moduleTemplate->getIconFactory()->getIcon('apps-pagetree-root', Icon::SIZE_SMALL)->render();
559  }
560 
561  if ($groupName === '' || $groupName !== $_EXTKEY) {
562  $groupName = empty($v['ctrl']['groupName']) ? $_EXTKEY : $v['ctrl']['groupName'];
563  }
564  $rowContent .= $newLink;
565  }
566  // Compile table row:
567  if ($table === 'tt_content') {
568  $startRows[] = '<li>' . $rowContent . '</li>';
569  } else {
570  $this->tRows[$groupName]['title'] = $thisTitle;
571  $this->tRows[$groupName]['html'][] = $rowContent;
572  $this->tRows[$groupName]['table'][] = $table;
573  }
574  }
575  }
576  }
577  }
578  // User sort
579  if (isset($pageTS['mod.']['wizards.']['newRecord.']['order'])) {
580  $this->newRecordSortList = GeneralUtility::trimExplode(',', $pageTS['mod.']['wizards.']['newRecord.']['order'], true);
581  }
582  uksort($this->tRows, [$this, 'sortNewRecordsByConfig']);
583  // Compile table row:
584  $finalRows = [];
585  $finalRows[] = implode('', $startRows);
586  foreach ($this->tRows as $key => $value) {
587  $row = '<li>' . $iconFile[$key] . ' <strong>' . $value['title'] . '</strong><ul>';
588  foreach ($value['html'] as $recordKey => $record) {
589  $row .= '<li>' . $record . ' ' . BackendUtility::wrapInHelp($value['table'][$recordKey], '') . '</li>';
590  }
591  $row .= '</ul></li>';
592  $finalRows[] = $row;
593  }
594 
595  $finalRows[] = '</ul>';
596  // Make table:
597  $this->code .= implode('', $finalRows);
598  }
599 
607  public function sortNewRecordsByConfig($a, $b)
608  {
609  if (!empty($this->newRecordSortList)) {
610  if (in_array($a, $this->newRecordSortList) && in_array($b, $this->newRecordSortList)) {
611  // Both are in the list, return relative to position in array
612  $sub = array_search($a, $this->newRecordSortList) - array_search($b, $this->newRecordSortList);
613  $ret = ($sub < 0 ? -1 : $sub == 0) ? 0 : 1;
614  } elseif (in_array($a, $this->newRecordSortList)) {
615  // First element is in array, put to top
616  $ret = -1;
617  } elseif (in_array($b, $this->newRecordSortList)) {
618  // Second element is in array, put first to bottom
619  $ret = 1;
620  } else {
621  // No element is in array, return alphabetic order
622  $ret = strnatcasecmp($this->tRows[$a]['title'], $this->tRows[$b]['title']);
623  }
624  return $ret;
625  }
626  // Return alphabetic order
627  return strnatcasecmp($this->tRows[$a]['title'], $this->tRows[$b]['title']);
628  }
629 
639  public function linkWrap($linkText, $table, $pid, $addContentTable = false)
640  {
641  $urlParameters = [
642  'edit' => [
643  $table => [
644  $pid => 'new'
645  ]
646  ],
647  'returnUrl' => $this->returnUrl
648  ];
649  if ($table === 'pages' && $addContentTable) {
650  $urlParameters['tt_content']['prev'] = 'new';
651  $urlParameters['returnNewPageId'] = 1;
652  } elseif ($table === 'pages_language_overlay') {
653  $urlParameters['overrideVals']['pages_language_overlay']['doktype'] = (int)$this->pageinfo['doktype'];
654  }
655  $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
656  return '<a href="' . htmlspecialchars($url) . '">' . $linkText . '</a>';
657  }
658 
666  public function isTableAllowedForThisPage($pid_row, $checkTable)
667  {
668  if (!is_array($pid_row)) {
669  return $this->getBackendUserAuthentication()->isAdmin();
670  }
671  // be_users and be_groups may not be created anywhere but in the root.
672  if ($checkTable === 'be_users' || $checkTable === 'be_groups') {
673  return false;
674  }
675  // Checking doktype:
676  $doktype = (int)$pid_row['doktype'];
677  if (!($allowedTableList = $GLOBALS['PAGES_TYPES'][$doktype]['allowedTables'])) {
678  $allowedTableList = $GLOBALS['PAGES_TYPES']['default']['allowedTables'];
679  }
680  // If all tables or the table is listed as an allowed type, return TRUE
681  if (strstr($allowedTableList, '*') || GeneralUtility::inList($allowedTableList, $checkTable)) {
682  return true;
683  }
684 
685  return false;
686  }
687 
703  public function showNewRecLink($table, array $allowedNewTables = [], array $deniedNewTables = [])
704  {
705  if (!$this->getBackendUserAuthentication()->check('tables_modify', $table)) {
706  return false;
707  }
708 
711  // No deny/allow tables are set:
712  if (empty($allowedNewTables) && empty($deniedNewTables)) {
713  return true;
714  }
715 
716  return !in_array($table, $deniedNewTables) && (empty($allowedNewTables) || in_array($table, $allowedNewTables));
717  }
718 
724  protected function checkIfLanguagesExist()
725  {
726  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
727  ->getQueryBuilderForTable('sys_language');
728  $queryBuilder->getRestrictions()->removeAll();
729 
730  $count = $queryBuilder
731  ->count('uid')
732  ->from('sys_language')
733  ->execute()
734  ->fetchColumn(0);
735  return (bool)$count;
736  }
737 
743  protected function getLanguageService()
744  {
745  return $GLOBALS['LANG'];
746  }
747 
753  protected function getBackendUserAuthentication()
754  {
755  return $GLOBALS['BE_USER'];
756  }
757 }
static getPagesTSconfig($id, $rootLine=null, $returnPartArray=false)
showNewRecLink($table, array $allowedNewTables=[], array $deniedNewTables=[])
static intExplode($delimiter, $string, $removeEmptyValues=false, $limit=0)
static readPageAccess($id, $perms_clause)
static viewOnClick( $pageUid, $backPath='', $rootLine=null, $anchorSection='', $alternativeUrl='', $additionalGetVars='', $switchFocus=true)
static getAbsoluteWebPath($targetPath)
Definition: PathUtility.php:40
static BEgetRootLine($uid, $clause='', $workspaceOL=false)
mainAction(ServerRequestInterface $request, ResponseInterface $response)
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
static linkThisScript(array $getParams=[])
static makeInstance($className,... $constructorArguments)
static cshItem($table, $field, $_='', $wrap='')
$EM_CONF[$_EXTKEY]
Definition: ext_emconf.php:2
static redirect($url, $httpStatus=self::HTTP_STATUS_303)
linkWrap($linkText, $table, $pid, $addContentTable=false)
static getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static getExtensionIcon($extensionPath, $returnFullPath=false)