本文整理汇总了PHP中TYPO3\CMS\Backend\Utility\BackendUtility::getRecordLocalization方法的典型用法代码示例。如果您正苦于以下问题:PHP BackendUtility::getRecordLocalization方法的具体用法?PHP BackendUtility::getRecordLocalization怎么用?PHP BackendUtility::getRecordLocalization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Backend\Utility\BackendUtility
的用法示例。
在下文中一共展示了BackendUtility::getRecordLocalization方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTranslation
/**
* Get translation
*
* @param int $uid
* @param int $sysLanguageUid
* @return Tx_MooxNews_Domain_Model_News
*/
public function getTranslation($uid, $sysLanguageUid)
{
$translation = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordLocalization('tx_mooxnews_domain_model_news', $uid, $sysLanguageUid);
if (is_array($translation[0])) {
$return = $translation[0];
}
return $return;
}
示例2: getResults
/**
* @param $pageInfo
* @param $lang
* @return array
*/
protected function getResults($pageInfo, $lang)
{
$results = [];
if ($lang) {
$tableName = 'pages_language_overlay';
$localizedPageInfo = BackendUtility::getRecordLocalization('pages', $pageInfo['uid'], $lang);
if ($localizedPageInfo[0]) {
$uidForeign = $localizedPageInfo[0]['uid'];
} else {
return [];
}
} else {
$tableName = 'pages';
$uidForeign = $pageInfo['uid'];
}
$where = 'uid_foreign = ' . $uidForeign;
$where .= ' AND tablenames = "' . $tableName . '"';
$res = $this->getDatabaseConnection()->exec_SELECTquery('results', 'tx_csseo_domain_model_evaluation', $where);
while ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
$results = unserialize($row['results']);
}
return $results;
}
示例3: getPreviousLocalizedRecordUid
/**
* Returning uid of previous localized record, if any, for tables with a "sortby" column
* Used when new localized records are created so that localized records are sorted in the same order as the default language records
*
* @param string $table Table name
* @param int $uid Uid of default language record
* @param int $pid Pid of default language record
* @param int $language Language of localization
* @return int uid of record after which the localized record should be inserted
*/
protected function getPreviousLocalizedRecordUid($table, $uid, $pid, $language)
{
$previousLocalizedRecordUid = $uid;
if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['sortby']) {
$sortRow = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
$select = $sortRow . ',pid,uid';
// For content elements, we also need the colPos
if ($table === 'tt_content') {
$select .= ',colPos';
}
// Get the sort value of the default language record
$row = BackendUtility::getRecord($table, $uid, $select);
if (is_array($row)) {
// Find the previous record in default language on the same page
$where = 'pid=' . (int) $pid . ' AND ' . 'sys_language_uid=0' . ' AND ' . $sortRow . '<' . (int) $row[$sortRow];
// Respect the colPos for content elements
if ($table === 'tt_content') {
$where .= ' AND colPos=' . (int) $row['colPos'];
}
$res = $this->databaseConnection->exec_SELECTquery($select, $table, $where . $this->deleteClause($table), '', $sortRow . ' DESC', '1');
// If there is an element, find its localized record in specified localization language
if ($previousRow = $this->databaseConnection->sql_fetch_assoc($res)) {
$previousLocalizedRecord = BackendUtility::getRecordLocalization($table, $previousRow['uid'], $language);
if (is_array($previousLocalizedRecord[0])) {
$previousLocalizedRecordUid = $previousLocalizedRecord[0]['uid'];
}
}
$this->databaseConnection->sql_free_result($res);
}
}
return $previousLocalizedRecordUid;
}
示例4: loadRecordFromDatabase
/**
* @param integer $uid
* @param integer $languageUid
* @return array|NULL
*/
protected function loadRecordFromDatabase($uid, $languageUid = 0)
{
$uid = (int) $uid;
$languageUid = (int) $languageUid;
if (0 === $languageUid) {
$record = BackendUtility::getRecord('tt_content', $uid);
} else {
$record = BackendUtility::getRecordLocalization('tt_content', $uid, $languageUid);
}
$record = $this->workspacesAwareRecordService->getSingle('tt_content', '*', $record['uid']);
return $record;
}
示例5: overwriteLocale
/**
* Overwrites the localization of a record
* if the record does not have the localization, it is copied to the record.
*
* @param string $table Name of the table in which we overwrite records
* @param int $uidCopied Uid of the record that is the overwriter
* @param int $uidOverwrite Uid of the record that is to be overwritten
* @param int $loc Uid of the syslang that is overwritten
*
* @return bool Success
*/
public function overwriteLocale($table, $uidCopied, $uidOverwrite, $loc)
{
$backendUser = $this->getBackendUser();
// check params
if (!is_string($table) || !is_numeric($uidCopied) || !is_numeric($uidOverwrite) || !is_numeric($loc)) {
if (TYPO3_DLOG) {
GeneralUtility::devLog('copyLocale (belib) gets passed invalid parameters.', COMMERCE_EXTKEY, 3);
}
return false;
}
$tableConfig = SettingsFactory::getInstance()->getTcaValue($table);
// check if table is defined in the TCA
if ($tableConfig && $uidCopied) {
// make data
$recFrom = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordLocalization($table, $uidCopied, $loc);
$recTo = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordLocalization($table, $uidOverwrite, $loc);
// if the item is not localized, return
if (false == $recFrom) {
return true;
}
// if the overwritten record does not have
// the corresponding localization, just copy it
if (false == $recTo) {
return self::copyLocale($table, $uidCopied, $uidOverwrite, $loc);
}
// overwrite l18n parent
$recFrom[0]['l18n_parent'] = $uidOverwrite;
// unset uid for cleanliness
unset($recFrom[0]['uid']);
// unset all fields that are not supposed to be copied on localized versions
foreach ($tableConfig['columns'] as $fN => $fCfg) {
// Otherwise, do not copy field (unless it is the
// language field or pointer to the original language)
if (GeneralUtility::inList('exclude,noCopy,mergeIfNotBlank', $fCfg['l10n_mode']) && $fN != $tableConfig['ctrl']['languageField'] && $fN != $tableConfig['ctrl']['transOrigPointerField']) {
unset($recFrom[0][$fN]);
} elseif (isset($fCfg['config']['type']) && 'flex' == $fCfg['config']['type'] && isset($recFrom[0][$fN])) {
if ($recFrom[0][$fN]) {
$recFrom[0][$fN] = GeneralUtility::xml2array($recFrom[0][$fN]);
if (trim($recFrom[0][$fN]) == '') {
unset($recFrom[0][$fN]);
}
} else {
unset($recFrom[0][$fN]);
}
}
}
$data = array();
$data[$table][$recTo[0]['uid']] = $recFrom[0];
// init tce
/**
* Data handler.
*
* @var \TYPO3\CMS\Core\DataHandling\DataHandler $tce
*/
$tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
$tce->stripslashes_values = 0;
$tcaDefaultOverride = $backendUser->getTSConfigProp('TCAdefaults');
if (is_array($tcaDefaultOverride)) {
$tce->setDefaultsFromUserTS($tcaDefaultOverride);
}
// start
$tce->start($data, array());
// Write to session that we copy
// this is used by the hook to the datamap class to figure out if
// it should call the dynaflex so far this is the best (though not
// very clean) way to solve the issue we get when saving an article
$backendUser->uc['txcommerce_copyProcess'] = 1;
$backendUser->writeUC();
$tce->process_datamap();
// copying done, clear session
$backendUser->uc['txcommerce_copyProcess'] = 0;
$backendUser->writeUC();
// for articles we have to overwrite the attributes
if ('tx_commerce_articles' == $table) {
self::overwriteArticleAttributes($uidCopied, $uidOverwrite, $loc);
}
}
return true;
}
示例6: getPreviousLocalizedRecordUid
/**
* Returning uid of previous localized record, if any, for tables with a "sortby" column
* Used when new localized records are created so that localized records are sorted in the same order as the default language records
*
* This is a port from DataHandler::getPreviousLocalizedRecordUid that respects tx_flux_parent and tx_flux_column!
*
* @param integer $uid Uid of default language record
* @param integer $language Language of localization
* @param TYPO3\CMS\Core\DataHandling\DataHandler $datahandler
* @return integer uid of record after which the localized record should be inserted
*/
protected function getPreviousLocalizedRecordUid($uid, $language, DataHandler $reference)
{
$table = 'tt_content';
$previousLocalizedRecordUid = $uid;
$sortRow = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
$select = $sortRow . ',pid,uid,colPos,tx_flux_parent,tx_flux_column';
// Get the sort value of the default language record
$row = BackendUtility::getRecord($table, $uid, $select);
if (is_array($row)) {
// Find the previous record in default language on the same page
$where = sprintf('pid=%d AND sys_language_uid=0 AND %s < %d', (int) $row['pid'], $sortRow, (int) $row[$sortRow]);
// Respect the colPos for content elements
if ($table === 'tt_content') {
$where .= sprintf(' AND colPos=%d AND tx_flux_column=\'%s\' AND tx_flux_parent=%d', (int) $row['colPos'], $row['tx_flux_column'], (int) $row['tx_flux_parent']);
}
$where .= $reference->deleteClause($table);
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, '', $sortRow . ' DESC', '1');
// If there is an element, find its localized record in specified localization language
if ($previousRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$previousLocalizedRecord = BackendUtility::getRecordLocalization($table, $previousRow['uid'], $language);
if (is_array($previousLocalizedRecord[0])) {
$previousLocalizedRecordUid = $previousLocalizedRecord[0]['uid'];
}
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
}
return $previousLocalizedRecordUid;
}
示例7: getTranslations
/**
* Get translations
*
* @param int $l10nParent
* @param array $settings
* @param array $languages
* @return \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult
*/
public function getTranslations($l10nParent, $settings = array(), $languages = array())
{
$translations = array();
foreach ($languages as $language) {
if ($language['uid'] > 0) {
$translation = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordLocalization('tx_mooxnews_domain_model_news', $l10nParent, $language['uid']);
$language[0] = $language['title'];
$language[1] = $language['uid'];
$language[2] = $language['flagIcon'];
if (is_array($translation[0])) {
$translation[0]['language'] = $language;
$translations[] = $translation[0];
} else {
$translations[] = array("notranslation" => true, 'language' => $language);
}
}
}
return $translations;
/*
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
$newsRepository = $objectManager->get('Tx_MooxNews_Domain_Repository_NewsRepository');
return $newsRepository->findTranslations($l10nParent);
*/
}
示例8: displayCategoryTree
//.........这里部分代码省略.........
// If a SINGLE selector box...
if ($maxitems <= 1 and !$config['treeView']) {
} else {
if ($row['sys_language_uid'] && $row['l18n_parent']) {
// the current record is a translation of another record
if ($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['tx_cal']) {
// get tt_news extConf array
$confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['tx_cal']);
}
if ($confArr['useStoragePid']) {
$TSconfig = BackendUtility::getTCEFORM_TSconfig($table, $row);
$storagePid = $TSconfig['_STORAGE_PID'] ? $TSconfig['_STORAGE_PID'] : 0;
$SPaddWhere = ' AND tx_cal_category.pid IN (' . $storagePid . ')';
}
$errorMsg = array();
$notAllowedItems = array();
if ($GLOBALS['BE_USER']->getTSConfigVal('options.useListOfAllowedItems') && !$GLOBALS['BE_USER']->isAdmin()) {
$notAllowedItems = $this->getNotAllowedItems($PA, $SPaddWhere);
}
// get categories of the translation original
// $catres = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query ('tx_cal_category.uid,tx_cal_category.title,tt_news_cat_mm.sorting AS mmsorting', 'tt_news', 'tt_news_cat_mm', 'tt_news_cat', ' AND tt_news_cat_mm.uid_local='.$row['l18n_parent'].$SPaddWhere,'', 'mmsorting');
$catres = false;
if ($table == 'tx_cal_event') {
$catres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_cal_category.uid, tx_cal_category.title', 'tx_cal_category,tx_cal_event_category_mm', 'tx_cal_category.uid = tx_cal_event_category_mm.uid_foreign and tx_cal_event_category_mm.uid_local=' . $row['l18n_parent'] . $SPaddWhere);
} else {
$catres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_cal_category.uid, tx_cal_category.title', 'tx_cal_category', 'tx_cal_category.uid=' . $row['l18n_parent'] . $SPaddWhere);
}
$categories = array();
$NACats = array();
$na = false;
if ($catres) {
while ($catrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($catres)) {
if (TYPO3_MODE == 'BE' || $GLOBALS['TSFE']->beUserLogin && $GLOBALS['BE_USER']->extAdmEnabled) {
$tempRow = BackendUtility::getRecordLocalization('tx_cal_category', $catrow['uid'], $PA['row']['sys_language_uid'], '');
if (is_array($tempRow)) {
$catrow = $tempRow[0];
}
}
if (in_array($catrow['uid'], $notAllowedItems)) {
$categories[$catrow['uid']] = $NACats[] = '<p style="padding:0px;color:red;font-weight:bold;">- ' . $catrow['title'] . ' <span class="typo3-dimmed"><em>[' . $catrow['uid'] . ']</em></span></p>';
$na = true;
} else {
$categories[$catrow['uid']] = '<p style="padding:0px;">- ' . $catrow['title'] . ' <span class="typo3-dimmed"><em>[' . $catrow['uid'] . ']</em></span></p>';
}
}
$GLOBALS['TYPO3_DB']->sql_free_result($catres);
}
if ($na) {
$this->NA_Items = '<table class="warningbox" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td><img src="gfx/icon_fatalerror.gif" class="absmiddle" alt="" height="16" width="18">SAVING DISABLED!! <br />' . ($row['l18n_parent'] && $row['sys_language_uid'] ? 'The translation original of this' : 'This') . ' record has the following categories assigned that are not defined in your BE usergroup: ' . implode($NACats, chr(10)) . '</td></tr></tbody></table>';
}
$item = implode($categories, chr(10));
if ($item) {
$item = 'Categories from the translation original of this record:<br />' . $item;
} else {
$item = 'The translation original of this record has no categories assigned.<br />';
}
$item = '<div class="typo3-TCEforms-originalLanguageValue">' . $item . '</div>';
} else {
// build tree selector
$item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ? 1 : 0) . '" />';
// Set max and min items:
if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 4006000) {
$maxitems = MathUtility::forceIntegerInRange($config['maxitems'], 0);
if (!$maxitems) {
$maxitems = 100000;
}