Exemplo n.º 1
0
 /**
  * Returns a combined binary representation of the current users permissions for the page-record, $row.
  * The perms for user, group and everybody is OR'ed together (provided that the page-owner is the user and for the groups that the user is a member of the group
  * If the user is admin, 31 is returned	(full permissions for all five flags)
  *
  * @param	array		Input page row with all perms_* fields available.
  * @param	object		BE User Object
  * @return	integer		Bitwise representation of the users permissions in relation to input page row, $row
  */
 public function calcPerms($params, $that)
 {
     $row = $params['row'];
     $beAclConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['be_acl']);
     if (!$beAclConfig['disableOldPermissionSystem']) {
         $out = $params['outputPermissions'];
     } else {
         $out = 0;
     }
     $rootLine = BackendUtility::BEgetRootLine($row['uid']);
     $i = 0;
     $takeUserIntoAccount = 1;
     $groupIdsAlreadyUsed = array();
     foreach ($rootLine as $level => $values) {
         if ($i != 0) {
             $recursive = ' AND recursive=1';
         } else {
             $recursive = '';
         }
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_beacl_acl', 'pid=' . intval($values['uid']) . $recursive, '', 'recursive ASC');
         while ($result = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             if ($result['type'] == 0 && $that->user['uid'] == $result['object_id'] && $takeUserIntoAccount) {
                 // user has to be taken into account
                 $out |= $result['permissions'];
                 $takeUserIntoAccount = 0;
             } elseif ($result['type'] == 1 && $that->isMemberOfGroup($result['object_id']) && !in_array($result['object_id'], $groupIdsAlreadyUsed)) {
                 $out |= $result['permissions'];
                 $groupIdsAlreadyUsed[] = $result['object_id'];
             }
         }
         $i++;
     }
     return $out;
 }
Exemplo n.º 2
0
 /**
  * Administrative links for a table / record
  *
  * @param string $table Table name
  * @param array $row Record for which administrative links are generated.
  *
  * @return string HTML link tags.
  */
 public function adminLinks($table, array $row)
 {
     if ($table !== 'tx_commerce_products') {
         return parent::adminLinks($table, $row);
     } else {
         $language = $this->getLanguageService();
         // Edit link:
         $adminLink = '<a href="#" onclick="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick('&edit[' . $table . '][' . $row['uid'] . ']=edit', $this->doc->backPath)) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-open', array('title' => $language->sL('LLL:EXT:lang/locallang_core.xml:cm.edit', TRUE))) . '</a>';
         // Delete link:
         $adminLink .= '<a href="' . htmlspecialchars($this->doc->issueCommand('&cmd[' . $table . '][' . $row['uid'] . '][delete]=1')) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-delete', array('title' => $language->sL('LLL:EXT:lang/locallang_core.php:cm.delete', TRUE))) . '</a>';
         if ($row['pid'] == -1) {
             // get page TSconfig
             $pagesTyposcriptConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($GLOBALS['_POST']['popViewId']);
             if ($pagesTyposcriptConfig['tx_commerce.']['singlePid']) {
                 $previewPageId = $pagesTyposcriptConfig['tx_commerce.']['singlePid'];
             } else {
                 $previewPageId = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][COMMERCE_EXTKEY]['extConf']['previewPageID'];
             }
             $sysLanguageUid = (int) $row['sys_language_uid'];
             /**
              * Product
              *
              * @var $product Tx_Commerce_Domain_Model_Product
              */
             $product = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Domain_Model_Product', $row['t3ver_oid'], $sysLanguageUid);
             $product->loadData();
             $getVars = ($sysLanguageUid > 0 ? '&L=' . $sysLanguageUid : '') . '&ADMCMD_vPrev[' . rawurlencode($table . ':' . $row['t3ver_oid']) . ']=' . $row['uid'] . '&no_cache=1&tx_commerce_pi1[showUid]=' . $product->getUid() . '&tx_commerce_pi1[catUid]=' . current($product->getMasterparentCategory());
             $adminLink .= '<a href="#" onclick="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick($previewPageId, $this->doc->backPath, \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($row['_REAL_PID']), '', '', $getVars)) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-view') . '</a>';
         }
         return $adminLink;
     }
 }
Exemplo n.º 3
0
 /**
  * This method is called by a hook in the TYPO3 Core Engine (TCEmain) when a record is saved.
  *
  * We use the tx_linkhandler for backend "save & show" button to display records on the configured detail view page
  *
  * @param array $fieldArray: The field names and their values to be processed (passed by reference)
  * @param string $table: The table TCEmain is currently processing
  * @param string $id: The records id (if any)
  * @param object $pObj: Reference to the parent object (TCEmain)
  * @return void
  */
 public function processDatamap_preProcessFieldArray($fieldArray, $table, $id, $pObj)
 {
     if (isset($GLOBALS['_POST']['_savedokview_x'])) {
         $settingFound = FALSE;
         $currentPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($GLOBALS['_POST']['popViewId']);
         $rootLineStruct = \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($currentPageId);
         $defaultPageId = isset($rootLineStruct[0]) && array_key_exists('uid', $rootLineStruct[0]) ? $rootLineStruct[0]['uid'] : $currentPageId;
         $pagesTsConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($currentPageId, $rootLineStruct);
         $handlerConfigurationStruct = $pagesTsConfig['mod.']['tx_linkhandler.'];
         // search for the current setting for given table
         foreach ($pagesTsConfig['mod.']['tx_linkhandler.'] as $key => $handler) {
             if (is_array($handler) && $handler['listTables'] === $table) {
                 $settingFound = TRUE;
                 $selectedConfiguration = $key;
                 break;
             }
         }
         if ($settingFound) {
             $l18nPointer = array_key_exists('transOrigPointerField', $GLOBALS['TCA'][$table]['ctrl']) ? $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] : '';
             if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) {
                 $id = $pObj->substNEWwithIDs[$id];
             }
             if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) {
                 $recordArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $id);
             } else {
                 $recordArray = $fieldArray;
             }
             if (array_key_exists('previewPageId', $handlerConfigurationStruct[$selectedConfiguration]) && \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($handlerConfigurationStruct[$selectedConfiguration]['previewPageId']) > 0) {
                 $previewPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($handlerConfigurationStruct[$selectedConfiguration]['previewPageId']);
             } else {
                 $previewPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($defaultPageId);
             }
             if ($GLOBALS['BE_USER']->workspace != 0) {
                 $timeToLiveHours = intval($GLOBALS['BE_USER']->getTSConfigVal('options.workspaces.previewLinkTTLHours')) ? intval($GLOBALS['BE_USER']->getTSConfigVal('options.workspaces.previewLinkTTLHours')) : 24 * 2;
                 $wsPreviewValue = ';' . $GLOBALS['BE_USER']->workspace . ':' . $GLOBALS['BE_USER']->user['uid'] . ':' . 60 * 60 * $timeToLiveHours;
                 // get record UID for
                 if (array_key_exists($l18nPointer, $recordArray) && $recordArray[$l18nPointer] > 0 && $recordArray['sys_language_uid'] > 0) {
                     $id = $recordArray[$l18nPointer];
                 } elseif (array_key_exists('t3ver_oid', $recordArray)) {
                     // this makes no sense because we already receive the UID of the WS-Placeholder which will be the real record in the LIVE-WS
                     $id = $recordArray['t3ver_oid'];
                 }
             } else {
                 $wsPreviewValue = '';
                 if (array_key_exists($l18nPointer, $recordArray) && $recordArray[$l18nPointer] > 0 && $recordArray['sys_language_uid'] > 0) {
                     $id = $recordArray[$l18nPointer];
                 }
             }
             $linkParamValue = 'record:' . $table . ':' . $id;
             $queryString = '&eID=linkhandlerPreview&linkParams=' . $linkParamValue . $wsPreviewValue;
             $languageParam = '&L=' . $recordArray['sys_language_uid'];
             $queryString .= $languageParam . '&authCode=' . t3lib_div::stdAuthCode($linkParamValue . $wsPreviewValue . $recordArray['sys_language_uid'], '', 32);
             $GLOBALS['_POST']['viewUrl'] = '/index.php?id=' . $previewPageId . $queryString . '&y=';
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Find users which has access to given page id
  * Checks db mounts
  *
  * @param integer $page
  * @return array
  */
 public function findUsersWithPageAccess($page)
 {
     $rootLine = BackendUtility::BEgetRootLine($page);
     $rootLineIds = array();
     foreach ($rootLine as $page) {
         $rootLineIds[] = (int) $page['uid'];
     }
     $users = $this->findAllowedUsersInRootLine($rootLineIds);
     return $users;
 }
 /**
  * Create the panel of buttons for submitting the form or otherwise perform operations.
  */
 protected function getButtons()
 {
     $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
     // CSH
     $cshButton = $buttonBar->makeHelpButton()->setModuleName('_MOD_web_func')->setFieldName('');
     $buttonBar->addButton($cshButton);
     if ($this->id && is_array($this->pageinfo)) {
         // View page
         $viewButton = $buttonBar->makeLinkButton()->setOnClick(BackendUtility::viewOnClick($this->pageinfo['uid'], '', BackendUtility::BEgetRootLine($this->pageinfo['uid'])))->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage'))->setIcon($this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL))->setHref('#');
         $buttonBar->addButton($viewButton);
         // Shortcut
         $shortcutButton = $buttonBar->makeShortcutButton()->setModuleName($this->moduleName)->setGetVariables(['id', 'edit_record', 'pointer', 'new_unique_uid', 'search_field', 'search_levels', 'showLimit'])->setSetVariables(array_keys($this->MOD_MENU));
         $buttonBar->addButton($shortcutButton);
     }
 }
 /**
  * Get domain name for requested page id
  *
  * @param integer $pageId
  * @return string|NULL Domain name from first sys_domains-Record or from TCEMAIN.previewDomain, NULL if neither is configured
  */
 protected function getDomainName($pageId)
 {
     $previewDomainConfig = $GLOBALS['BE_USER']->getTSConfig('TCEMAIN.previewDomain', BackendUtility::getPagesTSconfig($pageId));
     if ($previewDomainConfig['value']) {
         $domain = $previewDomainConfig['value'];
     } else {
         $domain = BackendUtility::firstDomainRecord(BackendUtility::BEgetRootLine($pageId));
     }
     return $domain;
 }
 /**
  * Adds the rootline of a given node to the tree expansion state and adds the node
  * itself as the current selected page. This leads to the expansion and selection of
  * the node in the tree after a refresh.
  *
  * @static
  * @param string $stateId
  * @param int $nodeId
  * @return array
  */
 public static function addRootlineOfNodeToStateHash($stateId, $nodeId)
 {
     $mountPoints = array_map('intval', $GLOBALS['BE_USER']->returnWebmounts());
     if (empty($mountPoints)) {
         $mountPoints = array(0);
     }
     $mountPoints[] = (int) $GLOBALS['BE_USER']->uc['pageTree_temporaryMountPoint'];
     $mountPoints = array_unique($mountPoints);
     /** @var $userSettingsController \TYPO3\CMS\Backend\Controller\UserSettingsController */
     $userSettingsController = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\UserSettingsController::class);
     $state = $userSettingsController->process('get', 'BackendComponents.States.' . $stateId);
     if (empty($state)) {
         $state = new \StdClass();
         $state->stateHash = new \StdClass();
     }
     $state->stateHash = (object) $state->stateHash;
     $rootline = BackendUtility::BEgetRootLine($nodeId, '', $GLOBALS['BE_USER']->workspace != 0);
     $rootlineIds = array();
     foreach ($rootline as $pageData) {
         $rootlineIds[] = (int) $pageData['uid'];
     }
     foreach ($mountPoints as $mountPoint) {
         if (!in_array($mountPoint, $rootlineIds, true)) {
             continue;
         }
         $isFirstNode = true;
         foreach ($rootline as $pageData) {
             $node = Commands::getNewNode($pageData, $mountPoint);
             if ($isFirstNode) {
                 $isFirstNode = false;
                 $state->stateHash->lastSelectedNode = $node->calculateNodeId();
             } else {
                 $state->stateHash->{$node->calculateNodeId('')} = 1;
             }
         }
     }
     $userSettingsController->process('set', 'BackendComponents.States.' . $stateId, $state);
     return (array) $state->stateHash;
 }
