2 namespace TYPO3\CMS\Backend\Controller;
152 parent::__construct();
167 $this->perms_clause = $beUser->getPagePermsClause(1);
169 if ($pidList = $beUser->getTSConfigVal(
'options.hideRecords.pages')) {
171 $this->perms_clause .=
' AND pages.uid NOT IN (' . $pidList .
')';
180 $this->moduleTemplate->getPageRenderer()->loadRequireJsModule(
'TYPO3/CMS/Backend/ClickMenu');
181 $this->moduleTemplate->getPageRenderer()->loadRequireJsModule(
'TYPO3/CMS/Backend/Tooltip');
184 $this->content .=
'<h1>'
185 . $this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_core.xlf:db_new.php.pagetitle')
192 if ($this->pageinfo[
'uid']) {
197 if ($beUser->doesUserHaveAccess($this->pageinfo, 8)) {
198 $this->newPagesInto = 1;
200 if ($beUser->doesUserHaveAccess($this->pageinfo, 16)) {
201 $this->newContentInto = 1;
203 if (($beUser->isAdmin() || is_array($this->pidInfo)) && $beUser->doesUserHaveAccess($this->pidInfo, 8)) {
204 $this->newPagesAfter = 1;
206 }
elseif ($beUser->isAdmin()) {
208 $this->newPagesInto = 1;
209 $this->newContentInto = 1;
210 $this->newPagesAfter = 0;
213 $this->newPagesInto = 0;
214 $this->newContentInto = 0;
215 $this->newPagesAfter = 0;
231 $response->
getBody()->write($this->moduleTemplate->renderContent());
244 if (empty($this->pageinfo)) {
246 $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation([]);
248 $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
254 $this->web_list_modTSconfig[
'properties'][
'allowedNewTables'],
259 $this->web_list_modTSconfig[
'properties'][
'deniedNewTables'],
266 $this->web_list_modTSconfig_pid[
'properties'][
'allowedNewTables'],
271 $this->web_list_modTSconfig_pid[
'properties'][
'deniedNewTables'],
276 $this->newPagesInto = 0;
278 if (!$this->
showNewRecLink(
'pages', $this->allowedNewTables_pid, $this->deniedNewTables_pid)) {
279 $this->newPagesAfter = 0;
282 if (is_array($this->pageinfo) && $this->pageinfo[
'uid']) {
283 $title = strip_tags($this->pageinfo[
$GLOBALS[
'TCA'][
'pages'][
'ctrl'][
'label']]);
285 $title =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'sitename'];
287 $this->moduleTemplate->setTitle($title);
290 if (!$this->pagesOnly) {
297 $this->content .=
'<div>' . $this->code .
'</div>';
301 $this->moduleTemplate->setContent($this->content);
311 $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
313 if (!$this->pagesOnly) {
316 $newPageButton = $buttonBar->makeLinkButton()
318 ->setTitle(
$lang->sL(
319 'LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:newPage',
322 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
'actions-page-new',
Icon::SIZE_SMALL));
326 $cshButton = $buttonBar->makeHelpButton()->setModuleName(
'xMOD_csh_corebe')->setFieldName(
'new_regular');
327 $buttonBar->addButton($cshButton);
332 $cshButton = $buttonBar->makeHelpButton()->setModuleName(
'xMOD_csh_corebe')->setFieldName(
'new_pages');
333 $buttonBar->addButton($cshButton);
336 if ($this->returnUrl) {
337 $returnButton = $buttonBar->makeLinkButton()
338 ->setHref($this->returnUrl)
339 ->setTitle(
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.goBack',
true))
340 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
'actions-view-go-back',
Icon::SIZE_SMALL));
345 if (is_array($this->pageinfo) && $this->pageinfo[
'uid']) {
348 if (isset($pagesTSconfig[
'TCEMAIN.'][
'preview.'][
'disableButtonForDokType'])) {
351 $pagesTSconfig[
'TCEMAIN.'][
'preview.'][
'disableButtonForDokType'],
356 $excludeDokTypes = array(
362 if (!in_array((
int)$this->pageinfo[
'doktype'], $excludeDokTypes,
true)) {
363 $viewButton = $buttonBar->makeLinkButton()
366 $this->pageinfo[
'uid'],
370 ->setTitle(
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.showPage',
true))
371 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
372 'actions-document-view',
385 public function pagesOnly()
392 if ($numberOfPages > 0) {
394 <h3>' . htmlspecialchars($this->
getLanguageService()->getLL(
'selectPosition')) .
':</h3>
398 $this->code .= $positionMap->positionTree(
412 'returnNewPageId' => 1,
413 'returnUrl' => BackendUtility::getModuleUrl(
'db_new', array(
'id' => $this->
id,
'pagesOnly' =>
'1'))
415 $url = BackendUtility::getModuleUrl(
'record_edit', $urlParameters);
430 $this->tRows = array();
436 $this->newPagesSelectPosition = !empty(
437 $pageTS[
'mod.'][
'wizards.'][
'newRecord.'][
'pages.'][
'show.'][
'pageSelectPosition']
440 $displayNewPagesIntoLink = $this->newPagesInto && !empty($pageTS[
'mod.'][
'wizards.'][
'newRecord.'][
'pages.'][
'show.'][
'pageInside']) ? 1 : 0;
441 $displayNewPagesAfterLink = $this->newPagesAfter && !empty($pageTS[
'mod.'][
'wizards.'][
'newRecord.'][
'pages.'][
'show.'][
'pageAfter']) ? 1 : 0;
447 $pageIcon = $this->moduleTemplate->getIconFactory()->getIconForRecord(
452 $newPageIcon = $this->moduleTemplate->getIconFactory()->getIcon(
'actions-page-new',
Icon::SIZE_SMALL)->render();
455 $newPageLinks = array();
458 $newPageLinks[] = $this->
linkWrap($this->moduleTemplate->getIconFactory()->getIconForRecord($table, array(),
Icon::SIZE_SMALL)->render() .
$lang->sL($v[
'ctrl'][
'title'],
true) .
' (' .
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:db_new.php.inside',
true) .
')', $table,
$this->id);
462 $newPageLinks[] = $this->
linkWrap($pageIcon .
$lang->sL($v[
'ctrl'][
'title'],
true) .
' (' .
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:db_new.php.after',
true) .
')',
'pages', -
$this->id);
465 if ($this->newPagesSelectPosition && $this->
showNewRecLink(
'pages')) {
467 $newPageLinks[] =
'<a href="' . htmlspecialchars(
GeneralUtility::linkThisScript(array(
'pagesOnly' => 1))) .
'">' . $pageIcon . htmlspecialchars(
$lang->getLL(
'pageSelectPosition')) .
'</a>';
470 $numPageLinks = count($newPageLinks);
471 for ($i = 0; $i < $numPageLinks; $i++) {
472 $rowContent .=
'<li>' . $newPageLinks[$i] .
'</li>';
475 $rowContent =
'<ul class="list-tree"><li>' . $newPageIcon .
'<strong>' .
476 $lang->getLL(
'createNewPage') .
'</strong><ul>' . $rowContent .
'</ul></li>';
478 $rowContent =
'<ul class="list-tree"><li><ul>' . $rowContent .
'</li></ul>';
481 $startRows = array($rowContent);
485 $newContentIcon = $this->moduleTemplate->getIconFactory()->getIcon(
'actions-document-new',
Icon::SIZE_SMALL)->render();
486 if ($this->newContentInto) {
489 foreach (
$GLOBALS[
'TCA'] as $table => $v) {
490 if ($table !=
'pages'
494 && (($v[
'ctrl'][
'rootLevel'] xor $this->
id) || $v[
'ctrl'][
'rootLevel'] == -1)
495 && $this->
getBackendUserAuthentication()->workspaceCreateNewRecord(($this->pageinfo[
'_ORIG_uid'] ? $this->pageinfo[
'_ORIG_uid'] : $this->
id), $table)
497 $newRecordIcon = $this->moduleTemplate->getIconFactory()->getIconForRecord($table, array(),
Icon::SIZE_SMALL)->render();
503 if ($table ==
'tt_content') {
504 $groupName =
$lang->getLL(
'createNewContent');
505 $rowContent = $newContentIcon .
'<strong>' .
$lang->getLL(
'createNewContent') .
'</strong><ul>';
508 $moduleName = $tsConfig[
'properties'][
'newContentElementWizard.'][
'override'] ?:
'new_content_element';
510 $rowContent .=
'<li>' . $newLink .
' ' . BackendUtility::wrapInHelp($table,
'') .
'</li><li><a href="' . htmlspecialchars(
$url) .
'">' . $newContentIcon . htmlspecialchars(
$lang->getLL(
'clickForWizard')) .
'</a></li></ul>';
513 if ($v[
'ctrl'][
'readOnly'] || $v[
'ctrl'][
'hideTable'] || $v[
'ctrl'][
'is_static']) {
516 if ($v[
'ctrl'][
'adminOnly'] && !$isAdmin) {
519 $nameParts = explode(
'_', $table);
522 if ($nameParts[0] ==
'tx' || $nameParts[0] ==
'tt') {
524 if (substr($v[
'ctrl'][
'title'], 0, 8) ==
'LLL:EXT:') {
525 $_EXTKEY = substr($v[
'ctrl'][
'title'], 8);
526 $_EXTKEY = substr($_EXTKEY, 0, strpos($_EXTKEY,
'/'));
527 if ($_EXTKEY !=
'') {
529 $temp = explode(
':', substr($v[
'ctrl'][
'title'], 9 + strlen($_EXTKEY)));
530 $langFile = $temp[0];
531 $thisTitle =
$lang->sL(
'LLL:EXT:' . $_EXTKEY .
'/' . $langFile .
':extension.title');
534 if (!$thisTitle && is_file($extEmConfFile)) {
536 include $extEmConfFile;
537 $thisTitle =
$EM_CONF[$_EXTKEY][
'title'];
542 if (empty($thisTitle)) {
543 $_EXTKEY = $nameParts[1];
544 $thisTitle = $nameParts[1];
545 $iconFile[$_EXTKEY] =
'';
552 $thisTitle =
$lang->getLL(
'system_records');
553 $iconFile[
'system'] = $this->moduleTemplate->getIconFactory()->getIcon(
'apps-pagetree-root',
Icon::SIZE_SMALL)->render();
555 if ($groupName ==
'' || $groupName != $_EXTKEY) {
556 $groupName = empty($v[
'ctrl'][
'groupName']) ? $_EXTKEY : $v[
'ctrl'][
'groupName'];
558 $rowContent .= $newLink;
561 if ($table ==
'tt_content') {
562 $startRows[] =
'<li>' . $rowContent .
'</li>';
564 $this->tRows[$groupName][
'title'] = $thisTitle;
565 $this->tRows[$groupName][
'html'][] = $rowContent;
566 $this->tRows[$groupName][
'table'][] = $table;
573 if (isset($pageTS[
'mod.'][
'wizards.'][
'newRecord.'][
'order'])) {
576 uksort($this->tRows, array($this,
'sortNewRecordsByConfig'));
578 $finalRows = array();
579 $finalRows[] = implode(
'', $startRows);
580 foreach ($this->tRows as $key => $value) {
581 $row =
'<li>' . $iconFile[$key] .
' <strong>' . $value[
'title'] .
'</strong><ul>';
582 foreach ($value[
'html'] as $recordKey => $record) {
583 $row .=
'<li>' . $record .
' ' . BackendUtility::wrapInHelp($value[
'table'][$recordKey],
'') .
'</li>';
585 $row .=
'</ul></li>';
589 $finalRows[] =
'</ul>';
591 $this->code .= implode(
'', $finalRows);
603 if (!empty($this->newRecordSortList)) {
604 if (in_array($a, $this->newRecordSortList) && in_array($b, $this->newRecordSortList)) {
606 $sub = array_search($a, $this->newRecordSortList) - array_search($b, $this->newRecordSortList);
607 $ret = ($sub < 0 ? -1 : $sub == 0) ? 0 : 1;
608 }
elseif (in_array($a, $this->newRecordSortList)) {
611 }
elseif (in_array($b, $this->newRecordSortList)) {
616 $ret = strnatcasecmp($this->tRows[$a][
'title'], $this->tRows[$b][
'title']);
621 return strnatcasecmp($this->tRows[$a][
'title'], $this->tRows[$b][
'title']);
646 public function linkWrap($linkText, $table, $pid, $addContentTable =
false)
656 if ($table ==
'pages' && $addContentTable) {
657 $urlParameters[
'tt_content'][
'prev'] =
'new';
658 $urlParameters[
'returnNewPageId'] = 1;
659 }
elseif ($table ==
'pages_language_overlay') {
660 $urlParameters[
'overrideVals'][
'pages_language_overlay'][
'doktype'] = (int)$this->pageinfo[
'doktype'];
662 $url = BackendUtility::getModuleUrl(
'record_edit', $urlParameters);
663 return '<a href="' . htmlspecialchars(
$url) .
'">' . $linkText .
'</a>';
675 if (!is_array($pid_row)) {
679 if ($checkTable ==
'be_users' || $checkTable ==
'be_groups') {
683 $doktype = (int)$pid_row[
'doktype'];
684 if (!($allowedTableList =
$GLOBALS[
'PAGES_TYPES'][$doktype][
'allowedTables'])) {
685 $allowedTableList =
$GLOBALS[
'PAGES_TYPES'][
'default'][
'allowedTables'];
734 if ($languageCount) {
735 $languageCount =
true;
737 return $languageCount;