2 namespace TYPO3\CMS\Backend\Controller\ContentElement;
129 parent::__construct();
142 $lang->includeLLFile(
'EXT:lang/locallang_misc.xlf');
143 $LOCAL_LANG_orig =
$GLOBALS[
'LOCAL_LANG'];
144 $lang->includeLLFile(
'EXT:backend/Resources/Private/Language/locallang_db_new_content_el.xlf');
146 $GLOBALS[
'LOCAL_LANG'] = $LOCAL_LANG_orig;
154 $this->MCONF[
'name'] =
'xMOD_db_new_content_el';
157 $this->config =
$config[
'mod.'][
'wizards.'][
'newContentElement.'];
162 $this->moduleTemplate->getPageRenderer()->loadRequireJsModule(
'TYPO3/CMS/Backend/ClickMenu');
166 $this->access = is_array($this->pageInfo) ? 1 : 0;
180 $this->moduleTemplate->setContent($this->content);
181 $response->
getBody()->write($this->moduleTemplate->renderContent());
194 $this->content .=
'<form action="" name="editForm" id="NewContentElementController"><input type="hidden" name="defValues" value="" />';
195 if ($this->
id && $this->access) {
200 if (isset($this->colPos)) {
201 if ($this->uid_pid < 0) {
203 $row[
'uid'] = abs($this->uid_pid);
207 $this->onClickEvent = $posMap->onClickInsertRecord(
215 $this->onClickEvent =
'';
220 $this->content .=
'<h1>' .
$lang->getLL(
'newContentElement') .
'</h1>';
224 $this->elementWrapper[
'section'] = array(
'',
'');
226 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'cms'][
'db_new_content_el'][
'wizardItemsHook'])) {
227 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'cms'][
'db_new_content_el'][
'wizardItemsHook'] as $classData) {
230 throw new \UnexpectedValueException(
231 '$hookObject must implement interface ' . NewContentElementWizardHookInterface::class,
235 $hookObject->manipulateWizardItems($wizardItems, $this);
239 $this->moduleTemplate->addJavaScriptCode(
240 'NewContentElementWizardInlineJavascript',
242 function goToalt_doc() { //
243 ' . $this->onClickEvent .
'
246 if(top.refreshMenu) {
249 top.TYPO3ModuleMenu.refreshMenu();
258 $menuItems = array();
259 foreach ($wizardItems as $k => $wInfo) {
260 if ($wInfo[
'header']) {
261 $menuItems[] = array(
262 'label' => htmlspecialchars($wInfo[
'header']),
263 'content' => $this->elementWrapper[
'section'][0]
265 $key = count($menuItems) - 1;
269 if (!$this->onClickEvent) {
271 $oC =
'document.editForm.defValues.value=unescape(' .
GeneralUtility::quoteJSvalue(rawurlencode($wInfo[
'params'])) .
');goToalt_doc();' . (!$this->onClickEvent ?
'window.location.hash=\'#sel2\';' :
'');
272 $content .=
'<div class="media-left"><input type="radio" name="tempB" value="' . htmlspecialchars($k) .
'" onclick="' . htmlspecialchars($oC) .
'" /></div>';
274 $aOnClick =
'document.getElementsByName(\'tempB\')[' . $cc .
'].checked=1;' . $oC .
'return false;';
276 $aOnClick =
"document.editForm.defValues.value=unescape('" . rawurlencode($wInfo[
'params']) .
"');goToalt_doc();" . (!$this->onClickEvent?
"window.location.hash='#sel2';":
'');
279 if (isset($wInfo[
'icon'])) {
281 .
' is deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8.'
282 .
' Register your icon in IconRegistry::registerIcon and use the new setting:'
283 .
' mod.wizards.newContentElement.wizardItems.*.elements.*.iconIdentifier');
284 $wInfo[
'iconIdentifier'] =
'content-' . $k;
285 $icon = $wInfo[
'icon'];
287 $icon = str_replace(
'../typo3conf/ext/',
'EXT:', $icon);
292 $iconRegistry->registerIcon($wInfo[
'iconIdentifier'], BitmapIconProvider::class, array(
296 $icon = $this->moduleTemplate->getIconFactory()->getIcon($wInfo[
'iconIdentifier'])->render();
297 $menuItems[$key][
'content'] .=
'
299 <a href="#" onclick="' . htmlspecialchars($aOnClick) .
'">
301 <div class="media-left">
304 <div class="media-body">
305 <strong>' . htmlspecialchars($wInfo[
'title']) .
'</strong>' .
307 nl2br(htmlspecialchars(trim($wInfo[
'description']))) .
315 foreach ($menuItems as $key => $val) {
316 $menuItems[$key][
'content'] .= $this->elementWrapper[
'section'][1];
319 $code =
'<p>' .
$lang->getLL(
'sel1', 1) .
'</p>' . $this->moduleTemplate->getDynamicTabMenu(
321 'new-content-element-wizard'
324 $this->content .= !$this->onClickEvent ?
'<h2>' .
$lang->getLL(
'1_selectType',
true) .
'</h2>' :
'';
325 $this->content .=
'<div>' . $code .
'</div>';
328 if (!$this->onClickEvent) {
330 $this->content .=
'<div><a name="sel2"></a></div>';
332 $code =
'<p>' .
$lang->getLL(
'sel2', 1) .
'</p>';
336 BackendLayoutView::class .
'->getColPosListItemsParsed',
340 $colPosIds = array_column($colPosArray, 1);
342 $colPosList = implode(
',', array_unique(array_map(
'intval', $colPosIds)));
344 $code .= $posMap->printContentElementColumns($this->
id, 0, $colPosList, 1, $this->R_URI);
345 $this->content .=
'<h2>' .
$lang->getLL(
'2_selectPosition',
true) .
'</h2><div>' . $code .
'</div>';
350 $this->content .=
'<h1>' .
$lang->getLL(
'newContentElement') .
'</h1>';
352 $this->content .=
'</form>';
362 $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
364 $backButton = $buttonBar->makeLinkButton()
365 ->setHref($this->R_URI)
367 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
368 'actions-view-go-back',
371 $buttonBar->addButton($backButton);
373 $cshButton = $buttonBar->makeHelpButton()->setModuleName(
'xMOD_csh_corebe')->setFieldName(
'new_ce');
374 $buttonBar->addButton($cshButton);
402 $wizardItems = array();
403 if (is_array($this->config)) {
404 $wizards = $this->config[
'wizardItems.'];
406 if (is_array($wizards)) {
407 foreach ($wizards as $groupKey => $wizardGroup) {
408 $groupKey = rtrim($groupKey,
'.');
410 $showAll = $wizardGroup[
'show'] ===
'*';
411 $groupItems = array();
412 if (is_array($appendWizards[$groupKey .
'.'][
'elements.'])) {
413 $wizardElements = array_merge((array)$wizardGroup[
'elements.'], $appendWizards[$groupKey .
'.'][
'elements.']);
415 $wizardElements = $wizardGroup[
'elements.'];
417 if (is_array($wizardElements)) {
418 foreach ($wizardElements as $itemKey => $itemConf) {
419 $itemKey = rtrim($itemKey,
'.');
420 if ($showAll || in_array($itemKey, $showItems)) {
423 $groupItems[$groupKey .
'_' . $itemKey] = $tmpItem;
428 if (!empty($groupItems)) {
430 $wizardItems = array_merge($wizardItems, $groupItems);
446 if (!is_array($wizardElements)) {
447 $wizardElements = array();
449 if (is_array(
$GLOBALS[
'TBE_MODULES_EXT'][
'xMOD_db_new_content_el'][
'addElClasses'])) {
450 foreach (
$GLOBALS[
'TBE_MODULES_EXT'][
'xMOD_db_new_content_el'][
'addElClasses'] as $class => $path) {
453 $wizardElements = $modObj->proc($wizardElements);
456 $returnElements = array();
457 foreach ($wizardElements as $key => $wizardItem) {
458 preg_match(
'/^[a-zA-Z0-9]+_/', $key, $group);
459 $wizardGroup = $group[0] ? substr($group[0], 0, -1) .
'.' : $key;
460 $returnElements[$wizardGroup][
'elements.'][substr($key, strlen($wizardGroup)) .
'.'] = $wizardItem;
462 return $returnElements;
475 $itemConf[
'tt_content_defValues'] = $itemConf[
'tt_content_defValues.'];
476 unset($itemConf[
'tt_content_defValues.']);
504 $row = array(
'pid' => $this->
id);
506 $headersUsed = array();
508 foreach ($wizardItems as $key => $cfg) {
510 if ($wizardItems[$key][
'params']) {
516 if (is_array($tempGetVars[
'defVals'][
'tt_content'])) {
517 $wizardItems[$key][
'tt_content_defValues'] = array_merge(
518 is_array($wizardItems[$key][
'tt_content_defValues']) ? $wizardItems[$key][
'tt_content_defValues'] : array(),
519 $tempGetVars[
'defVals'][
'tt_content']
521 unset($tempGetVars[
'defVals'][
'tt_content']);
526 if (is_array($wizardItems[$key][
'tt_content_defValues'])) {
529 foreach ($wizardItems[$key][
'tt_content_defValues'] as $fN => $fV) {
530 if (is_array(
$GLOBALS[
'TCA'][
'tt_content'][
'columns'][$fN])) {
533 $authModeDeny =
$config[
'type'] ==
'select' &&
$config[
'authMode']
534 && !$backendUser->checkAuthMode(
'tt_content', $fN, $fV,
$config[
'authMode']);
536 if (!isset($removeItems[$fN])) {
539 $TCEFORM_TSconfig[$fN][
'removeItems'],
543 if (!isset($keepItems[$fN])) {
546 $TCEFORM_TSconfig[$fN][
'keepItems'],
550 $isNotInKeepItems = !empty($keepItems[$fN]) && !in_array($fV, $keepItems[$fN]);
551 if ($authModeDeny || $fN ===
'CType' && in_array($fV, $removeItems[$fN]) || $isNotInKeepItems) {
553 unset($wizardItems[$key]);
557 $wizardItems[$key][
'params'] .=
'&defVals[tt_content][' . $fN .
']=' . rawurlencode($fV);
558 $tmp = explode(
'_', $key);
559 $headersUsed[$tmp[0]] = $tmp[0];
566 foreach ($wizardItems as $key => $cfg) {
567 $tmp = explode(
'_', $key);
568 if ($tmp[0] && !$tmp[1] && !in_array($tmp[0], $headersUsed)) {
569 unset($wizardItems[$key]);