Exemplo n.º 8
0
 /**
  * Create the panel of buttons for submitting the form or otherwise perform operations.
  *
  * @return array All available buttons as an assoc. array
  */
 protected function getButtons()
 {
     $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
     $lang = $this->getLanguageService();
     if ($this->id && $this->access) {
         // View page
         $viewButton = $buttonBar->makeLinkButton()->setHref('#')->setOnClick(BackendUtility::viewOnClick($this->pageinfo['uid'], '', BackendUtility::BEgetRootLine($this->pageinfo['uid'])))->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage'))->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-document-view', Icon::SIZE_SMALL));
         $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 99);
         if ($this->extClassConf['name'] === TypoScriptTemplateInformationModuleFunctionController::class) {
             // NEW button
             $urlParameters = ['id' => $this->id, 'template' => 'all', 'createExtension' => 'new'];
             if (!empty($this->e) && !GeneralUtility::_POST('_saveandclosedok')) {
                 $saveButton = $buttonBar->makeInputButton()->setName('_savedok')->setValue('1')->setForm('TypoScriptTemplateModuleController')->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-document-save', Icon::SIZE_SMALL))->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.saveDoc'));
                 $saveAndCloseButton = $buttonBar->makeInputButton()->setName('_saveandclosedok')->setValue('1')->setForm('TypoScriptTemplateModuleController')->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.saveCloseDoc'))->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-document-save-close', Icon::SIZE_SMALL));
                 $splitButtonElement = $buttonBar->makeSplitButton()->addItem($saveButton)->addItem($saveAndCloseButton);
                 $buttonBar->addButton($splitButtonElement, ButtonBar::BUTTON_POSITION_LEFT, 3);
                 // CLOSE button
                 $closeButton = $buttonBar->makeLinkButton()->setHref(BackendUtility::getModuleUrl('web_ts', ['id' => $this->id]))->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.closeDoc'))->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-document-close', Icon::SIZE_SMALL));
                 $buttonBar->addButton($closeButton);
             } else {
                 $newButton = $buttonBar->makeLinkButton()->setHref(BackendUtility::getModuleUrl('web_ts', $urlParameters))->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:db_new.php.pagetitle'))->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL));
                 $buttonBar->addButton($newButton);
             }
         } elseif ($this->extClassConf['name'] === TypoScriptTemplateConstantEditorModuleFunctionController::class && !empty($this->MOD_MENU['constant_editor_cat'])) {
             // SAVE button
             $saveButton = $buttonBar->makeInputButton()->setName('_savedok')->setValue('1')->setForm('TypoScriptTemplateModuleController')->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.saveDoc'))->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-document-save', Icon::SIZE_SMALL))->setShowLabelText(true);
             $buttonBar->addButton($saveButton);
         } elseif ($this->extClassConf['name'] === TypoScriptTemplateObjectBrowserModuleFunctionController::class) {
             if (!empty($this->sObj)) {
                 // BACK
                 $urlParameters = ['id' => $this->id];
                 $backButton = $buttonBar->makeLinkButton()->setHref(BackendUtility::getModuleUrl('web_ts', $urlParameters))->setClasses('typo3-goBack')->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.goBack'))->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL));
                 $buttonBar->addButton($backButton);
             }
         }
     }
     // Shortcut
     $shortcutButton = $buttonBar->makeShortcutButton()->setModuleName($this->MCONF['name'])->setGetVariables(['id', 'M']);
     $buttonBar->addButton($shortcutButton);
 }
 /**
  * [Describe function...]
  *
  * @param 	[type]		$id: ...
  * @param 	[type]		$perms_clause: ...
  * @return 	[type]		...
  * @todo Define visibility
  */
 public function ext_prevPageWithTemplate($id, $perms_clause)
 {
     $rootLine = BackendUtility::BEgetRootLine($id, $perms_clause ? ' AND ' . $perms_clause : '');
     foreach ($rootLine as $p) {
         if ($this->ext_getFirstTemplate($p['uid'])) {
             return $p;
         }
     }
 }
Exemplo n.º 10
0
 /**
  * Administrative links for a table / record
  *
  * @param string $table Table name
  * @param array $row Record for which administrative links are generated.
  * @return string HTML link tags.
  */
 public function adminLinks($table, $row)
 {
     // Edit link:
     $editUrl = BackendUtility::getModuleUrl('record_edit', ['edit' => [$table => [$row['uid'] => 'edit']], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]);
     $adminLink = '<a class="btn btn-default" href="' . htmlspecialchars($editUrl) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.edit', true) . '">' . $this->moduleTemplate->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
     // Delete link:
     $adminLink .= '<a class="btn btn-default" href="' . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction('&cmd[' . $table . '][' . $row['uid'] . '][delete]=1')) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.delete', true) . '">' . $this->moduleTemplate->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render() . '</a>';
     if ($table === 'pages') {
         // If another page module was specified, replace the default Page module with the new one
         $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
         $pageModule = BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
         // Perform some access checks:
         $a_wl = $GLOBALS['BE_USER']->check('modules', 'web_list');
         $a_wp = $GLOBALS['BE_USER']->check('modules', $pageModule);
         $adminLink .= '<a class="btn btn-default" href="#" onclick="top.loadEditId(' . $row['uid'] . ');top.goToModule(' . GeneralUtility::quoteJSvalue($pageModule) . '); return false;">' . $this->moduleTemplate->getIconFactory()->getIcon('actions-page-open', Icon::SIZE_SMALL)->render() . '</a>';
         $adminLink .= '<a class="btn btn-default" href="#" onclick="top.loadEditId(' . $row['uid'] . ');top.goToModule(\'web_list\'); return false;">' . $this->moduleTemplate->getIconFactory()->getIcon('actions-system-list-open', Icon::SIZE_SMALL)->render() . '</a>';
         // "View page" icon is added:
         $adminLink .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($row['uid'], '', BackendUtility::BEgetRootLine($row['uid']))) . '">' . $this->moduleTemplate->getIconFactory()->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '</a>';
     } else {
         if ($row['pid'] == -1) {
             $getVars = '&ADMCMD_vPrev[' . rawurlencode($table . ':' . $row['t3ver_oid']) . ']=' . $row['uid'];
             // "View page" icon is added:
             $adminLink .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($row['_REAL_PID'], '', BackendUtility::BEgetRootLine($row['_REAL_PID']), '', '', $getVars)) . '">' . $this->moduleTemplate->getIconFactory()->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '</a>';
         }
     }
     return '<div class="btn-group btn-group-sm" role="group">' . $adminLink . '</div>';
 }
