/**
  * MAIN function for page information of localization
  *
  * @return string Output HTML for the module.
  * @todo Define visibility
  */
 public function main()
 {
     global $BACK_PATH, $LANG, $SOBE;
     $theOutput = $this->pObj->doc->header($LANG->sL('LLL:EXT:cms/web_info/locallang.xlf:lang_title'));
     if ($this->pObj->id) {
         // Depth selector:
         $h_func = BackendUtility::getFuncMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
         $h_func .= BackendUtility::getFuncMenu($this->pObj->id, 'SET[lang]', $this->pObj->MOD_SETTINGS['lang'], $this->pObj->MOD_MENU['lang']);
         $theOutput .= $h_func;
         // Add CSH:
         $theOutput .= BackendUtility::cshItem('_MOD_web_info', 'lang', $GLOBALS['BACK_PATH'], '|<br />');
         // Showing the tree:
         // Initialize starting point of page tree:
         $treeStartingPoint = (int) $this->pObj->id;
         $treeStartingRecord = BackendUtility::getRecordWSOL('pages', $treeStartingPoint);
         $depth = $this->pObj->MOD_SETTINGS['depth'];
         // Initialize tree object:
         $tree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView');
         $tree->init('AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1));
         $tree->addField('l18n_cfg');
         // Creating top icon; the current page
         $HTML = IconUtility::getSpriteIconForRecord('pages', $treeStartingRecord);
         $tree->tree[] = array('row' => $treeStartingRecord, 'HTML' => $HTML);
         // Create the tree from starting point:
         if ($depth) {
             $tree->getTree($treeStartingPoint, $depth, '');
         }
         // Render information table:
         $theOutput .= $this->renderL10nTable($tree);
     }
     return $theOutput;
 }
예제 #2
0
 /**
  * Is commerce page check.
  *
  * @return bool
  */
 public static function isCommercePage()
 {
     $table = 'pages';
     $pageId = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
     $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($table, $pageId);
     return is_array($record) && isset($record['module']) && $record['module'] == 'commerce';
 }
예제 #3
0
 /**
  * MAIN function for page information of localization
  *
  * @return string Output HTML for the module.
  */
 public function main()
 {
     $theOutput = '<h1>' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_title')) . '</h1>';
     if ($this->pObj->id) {
         // Depth selector:
         $theOutput .= '<div class="form-inline form-inline-spaced">';
         $h_func = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
         $h_func .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[lang]', $this->pObj->MOD_SETTINGS['lang'], $this->pObj->MOD_MENU['lang']);
         $theOutput .= $h_func;
         // Add CSH:
         $theOutput .= BackendUtility::cshItem('_MOD_web_info', 'lang', null, '<div class="form-group"><span class="btn btn-default btn-sm">|</span></div><br />');
         $theOutput .= '</div>';
         // Showing the tree:
         // Initialize starting point of page tree:
         $treeStartingPoint = (int) $this->pObj->id;
         $treeStartingRecord = BackendUtility::getRecordWSOL('pages', $treeStartingPoint);
         $depth = $this->pObj->MOD_SETTINGS['depth'];
         // Initialize tree object:
         $tree = GeneralUtility::makeInstance(PageTreeView::class);
         $tree->init('AND ' . $this->getBackendUser()->getPagePermsClause(1));
         $tree->addField('l18n_cfg');
         // Creating top icon; the current page
         $HTML = $this->iconFactory->getIconForRecord('pages', $treeStartingRecord, Icon::SIZE_SMALL)->render();
         $tree->tree[] = ['row' => $treeStartingRecord, 'HTML' => $HTML];
         // Create the tree from starting point:
         if ($depth) {
             $tree->getTree($treeStartingPoint, $depth, '');
         }
         // Render information table:
         $theOutput .= $this->renderL10nTable($tree);
     }
     return $theOutput;
 }
 function main(&$backRef, $menuItems, $tableID, $srcId)
 {
     $this->backRef = $backRef;
     $this->beUser = $GLOBALS['BE_USER'];
     $this->LANG = $GLOBALS['LANG'];
     $this->includeLocalLang();
     if (($tableID == 'dragDrop_tt_news_cat' || $tableID == 'tt_news_cat_CM') && $srcId) {
         $table = 'tt_news_cat';
         $rec = BackendUtility::getRecordWSOL($table, $srcId);
         // fetch page record to get editing permissions
         $lCP = $this->beUser->calcPerms(BackendUtility::getRecord('pages', $rec['pid']));
         $doEdit = $lCP & 16;
         //			if ($doEdit && $tableID == 'dragDrop_tt_news_cat') {
         //				$dstId = intval(GeneralUtility::_GP('dstId'));
         //				$menuItems['moveinto'] = $this->dragDrop_moveCategory($srcId,$dstId);
         //				$menuItems['copyinto'] = $this->dragDrop_copyCategory($srcId,$dstId);
         //			}
         if ($tableID == 'tt_news_cat_CM') {
             $menuItems = array();
             if ($doEdit) {
                 $menuItems['edit'] = $this->DB_edit($table, $srcId);
                 $menuItems['new'] = $this->DB_new($table, $rec);
                 $menuItems['newsub'] = $this->DB_new($table, $rec, true);
             }
             $menuItems['info'] = $this->backRef->DB_info($table, $srcId);
             if ($doEdit) {
                 $menuItems['hide'] = $this->DB_hideUnhide($table, $rec, 'hidden');
                 $elInfo = array(GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle('tt_news_cat', $rec), $this->beUser->uc['titleLen']));
                 $menuItems['spacer2'] = 'spacer';
                 $menuItems['delete'] = $this->DB_delete($table, $srcId, $elInfo);
             }
         }
     }
     return $menuItems;
 }
