本文整理匯總了PHP中TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL方法的典型用法代碼示例。如果您正苦於以下問題:PHP BackendUtility::getRecordWSOL方法的具體用法?PHP BackendUtility::getRecordWSOL怎麽用?PHP BackendUtility::getRecordWSOL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TYPO3\CMS\Backend\Utility\BackendUtility
的用法示例。
在下文中一共展示了BackendUtility::getRecordWSOL方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: main
/**
* 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: isCommercePage
/**
* 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: main
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;
}
示例4: getEventRecordLabel
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;
}
示例5: setWorkspace
/**
* 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');
}
示例6: buildRepresentationForNode
/**
* 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;
}
示例7: buildRepresentationForNode
/**
* 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;
}
示例8: checkForAllowedLanguages
/**
* 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]);
}
}
}
}
}
示例9: addData
/**
* 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;
}
示例10: setWorkspace
/**
* @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']);
}
示例11: makeEditForm_accessCheck
/**
* 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'];
}
示例12: translationInfo
/**
* 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';
}
}
示例13: translationInfo
/**
* 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);
}
示例14: renderForeignRecordHeader
/**
* 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;
}
示例15: buildRepresentationForNode
/**
* 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;
}