Exemplo n.º 11
0
 /**
  * Create the panel of buttons for submitting the form or otherwise perform operations.
  *
  * @return array All available buttons as an assoc. array
  */
 protected function getButtons()
 {
     $buttons = array('csh' => '', 'view' => '', 'shortcut' => '');
     // CSH
     $buttons['csh'] = BackendUtility::cshItem('_MOD_web_info', '', $GLOBALS['BACK_PATH'], '', TRUE);
     // View page
     $buttons['view'] = '<a href="#" ' . 'onclick="' . htmlspecialchars(BackendUtility::viewOnClick($this->pageinfo['uid'], $GLOBALS['BACK_PATH'], BackendUtility::BEgetRootLine($this->pageinfo['uid']))) . '" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-view') . '</a>';
     // Shortcut
     if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
         $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']);
     }
     return $buttons;
 }
Exemplo n.º 12
0
 /**
  * This creates the buttons for die modules
  *
  * @param string $function Identifier for function of module
  * @return void
  */
 protected function makeButtons($function = '')
 {
     $lang = $this->getLanguageService();
     // View page
     if (!VersionState::cast($this->pageinfo['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
         $viewButton = $this->buttonBar->makeLinkButton()->setOnClick(htmlspecialchars(BackendUtility::viewOnClick($this->pageinfo['uid'], '', BackendUtility::BEgetRootLine($this->pageinfo['uid']))))->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', true))->setIcon($this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL))->setHref('#');
         $this->buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
     }
     // Shortcut
     $shortcutButton = $this->buttonBar->makeShortcutButton()->setModuleName($this->moduleName)->setGetVariables(['id', 'M', 'edit_record', 'pointer', 'new_unique_uid', 'search_field', 'search_levels', 'showLimit'])->setSetVariables(array_keys($this->MOD_MENU));
     $this->buttonBar->addButton($shortcutButton);
     // Cache
     if (!$this->modTSconfig['properties']['disableAdvanced']) {
         $clearCacheButton = $this->buttonBar->makeLinkButton()->setHref(BackendUtility::getModuleUrl($this->moduleName, ['id' => $this->pageinfo['uid'], 'clear_cache' => '1']))->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.clear_cache', true))->setIcon($this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL));
         $this->buttonBar->addButton($clearCacheButton, ButtonBar::BUTTON_POSITION_RIGHT, 1);
     }
     if (!$this->modTSconfig['properties']['disableIconToolbar']) {
         // Move record
         if (MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) {
             $urlParameters = ['table' => $this->eRParts[0], 'uid' => $this->eRParts[1], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
             $moveButton = $this->buttonBar->makeLinkButton()->setHref(BackendUtility::getModuleUrl('move_element', $urlParameters))->setTitle($lang->getLL('move_' . ($this->eRParts[0] == 'tt_content' ? 'record' : 'page'), true))->setIcon($this->iconFactory->getIcon('actions-' . ($this->eRParts[0] == 'tt_content' ? 'document' : 'page') . '-move', Icon::SIZE_SMALL));
             $this->buttonBar->addButton($moveButton, ButtonBar::BUTTON_POSITION_LEFT, 2);
         }
         // Edit page properties and page language overlay icons
         if ($this->pageIsNotLockedForEditors() && $this->getBackendUser()->checkLanguageAccess(0)) {
             // Edit localized page_language_overlay only when one specific language is selected
             if ($this->MOD_SETTINGS['function'] == 1 && $this->current_sys_language > 0) {
                 $overlayRecord = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('uid', 'pages_language_overlay', 'pid = ' . (int) $this->id . ' ' . 'AND sys_language_uid = ' . (int) $this->current_sys_language . BackendUtility::deleteClause('pages_language_overlay') . BackendUtility::versioningPlaceholderClause('pages_language_overlay'), '', '', '');
                 $editLanguageButton = $this->buttonBar->makeLinkButton()->setHref('#')->setTitle($lang->getLL('editPageLanguageOverlayProperties', true))->setOnClick(htmlspecialchars(BackendUtility::editOnClick('&edit[pages_language_overlay][' . $overlayRecord['uid'] . ']=edit')))->setIcon($this->iconFactory->getIcon('mimetypes-x-content-page-language-overlay', Icon::SIZE_SMALL));
                 $this->buttonBar->addButton($editLanguageButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
             }
             $editPageButton = $this->buttonBar->makeLinkButton()->setHref('#')->setTitle($lang->getLL('editPageProperties', true))->setOnClick(htmlspecialchars(BackendUtility::editOnClick('&edit[pages][' . $this->id . ']=edit')))->setIcon($this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL));
             $this->buttonBar->addButton($editPageButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
         }
         // Add CSH (Context Sensitive Help) icon to tool bar
         $contextSensitiveHelpButton = $this->buttonBar->makeHelpButton()->setModuleName($this->descrTable)->setFieldName($function === 'quickEdit' ? 'quickEdit' : 'columns_' . $this->MOD_SETTINGS['function']);
         $this->buttonBar->addButton($contextSensitiveHelpButton);
         // QuickEdit
         if ($function == 'quickEdit') {
             // Close Record
             $closeButton = $this->buttonBar->makeLinkButton()->setHref('#')->setOnClick(htmlspecialchars('jumpToUrl(' . GeneralUtility::quoteJSvalue($this->closeUrl) . '); return false;'))->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', true))->setIcon($this->iconFactory->getIcon('actions-document-close', Icon::SIZE_SMALL));
             $this->buttonBar->addButton($closeButton, ButtonBar::BUTTON_POSITION_LEFT, 0);
             // Save Record
             $saveButtonDropdown = $this->buttonBar->makeSplitButton();
             $saveButton = $this->buttonBar->makeInputButton()->setName('_savedok')->setValue('1')->setForm('PageLayoutController')->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', true))->setIcon($this->iconFactory->getIcon('actions-document-save', Icon::SIZE_SMALL));
             $saveButtonDropdown->addItem($saveButton);
             $saveAndCloseButton = $this->buttonBar->makeInputButton()->setName('_saveandclosedok')->setValue('1')->setForm('PageLayoutController')->setOnClick('document.editform.redirect.value=\'' . $this->closeUrl . '\';')->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', true))->setIcon($this->iconFactory->getIcon('actions-document-save-close', Icon::SIZE_SMALL));
             $saveButtonDropdown->addItem($saveAndCloseButton);
             $saveAndShowPageButton = $this->buttonBar->makeInputButton()->setName('_savedokview')->setValue('1')->setForm('PageLayoutController')->setOnClick('document.editform.redirect.value+=\'&popView=1\';')->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDocShow', true))->setIcon($this->iconFactory->getIcon('actions-document-save-view', Icon::SIZE_SMALL));
             $saveButtonDropdown->addItem($saveAndShowPageButton);
             $this->buttonBar->addButton($saveButtonDropdown, ButtonBar::BUTTON_POSITION_LEFT, 1);
             // Delete record
             if ($this->deleteButton) {
                 $deleteButton = $this->buttonBar->makeLinkButton()->setHref('#')->setOnClick(htmlspecialchars('return deleteRecord(' . GeneralUtility::quoteJSvalue($this->eRParts[0]) . ',' . GeneralUtility::quoteJSvalue($this->eRParts[1]) . ',' . GeneralUtility::quoteJSvalue(GeneralUtility::getIndpEnv('SCRIPT_NAME') . '?id=' . $this->id) . ');'))->setTitle($lang->getLL('deleteItem', true))->setIcon($this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL));
                 $this->buttonBar->addButton($deleteButton, ButtonBar::BUTTON_POSITION_LEFT, 4);
             }
             // History
             if ($this->undoButton) {
                 $undoButton = $this->buttonBar->makeLinkButton()->setHref('#')->setOnClick(htmlspecialchars('window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('record_history', array('element' => $this->eRParts[0] . ':' . $this->eRParts[1], 'revert' => 'ALL_FIELDS', 'sumUp' => -1, 'returnUrl' => $this->R_URI))) . '; return false;'))->setTitle(htmlspecialchars(sprintf($lang->getLL('undoLastChange'), BackendUtility::calcAge($GLOBALS['EXEC_TIME'] - $this->undoButtonR['tstamp'], $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears')))))->setIcon($this->iconFactory->getIcon('actions-edit-undo', Icon::SIZE_SMALL));
                 $this->buttonBar->addButton($undoButton, ButtonBar::BUTTON_POSITION_LEFT, 5);
                 $historyButton = $this->buttonBar->makeLinkButton()->setHref('#')->setOnClick(htmlspecialchars('jumpToUrl(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('record_history', array('element' => $this->eRParts[0] . ':' . $this->eRParts[1], 'returnUrl' => $this->R_URI)) . '#latest') . ');return false;'))->setTitle($lang->getLL('recordHistory', true))->setIcon($this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL));
                 $this->buttonBar->addButton($historyButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
             }
         }
     }
 }
 /**
  * Clears the treelist cache for all parents of a changed page.
  * gets called after creating a new page and after moving a page
  *
  * @param integer $affectedParentPage Parent page id of the changed page, the page to start clearing from
  * @return void
  */
 protected function clearCacheForAllParents($affectedParentPage)
 {
     $rootline = BackendUtility::BEgetRootLine($affectedParentPage);
     $rootlineIds = array();
     foreach ($rootline as $page) {
         if ($page['uid'] != 0) {
             $rootlineIds[] = $page['uid'];
         }
     }
     if (!empty($rootlineIds)) {
         $rootlineIdsImploded = implode(',', $rootlineIds);
         $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_treelist', 'pid IN(' . $rootlineIdsImploded . ')');
     }
 }
Exemplo n.º 14
0
    /**
     * Main function, rendering the document with the iframe with the RTE in.
     *
     * @return void
     * @todo Define visibility
     */
    public function main()
    {
        // Translate id to the workspace version:
        if ($versionRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->P['table'], $this->P['uid'], 'uid')) {
            $this->P['uid'] = $versionRec['uid'];
        }
        // If all parameters are available:
        if ($this->P['table'] && $this->P['field'] && $this->P['uid'] && $this->checkEditAccess($this->P['table'], $this->P['uid'])) {
            // Getting the raw record (we need only the pid-value from here...)
            $rawRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($this->P['table'], $this->P['uid']);
            \TYPO3\CMS\Backend\Utility\BackendUtility::fixVersioningPid($this->P['table'], $rawRec);
            // Setting JavaScript, including the pid value for viewing:
            $this->doc->JScode = $this->doc->wrapScriptTags('
					function jumpToUrl(URL,formEl) {	//
						if (document.editform) {
							if (!TBE_EDITOR.isFormChanged()) {
								window.location.href = URL;
							} else if (formEl) {
								if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
							}
						} else window.location.href = URL;
					}
				' . ($this->popView ? \TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick($rawRec['pid'], '', \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($rawRec['pid'])) : '') . '
			');
            // Initialize TCeforms - for rendering the field:
            $tceforms = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\FormEngine');
            // Init...
            $tceforms->initDefaultBEMode();
            // SPECIAL: Disables all wizards - we are NOT going to need them.
            $tceforms->disableWizards = 1;
            // SPECIAL: Setting background color of the RTE to ordinary background
            $tceforms->colorScheme[0] = $this->doc->bgColor;
            // Initialize style for RTE object:
            // Getting reference to the RTE object used to render the field!
            $RTEobj = \TYPO3\CMS\Backend\Utility\BackendUtility::RTEgetObj();
            if ($RTEobj->ID == 'rte') {
                $RTEobj->RTEdivStyle = 'position:relative; left:0px; top:0px; height:100%; width:100%; border:solid 0px;';
            }
            // Fetching content of record:
            $trData = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor');
            $trData->lockRecords = 1;
            $trData->fetchRecord($this->P['table'], $this->P['uid'], '');
            // Getting the processed record content out:
            $rec = reset($trData->regTableItems_data);
            $rec['uid'] = $this->P['uid'];
            $rec['pid'] = $rawRec['pid'];
            // TSconfig, setting width:
            $fieldTSConfig = $tceforms->setTSconfig($this->P['table'], $rec, $this->P['field']);
            if (strcmp($fieldTSConfig['RTEfullScreenWidth'], '')) {
                $width = $fieldTSConfig['RTEfullScreenWidth'];
            } else {
                $width = '100%';
            }
            // Get the form field and wrap it in the table with the buttons:
            $formContent = $tceforms->getSoloField($this->P['table'], $rec, $this->P['field']);
            $formContent = '


			<!--
				RTE wizard:
			-->
				<table border="0" cellpadding="0" cellspacing="0" width="' . $width . '" id="typo3-rtewizard">
					<tr>
						<td width="' . $width . '" colspan="2" id="c-formContent">' . $formContent . '</td>
						<td></td>
					</tr>
				</table>';
            // Adding hidden fields:
            $formContent .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($this->R_URI) . '" />
						<input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction');
            // Finally, add the whole setup:
            $this->content .= $tceforms->printNeededJSFunctions_top() . $formContent . $tceforms->printNeededJSFunctions();
        } else {
            // ERROR:
            $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('forms_title'), '<span class="typo3-red">' . $GLOBALS['LANG']->getLL('table_noData', 1) . '</span>', 0, 1);
        }
        // Setting up the buttons and markers for docheader
        $docHeaderButtons = $this->getButtons();
        $markers['CONTENT'] = $this->content;
        // Build the <body> for the module
        $this->content = $this->doc->startPage('');
        $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
        $this->content .= $this->doc->endPage();
        $this->content = $this->doc->insertStylesAndJS($this->content);
    }
Exemplo n.º 15
0
    /**
     * Main function, rendering the document with the iFrame with the RTE in.
     *
     * @return void
     */
    public function main()
    {
        $this->content .= '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_db')) . '" method="post" enctype="multipart/form-data" id="RteController" name="editform" ' . ' onsubmit="return TBE_EDITOR.checkSubmit(1);">';
        // Translate id to the workspace version:
        if ($versionedRecord = BackendUtility::getWorkspaceVersionOfRecord($this->getBackendUserAuthentication()->workspace, $this->P['table'], $this->P['uid'], 'uid')) {
            $this->P['uid'] = $versionedRecord['uid'];
        }
        // If all parameters are available:
        if ($this->P['table'] && $this->P['field'] && $this->P['uid'] && $this->checkEditAccess($this->P['table'], $this->P['uid'])) {
            /** @var TcaDatabaseRecord $formDataGroup */
            $formDataGroup = GeneralUtility::makeInstance(TcaDatabaseRecord::class);
            /** @var FormDataCompiler $formDataCompiler */
            $formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup);
            /** @var NodeFactory $nodeFactory */
            $nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
            $formDataCompilerInput = ['vanillaUid' => (int) $this->P['uid'], 'tableName' => $this->P['table'], 'command' => 'edit', 'disabledWizards' => true];
            $formData = $formDataCompiler->compile($formDataCompilerInput);
            $formData['fieldListToRender'] = $this->P['field'];
            $formData['renderType'] = 'outerWrapContainer';
            $formResult = $nodeFactory->create($formData)->render();
            /** @var FormResultCompiler $formResultCompiler */
            $formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class);
            $formResultCompiler->mergeResult($formResult);
            // override the default jumpToUrl
            $this->moduleTemplate->addJavaScriptCode('RteWizardInlineCode', 'function jumpToUrl(URL,formEl) {
					if (document.editform) {
						if (!TBE_EDITOR.isFormChanged()) {
							window.location.href = URL;
						} else if (formEl) {
							if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
						}
					} else {
						window.location.href = URL;
					}
				}
			');
            // Setting JavaScript of the pid value for viewing:
            if ($this->popView) {
                $this->moduleTemplate->addJavaScriptCode('PopupViewInlineJS', BackendUtility::viewOnClick($formData['databaseRow']['pid'], '', BackendUtility::BEgetRootLine($formData['databaseRow']['pid'])));
            }
            $pageTsConfigMerged = $formData['pageTsConfigMerged'];
            if ((string) $pageTsConfigMerged['TCEFORM.'][$this->P['table'] . '.'][$this->P['field'] . '.']['RTEfullScreenWidth'] !== '') {
                $width = (string) $pageTsConfigMerged['TCEFORM.'][$this->P['table'] . '.'][$this->P['field'] . '.']['RTEfullScreenWidth'];
            } else {
                $width = '100%';
            }
            // Get the form field and wrap it in the table with the buttons:
            $formContent = $formResult['html'];
            $formContent = '
				<table border="0" cellpadding="0" cellspacing="0" width="' . $width . '" id="typo3-rtewizard">
					<tr>
						<td width="' . $width . '" colspan="2" id="c-formContent">' . $formContent . '</td>
						<td></td>
					</tr>
				</table>';
            // Adding hidden fields:
            $formContent .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($this->R_URI) . '" />
						<input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />';
            // Finally, add the whole setup:
            $this->content .= $formResultCompiler->JStop() . $formContent . $formResultCompiler->printNeededJSFunctions();
        } else {
            // ERROR:
            $this->content .= '<h2>' . $this->getLanguageService()->getLL('forms_title', true) . '</h2>' . '<div><span class="text-danger">' . $this->getLanguageService()->getLL('table_noData', true) . '</span></div>';
        }
        // Setting up the buttons and markers for docHeader
        $this->getButtons();
        // Build the <body> for the module
        $this->content .= '</form>';
        $this->moduleTemplate->setContent($this->content);
    }