예제 #5
0
파일: Labels.php 프로젝트: ulrikkold/cal
 function getEventRecordLabel(&$params, &$pObj)
 {
     if ($params['table'] != 'tx_cal_event' && $params['table'] != 'tx_cal_exception_event') {
         return '';
     }
     // Get complete record
     $rec = BackendUtility::getRecordWSOL($params['table'], $params['row']['uid']);
     $dateObj = new \TYPO3\CMS\Cal\Model\CalDate($rec['start_date'] . '000000');
     $dateObj->setTZbyId('UTC');
     $format = str_replace(array('d', 'm', 'y', 'Y'), array('%d', '%m', '%y', '%Y'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']);
     if ($rec['allday'] || $params['table'] == 'tx_cal_exception_event') {
         /* If we have an all day event, only show the date */
         $datetime = $dateObj->format($format);
         $params['start_date'] = $datetime;
     } else {
         /* For normal events, show both the date and time */
         // gmdate is ok, as long as $rec['start_time'] just holds information about 24h.
         $datetime = $dateObj->format($format);
         $params['start_date'] = $datetime;
         $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['cal']);
         if ($extConf['showTimes'] == 1) {
             $datetime .= ' ' . gmdate($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $rec['start_time']);
         }
     }
     // Assemble the label
     $label = $datetime . ': ' . $rec['title'];
     // Write to the label
     $params['title'] = $label;
 }
예제 #6
0
 /**
  * Sets the TYPO3 Backend context to a certain workspace,
  * called by the Backend toolbar menu
  *
  * @param array $parameters
  * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxRequestHandler
  * @return void
  */
 public function setWorkspace($parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxRequestHandler)
 {
     $workspaceId = (int) GeneralUtility::_GP('workspaceId');
     $pageId = (int) GeneralUtility::_GP('pageId');
     $finalPageUid = 0;
     $originalPageId = $pageId;
     $this->getBackendUser()->setWorkspace($workspaceId);
     while ($pageId) {
         $page = BackendUtility::getRecordWSOL('pages', $pageId, '*', ' AND pages.t3ver_wsid IN (0, ' . $workspaceId . ')');
         if ($page) {
             if ($this->getBackendUser()->doesUserHaveAccess($page, 1)) {
                 break;
             }
         } else {
             $page = BackendUtility::getRecord('pages', $pageId);
         }
         $pageId = $page['pid'];
     }
     if (isset($page['uid'])) {
         $finalPageUid = (int) $page['uid'];
     }
     $response = array('title' => \TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($workspaceId), 'workspaceId' => $workspaceId, 'pageId' => $finalPageUid && $originalPageId == $finalPageUid ? NULL : $finalPageUid);
     $ajaxRequestHandler->setContent($response);
     $ajaxRequestHandler->setContentFormat('json');
 }
예제 #7
0
 /**
  * Sets the TYPO3 Backend context to a certain workspace,
  * called by the Backend toolbar menu
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function switchWorkspaceAction(ServerRequestInterface $request, ResponseInterface $response)
 {
     $parsedBody = $request->getParsedBody();
     $queryParams = $request->getQueryParams();
     $workspaceId = (int) (isset($parsedBody['workspaceId']) ? $parsedBody['workspaceId'] : $queryParams['workspaceId']);
     $pageId = (int) (isset($parsedBody['pageId']) ? $parsedBody['pageId'] : $queryParams['pageId']);
     $finalPageUid = 0;
     $originalPageId = $pageId;
     $this->getBackendUser()->setWorkspace($workspaceId);
     while ($pageId) {
         $page = BackendUtility::getRecordWSOL('pages', $pageId, '*', ' AND pages.t3ver_wsid IN (0, ' . $workspaceId . ')');
         if ($page) {
             if ($this->getBackendUser()->doesUserHaveAccess($page, 1)) {
                 break;
             }
         } else {
             $page = BackendUtility::getRecord('pages', $pageId);
         }
         $pageId = $page['pid'];
     }
     if (isset($page['uid'])) {
         $finalPageUid = (int) $page['uid'];
     }
     $ajaxResponse = ['title' => \TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($workspaceId), 'workspaceId' => $workspaceId, 'pageId' => $finalPageUid && $originalPageId == $finalPageUid ? null : $finalPageUid];
     $response->getBody()->write(json_encode($ajaxResponse));
     return $response;
 }
예제 #8
0
 /**
  * Builds a complete node including children
  *
  * @param \TYPO3\CMS\Backend\Tree\TreeNode|\TYPO3\CMS\Backend\Tree\TreeNode $basicNode
  * @param NULL|\TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode $parent
  * @param integer $level
  * @param bool $restriction
  * @return \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode node
  */
 protected function buildRepresentationForNode(\TYPO3\CMS\Backend\Tree\TreeNode $basicNode, \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode $parent = null, $level = 0, $restriction = false)
 {
     $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     /**@param $node \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode */
     $node = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode::class);
     $row = array();
     if ($basicNode->getId() == 0) {
         $node->setSelected(false);
         $node->setExpanded(true);
         $node->setLabel($GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->tableName]['ctrl']['title']));
     } else {
         $row = BackendUtility::getRecordWSOL($this->tableName, $basicNode->getId(), '*', '', false);
         if ($this->getLabelField() !== '') {
             $label = CategoryService::translateCategoryRecord($row[$this->getLabelField()], $row);
             $node->setLabel($label);
         } else {
             $node->setLabel($basicNode->getId());
         }
         $node->setSelected(GeneralUtility::inList($this->getSelectedList(), $basicNode->getId()));
         $node->setExpanded($this->isExpanded($basicNode));
         $node->setLabel($node->getLabel());
     }
     $node->setId($basicNode->getId());
     // Break to force single category activation
     if ($parent != null && $level != 0 && $this->isSingleCategoryAclActivated() && !$this->isCategoryAllowed($node)) {
         return null;
     }
     $node->setSelectable(!GeneralUtility::inList($this->getNonSelectableLevelList(), $level) && !in_array($basicNode->getId(), $this->getItemUnselectableList()));
     $node->setSortValue($this->nodeSortValues[$basicNode->getId()]);
     $node->setIcon($iconFactory->getIconForRecord($this->tableName, $row, Icon::SIZE_SMALL)->render());
     $node->setParentNode($parent);
     if ($basicNode->hasChildNodes()) {
         $node->setHasChildren(true);
         /** @var \TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection $childNodes */
         $childNodes = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection::class);
         $foundSomeChild = false;
         foreach ($basicNode->getChildNodes() as $child) {
             // Change in custom TreeDataProvider by adding the if clause
             if ($restriction || $this->isCategoryAllowed($child)) {
                 $returnedChild = $this->buildRepresentationForNode($child, $node, $level + 1, true);
                 if (!is_null($returnedChild)) {
                     $foundSomeChild = true;
                     $childNodes->append($returnedChild);
                 } else {
                     $node->setParentNode(null);
                     $node->setHasChildren(false);
                 }
             }
             // Change in custom TreeDataProvider end
         }
         if ($foundSomeChild) {
             $node->setChildNodes($childNodes);
         }
     }
     return $node;
 }
 /**
  * Builds a complete node including children
  *
  * @param \TYPO3\CMS\Backend\Tree\TreeNode|\TYPO3\CMS\Backend\Tree\TreeNode $basicNode
  * @param NULL|\TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode $parent
  * @param integer $level
  * @param bool $restriction
  * @return \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode node
  */
 protected function buildRepresentationForNode(\TYPO3\CMS\Backend\Tree\TreeNode $basicNode, \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode $parent = NULL, $level = 0, $restriction = FALSE)
 {
     /**@param $node \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode */
     $node = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Tree\\TableConfiguration\\DatabaseTreeNode');
     $row = array();
     if ($basicNode->getId() == 0) {
         $node->setSelected(FALSE);
         $node->setExpanded(TRUE);
         $node->setLabel($GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->tableName]['ctrl']['title']));
     } else {
         $row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($this->tableName, $basicNode->getId(), '*', '', FALSE);
         if ($this->getLabelField() !== '') {
             $label = Tx_MooxNews_Service_CategoryService::translateCategoryRecord($row[$this->getLabelField()], $row);
             $node->setLabel($label);
         } else {
             $node->setLabel($basicNode->getId());
         }
         $node->setSelected(\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->getSelectedList(), $basicNode->getId()));
         $node->setExpanded($this->isExpanded($basicNode));
         $node->setLabel($node->getLabel());
     }
     $node->setId($basicNode->getId());
     // Break to force single category activation
     if ($parent != NULL && $level != 0 && $this->isSingleCategoryAclActivated() && !$this->isCategoryAllowed($node)) {
         return NULL;
     }
     $node->setSelectable(!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->getNonSelectableLevelList(), $level) && !in_array($basicNode->getId(), $this->getItemUnselectableList()));
     $node->setSortValue($this->nodeSortValues[$basicNode->getId()]);
     $node->setIcon(\TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconClass($this->tableName, $row));
     $node->setParentNode($parent);
     if ($basicNode->hasChildNodes()) {
         $node->setHasChildren(TRUE);
         /** @var \TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection $childNodes */
         $childNodes = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\SortedTreeNodeCollection');
         $foundSomeChild = FALSE;
         foreach ($basicNode->getChildNodes() as $child) {
             // Change in custom TreeDataProvider by adding the if clause
             if ($restriction || $this->isCategoryAllowed($child)) {
                 $returnedChild = $this->buildRepresentationForNode($child, $node, $level + 1, TRUE);
                 if (!is_null($returnedChild)) {
                     $foundSomeChild = TRUE;
                     $childNodes->append($returnedChild);
                 } else {
                     $node->setParentNode(NULL);
                     $node->setHasChildren(FALSE);
                 }
             }
             // Change in custom TreeDataProvider end
         }
         if ($foundSomeChild) {
             $node->setChildNodes($childNodes);
         }
     }
     return $node;
 }