Exemplo n.º 16
0
 /**
  * Adding CM element for View Page
  *
  * @param integer $id Page uid (PID)
  * @param string $anchor Anchor, if any
  * @return array Item array, element in $menuItems
  * @internal
  * @todo Define visibility
  */
 public function DB_view($id, $anchor = '')
 {
     return $this->linkItem($this->label('view'), $this->excludeIcon(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-view')), \TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick($id, $this->PH_backPath, \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($id), $anchor) . 'return hideCM();');
 }
Exemplo n.º 17
0
 /**
  * Determines the rootline for the current page.
  *
  * @return array The rootline for the current page.
  */
 protected function determineRootline()
 {
     $pageId = isset($this->pageId) ? $this->pageId : $this->determinePageId();
     $rootline = \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($pageId, '', TRUE);
     return $rootline;
 }
 /**
  * Create the panel of buttons for submitting the form or otherwise perform operations.
  */
 protected function getButtons()
 {
     $lang = $this->getLanguageService();
     $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
     // Regular new element:
     if (!$this->pagesOnly) {
         // New page
         if ($this->showNewRecLink('pages')) {
             $newPageButton = $buttonBar->makeLinkButton()->setHref(GeneralUtility::linkThisScript(array('pagesOnly' => '1')))->setTitle($lang->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:newPage'))->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-page-new', Icon::SIZE_SMALL));
             $buttonBar->addButton($newPageButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
         }
         // CSH
         $cshButton = $buttonBar->makeHelpButton()->setModuleName('xMOD_csh_corebe')->setFieldName('new_regular');
         $buttonBar->addButton($cshButton);
     } elseif ($this->showNewRecLink('pages')) {
         // Pages only wizard
         // CSH
         $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'new_pages');
         $cshButton = $buttonBar->makeHelpButton()->setModuleName('xMOD_csh_corebe')->setFieldName('new_pages');
         $buttonBar->addButton($cshButton);
     }
     // Back
     if ($this->returnUrl) {
         $returnButton = $buttonBar->makeLinkButton()->setHref($this->returnUrl)->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack'))->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL));
         $buttonBar->addButton($returnButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
     }
     if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
         // View
         $pagesTSconfig = BackendUtility::getPagesTSconfig($this->pageinfo['uid']);
         if (isset($pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'])) {
             $excludeDokTypes = GeneralUtility::intExplode(',', $pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'], true);
         } else {
             // exclude sysfolders and recycler by default
             $excludeDokTypes = array(PageRepository::DOKTYPE_RECYCLER, PageRepository::DOKTYPE_SYSFOLDER, PageRepository::DOKTYPE_SPACER);
         }
         if (!in_array((int) $this->pageinfo['doktype'], $excludeDokTypes, true)) {
             $viewButton = $buttonBar->makeLinkButton()->setHref('#')->setOnClick(BackendUtility::viewOnClick($this->pageinfo['uid'], '', BackendUtility::BEgetRootLine($this->pageinfo['uid'])))->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage'))->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-document-view', Icon::SIZE_SMALL));
             $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 30);
         }
     }
 }