예제 #10
0
 /**
  * Checks if a language is allowed in this particular container - only this one container defines the allowed languages regardless of any parent
  *
  * @param array $items : The items of the current language list
  * @param  integer $gridContainerId : The ID of the current container
  *
  * @return  void
  */
 public function checkForAllowedLanguages(&$items, $gridContainerId)
 {
     if ((int) $gridContainerId > 0) {
         $parentContainer = BackendUtility::getRecordWSOL('tt_content', $gridContainerId);
         if (is_array($items) && !empty($items) && (int) $parentContainer['uid'] > 0) {
             foreach ($items as $item => $valueArray) {
                 if ((int) $parentContainer['sys_language_uid'] > -1 && (int) $valueArray[1] !== (int) $parentContainer['sys_language_uid']) {
                     unset($items[$item]);
                 }
             }
         }
     }
 }
 /**
  * Fetch default language if handled record is a localized one,
  * unserialize transOrigDiffSourceField if it is defined,
  * fetch additional languages if requested.
  *
  * @param array $result
  * @return array
  * @throws DatabaseDefaultLanguageException
  */
 public function addData(array $result)
 {
     if (!empty($result['processedTca']['ctrl']['languageField']) && !empty($result['processedTca']['ctrl']['transOrigPointerField'])) {
         $languageField = $result['processedTca']['ctrl']['languageField'];
         $fieldWithUidOfDefaultRecord = $result['processedTca']['ctrl']['transOrigPointerField'];
         if (isset($result['databaseRow'][$languageField]) && $result['databaseRow'][$languageField] > 0 && isset($result['databaseRow'][$fieldWithUidOfDefaultRecord]) && $result['databaseRow'][$fieldWithUidOfDefaultRecord] > 0) {
             // Table pages has its overlays in pages_language_overlay, this is accounted here
             $tableNameWithDefaultRecords = $result['tableName'];
             if (!empty($result['processedTca']['ctrl']['transOrigPointerTable'])) {
                 $tableNameWithDefaultRecords = $result['processedTca']['ctrl']['transOrigPointerTable'];
             }
             // Default language record of localized record
             $defaultLanguageRow = BackendUtility::getRecordWSOL($tableNameWithDefaultRecords, (int) $result['databaseRow'][$fieldWithUidOfDefaultRecord]);
             if (!is_array($defaultLanguageRow)) {
                 throw new DatabaseDefaultLanguageException('Default language record with id ' . (int) $result['databaseRow'][$fieldWithUidOfDefaultRecord] . ' not found in table ' . $result['tableName'] . ' while editing record ' . $result['databaseRow']['uid'], 1438249426);
             }
             $result['defaultLanguageRow'] = $defaultLanguageRow;
             // Unserialize the "original diff source" if given
             if (!empty($result['processedTca']['ctrl']['transOrigDiffSourceField']) && !empty($result['databaseRow'][$result['processedTca']['ctrl']['transOrigDiffSourceField']])) {
                 $defaultLanguageKey = $result['tableName'] . ':' . (int) $result['databaseRow']['uid'];
                 $result['defaultLanguageDiffRow'][$defaultLanguageKey] = unserialize($result['databaseRow'][$result['processedTca']['ctrl']['transOrigDiffSourceField']]);
             }
             // Add language overlays from further localizations if requested
             // @todo: Permission check if user is in "restrict ot language" is missing here.
             // @todo: The TranslationConfigurationProvider is more stupid than good for us ... invent a better translation overlay api!
             if (!empty($result['userTsConfig']['options.']['additionalPreviewLanguages'])) {
                 $additionalLanguageUids = GeneralUtility::intExplode(',', $result['userTsConfig']['options.']['additionalPreviewLanguages'], true);
                 /** @var TranslationConfigurationProvider $translationProvider */
                 $translationProvider = GeneralUtility::makeInstance(TranslationConfigurationProvider::class);
                 foreach ($additionalLanguageUids as $additionalLanguageUid) {
                     // Continue if this system language record does not exist or if 0 or -1 is requested
                     // or if row is the same as the to-be-displayed row
                     if ($additionalLanguageUid <= 0 || !isset($result['systemLanguageRows'][$additionalLanguageUid]) || $additionalLanguageUid === (int) $result['databaseRow'][$languageField]) {
                         continue;
                     }
                     $translationInfo = $translationProvider->translationInfo($tableNameWithDefaultRecords, (int) $result['databaseRow'][$fieldWithUidOfDefaultRecord], $additionalLanguageUid);
                     if (!empty($translationInfo['translations'][$additionalLanguageUid]['uid'])) {
                         $record = BackendUtility::getRecordWSOL($result['tableName'], (int) $translationInfo['translations'][$additionalLanguageUid]['uid']);
                         $result['additionalLanguageRows'][$additionalLanguageUid] = $record;
                     }
                 }
             }
         }
     }
     return $result;
 }
예제 #12
0
 /**
  * Information about translation for an element
  * Will overlay workspace version of record too!
  *
  * @param string $table Table name
  * @param int $uid Record uid
  * @param int $languageUid Language uid. If 0, then all languages are selected.
  * @param array $row The record to be translated
  * @param string $selFieldList Select fields for the query which fetches the translations of the current record
  * @return mixed Array with information or error message as a string.
  */
 public function translationInfo($table, $uid, $languageUid = 0, array $row = null, $selFieldList = '')
 {
     if (!$GLOBALS['TCA'][$table] || !$uid) {
         return 'No table "' . $table . '" or no UID value';
     }
     if ($row === null) {
         $row = BackendUtility::getRecordWSOL($table, $uid);
     }
     if (!is_array($row)) {
         return 'Record "' . $table . '_' . $uid . '" was not found';
     }
     $translationTable = $this->getTranslationTable($table);
     if ($translationTable === '') {
         return 'Translation is not supported for this table!';
     }
     if ($translationTable === $table && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) {
         return 'Record "' . $table . '_' . $uid . '" seems to be a translation already (has a language value "' . $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] . '", relation to record "' . $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] . '")';
     }
     if ($translationTable === $table && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0) {
         return 'Record "' . $table . '_' . $uid . '" seems to be a translation already (has a relation to record "' . $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] . '")';
     }
     // Look for translations of this record, index by language field value:
     if (!$selFieldList) {
         $selFieldList = 'uid,' . $GLOBALS['TCA'][$translationTable]['ctrl']['languageField'];
     }
     $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($translationTable);
     $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class))->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
     $queryBuilder->select(...GeneralUtility::trimExplode(',', $selFieldList))->from($translationTable)->where($queryBuilder->expr()->eq($GLOBALS['TCA'][$translationTable]['ctrl']['transOrigPointerField'], $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)), $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($table === 'pages' ? $row['uid'] : $row['pid'], \PDO::PARAM_INT)));
     if (!$languageUid) {
         $queryBuilder->andWhere($queryBuilder->expr()->gt($GLOBALS['TCA'][$translationTable]['ctrl']['languageField'], $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)));
     } else {
         $queryBuilder->andWhere($queryBuilder->expr()->eq($GLOBALS['TCA'][$translationTable]['ctrl']['languageField'], $queryBuilder->createNamedParameter($languageUid, \PDO::PARAM_INT)));
     }
     $translationRecords = $queryBuilder->execute()->fetchAll();
     $translations = [];
     $translationsErrors = [];
     foreach ($translationRecords as $translationRecord) {
         if (!isset($translations[$translationRecord[$GLOBALS['TCA'][$translationTable]['ctrl']['languageField']]])) {
             $translations[$translationRecord[$GLOBALS['TCA'][$translationTable]['ctrl']['languageField']]] = $translationRecord;
         } else {
             $translationsErrors[$translationRecord[$GLOBALS['TCA'][$translationTable]['ctrl']['languageField']]][] = $translationRecord;
         }
     }
     return ['table' => $table, 'uid' => $uid, 'CType' => $row['CType'], 'sys_language_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']], 'translation_table' => $translationTable, 'translations' => $translations, 'excessive_translations' => $translationsErrors];
 }
예제 #13
0
 /**
  * @param $parameter
  * @return array
  */
 public function setWorkspace($parameter)
 {
     $workspaceId = (int) $parameter->workSpaceId;
     $pageId = (int) $parameter->pageId;
     $GLOBALS['BE_USER']->setWorkspace($workspaceId);
     while ($pageId) {
         $page = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $pageId, '*', ' AND pages.t3ver_wsid IN (0, ' . $workspaceId . ')');
         if ($page) {
             if ($GLOBALS['BE_USER']->doesUserHaveAccess($page, 1)) {
                 break;
             }
         } else {
             $page = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $pageId);
         }
         $pageId = $page['pid'];
     }
     return array('title' => \TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($workspaceId), 'id' => $workspaceId, 'page' => isset($page['uid']) && $parameter->pageId == $page['uid'] ? NULL : (int) $page['uid']);
 }
예제 #14
0
 /**
  * Use that hook to show a info message in case someone starts editing
  * a staged element
  *
  * @param array $params
  * @param \TYPO3\CMS\Backend\Controller\EditDocumentController $form
  * @return bool
  */
 public function makeEditForm_accessCheck($params, &$form)
 {
     if ($GLOBALS['BE_USER']->workspace !== 0 && $GLOBALS['TCA'][$params['table']]['ctrl']['versioningWS']) {
         $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($params['table'], $params['uid']);
         if (abs($record['t3ver_stage']) > \TYPO3\CMS\Workspaces\Service\StagesService::STAGE_EDIT_ID) {
             $stages = GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Service\StagesService::class);
             $stageName = $stages->getStageTitle($record['t3ver_stage']);
             $editingName = $stages->getStageTitle(\TYPO3\CMS\Workspaces\Service\StagesService::STAGE_EDIT_ID);
             $message = $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:info.elementAlreadyModified');
             $flashMessage = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, sprintf($message, $stageName, $editingName), '', \TYPO3\CMS\Core\Messaging\FlashMessage::INFO, TRUE);
             /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
             $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
             /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
             $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
             $defaultFlashMessageQueue->enqueue($flashMessage);
         }
     }
     return $params['hasAccess'];
 }
 /**
  * Information about translation for an element
  * Will overlay workspace version of record too!
  *
  * @param string $table Table name
  * @param integer $uid Record uid
  * @param integer $sys_language_uid Language uid. If zero, then all languages are selected.
  * @param array $row The record to be translated
  * @param array $selFieldList Select fields for the query which fetches the translations of the current record
  * @return array Array with information. Errors will return string with message.
  * @todo Define visibility
  */
 public function translationInfo($table, $uid, $sys_language_uid = 0, $row = NULL, $selFieldList = '')
 {
     if ($GLOBALS['TCA'][$table] && $uid) {
         if ($row === NULL) {
             $row = BackendUtility::getRecordWSOL($table, $uid);
         }
         if (is_array($row)) {
             $trTable = $this->getTranslationTable($table);
             if ($trTable) {
                 if ($trTable !== $table || $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] <= 0) {
                     if ($trTable !== $table || $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] == 0) {
                         // Look for translations of this record, index by language field value:
                         $translationsTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($selFieldList ? $selFieldList : 'uid,' . $GLOBALS['TCA'][$trTable]['ctrl']['languageField'], $trTable, $GLOBALS['TCA'][$trTable]['ctrl']['transOrigPointerField'] . '=' . (int) $uid . ' AND pid=' . (int) ($table === 'pages' ? $row['uid'] : $row['pid']) . ' AND ' . $GLOBALS['TCA'][$trTable]['ctrl']['languageField'] . (!$sys_language_uid ? '>0' : '=' . (int) $sys_language_uid) . BackendUtility::deleteClause($trTable) . BackendUtility::versioningPlaceholderClause($trTable));
                         $translations = array();
                         $translations_errors = array();
                         foreach ($translationsTemp as $r) {
                             if (!isset($translations[$r[$GLOBALS['TCA'][$trTable]['ctrl']['languageField']]])) {
                                 $translations[$r[$GLOBALS['TCA'][$trTable]['ctrl']['languageField']]] = $r;
                             } else {
                                 $translations_errors[$r[$GLOBALS['TCA'][$trTable]['ctrl']['languageField']]][] = $r;
                             }
                         }
                         return array('table' => $table, 'uid' => $uid, 'CType' => $row['CType'], 'sys_language_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']], 'translation_table' => $trTable, 'translations' => $translations, 'excessive_translations' => $translations_errors);
                     } else {
                         return 'Record "' . $table . '_' . $uid . '" seems to be a translation already (has a relation to record "' . $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] . '")';
                     }
                 } else {
                     return 'Record "' . $table . '_' . $uid . '" seems to be a translation already (has a language value "' . $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] . '", relation to record "' . $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] . '")';
                 }
             } else {
                 return 'Translation is not supported for this table!';
             }
         } else {
             return 'Record "' . $table . '_' . $uid . '" was not found';
         }
     } else {
         return 'No table "' . $table . '" or no UID value';
     }
 }
 /**
  * Information about translation for an element
  * Will overlay workspace version of record too!
  *
  * @param string $table Table name
  * @param int $uid Record uid
  * @param int $languageUid Language uid. If 0, then all languages are selected.
  * @param array $row The record to be translated
  * @param string $selFieldList Select fields for the query which fetches the translations of the current record
  * @return mixed Array with information or error message as a string.
  */
 public function translationInfo($table, $uid, $languageUid = 0, array $row = null, $selFieldList = '')
 {
     if (!$GLOBALS['TCA'][$table] || !$uid) {
         return 'No table "' . $table . '" or no UID value';
     }
     if ($row === null) {
         $row = BackendUtility::getRecordWSOL($table, $uid);
     }
     if (!is_array($row)) {
         return 'Record "' . $table . '_' . $uid . '" was not found';
     }
     $translationTable = $this->getTranslationTable($table);
     if ($translationTable === '') {
         return 'Translation is not supported for this table!';
     }
     if ($translationTable === $table && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) {
         return 'Record "' . $table . '_' . $uid . '" seems to be a translation already (has a language value "' . $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] . '", relation to record "' . $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] . '")';
     }
     if ($translationTable === $table && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0) {
         return 'Record "' . $table . '_' . $uid . '" seems to be a translation already (has a relation to record "' . $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] . '")';
     }
     // Look for translations of this record, index by language field value:
     if (!$selFieldList) {
         $selFieldList = 'uid,' . $GLOBALS['TCA'][$translationTable]['ctrl']['languageField'];
     }
     $where = $GLOBALS['TCA'][$translationTable]['ctrl']['transOrigPointerField'] . '=' . (int) $uid . ' AND pid=' . (int) ($table === 'pages' ? $row['uid'] : $row['pid']) . ' AND ' . $GLOBALS['TCA'][$translationTable]['ctrl']['languageField'] . (!$languageUid ? '>0' : '=' . (int) $languageUid) . BackendUtility::deleteClause($translationTable) . BackendUtility::versioningPlaceholderClause($translationTable);
     $translationRecords = $this->getDatabaseConnection()->exec_SELECTgetRows($selFieldList, $translationTable, $where);
     $translations = array();
     $translationsErrors = array();
     foreach ($translationRecords as $translationRecord) {
         if (!isset($translations[$translationRecord[$GLOBALS['TCA'][$translationTable]['ctrl']['languageField']]])) {
             $translations[$translationRecord[$GLOBALS['TCA'][$translationTable]['ctrl']['languageField']]] = $translationRecord;
         } else {
             $translationsErrors[$translationRecord[$GLOBALS['TCA'][$translationTable]['ctrl']['languageField']]][] = $translationRecord;
         }
     }
     return array('table' => $table, 'uid' => $uid, 'CType' => $row['CType'], 'sys_language_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']], 'translation_table' => $translationTable, 'translations' => $translations, 'excessive_translations' => $translationsErrors);
 }