Exemplo n.º 19
0
 /**
  * Initializes the $_SERVER['HTTP_HOST'] environment variable in CLI
  * environments dependent on the Index Queue item's root page.
  *
  * When the Index Queue Worker task is executed by a cron job there is no
  * HTTP_HOST since we are in a CLI environment. RealURL needs the host
  * information to generate a proper URL though. Using the Index Queue item's
  * root page information we can determine the correct host although being
  * in a CLI environment.
  *
  * @param Item $item Index Queue item to use to determine the host.
  */
 protected function initializeHttpHost(Item $item)
 {
     static $hosts = array();
     $rootpageId = $item->getRootPageUid();
     $hostFound = !empty($hosts[$rootpageId]);
     if (!$hostFound) {
         $rootline = BackendUtility::BEgetRootLine($rootpageId);
         $host = BackendUtility::firstDomainRecord($rootline);
         $hosts[$rootpageId] = $host;
     }
     $_SERVER['HTTP_HOST'] = $hosts[$rootpageId];
     // needed since TYPO3 7.5
     GeneralUtility::flushInternalRuntimeCaches();
 }
Exemplo n.º 20
0
 /**
  * Gets the page root-line.
  *
  * @param int $pageId
  * @return array
  */
 protected function getRootLine($pageId)
 {
     return BackendUtility::BEgetRootLine($pageId, '', true);
 }
Exemplo n.º 21
0
 /**
  * Constructs a valid Url for browser output
  *
  * @param array $row Broken link record
  * @return string Parsed broken url
  */
 public function getBrokenUrl($row)
 {
     $domain = rtrim(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'), '/');
     $rootLine = BackendUtility::BEgetRootLine($row['record_pid']);
     // checks alternate domains
     if (count($rootLine) > 0) {
         $protocol = GeneralUtility::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://';
         $domainRecord = BackendUtility::firstDomainRecord($rootLine);
         if (!empty($domainRecord)) {
             $domain = $protocol . $domainRecord;
         }
     }
     return $domain . '/index.php?id=' . $row['url'];
 }
Exemplo n.º 22
0
 /**
  * Create the panel of buttons for submitting the form or otherwise perform
  * operations.
  *
  * @param ModuleTemplate $moduleTemplate
  */
 public function getDocHeaderButtons(ModuleTemplate $moduleTemplate)
 {
     $buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar();
     $module = $this->getModule();
     $backendUser = $this->getBackendUserAuthentication();
     $lang = $this->getLanguageService();
     // Get users permissions for this page record:
     $localCalcPerms = $backendUser->calcPerms($this->pageRow);
     // CSH
     if ((string) $this->id === '') {
         $fieldName = 'list_module_noId';
     } elseif (!$this->id) {
         $fieldName = 'list_module_root';
     } else {
         $fieldName = 'list_module';
     }
     $cshButton = $buttonBar->makeHelpButton()->setModuleName('xMOD_csh_corebe')->setFieldName($fieldName);
     $buttonBar->addButton($cshButton);
     if (isset($this->id)) {
         // View Exclude doktypes 254,255 Configuration:
         // mod.web_list.noViewWithDokTypes = 254,255
         if (isset($module->modTSconfig['properties']['noViewWithDokTypes'])) {
             $noViewDokTypes = GeneralUtility::trimExplode(',', $module->modTSconfig['properties']['noViewWithDokTypes'], true);
         } else {
             //default exclusion: doktype 254 (folder), 255 (recycler)
             $noViewDokTypes = array(PageRepository::DOKTYPE_SYSFOLDER, PageRepository::DOKTYPE_RECYCLER);
         }
         // New record on pages that are not locked by editlock
         if (!$module->modTSconfig['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
             $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', ['id' => $this->id])) . ');';
             $newRecordButton = $buttonBar->makeLinkButton()->setHref('#')->setOnClick($onClick)->setTitle($lang->getLL('newRecordGeneral', true))->setIcon($this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL));
             $buttonBar->addButton($newRecordButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
         }
         if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
             $onClick = BackendUtility::viewOnClick($this->id, '', BackendUtility::BEgetRootLine($this->id));
             $viewButton = $buttonBar->makeLinkButton()->setHref('#')->setOnClick($onClick)->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', true))->setIcon($this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL));
             $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
         }
         // If edit permissions are set, see
         // \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
         if ($localCalcPerms & Permission::PAGE_EDIT && !empty($this->id) && $this->editLockPermissions()) {
             // Edit
             $params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
             $onClick = BackendUtility::editOnClick($params, '', -1);
             $editButton = $buttonBar->makeLinkButton()->setHref('#')->setOnClick($onClick)->setTitle($lang->getLL('editPage', true))->setIcon($this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL));
             $buttonBar->addButton($editButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
         }
         // Paste
         if (($localCalcPerms & Permission::PAGE_NEW || $localCalcPerms & Permission::CONTENT_EDIT) && $this->editLockPermissions()) {
             $elFromTable = $this->clipObj->elFromTable('');
             if (!empty($elFromTable)) {
                 $onClick = 'return ' . $this->clipObj->confirmMsg('pages', $this->pageRow, 'into', $elFromTable);
                 $pasteButton = $buttonBar->makeLinkButton()->setHref($this->clipObj->pasteUrl('', $this->id))->setOnClick($onClick)->setTitle($lang->getLL('clip_paste', true))->setIcon($this->iconFactory->getIcon('actions-document-paste-after', Icon::SIZE_SMALL));
                 $buttonBar->addButton($pasteButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
             }
         }
         // Cache
         $clearCacheButton = $buttonBar->makeLinkButton()->setHref($this->listURL() . '&clear_cache=1')->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.clear_cache', true))->setIcon($this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL));
         $buttonBar->addButton($clearCacheButton, ButtonBar::BUTTON_POSITION_RIGHT);
         if ($this->table && (!isset($module->modTSconfig['properties']['noExportRecordsLinks']) || isset($module->modTSconfig['properties']['noExportRecordsLinks']) && !$module->modTSconfig['properties']['noExportRecordsLinks'])) {
             // CSV
             $csvButton = $buttonBar->makeLinkButton()->setHref($this->listURL() . '&csv=1')->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.csv', true))->setIcon($this->iconFactory->getIcon('actions-document-export-csv', Icon::SIZE_SMALL));
             $buttonBar->addButton($csvButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
             // Export
             if (ExtensionManagementUtility::isLoaded('impexp')) {
                 $url = BackendUtility::getModuleUrl('xMOD_tximpexp', array('tx_impexp[action]' => 'export'));
                 $exportButton = $buttonBar->makeLinkButton()->setHref($url . '&tx_impexp[list][]=' . rawurlencode($this->table . ':' . $this->id))->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.export', true))->setIcon($this->iconFactory->getIcon('actions-document-export-t3d', Icon::SIZE_SMALL));
                 $buttonBar->addButton($exportButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
             }
         }
         // Reload
         $reloadButton = $buttonBar->makeLinkButton()->setHref($this->listURL())->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', true))->setIcon($this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
         $buttonBar->addButton($reloadButton, ButtonBar::BUTTON_POSITION_RIGHT);
         // Shortcut
         if ($backendUser->mayMakeShortcut()) {
             $shortCutButton = $buttonBar->makeShortcutButton()->setModuleName('web_list')->setGetVariables(['id', 'M', 'imagemode', 'pointer', 'table', 'search_field', 'search_levels', 'showLimit', 'sortField', 'sortRev'])->setSetVariables(array_keys($this->MOD_MENU));
             $buttonBar->addButton($shortCutButton, ButtonBar::BUTTON_POSITION_RIGHT);
         }
         // Back
         if ($this->returnUrl) {
             $href = htmlspecialchars(GeneralUtility::linkThisUrl($this->returnUrl, array('id' => $this->id)));
             $buttons['back'] = '<a href="' . $href . '" class="typo3-goBack" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', true) . '">' . $this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL) . '</a>';
         }
     }
 }
Exemplo n.º 23
0
 /**
  * Returns the mount point path for a temporary mount or the given id
  *
  * @param int $uid
  * @return string
  */
 public static function getMountPointPath($uid = -1)
 {
     if ($uid === -1) {
         $uid = (int) $GLOBALS['BE_USER']->uc['pageTree_temporaryMountPoint'];
     }
     if ($uid <= 0) {
         return '';
     }
     if (self::$useNavTitle === NULL) {
         self::$useNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
     }
     $rootline = array_reverse(BackendUtility::BEgetRootLine($uid));
     array_shift($rootline);
     $path = array();
     foreach ($rootline as $rootlineElement) {
         $record = self::getNodeRecord($rootlineElement['uid']);
         $text = $record['title'];
         if (self::$useNavTitle && trim($record['nav_title']) !== '') {
             $text = $record['nav_title'];
         }
         $path[] = htmlspecialchars($text);
     }
     return '/' . implode('/', $path);
 }
 /**
  * Create the panel of buttons for submitting the form or otherwise perform operations.
  *
  * @return array All available buttons as an assoc. array
  */
 protected function getButtons()
 {
     $buttons = array('back' => '', 'close' => '', 'new' => '', 'save' => '', 'save_close' => '', 'view' => '', 'shortcut' => '');
     if ($this->id && $this->access) {
         // View page
         $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($this->pageinfo['uid'], $GLOBALS['BACK_PATH'], BackendUtility::BEgetRootLine($this->pageinfo['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-view') . '</a>';
         if ($this->extClassConf['name'] == 'TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateInformationModuleFunctionController') {
             // NEW button
             $buttons['new'] = '<input type="image" class="c-inputButton" name="createExtension" value="New"' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/new_el.gif', '') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:db_new.php.pagetitle', TRUE) . '" />';
             if (!empty($this->e) && !GeneralUtility::_POST('abort') && !GeneralUtility::_POST('saveclose')) {
                 // no NEW-button while edit
                 $buttons['new'] = '';
                 // SAVE button
                 $buttons['save'] = IconUtility::getSpriteIcon('actions-document-save', array('html' => '<input type="image" class="c-inputButton" name="submit" src="clear.gif" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '" ' . 'value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '" ' . '/>'));
                 // SAVE AND CLOSE button
                 $buttons['save_close'] = IconUtility::getSpriteIcon('actions-document-save-close', array('html' => '<input type="image" class="c-inputButton" name="saveclose" src="clear.gif" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', TRUE) . '" ' . 'value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', TRUE) . '" ' . '/>'));
                 // CLOSE button
                 $buttons['close'] = IconUtility::getSpriteIcon('actions-document-close', array('html' => '<input type="image" class="c-inputButton" name="abort" src="clear.gif" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', TRUE) . '" ' . 'value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', TRUE) . '" ' . '/>'));
             }
         } elseif ($this->extClassConf['name'] == 'TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateConstantEditorModuleFunctionController' && count($this->MOD_MENU['constant_editor_cat'])) {
             // SAVE button
             $buttons['save'] = IconUtility::getSpriteIcon('actions-document-save', array('html' => '<input type="image" class="c-inputButton" name="submit" src="clear.gif" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '" ' . 'value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '" ' . '/>'));
         } elseif ($this->extClassConf['name'] == 'TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateObjectBrowserModuleFunctionController') {
             if (!empty($this->sObj)) {
                 // BACK
                 $urlParameters = array('id' => $this->id);
                 $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
                 $buttons['back'] = '<a href="' . htmlspecialchars($aHref) . '" class="typo3-goBack" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', TRUE) . '">' . IconUtility::getSpriteIcon('actions-view-go-back') . '</a>';
             }
         }
         // Shortcut
         if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
             $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']);
         }
     } else {
         // Shortcut
         if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
             $buttons['shortcut'] = $this->doc->makeShortcutIcon('id', '', $this->MCONF['name']);
         }
     }
     return $buttons;
 }