예제 #17
0
 /**
  * Renders the HTML header for a foreign record, such as the title, toggle-function, drag'n'drop, etc.
  * Later on the command-icons are inserted here.
  *
  * @param string $parentUid The uid of the parent (embedding) record (uid or NEW...)
  * @param string $foreign_table The foreign_table we create a header for
  * @param array $rec The current record of that foreign_table
  * @param array $config content of $PA['fieldConf']['config']
  * @param boolean $isVirtualRecord
  * @return string The HTML code of the header
  * @todo Define visibility
  */
 public function renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord = FALSE)
 {
     // Init:
     $objectId = $this->inlineNames['object'] . self::Structure_Separator . $foreign_table . self::Structure_Separator . $rec['uid'];
     // We need the returnUrl of the main script when loading the fields via AJAX-call (to correct wizard code, so include it as 3rd parameter)
     // Pre-Processing:
     $isOnSymmetricSide = RelationHandler::isOnSymmetricSide($parentUid, $config, $rec);
     $hasForeignLabel = !$isOnSymmetricSide && $config['foreign_label'] ? TRUE : FALSE;
     $hasSymmetricLabel = $isOnSymmetricSide && $config['symmetric_label'] ? TRUE : FALSE;
     // Get the record title/label for a record:
     // Try using a self-defined user function only for formatted labels
     if (isset($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc'])) {
         $params = array('table' => $foreign_table, 'row' => $rec, 'title' => '', 'isOnSymmetricSide' => $isOnSymmetricSide, 'options' => isset($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc_options']) ? $GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc_options'] : array(), 'parent' => array('uid' => $parentUid, 'config' => $config));
         // callUserFunction requires a third parameter, but we don't want to give $this as reference!
         $null = NULL;
         GeneralUtility::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc'], $params, $null);
         $recTitle = $params['title'];
         // Try using a normal self-defined user function
     } elseif (isset($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'])) {
         $params = array('table' => $foreign_table, 'row' => $rec, 'title' => '', 'isOnSymmetricSide' => $isOnSymmetricSide, 'parent' => array('uid' => $parentUid, 'config' => $config));
         // callUserFunction requires a third parameter, but we don't want to give $this as reference!
         $null = NULL;
         GeneralUtility::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'], $params, $null);
         $recTitle = $params['title'];
     } elseif ($hasForeignLabel || $hasSymmetricLabel) {
         $titleCol = $hasForeignLabel ? $config['foreign_label'] : $config['symmetric_label'];
         $foreignConfig = $this->getPossibleRecordsSelectorConfig($config, $titleCol);
         // Render title for everything else than group/db:
         if ($foreignConfig['type'] != 'groupdb') {
             $recTitle = BackendUtility::getProcessedValueExtra($foreign_table, $titleCol, $rec[$titleCol], 0, 0, FALSE);
         } else {
             // $recTitle could be something like: "tx_table_123|...",
             $valueParts = GeneralUtility::trimExplode('|', $rec[$titleCol]);
             $itemParts = GeneralUtility::revExplode('_', $valueParts[0], 2);
             $recTemp = BackendUtility::getRecordWSOL($itemParts[0], $itemParts[1]);
             $recTitle = BackendUtility::getRecordTitle($itemParts[0], $recTemp, FALSE);
         }
         $recTitle = BackendUtility::getRecordTitlePrep($recTitle);
         if (trim($recTitle) === '') {
             $recTitle = BackendUtility::getNoRecordTitle(TRUE);
         }
     } else {
         $recTitle = BackendUtility::getRecordTitle($foreign_table, $rec, TRUE);
     }
     $altText = BackendUtility::getRecordIconAltText($rec, $foreign_table);
     $iconImg = IconUtility::getSpriteIconForRecord($foreign_table, $rec, array('title' => htmlspecialchars($altText), 'id' => $objectId . '_icon'));
     $label = '<span id="' . $objectId . '_label">' . $recTitle . '</span>';
     $ctrl = $this->renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config, $isVirtualRecord);
     $thumbnail = FALSE;
     // Renders a thumbnail for the header
     if (!empty($config['appearance']['headerThumbnail']['field'])) {
         $fieldValue = $rec[$config['appearance']['headerThumbnail']['field']];
         $firstElement = array_shift(GeneralUtility::trimExplode(',', $fieldValue));
         $fileUid = array_pop(BackendUtility::splitTable_Uid($firstElement));
         if (!empty($fileUid)) {
             $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($fileUid);
             if ($fileObject && $fileObject->isMissing()) {
                 $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
                 $thumbnail = $flashMessage->render();
             } elseif ($fileObject) {
                 $imageSetup = $config['appearance']['headerThumbnail'];
                 unset($imageSetup['field']);
                 $imageSetup = array_merge(array('width' => '45', 'height' => '45c'), $imageSetup);
                 $processedImage = $fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $imageSetup);
                 // Only use a thumbnail if the processing was successful.
                 if (!$processedImage->usesOriginalFile()) {
                     $imageUrl = $processedImage->getPublicUrl(TRUE);
                     $thumbnail = '<img class="t3-form-field-header-inline-thumbnail-image" src="' . $imageUrl . '" alt="' . htmlspecialchars($altText) . '" title="' . htmlspecialchars($altText) . '">';
                 }
             }
         }
     }
     if (!empty($config['appearance']['headerThumbnail']['field']) && $thumbnail) {
         $headerClasses = ' t3-form-field-header-inline-has-thumbnail';
         $mediaContainer = '<div class="t3-form-field-header-inline-thumbnail" id="' . $objectId . '_thumbnailcontainer">' . $thumbnail . '</div>';
     } else {
         $headerClasses = ' t3-form-field-header-inline-has-icon';
         $mediaContainer = '<div class="t3-form-field-header-inline-icon" id="' . $objectId . '_iconcontainer">' . $iconImg . '</div>';
     }
     $header = '<div class="t3-form-field-header-inline-wrap' . $headerClasses . '">' . '<div class="t3-form-field-header-inline-ctrl">' . $ctrl . '</div>' . '<div class="t3-form-field-header-inline-body">' . $mediaContainer . '<div class="t3-form-field-header-inline-summary">' . $label . '</div>' . '</div>' . '</div>';
     return $header;
 }
 /**
  * Builds a complete node including childs
  *
  * @param \TYPO3\CMS\Backend\Tree\TreeNode $basicNode
  * @param NULL|\TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode $parent
  * @param int $level
  * @return \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode Node object
  */
 protected function buildRepresentationForNode(\TYPO3\CMS\Backend\Tree\TreeNode $basicNode, DatabaseTreeNode $parent = NULL, $level = 0)
 {
     /** @var $node \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode */
     $node = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode::class);
     $row = array();
     if ($basicNode->getId() == 0) {
         $node->setSelected(FALSE);
         $node->setExpanded(TRUE);
         $node->setLabel($GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->tableName]['ctrl']['title']));
     } else {
         $row = BackendUtility::getRecordWSOL($this->tableName, $basicNode->getId(), '*', '', FALSE);
         $node->setLabel(BackendUtility::getRecordTitle($this->tableName, $row) ?: $basicNode->getId());
         $node->setSelected(GeneralUtility::inList($this->getSelectedList(), $basicNode->getId()));
         $node->setExpanded($this->isExpanded($basicNode));
     }
     $node->setId($basicNode->getId());
     $node->setSelectable(!GeneralUtility::inList($this->getNonSelectableLevelList(), $level) && !in_array($basicNode->getId(), $this->getItemUnselectableList()));
     $node->setSortValue($this->nodeSortValues[$basicNode->getId()]);
     $node->setIcon(\TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconClass($this->tableName, $row));
     $node->setParentNode($parent);
     if ($basicNode->hasChildNodes()) {
         $node->setHasChildren(TRUE);
         /** @var $childNodes \TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection */
         $childNodes = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection::class);
         foreach ($basicNode->getChildNodes() as $child) {
             $childNodes->append($this->buildRepresentationForNode($child, $node, $level + 1));
         }
         $node->setChildNodes($childNodes);
     }
     return $node;
 }
예제 #19
0
 /**
  * For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
  *
  * @param string $href HREF value tp analyse
  * @param string $siteUrl The URL of the current website (frontend)
  * @return array Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
  * @todo Define visibility
  */
 public function parseCurUrl($href, $siteUrl)
 {
     $href = trim($href);
     if ($href) {
         $info = array();
         // Default is "url":
         $info['value'] = $href;
         $info['act'] = 'url';
         $specialParts = explode('#_SPECIAL', $href);
         // Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
         if (count($specialParts) == 2) {
             $info['value'] = '#_SPECIAL' . $specialParts[1];
             $info['act'] = 'spec';
         } elseif (strpos($href, 'file:') !== FALSE) {
             $rel = substr($href, strpos($href, 'file:') + 5);
             $rel = rawurldecode($rel);
             // resolve FAL-api "file:UID-of-sys_file-record" and "file:combined-identifier"
             $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($rel);
             if ($fileOrFolderObject instanceof Folder) {
                 $info['act'] = 'folder';
                 $info['value'] = $fileOrFolderObject->getCombinedIdentifier();
             } elseif ($fileOrFolderObject instanceof File) {
                 $info['act'] = 'file';
                 $info['value'] = $fileOrFolderObject->getUid();
             } else {
                 $info['value'] = $rel;
             }
         } elseif (GeneralUtility::isFirstPartOfStr($href, $siteUrl)) {
             // If URL is on the current frontend website:
             // URL is a file, which exists:
             if (file_exists(PATH_site . rawurldecode($href))) {
                 $info['value'] = rawurldecode($href);
                 if (@is_dir(PATH_site . $info['value'])) {
                     $info['act'] = 'folder';
                 } else {
                     $info['act'] = 'file';
                 }
             } else {
                 // URL is a page (id parameter)
                 $uP = parse_url($href);
                 $pp = preg_split('/^id=/', $uP['query']);
                 $pp[1] = preg_replace('/&id=[^&]*/', '', $pp[1]);
                 $parameters = explode('&', $pp[1]);
                 $id = array_shift($parameters);
                 if ($id) {
                     // Checking if the id-parameter is an alias.
                     if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) {
                         list($idPartR) = BackendUtility::getRecordsByField('pages', 'alias', $id);
                         $id = (int) $idPartR['uid'];
                     }
                     $pageRow = BackendUtility::getRecordWSOL('pages', $id);
                     $titleLen = (int) $GLOBALS['BE_USER']->uc['titleLen'];
                     $info['value'] = $GLOBALS['LANG']->getLL('page', TRUE) . ' \'' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($pageRow['title'], $titleLen)) . '\' (ID:' . $id . ($uP['fragment'] ? ', #' . $uP['fragment'] : '') . ')';
                     $info['pageid'] = $id;
                     $info['cElement'] = $uP['fragment'];
                     $info['act'] = 'page';
                     $info['query'] = $parameters[0] ? '&' . implode('&', $parameters) : '';
                 }
             }
         } else {
             // Email link:
             if (strtolower(substr($href, 0, 7)) == 'mailto:') {
                 $info['value'] = trim(substr($href, 7));
                 $info['act'] = 'mail';
             }
         }
         $info['info'] = $info['value'];
     } else {
         // NO value inputted:
         $info = array();
         $info['info'] = $GLOBALS['LANG']->getLL('none');
         $info['value'] = '';
         $info['act'] = 'page';
     }
     // let the hook have a look
     foreach ($this->hookObjects as $hookObject) {
         $info = $hookObject->parseCurrentUrl($href, $siteUrl, $info);
     }
     return $info;
 }
 /**
  * For RTE: This displays all content elements on a page and lets you create a link to the element.
  *
  * @return	string		HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
  */
 function expandPage()
 {
     $out = '';
     $expPageId = $this->browseLinks->expandPage;
     // Set page id (if any) to expand
     // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
     if (!$this->browseLinks->expandPage && $this->browseLinks->curUrlInfo['cElement']) {
         $expPageId = $this->browseLinks->curUrlInfo['pageid'];
         // Set to the current link page id.
     }
     // Draw the record list IF there is a page id to expand:
     if ($expPageId && t3lib_utility_Math::canBeInterpretedAsInteger($expPageId) && $GLOBALS['BE_USER']->isInWebMount($expPageId)) {
         // Set header:
         $out .= $this->browseLinks->barheader($GLOBALS['LANG']->getLL('contentElements') . ':');
         // Create header for listing, showing the page title/icon:
         $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
         $mainPageRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $expPageId);
         $picon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec);
         $picon .= \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('pages', $mainPageRec, TRUE);
         $out .= $picon . '<br />';
         // Look up tt_content elements from the expanded page:
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,header,hidden,starttime,endtime,fe_group,CType,colPos,bodytext,tx_jfmulticontent_view,tx_jfmulticontent_pages,tx_jfmulticontent_contents', 'tt_content', 'pid=' . intval($expPageId) . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tt_content') . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause('tt_content'), '', 'colPos,sorting');
         $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
         // Traverse list of records:
         $c = 0;
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $c++;
             $icon = t3lib_iconWorks::getSpriteIconForRecord('tt_content', $row);
             if ($this->browseLinks->curUrlInfo['act'] == 'page' && $this->browseLinks->curUrlInfo['cElement'] == $row['uid']) {
                 $arrCol = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
             } else {
                 $arrCol = '';
             }
             // Putting list element HTML together:
             $out .= '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/join' . ($c == $cc ? 'bottom' : '') . '.gif', 'width="18" height="16"') . ' alt="" />' . $arrCol . '<a href="#" onclick="return link_typo3Page(\'' . $expPageId . '\',\'#' . $row['uid'] . '\');">' . $icon . \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('tt_content', $row, TRUE) . '</a><br />';
             $contents = array();
             // get all contents
             switch ($row['tx_jfmulticontent_view']) {
                 case "page":
                     $contents = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(",", $row['tx_jfmulticontent_pages']);
                     break;
                 case "content":
                     $contents = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(",", $row['tx_jfmulticontent_contents']);
                     break;
                 case "irre":
                     $resIrre = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'tx_jfmulticontent_irre_parentid=' . intval($row['uid']) . ' AND deleted = 0 AND hidden = 0', '', '');
                     while ($rowIrre = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resIrre)) {
                         $contents[] = $rowIrre['uid'];
                     }
                     break;
             }
             if (count($contents) > 0) {
                 $out .= '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/line.gif', 'width="18" height="16"') . ' alt="" />' . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/blank.gif', 'width="18" height="16"') . ' alt="" />';
                 foreach ($contents as $key => $content) {
                     $out .= '<a href="#" onclick="return link_typo3Page(\'' . $expPageId . '\',\'#jfmulticontent_c' . $row['uid'] . '-' . ($key + 1) . '\');">' . '&nbsp;' . ($key + 1) . '&nbsp;' . '</a>';
                 }
                 $out .= '<br/>';
             }
         }
     }
     return $out;
 }