Exemplo n.º 25
0
    /**
     * Renders Content Elements from the tt_content table from page id
     *
     * @param int $id Page id
     * @return string HTML for the listing
     */
    public function getTable_tt_content($id)
    {
        $backendUser = $this->getBackendUser();
        $this->pageinfo = BackendUtility::readPageAccess($this->id, $backendUser->getPagePermsClause($this->ext_CALC_PERMS));
        $this->initializeLanguages();
        $this->initializeClipboard();
        $pageTitleParamForAltDoc = '&recTitle=' . rawurlencode(BackendUtility::getRecordTitle('pages', BackendUtility::getRecordWSOL('pages', $id), true));
        /** @var $pageRenderer PageRenderer */
        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
        $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LayoutModule/DragDrop');
        $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
        $userCanEditPage = $this->ext_CALC_PERMS & Permission::PAGE_EDIT && !empty($this->id) && ($backendUser->isAdmin() || (int) $this->pageinfo['editlock'] === 0);
        if ($this->tt_contentConfig['languageColsPointer'] > 0) {
            $userCanEditPage = $this->getBackendUser()->check('tables_modify', 'pages_language_overlay');
        }
        if ($userCanEditPage) {
            $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/PageActions', 'function(PageActions) {
                PageActions.setPageId(' . (int) $this->id . ');
                PageActions.setLanguageOverlayId(' . $this->tt_contentConfig['languageColsPointer'] . ');
                PageActions.initializePageTitleRenaming();
            }');
        }
        // Get labels for CTypes and tt_content element fields in general:
        $this->CType_labels = array();
        foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $val) {
            $this->CType_labels[$val[1]] = $this->getLanguageService()->sL($val[0]);
        }
        $this->itemLabels = array();
        foreach ($GLOBALS['TCA']['tt_content']['columns'] as $name => $val) {
            $this->itemLabels[$name] = $this->getLanguageService()->sL($val['label']);
        }
        $languageColumn = array();
        $out = '';
        // Setting language list:
        $langList = $this->tt_contentConfig['sys_language_uid'];
        if ($this->tt_contentConfig['languageMode']) {
            if ($this->tt_contentConfig['languageColsPointer']) {
                $langList = '0,' . $this->tt_contentConfig['languageColsPointer'];
            } else {
                $langList = implode(',', array_keys($this->tt_contentConfig['languageCols']));
            }
            $languageColumn = array();
        }
        $langListArr = GeneralUtility::intExplode(',', $langList);
        $defLanguageCount = array();
        $defLangBinding = array();
        // For each languages... :
        // If not languageMode, then we'll only be through this once.
        foreach ($langListArr as $lP) {
            $lP = (int) $lP;
            if (!isset($this->contentElementCache[$lP])) {
                $this->contentElementCache[$lP] = array();
            }
            if (count($langListArr) === 1 || $lP === 0) {
                $showLanguage = ' AND sys_language_uid IN (' . $lP . ',-1)';
            } else {
                $showLanguage = ' AND sys_language_uid=' . $lP;
            }
            $cList = explode(',', $this->tt_contentConfig['cols']);
            $content = array();
            $head = array();
            // Select content records per column
            $contentRecordsPerColumn = $this->getContentRecordsPerColumn('table', $id, array_values($cList), $showLanguage);
            // For each column, render the content into a variable:
            foreach ($cList as $key) {
                if (!isset($this->contentElementCache[$lP][$key])) {
                    $this->contentElementCache[$lP][$key] = array();
                }
                if (!$lP) {
                    $defLanguageCount[$key] = array();
                }
                // Start wrapping div
                $content[$key] .= '<div data-colpos="' . $key . '" data-language-uid="' . $lP . '" class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-' . $lP . ' t3-page-ce-wrapper';
                if (empty($contentRecordsPerColumn[$key])) {
                    $content[$key] .= ' t3-page-ce-empty';
                }
                $content[$key] .= '">';
                // Add new content at the top most position
                $link = '';
                if ($this->getPageLayoutController()->pageIsNotLockedForEditors() && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)) {
                    $link = '<a href="#" onclick="' . htmlspecialchars($this->newContentElementOnClick($id, $key, $lP)) . '" title="' . $this->getLanguageService()->getLL('newContentElement', true) . '" class="btn btn-default btn-sm">' . $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render() . ' ' . $this->getLanguageService()->getLL('content', true) . '</a>';
                }
                $content[$key] .= '
				<div class="t3-page-ce t3js-page-ce" data-page="' . (int) $id . '" id="' . StringUtility::getUniqueId() . '">
					<div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $key . '-' . 'page-' . $id . '-' . StringUtility::getUniqueId() . '">' . $link . '</div>
                    <div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
                </div>
				';
                $editUidList = '';
                $rowArr = $contentRecordsPerColumn[$key];
                $this->generateTtContentDataArray($rowArr);
                foreach ((array) $rowArr as $rKey => $row) {
                    $this->contentElementCache[$lP][$key][$row['uid']] = $row;
                    if ($this->tt_contentConfig['languageMode']) {
                        $languageColumn[$key][$lP] = $head[$key] . $content[$key];
                        if (!$this->defLangBinding) {
                            $languageColumn[$key][$lP] .= $this->newLanguageButton($this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP), $lP, $key);
                        }
                    }
                    if (is_array($row) && !VersionState::cast($row['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
                        $singleElementHTML = '';
                        if (!$lP && ($this->defLangBinding || $row['sys_language_uid'] != -1)) {
                            $defLanguageCount[$key][] = isset($row['_ORIG_uid']) ? $row['_ORIG_uid'] : $row['uid'];
                        }
                        $editUidList .= $row['uid'] . ',';
                        $disableMoveAndNewButtons = $this->defLangBinding && $lP > 0;
                        if (!$this->tt_contentConfig['languageMode']) {
                            $singleElementHTML .= '<div class="t3-page-ce-dragitem" id="' . StringUtility::getUniqueId() . '">';
                        }
                        $singleElementHTML .= $this->tt_content_drawHeader($row, $this->tt_contentConfig['showInfo'] ? 15 : 5, $disableMoveAndNewButtons, !$this->tt_contentConfig['languageMode'], $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT));
                        $innerContent = '<div ' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . '>' . $this->tt_content_drawItem($row) . '</div>';
                        $singleElementHTML .= '<div class="t3-page-ce-body-inner">' . $innerContent . '</div>' . $this->tt_content_drawFooter($row);
                        $isDisabled = $this->isDisabled('tt_content', $row);
                        $statusHidden = $isDisabled ? ' t3-page-ce-hidden t3js-hidden-record' : '';
                        $displayNone = !$this->tt_contentConfig['showHidden'] && $isDisabled ? ' style="display: none;"' : '';
                        $singleElementHTML = '<div class="t3-page-ce t3js-page-ce t3js-page-ce-sortable ' . $statusHidden . '" id="element-tt_content-' . $row['uid'] . '" data-table="tt_content" data-uid="' . $row['uid'] . '"' . $displayNone . '>' . $singleElementHTML . '</div>';
                        if ($this->tt_contentConfig['languageMode']) {
                            $singleElementHTML .= '<div class="t3-page-ce t3js-page-ce">';
                        }
                        $singleElementHTML .= '<div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $key . '-' . 'page-' . $id . '-' . StringUtility::getUniqueId() . '">';
                        // Add icon "new content element below"
                        if (!$disableMoveAndNewButtons && $this->getPageLayoutController()->pageIsNotLockedForEditors() && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)) {
                            // New content element:
                            if ($this->option_newWizard) {
                                $onClick = 'window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('new_content_element') . '&id=' . $row['pid'] . '&sys_language_uid=' . $row['sys_language_uid'] . '&colPos=' . $row['colPos'] . '&uid_pid=' . -$row['uid'] . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'))) . ';';
                            } else {
                                $params = '&edit[tt_content][' . -$row['uid'] . ']=new';
                                $onClick = BackendUtility::editOnClick($params);
                            }
                            $singleElementHTML .= '
								<a href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $this->getLanguageService()->getLL('newContentElement', true) . '" class="btn btn-default btn-sm">' . $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render() . ' ' . $this->getLanguageService()->getLL('content', true) . '</a>
							';
                        }
                        $singleElementHTML .= '</div></div><div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div></div>';
                        if ($this->defLangBinding && $this->tt_contentConfig['languageMode']) {
                            $defLangBinding[$key][$lP][$row[$lP ? 'l18n_parent' : 'uid']] = $singleElementHTML;
                        } else {
                            $content[$key] .= $singleElementHTML;
                        }
                    } else {
                        unset($rowArr[$rKey]);
                    }
                }
                $content[$key] .= '</div>';
                // Add new-icon link, header:
                $newP = $this->newContentElementOnClick($id, $key, $lP);
                $colTitle = BackendUtility::getProcessedValue('tt_content', 'colPos', $key);
                $tcaItems = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getColPosListItemsParsed', $id, $this);
                foreach ($tcaItems as $item) {
                    if ($item[1] == $key) {
                        $colTitle = $this->getLanguageService()->sL($item[0]);
                    }
                }
                $pasteP = array('colPos' => $key, 'sys_language_uid' => $lP);
                $editParam = $this->doEdit && !empty($rowArr) ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc : '';
                $head[$key] .= $this->tt_content_drawColHeader($colTitle, $editParam, $newP, $pasteP);
            }
            // For each column, fit the rendered content into a table cell:
            $out = '';
            if ($this->tt_contentConfig['languageMode']) {
                // in language mode process the content elements, but only fill $languageColumn. output will be generated later
                $sortedLanguageColumn = array();
                foreach ($cList as $key) {
                    $languageColumn[$key][$lP] = $head[$key] . $content[$key];
                    if (!$this->defLangBinding) {
                        $languageColumn[$key][$lP] .= $this->newLanguageButton($this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP), $lP, $key);
                    }
                    // We sort $languageColumn again according to $cList as it may contain data already from above.
                    $sortedLanguageColumn[$key] = $languageColumn[$key];
                }
                $languageColumn = $sortedLanguageColumn;
            } else {
                $backendLayout = $this->getBackendLayoutView()->getSelectedBackendLayout($this->id);
                // GRID VIEW:
                $grid = '<div class="t3-grid-container"><table border="0" cellspacing="0" cellpadding="0" width="100%" class="t3-page-columns t3-grid-table t3js-page-columns">';
                // Add colgroups
                $colCount = (int) $backendLayout['__config']['backend_layout.']['colCount'];
                $rowCount = (int) $backendLayout['__config']['backend_layout.']['rowCount'];
                $grid .= '<colgroup>';
                for ($i = 0; $i < $colCount; $i++) {
                    $grid .= '<col style="width:' . 100 / $colCount . '%"></col>';
                }
                $grid .= '</colgroup>';
                // Cycle through rows
                for ($row = 1; $row <= $rowCount; $row++) {
                    $rowConfig = $backendLayout['__config']['backend_layout.']['rows.'][$row . '.'];
                    if (!isset($rowConfig)) {
                        continue;
                    }
                    $grid .= '<tr>';
                    for ($col = 1; $col <= $colCount; $col++) {
                        $columnConfig = $rowConfig['columns.'][$col . '.'];
                        if (!isset($columnConfig)) {
                            continue;
                        }
                        // Which tt_content colPos should be displayed inside this cell
                        $columnKey = (int) $columnConfig['colPos'];
                        // Render the grid cell
                        $colSpan = (int) $columnConfig['colspan'];
                        $rowSpan = (int) $columnConfig['rowspan'];
                        $grid .= '<td valign="top"' . ($colSpan > 0 ? ' colspan="' . $colSpan . '"' : '') . ($rowSpan > 0 ? ' rowspan="' . $rowSpan . '"' : '') . ' data-colpos="' . (int) $columnConfig['colPos'] . '" data-language-uid="' . $lP . '" class="t3js-page-lang-column-' . $lP . ' t3js-page-column t3-grid-cell t3-page-column t3-page-column-' . $columnKey . (!isset($columnConfig['colPos']) || $columnConfig['colPos'] === '' ? ' t3-grid-cell-unassigned' : '') . (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && !$head[$columnKey] || !GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos']) ? ' t3-grid-cell-restricted' : '') . ($colSpan > 0 ? ' t3-gridCell-width' . $colSpan : '') . ($rowSpan > 0 ? ' t3-gridCell-height' . $rowSpan : '') . '">';
                        // Draw the pre-generated header with edit and new buttons if a colPos is assigned.
                        // If not, a new header without any buttons will be generated.
                        if (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && $head[$columnKey] && GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])) {
                            $grid .= $head[$columnKey] . $content[$columnKey];
                        } elseif (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])) {
                            $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('noAccess'), '', '');
                        } elseif (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && !GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])) {
                            $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name']) . ' (' . $this->getLanguageService()->getLL('noAccess') . ')', '', '');
                        } elseif (isset($columnConfig['name']) && $columnConfig['name'] !== '') {
                            $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name']) . ' (' . $this->getLanguageService()->getLL('notAssigned') . ')', '', '');
                        } else {
                            $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('notAssigned'), '', '');
                        }
                        $grid .= '</td>';
                    }
                    $grid .= '</tr>';
                }
                $out .= $grid . '</table></div>';
            }
            // CSH:
            $out .= BackendUtility::cshItem($this->descrTable, 'columns_multi');
        }
        // If language mode, then make another presentation:
        // Notice that THIS presentation will override the value of $out!
        // But it needs the code above to execute since $languageColumn is filled with content we need!
        if ($this->tt_contentConfig['languageMode']) {
            // Get language selector:
            $languageSelector = $this->languageSelector($id);
            // Reset out - we will make new content here:
            $out = '';
            // Traverse languages found on the page and build up the table displaying them side by side:
            $cCont = array();
            $sCont = array();
            foreach ($langListArr as $lP) {
                // Header:
                $lP = (int) $lP;
                $cCont[$lP] = '
					<td valign="top" class="t3-page-column" data-language-uid="' . $lP . '">
						<h2>' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '</h2>
					</td>';
                // "View page" icon is added:
                $viewLink = '';
                if (!VersionState::cast($this->getPageLayoutController()->pageinfo['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
                    $onClick = BackendUtility::viewOnClick($this->id, '', BackendUtility::BEgetRootLine($this->id), '', '', '&L=' . $lP);
                    $viewLink = '<a href="#" class="btn btn-default btn-sm" onclick="' . htmlspecialchars($onClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', true) . '">' . $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render() . '</a>';
                }
                // Language overlay page header:
                if ($lP) {
                    list($lpRecord) = BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . $lP);
                    BackendUtility::workspaceOL('pages_language_overlay', $lpRecord);
                    $params = '&edit[pages_language_overlay][' . $lpRecord['uid'] . ']=edit&overrideVals[pages_language_overlay][sys_language_uid]=' . $lP;
                    $recordIcon = BackendUtility::wrapClickMenuOnIcon($this->iconFactory->getIconForRecord('pages_language_overlay', $lpRecord, Icon::SIZE_SMALL)->render(), 'pages_language_overlay', $lpRecord['uid']);
                    $editLink = $this->getBackendUser()->check('tables_modify', 'pages_language_overlay') ? '<a href="#" class="btn btn-default btn-sm" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params)) . '" title="' . $this->getLanguageService()->getLL('edit', true) . '">' . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>' : '';
                    $lPLabel = '<div class="btn-group">' . $viewLink . $editLink . '</div>' . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($lpRecord['title'], 20));
                } else {
                    $params = '&edit[pages][' . $this->id . ']=edit';
                    $recordIcon = BackendUtility::wrapClickMenuOnIcon($this->iconFactory->getIconForRecord('pages', $this->pageRecord, Icon::SIZE_SMALL)->render(), 'pages', $this->id);
                    $editLink = $this->getBackendUser()->check('tables_modify', 'pages_language_overlay') ? '<a href="#" class="btn btn-default btn-sm" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params)) . '" title="' . $this->getLanguageService()->getLL('edit', true) . '">' . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>' : '';
                    $lPLabel = '<div class="btn-group">' . $viewLink . $editLink . '</div>' . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($this->pageRecord['title'], 20));
                }
                $sCont[$lP] = '
					<td nowrap="nowrap" class="t3-page-column t3-page-lang-label">' . $lPLabel . '</td>';
            }
            // Add headers:
            $out .= '<tr>' . implode($cCont) . '</tr>';
            $out .= '<tr>' . implode($sCont) . '</tr>';
            unset($cCont, $sCont);
            // Traverse previously built content for the columns:
            foreach ($languageColumn as $cKey => $cCont) {
                $out .= '<tr>';
                foreach ($cCont as $languageId => $columnContent) {
                    $out .= '<td valign="top" class="t3-grid-cell t3-page-column t3js-page-column t3js-page-lang-column t3js-page-lang-column-' . $languageId . '">' . $columnContent . '</td>';
                }
                $out .= '</tr>';
                if ($this->defLangBinding) {
                    // "defLangBinding" mode
                    foreach ($defLanguageCount[$cKey] as $defUid) {
                        $cCont = array();
                        foreach ($langListArr as $lP) {
                            $cCont[] = $defLangBinding[$cKey][$lP][$defUid] . $this->newLanguageButton($this->getNonTranslatedTTcontentUids(array($defUid), $id, $lP), $lP, $cKey);
                        }
                        $out .= '
                        <tr>
							<td valign="top" class="t3-grid-cell">' . implode('</td>' . '
							<td valign="top" class="t3-grid-cell">', $cCont) . '</td>
						</tr>';
                    }
                }
            }
            // Finally, wrap it all in a table and add the language selector on top of it:
            $out = $languageSelector . '
                <div class="t3-grid-container">
                    <table cellpadding="0" cellspacing="0" class="t3-page-columns t3-grid-table t3js-page-columns">
						' . $out . '
                    </table>
				</div>';
            // CSH:
            $out .= BackendUtility::cshItem($this->descrTable, 'language_list');
        }
        return $out;
    }
 /**
  * Renders table rows of all pages containing TSConfig together with its rootline
  *
  * @return array
  */
 protected function getOverviewOfPagesUsingTSConfig()
 {
     $db = $this->getDatabaseConnection();
     $res = $db->exec_SELECTquery('uid, TSconfig', 'pages', 'TSconfig != \'\'' . BackendUtility::deleteClause('pages') . BackendUtility::versioningPlaceholderClause('pages'), 'pages.uid');
     $pageArray = array();
     while ($row = $db->sql_fetch_assoc($res)) {
         $this->setInPageArray($pageArray, BackendUtility::BEgetRootLine($row['uid'], 'AND 1=1'), $row);
     }
     return $this->getList($pageArray);
 }
 /**
  * initialize the TYPO3 frontend
  * 
  * @param integer $id
  * @param integer $typeNum
  */
 protected function initTSFE($id = 1, $typeNum = 0)
 {
     EidUtility::initTCA();
     if (!is_object($GLOBALS['TT'])) {
         $GLOBALS['TT'] = new \TYPO3\CMS\Core\TimeTracker\NullTimeTracker();
         $GLOBALS['TT']->start();
     }
     $GLOBALS['TSFE'] = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], $id, $typeNum);
     $GLOBALS['TSFE']->connectToDB();
     $GLOBALS['TSFE']->initFEuser();
     $GLOBALS['TSFE']->determineId();
     $GLOBALS['TSFE']->initTemplate();
     $GLOBALS['TSFE']->getConfigArray();
     if (ExtensionManagementUtility::isLoaded('realurl')) {
         $rootline = BackendUtility::BEgetRootLine($id);
         $host = BackendUtility::firstDomainRecord($rootline);
         $_SERVER['HTTP_HOST'] = $host;
     }
 }