예제 #21
0
 /**
  * Gets the page id by a record.
  *
  * @param string $table Name of the table
  * @param integer $id Id of the accordant record
  * @param boolean $ignoreTable Whether to ignore the page, if TRUE a positive
  * @return integer Id of the page the record is persisted on
  */
 protected function getPageIdByRecord($table, $id, $ignoreTable = FALSE)
 {
     $pageId = 0;
     $id = (int) $id;
     if ($table && $id) {
         if (($ignoreTable || $table === 'pages') && $id >= 0) {
             $pageId = $id;
         } else {
             $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($table, abs($id), '*', '', FALSE);
             $pageId = $record['pid'];
         }
     }
     return $pageId;
 }
 /**
  * Init file/folder parameters
  */
 protected function initFileOrFolderRecord()
 {
     $fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->uid);
     if ($fileOrFolderObject instanceof Folder) {
         $this->folderObject = $fileOrFolderObject;
         $this->access = $this->folderObject->checkActionPermission('read');
         $this->type = 'folder';
     } else {
         $this->fileObject = $fileOrFolderObject;
         $this->access = $this->fileObject->checkActionPermission('read');
         $this->type = 'file';
         $this->table = 'sys_file';
         try {
             $this->row = BackendUtility::getRecordWSOL($this->table, $fileOrFolderObject->getUid());
         } catch (\Exception $e) {
             $this->row = array();
         }
     }
 }
예제 #23
0
 /**
  * Returns item record $table,$uid if selected on current clipboard
  * If table and uid is blank, the first element is returned.
  * Makes sense only for DB records - not files!
  *
  * @param string $table Table name
  * @param integer $uid Element uid
  * @return array Element record with extra field _RECORD_TITLE set to the title of the record
  * @todo Define visibility
  */
 public function getSelectedRecord($table = '', $uid = '')
 {
     if (!$table && !$uid) {
         $elArr = $this->elFromTable('');
         reset($elArr);
         list($table, $uid) = explode('|', key($elArr));
     }
     if ($this->isSelected($table, $uid)) {
         $selRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($table, $uid);
         $selRec['_RECORD_TITLE'] = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($table, $selRec);
         return $selRec;
     }
 }
 /**
  * Get the list of pages to show.
  * This function is called recursively
  *
  * @param array $pageArray The Page Array
  * @param array $lines Lines that have been processed up to this point
  * @param int $pageDepth The level of the current $pageArray being processed
  * @return array
  */
 protected function getList($pageArray, $lines = array(), $pageDepth = 0)
 {
     if (!is_array($pageArray)) {
         return $lines;
     }
     foreach ($pageArray as $identifier => $_) {
         if (!MathUtility::canBeInterpretedAsInteger($identifier)) {
             continue;
         }
         $line = array();
         $line['padding'] = $pageDepth * 20;
         if (isset($pageArray[$identifier . '_'])) {
             $line['link'] = htmlspecialchars(GeneralUtility::linkThisScript(array('id' => $identifier)));
             $line['icon'] = $this->iconFactory->getIconForRecord('pages', BackendUtility::getRecordWSOL('pages', $identifier), Icon::SIZE_SMALL)->render();
             $line['title'] = htmlspecialchars('ID: ' . $identifier);
             $line['pageTitle'] = GeneralUtility::fixed_lgd_cs($pageArray[$identifier], 30);
             $line['includedFiles'] = $pageArray[$identifier . '_']['includeLines'] === 0 ? '' : $pageArray[$identifier . '_']['includeLines'];
             $line['lines'] = $pageArray[$identifier . '_']['writtenLines'] === 0 ? '' : $pageArray[$identifier . '_']['writtenLines'];
         } else {
             $line['link'] = '';
             $line['icon'] = $this->iconFactory->getIconForRecord('pages', BackendUtility::getRecordWSOL('pages', $identifier), Icon::SIZE_SMALL)->render();
             $line['title'] = '';
             $line['pageTitle'] = GeneralUtility::fixed_lgd_cs($pageArray[$identifier], 30);
             $line['includedFiles'] = '';
             $line['lines'] = '';
         }
         $lines[] = $line;
         $lines = $this->getList($pageArray[$identifier . '.'], $lines, $pageDepth + 1);
     }
     return $lines;
 }
예제 #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;
    }
예제 #26
0
 /**
  * Get the list
  *
  * @param array $pArray
  * @param array $lines
  * @param int $c
  * @return array
  */
 public function renderList($pArray, $lines = [], $c = 0)
 {
     if (!is_array($pArray)) {
         return $lines;
     }
     $statusCheckedIcon = $this->moduleTemplate->getIconFactory()->getIcon('status-status-checked', Icon::SIZE_SMALL)->render();
     $i = 0;
     foreach ($pArray as $k => $v) {
         if (MathUtility::canBeInterpretedAsInteger($k)) {
             $line = [];
             $key = $k . '_';
             $line['marginLeft'] = $c * 20;
             $line['class'] = $i++ % 2 === 0 ? 'bgColor4' : 'bgColor6';
             $line['pageTitle'] = GeneralUtility::fixed_lgd_cs($pArray[$k], 30);
             $line['icon'] = $this->moduleTemplate->getIconFactory()->getIconForRecord('pages', BackendUtility::getRecordWSOL('pages', $k), Icon::SIZE_SMALL)->render();
             if (!empty($pArray[$key])) {
                 $line['href'] = GeneralUtility::linkThisScript(['id' => (int) $k]);
                 $line['title'] = 'ID: ' . (int) $k;
                 $line['count'] = $pArray[$k . '_']['count'];
                 $line['root_max_val'] = $pArray[$key]['root_max_val'] > 0 ? $statusCheckedIcon : '&nbsp;';
                 $line['root_min_val'] = $pArray[$key]['root_min_val'] === 0 ? $statusCheckedIcon : '&nbsp;';
             } else {
                 $line['href'] = '';
                 $line['title'] = '';
                 $line['count'] = '';
                 $line['root_max_val'] = '';
                 $line['root_min_val'] = '';
             }
             $lines[] = $line;
             $lines = $this->renderList($pArray[$k . '.'], $lines, $c + 1);
         }
     }
     return $lines;
 }
예제 #27
0
 /**
  * Returns a node record from a given id
  *
  * @param int $nodeId
  * @param bool $unsetMovePointers
  * @return array
  */
 public static function getNodeRecord($nodeId, $unsetMovePointers = TRUE)
 {
     $record = BackendUtility::getRecordWSOL('pages', $nodeId, '*', '', TRUE, $unsetMovePointers);
     return $record;
 }
예제 #28
0
 /**
  * Make 2nd level clickmenu (only for DBmenus)
  *
  * @param string $table Table name
  * @param integer $uid UID for the current record.
  * @return string HTML content
  * @todo Define visibility
  */
 public function printNewDBLevel($table, $uid)
 {
     // Setting internal record to the table/uid :
     $this->rec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($table, $uid);
     $menuItems = array();
     $root = 0;
     // Rootlevel
     if ($table == 'pages' && !strcmp($uid, '0')) {
         $root = 1;
     }
     // If record was found, check permissions and get menu items.
     if (is_array($this->rec) || $root) {
         $lCP = $GLOBALS['BE_USER']->calcPerms(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $table == 'pages' ? $this->rec['uid'] : $this->rec['pid']));
         // Edit:
         if (!$root && ($GLOBALS['BE_USER']->isPSet($lCP, $table, 'edit') || $GLOBALS['BE_USER']->isPSet($lCP, $table, 'editcontent'))) {
             $this->editOK = 1;
         }
         $menuItems = $this->processingByExtClassArray($menuItems, $table, $uid);
     }
     // Return the printed elements:
     if (!is_array($menuItems)) {
         $menuItems = array();
     }
     return $this->printItems($menuItems, $root ? \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('apps-pagetree-root') . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) : \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $this->rec, array('title' => htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordIconAltText($this->rec, $table)))) . \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($table, $this->rec, TRUE));
 }
예제 #29
0
 /**
  * Creating the module output.
  *
  * @return void
  */
 public function main()
 {
     $lang = $this->getLanguageService();
     if ($this->page_id) {
         $backendUser = $this->getBackendUser();
         $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Tooltip');
         // Get record for element:
         $elRow = BackendUtility::getRecordWSOL($this->table, $this->moveUid);
         // Headerline: Icon, record title:
         $headerLine = '<span ' . BackendUtility::getRecordToolTip($elRow, $this->table) . '>' . $this->moduleTemplate->getIconFactory()->getIconForRecord($this->table, $elRow, Icon::SIZE_SMALL)->render() . '</span>';
         $headerLine .= BackendUtility::getRecordTitle($this->table, $elRow, true);
         // Make-copy checkbox (clicking this will reload the page with the GET var makeCopy set differently):
         $onClick = 'window.location.href=' . GeneralUtility::quoteJSvalue(GeneralUtility::linkThisScript(array('makeCopy' => !$this->makeCopy))) . ';';
         $headerLine .= '<div><input type="hidden" name="makeCopy" value="0" />' . '<input type="checkbox" name="makeCopy" id="makeCopy" value="1"' . ($this->makeCopy ? ' checked="checked"' : '') . ' onclick="' . htmlspecialchars($onClick) . '" /> <label for="makeCopy" class="t3-label-valign-top">' . $lang->getLL('makeCopy', 1) . '</label></div>';
         // Add the header-content to the module content:
         $this->content .= '<div>' . $headerLine . '</div>';
         // Reset variable to pick up the module content in:
         $code = '';
         // IF the table is "pages":
         if ((string) $this->table == 'pages') {
             // Get page record (if accessible):
             $pageInfo = BackendUtility::readPageAccess($this->page_id, $this->perms_clause);
             if (is_array($pageInfo) && $backendUser->isInWebMount($pageInfo['pid'], $this->perms_clause)) {
                 // Initialize the position map:
                 $posMap = GeneralUtility::makeInstance(PageMovingPagePositionMap::class);
                 $posMap->moveOrCopy = $this->makeCopy ? 'copy' : 'move';
                 // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
                 if ($pageInfo['pid']) {
                     $pidPageInfo = BackendUtility::readPageAccess($pageInfo['pid'], $this->perms_clause);
                     if (is_array($pidPageInfo)) {
                         if ($backendUser->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) {
                             $code .= '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('uid' => (int) $pageInfo['pid'], 'moveUid' => $this->moveUid))) . '">' . $this->moduleTemplate->getIconFactory()->getIcon('actions-view-go-up', Icon::SIZE_SMALL)->render() . BackendUtility::getRecordTitle('pages', $pidPageInfo, true) . '</a><br />';
                         } else {
                             $code .= $this->moduleTemplate->getIconFactory()->getIconForRecord('pages', $pidPageInfo, Icon::SIZE_SMALL)->render() . BackendUtility::getRecordTitle('pages', $pidPageInfo, true) . '<br />';
                         }
                     }
                 }
                 // Create the position tree:
                 $code .= $posMap->positionTree($this->page_id, $pageInfo, $this->perms_clause, $this->R_URI);
             }
         }
         // IF the table is "tt_content":
         if ((string) $this->table == 'tt_content') {
             // First, get the record:
             $tt_content_rec = BackendUtility::getRecord('tt_content', $this->moveUid);
             // ?
             if (!$this->input_moveUid) {
                 $this->page_id = $tt_content_rec['pid'];
             }
             // Checking if the parent page is readable:
             $pageInfo = BackendUtility::readPageAccess($this->page_id, $this->perms_clause);
             if (is_array($pageInfo) && $backendUser->isInWebMount($pageInfo['pid'], $this->perms_clause)) {
                 // Initialize the position map:
                 $posMap = GeneralUtility::makeInstance(ContentMovingPagePositionMap::class);
                 $posMap->moveOrCopy = $this->makeCopy ? 'copy' : 'move';
                 $posMap->cur_sys_language = $this->sys_language;
                 // Headerline for the parent page: Icon, record title:
                 $headerLine = '<span ' . BackendUtility::getRecordToolTip($pageInfo, 'pages') . '>' . $this->moduleTemplate->getIconFactory()->getIconForRecord('pages', $pageInfo, Icon::SIZE_SMALL)->render() . '</span>';
                 $headerLine .= BackendUtility::getRecordTitle('pages', $pageInfo, true);
                 // Load SHARED page-TSconfig settings and retrieve column list from there, if applicable:
                 // SHARED page-TSconfig settings.
                 // $modTSconfig_SHARED = BackendUtility::getModTSconfig($this->pageId, 'mod.SHARED');
                 $colPosArray = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getColPosListItemsParsed', $this->page_id, $this);
                 $colPosIds = array();
                 foreach ($colPosArray as $colPos) {
                     $colPosIds[] = $colPos[1];
                 }
                 // Removing duplicates, if any
                 $colPosList = implode(',', array_unique($colPosIds));
                 // Adding parent page-header and the content element columns from position-map:
                 $code = $headerLine . '<br />';
                 $code .= $posMap->printContentElementColumns($this->page_id, $this->moveUid, $colPosList, 1, $this->R_URI);
                 // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
                 $code .= '<br /><br />';
                 if ($pageInfo['pid']) {
                     $pidPageInfo = BackendUtility::readPageAccess($pageInfo['pid'], $this->perms_clause);
                     if (is_array($pidPageInfo)) {
                         if ($backendUser->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) {
                             $code .= '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('uid' => (int) $pageInfo['pid'], 'moveUid' => $this->moveUid))) . '">' . $this->moduleTemplate->getIconFactory()->getIcon('actions-view-go-up', Icon::SIZE_SMALL)->render() . BackendUtility::getRecordTitle('pages', $pidPageInfo, true) . '</a><br />';
                         } else {
                             $code .= $this->moduleTemplate->getIconFactory()->getIconForRecord('pages', $pidPageInfo, Icon::SIZE_SMALL)->render() . BackendUtility::getRecordTitle('pages', $pidPageInfo, true) . '<br />';
                         }
                     }
                 }
                 // Create the position tree (for pages):
                 $code .= $posMap->positionTree($this->page_id, $pageInfo, $this->perms_clause, $this->R_URI);
             }
         }
         // Add the $code content as a new section to the module:
         $this->content .= '<h2>' . $lang->getLL('selectPositionOfElement') . '</h2>';
         $this->content .= '<div>' . $code . '</div>';
     }
     // Setting up the buttons and markers for docheader
     $this->getButtons();
     // Build the <body> for the module
     $this->moduleTemplate->setTitle($lang->getLL('movingElement'));
 }
예제 #30
0
 /**
  * Returns the record for a uid.
  * For tables: Looks up the record in the database.
  * For arrays: Returns the fake record for uid id.
  *
  * @param int $uid UID to look up
  * @return array The record
  */
 public function getRecord($uid)
 {
     if (is_array($this->data)) {
         return $this->dataLookup[$uid];
     } else {
         return BackendUtility::getRecordWSOL($this->table, $uid);
     }
 }