Exemplo n.º 28
0
 /**
  * Check if a page is inside the rootline the current user can see
  *
  * @param int $pageId Id of the the page to be checked
  * @return bool Access to the page
  */
 protected function checkRootline($pageId)
 {
     $access = false;
     $dbMounts = array_flip(explode(',', trim($this->getBackendUser()->dataLists['webmount_list'], ',')));
     $rootline = BackendUtility::BEgetRootLine($pageId);
     foreach ($rootline as $page) {
         if (isset($dbMounts[$page['uid']]) && !$access) {
             $access = true;
         }
     }
     return $access;
 }
Exemplo n.º 29
0
 /**
  * Registers the Icons into the docheader
  *
  * @return void
  * @throws \InvalidArgumentException
  */
 protected function registerDocHeaderButtons()
 {
     /** @var ButtonBar $buttonBar */
     $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
     $currentRequest = $this->request;
     $moduleName = $currentRequest->getPluginName();
     $getVars = $this->request->getArguments();
     $extensionName = $currentRequest->getControllerExtensionName();
     if (empty($getVars)) {
         $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
         $getVars = array('id', 'M', $modulePrefix);
     }
     $shortcutButton = $buttonBar->makeShortcutButton()->setModuleName($moduleName)->setGetVariables($getVars);
     $buttonBar->addButton($shortcutButton);
     if ($this->id > 0) {
         $iconFactory = $this->view->getModuleTemplate()->getIconFactory();
         $viewButton = $buttonBar->makeLinkButton()->setOnClick(htmlspecialchars(BackendUtility::viewOnClick($this->pageInfo['uid'], '', BackendUtility::BEgetRootLine($this->pageInfo['uid']))))->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', true))->setIcon($iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL))->setHref('#');
         $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
     }
 }
    /**
     * Returns the rendered record actions
     *
     * @param string $table
     * @param int $uid
     * @return string
     */
    protected function getRecordActions($table, $uid)
    {
        if ($table === '' || $uid < 0) {
            return '';
        }
        // Edit button
        $urlParameters = ['edit' => [$table => [$uid => 'edit']], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
        $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
        $pageActionIcons = '
			<a class="btn btn-default btn-sm" href="' . htmlspecialchars($url) . '">
				' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '
			</a>';
        // History button
        $urlParameters = ['element' => $table . ':' . $uid, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
        $url = BackendUtility::getModuleUrl('record_history', $urlParameters);
        $pageActionIcons .= '
			<a class="btn btn-default btn-sm" href="' . htmlspecialchars($url) . '">
				' . $this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render() . '
			</a>';
        if ($table === 'pages') {
            // Recordlist button
            $url = BackendUtility::getModuleUrl('web_list', array('id' => $uid, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')));
            $pageActionIcons .= '
				<a class="btn btn-default btn-sm" href="' . htmlspecialchars($url) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showList') . '">
					' . $this->iconFactory->getIcon('actions-system-list-open', Icon::SIZE_SMALL)->render() . '
				</a>';
            // View page button
            $viewOnClick = BackendUtility::viewOnClick($uid, '', BackendUtility::BEgetRootLine($uid));
            $pageActionIcons .= '
				<a class="btn btn-default btn-sm" href="#" onclick="' . htmlspecialchars($viewOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', true) . '">
					' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '
				</a>';
        }
        return '
			<div class="btn-group" role="group">
				' . $pageActionIcons . '
			</div>';
    }