本文整理匯總了PHP中TYPO3\CMS\Backend\Utility\BackendUtility::getWorkspaceVersionOfRecord方法的典型用法代碼示例。如果您正苦於以下問題:PHP BackendUtility::getWorkspaceVersionOfRecord方法的具體用法?PHP BackendUtility::getWorkspaceVersionOfRecord怎麽用?PHP BackendUtility::getWorkspaceVersionOfRecord使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TYPO3\CMS\Backend\Utility\BackendUtility
的用法示例。
在下文中一共展示了BackendUtility::getWorkspaceVersionOfRecord方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: main
/**
* Main function, rendering the document with the iframe with the RTE in.
*
* @return void
* @todo Define visibility
*/
public function main()
{
// Translate id to the workspace version:
if ($versionRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->P['table'], $this->P['uid'], 'uid')) {
$this->P['uid'] = $versionRec['uid'];
}
// If all parameters are available:
if ($this->P['table'] && $this->P['field'] && $this->P['uid'] && $this->checkEditAccess($this->P['table'], $this->P['uid'])) {
// Getting the raw record (we need only the pid-value from here...)
$rawRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($this->P['table'], $this->P['uid']);
\TYPO3\CMS\Backend\Utility\BackendUtility::fixVersioningPid($this->P['table'], $rawRec);
// Setting JavaScript, including the pid value for viewing:
$this->doc->JScode = $this->doc->wrapScriptTags('
function jumpToUrl(URL,formEl) { //
if (document.editform) {
if (!TBE_EDITOR.isFormChanged()) {
window.location.href = URL;
} else if (formEl) {
if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
}
} else window.location.href = URL;
}
' . ($this->popView ? \TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick($rawRec['pid'], '', \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($rawRec['pid'])) : '') . '
');
// Initialize TCeforms - for rendering the field:
$tceforms = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\FormEngine');
// Init...
$tceforms->initDefaultBEMode();
// SPECIAL: Disables all wizards - we are NOT going to need them.
$tceforms->disableWizards = 1;
// SPECIAL: Setting background color of the RTE to ordinary background
$tceforms->colorScheme[0] = $this->doc->bgColor;
// Initialize style for RTE object:
// Getting reference to the RTE object used to render the field!
$RTEobj = \TYPO3\CMS\Backend\Utility\BackendUtility::RTEgetObj();
if ($RTEobj->ID == 'rte') {
$RTEobj->RTEdivStyle = 'position:relative; left:0px; top:0px; height:100%; width:100%; border:solid 0px;';
}
// Fetching content of record:
$trData = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor');
$trData->lockRecords = 1;
$trData->fetchRecord($this->P['table'], $this->P['uid'], '');
// Getting the processed record content out:
$rec = reset($trData->regTableItems_data);
$rec['uid'] = $this->P['uid'];
$rec['pid'] = $rawRec['pid'];
// TSconfig, setting width:
$fieldTSConfig = $tceforms->setTSconfig($this->P['table'], $rec, $this->P['field']);
if (strcmp($fieldTSConfig['RTEfullScreenWidth'], '')) {
$width = $fieldTSConfig['RTEfullScreenWidth'];
} else {
$width = '100%';
}
// Get the form field and wrap it in the table with the buttons:
$formContent = $tceforms->getSoloField($this->P['table'], $rec, $this->P['field']);
$formContent = '
<!--
RTE wizard:
-->
<table border="0" cellpadding="0" cellspacing="0" width="' . $width . '" id="typo3-rtewizard">
<tr>
<td width="' . $width . '" colspan="2" id="c-formContent">' . $formContent . '</td>
<td></td>
</tr>
</table>';
// Adding hidden fields:
$formContent .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($this->R_URI) . '" />
<input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction');
// Finally, add the whole setup:
$this->content .= $tceforms->printNeededJSFunctions_top() . $formContent . $tceforms->printNeededJSFunctions();
} else {
// ERROR:
$this->content .= $this->doc->section($GLOBALS['LANG']->getLL('forms_title'), '<span class="typo3-red">' . $GLOBALS['LANG']->getLL('table_noData', 1) . '</span>', 0, 1);
}
// Setting up the buttons and markers for docheader
$docHeaderButtons = $this->getButtons();
$markers['CONTENT'] = $this->content;
// Build the <body> for the module
$this->content = $this->doc->startPage('');
$this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
$this->content .= $this->doc->endPage();
$this->content = $this->doc->insertStylesAndJS($this->content);
}
示例2: getPage
/**
* Return the original or workspace page depending on workspace-mode
*
* @param integer $pageUid
* @return array|boolean
*/
public function getPage($pageUid)
{
$table = 'pages';
$wsId = intval($GLOBALS['BE_USER']->workspace);
$pageUid = intval($pageUid);
if (1 > $pageUid) {
return FALSE;
}
// check if active workspace is available
$page = BackendUtility::getWorkspaceVersionOfRecord($wsId, $table, $pageUid);
if (FALSE === $page) {
// no workspace available ... use original one
$page = BackendUtility::getRecord($table, $pageUid, '*');
}
return $page;
}
示例3: main
/**
* Main function, rendering the document with the iFrame with the RTE in.
*
* @return void
*/
public function main()
{
$this->content .= '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_db')) . '" method="post" enctype="multipart/form-data" id="RteController" name="editform" ' . ' onsubmit="return TBE_EDITOR.checkSubmit(1);">';
// Translate id to the workspace version:
if ($versionedRecord = BackendUtility::getWorkspaceVersionOfRecord($this->getBackendUserAuthentication()->workspace, $this->P['table'], $this->P['uid'], 'uid')) {
$this->P['uid'] = $versionedRecord['uid'];
}
// If all parameters are available:
if ($this->P['table'] && $this->P['field'] && $this->P['uid'] && $this->checkEditAccess($this->P['table'], $this->P['uid'])) {
/** @var TcaDatabaseRecord $formDataGroup */
$formDataGroup = GeneralUtility::makeInstance(TcaDatabaseRecord::class);
/** @var FormDataCompiler $formDataCompiler */
$formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup);
/** @var NodeFactory $nodeFactory */
$nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
$formDataCompilerInput = ['vanillaUid' => (int) $this->P['uid'], 'tableName' => $this->P['table'], 'command' => 'edit', 'disabledWizards' => true];
$formData = $formDataCompiler->compile($formDataCompilerInput);
$formData['fieldListToRender'] = $this->P['field'];
$formData['renderType'] = 'outerWrapContainer';
$formResult = $nodeFactory->create($formData)->render();
/** @var FormResultCompiler $formResultCompiler */
$formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class);
$formResultCompiler->mergeResult($formResult);
// override the default jumpToUrl
$this->moduleTemplate->addJavaScriptCode('RteWizardInlineCode', 'function jumpToUrl(URL,formEl) {
if (document.editform) {
if (!TBE_EDITOR.isFormChanged()) {
window.location.href = URL;
} else if (formEl) {
if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
}
} else {
window.location.href = URL;
}
}
');
// Setting JavaScript of the pid value for viewing:
if ($this->popView) {
$this->moduleTemplate->addJavaScriptCode('PopupViewInlineJS', BackendUtility::viewOnClick($formData['databaseRow']['pid'], '', BackendUtility::BEgetRootLine($formData['databaseRow']['pid'])));
}
$pageTsConfigMerged = $formData['pageTsConfigMerged'];
if ((string) $pageTsConfigMerged['TCEFORM.'][$this->P['table'] . '.'][$this->P['field'] . '.']['RTEfullScreenWidth'] !== '') {
$width = (string) $pageTsConfigMerged['TCEFORM.'][$this->P['table'] . '.'][$this->P['field'] . '.']['RTEfullScreenWidth'];
} else {
$width = '100%';
}
// Get the form field and wrap it in the table with the buttons:
$formContent = $formResult['html'];
$formContent = '
<table border="0" cellpadding="0" cellspacing="0" width="' . $width . '" id="typo3-rtewizard">
<tr>
<td width="' . $width . '" colspan="2" id="c-formContent">' . $formContent . '</td>
<td></td>
</tr>
</table>';
// Adding hidden fields:
$formContent .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($this->R_URI) . '" />
<input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />';
// Finally, add the whole setup:
$this->content .= $formResultCompiler->JStop() . $formContent . $formResultCompiler->printNeededJSFunctions();
} else {
// ERROR:
$this->content .= '<h2>' . $this->getLanguageService()->getLL('forms_title', true) . '</h2>' . '<div><span class="text-danger">' . $this->getLanguageService()->getLL('table_noData', true) . '</span></div>';
}
// Setting up the buttons and markers for docHeader
$this->getButtons();
// Build the <body> for the module
$this->content .= '</form>';
$this->moduleTemplate->setContent($this->content);
}
示例4: getRecord
/**
* Get a single record row for a TCA table from the database.
* t3lib_transferData is used for "upgrading" the values, especially the relations.
*
* @param integer $pid The pid of the page the record should be stored (only relevant for NEW records)
* @param string $table The table to fetch data from (= foreign_table)
* @param string $uid The uid of the record to fetch, or the pid if a new record should be created
* @param string $cmd The command to perform, empty or 'new'
* @return array A record row from the database post-processed by t3lib_transferData
* @todo Define visibility
*/
public function getRecord($pid, $table, $uid, $cmd = '')
{
// Fetch workspace version of a record (if any):
if ($cmd !== 'new' && $GLOBALS['BE_USER']->workspace !== 0) {
$workspaceVersion = \TYPO3\CMS\Backend\Utility\BackendUtility::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $table, $uid, 'uid');
if ($workspaceVersion !== FALSE) {
$uid = $workspaceVersion['uid'];
}
}
$trData = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor');
$trData->addRawData = TRUE;
$trData->lockRecords = 1;
$trData->disableRTE = $GLOBALS['SOBE']->MOD_SETTINGS['disableRTE'];
// If a new record should be created
$trData->fetchRecord($table, $uid, $cmd === 'new' ? 'new' : '');
$rec = reset($trData->regTableItems_data);
return $rec;
}
示例5: versionizeRecord
/**
* Creates a new version of a record
* (Requires support in the table)
*
* @param string $table Table name
* @param int $id Record uid to versionize
* @param string $label Version label
* @param bool $delete If TRUE, the version is created to delete the record.
* @return int|NULL Returns the id of the new version (if any)
* @see copyRecord()
*/
public function versionizeRecord($table, $id, $label, $delete = false)
{
$id = (int) $id;
// Stop any actions if the record is marked to be deleted:
// (this can occur if IRRE elements are versionized and child elements are removed)
if ($this->isElementToBeDeleted($table, $id)) {
return null;
}
if (!$GLOBALS['TCA'][$table] || !$GLOBALS['TCA'][$table]['ctrl']['versioningWS'] || $id <= 0) {
if ($this->enableLogging) {
$this->newlog('Versioning is not supported for this table "' . $table . '" / ' . $id, 1);
}
return null;
}
if (!$this->doesRecordExist($table, $id, 'show')) {
if ($this->enableLogging) {
$this->newlog('You didn\'t have correct permissions to make a new version (copy) of this record "' . $table . '" / ' . $id, 1);
}
return null;
}
// Select main record:
$row = $this->recordInfo($table, $id, 'pid,t3ver_id,t3ver_state');
if (!is_array($row)) {
if ($this->enableLogging) {
$this->newlog('Record "' . $table . ':' . $id . '" you wanted to versionize did not exist!', 1);
}
return null;
}
// Record must be online record
if ($row['pid'] < 0) {
if ($this->enableLogging) {
$this->newlog('Record "' . $table . ':' . $id . '" you wanted to versionize was already a version in archive (pid=-1)!', 1);
}
return null;
}
// Record must not be placeholder for moving.
if (VersionState::cast($row['t3ver_state'])->equals(VersionState::MOVE_PLACEHOLDER)) {
if ($this->enableLogging) {
$this->newlog('Record cannot be versioned because it is a placeholder for a moving operation', 1);
}
return null;
}
if ($delete && $this->cannotDeleteRecord($table, $id)) {
if ($this->enableLogging) {
$this->newlog('Record cannot be deleted: ' . $this->cannotDeleteRecord($table, $id), 1);
}
return null;
}
// Look for next version number:
$res = $this->databaseConnection->exec_SELECTquery('t3ver_id', $table, '((pid=-1 && t3ver_oid=' . $id . ') OR uid=' . $id . ')' . $this->deleteClause($table), '', 't3ver_id DESC', '1');
list($highestVerNumber) = $this->databaseConnection->sql_fetch_row($res);
$this->databaseConnection->sql_free_result($res);
// Look for version number of the current:
$subVer = $row['t3ver_id'] . '.' . ($highestVerNumber + 1);
// Set up the values to override when making a raw-copy:
$overrideArray = array('t3ver_id' => $highestVerNumber + 1, 't3ver_oid' => $id, 't3ver_label' => $label ?: $subVer . ' / ' . date('d-m-Y H:m:s'), 't3ver_wsid' => $this->BE_USER->workspace, 't3ver_state' => (string) ($delete ? new VersionState(VersionState::DELETE_PLACEHOLDER) : new VersionState(VersionState::DEFAULT_STATE)), 't3ver_count' => 0, 't3ver_stage' => 0, 't3ver_tstamp' => 0);
if ($GLOBALS['TCA'][$table]['ctrl']['editlock']) {
$overrideArray[$GLOBALS['TCA'][$table]['ctrl']['editlock']] = 0;
}
// Checking if the record already has a version in the current workspace of the backend user
if ($this->BE_USER->workspace !== 0) {
// Look for version already in workspace:
$versionRecord = BackendUtility::getWorkspaceVersionOfRecord($this->BE_USER->workspace, $table, $id, 'uid');
}
// Create new version of the record and return the new uid
if (empty($versionRecord['uid'])) {
// Create raw-copy and return result:
// The information of the label to be used for the workspace record
// as well as the information whether the record shall be removed
// must be forwarded (creating remove placeholders on a workspace are
// done by copying the record and override several fields).
$workspaceOptions = array('delete' => $delete, 'label' => $label);
return $this->copyRecord_raw($table, $id, -1, $overrideArray, $workspaceOptions);
// Reuse the existing record and return its uid
// (prior to TYPO3 CMS 6.2, an error was thrown here, which
// did not make much sense since the information is available)
} else {
return $versionRecord['uid'];
}
return null;
}
示例6: resolveElement
/**
* Convert input element reference to workspace version if any.
*
* @param string $table Table of input element
* @param integer $uid UID of record
* @return integer converted UID of record
* @todo Define visibility
*/
public function resolveElement($table, $uid)
{
if (isset($GLOBALS['TCA'][$table])) {
if ($workspaceVersion = BackendUtility::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $table, $uid, 'uid')) {
$uid = $workspaceVersion['uid'];
}
}
return $uid;
}
示例7: moveRecord_processFieldValue
/**
* Processes a single field of a moved record and follows references.
*
* @param DataHandler $dataHandler Calling DataHandler instance
* @param int $resolvedPageId Resolved real destination page id
* @param string $table Name of parent table
* @param int $uid UID of the parent record
* @param string $field Name of the field of the parent record
* @param string $value Value of the field of the parent record
* @param array $configuration TCA field configuration of the parent record
* @return void
*/
protected function moveRecord_processFieldValue(DataHandler $dataHandler, $resolvedPageId, $table, $uid, $field, $value, array $configuration)
{
$inlineFieldType = $dataHandler->getInlineFieldType($configuration);
$inlineProcessing = ($inlineFieldType === 'list' || $inlineFieldType === 'field') && BackendUtility::isTableMovePlaceholderAware($configuration['foreign_table']) && (!isset($configuration['behaviour']['disableMovingChildrenWithParent']) || !$configuration['behaviour']['disableMovingChildrenWithParent']);
if ($inlineProcessing) {
if ($table === 'pages') {
// If the inline elements are related to a page record,
// make sure they reside at that page and not at its parent
$resolvedPageId = $uid;
}
$dbAnalysis = $this->createRelationHandlerInstance();
$dbAnalysis->start($value, $configuration['foreign_table'], '', $uid, $table, $configuration);
// Moving records to a positive destination will insert each
// record at the beginning, thus the order is reversed here:
foreach ($dbAnalysis->itemArray as $item) {
$versionedRecord = BackendUtility::getWorkspaceVersionOfRecord($dataHandler->BE_USER->workspace, $item['table'], $item['id'], 'uid,t3ver_state');
if (empty($versionedRecord) || VersionState::cast($versionedRecord['t3ver_state'])->indicatesPlaceholder()) {
continue;
}
$dataHandler->moveRecord($item['table'], $item['id'], $resolvedPageId);
}
}
}
示例8: renderQuickEdit
//.........這裏部分代碼省略.........
$this->deleteButton = \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->eRParts[1]) && $edit_record && ($this->eRParts[0] != 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] == 'pages' && $this->CALC_PERMS & 4);
// If undo-button should be rendered (depends on available items in sys_history)
$this->undoButton = 0;
$undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->eRParts[0], 'sys_history') . ' AND recuid=' . intval($this->eRParts[1]), '', 'tstamp DESC', '1');
if ($this->undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
$this->undoButton = 1;
}
// Setting up the Return URL for coming back to THIS script (if links take the user to another script)
$R_URL_parts = parse_url(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'));
$R_URL_getvars = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET();
unset($R_URL_getvars['popView']);
unset($R_URL_getvars['new_unique_uid']);
$R_URL_getvars['edit_record'] = $edit_record;
$this->R_URI = $R_URL_parts['path'] . '?' . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', $R_URL_getvars);
// Setting close url/return url for exiting this script:
// Goes to 'Columns' view if close is pressed (default)
$this->closeUrl = $this->local_linkThisScript(array('SET' => array('function' => 1)));
if ($GLOBALS['BE_USER']->uc['condensedMode']) {
$this->closeUrl = $GLOBALS['BACK_PATH'] . 'alt_db_navframe.php';
}
if ($this->returnUrl) {
$this->closeUrl = $this->returnUrl;
}
// Return-url for JavaScript:
$retUrlStr = $this->returnUrl ? '+\'&returnUrl=\'+\'' . rawurlencode($this->returnUrl) . '\'' : '';
// Drawing the edit record selectbox
$this->editSelect = '<select name="edit_record" onchange="' . htmlspecialchars('jumpToUrl(\'db_layout.php?id=' . $this->id . '&edit_record=\'+escape(this.options[this.selectedIndex].value)' . $retUrlStr . ',this);') . '">' . implode('', $opt) . '</select>';
// Creating editing form:
if ($GLOBALS['BE_USER']->check('tables_modify', $this->eRParts[0]) && $edit_record && ($this->eRParts[0] !== 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] === 'pages' && $this->CALC_PERMS & 1)) {
// Splitting uid parts for special features, if new:
list($uidVal, $ex_pid, $ex_colPos) = explode('/', $this->eRParts[1]);
// Convert $uidVal to workspace version if any:
if ($uidVal != 'new') {
if ($draftRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->eRParts[0], $uidVal, 'uid')) {
$uidVal = $draftRecord['uid'];
}
}
// Initializing transfer-data object:
$trData = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor');
$trData->addRawData = TRUE;
$trData->defVals[$this->eRParts[0]] = array('colPos' => intval($ex_colPos), 'sys_language_uid' => intval($this->current_sys_language));
$trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
$trData->lockRecords = 1;
// 'new'
$trData->fetchRecord($this->eRParts[0], $uidVal == 'new' ? $this->id : $uidVal, $uidVal);
// Getting/Making the record:
reset($trData->regTableItems_data);
$rec = current($trData->regTableItems_data);
if ($uidVal == 'new') {
$new_unique_uid = uniqid('NEW');
$rec['uid'] = $new_unique_uid;
$rec['pid'] = intval($ex_pid) ? intval($ex_pid) : $this->id;
$recordAccess = TRUE;
} else {
$rec['uid'] = $uidVal;
// Checking internals access:
$recordAccess = $GLOBALS['BE_USER']->recordEditAccessInternals($this->eRParts[0], $uidVal);
}
if (!$recordAccess) {
// If no edit access, print error message:
$content .= $this->doc->section($GLOBALS['LANG']->getLL('noAccess'), $GLOBALS['LANG']->getLL('noAccess_msg') . '<br /><br />' . ($GLOBALS['BE_USER']->errorMsg ? 'Reason: ' . $GLOBALS['BE_USER']->errorMsg . '<br /><br />' : ''), 0, 1);
} elseif (is_array($rec)) {
// If the record is an array (which it will always be... :-)
// Create instance of TCEforms, setting defaults:
$tceforms = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\FormEngine');
$tceforms->backPath = $GLOBALS['BACK_PATH'];
示例9: workspaceAllowAutoCreation
/**
* Evaluates if auto creation of a version of a record is allowed.
*
* @param string $table Table of the record
* @param integer $id UID of record
* @param integer $recpid PID of record
* @return boolean TRUE if ok.
* @todo Define visibility
*/
public function workspaceAllowAutoCreation($table, $id, $recpid)
{
// Auto-creation of version: In offline workspace, test if versioning is
// enabled and look for workspace version of input record.
// If there is no versionized record found we will create one and save to that.
if ($this->workspace !== 0 && !$this->workspaceRec['disable_autocreate'] && $GLOBALS['TCA'][$table]['ctrl']['versioningWS'] && $recpid >= 0 && !BackendUtility::getWorkspaceVersionOfRecord($this->workspace, $table, $id, 'uid')) {
// There must be no existing version of this record in workspace.
return TRUE;
} elseif ($this->workspaceRec['disable_autocreate']) {
GeneralUtility::deprecationLog('Usage of disable_autocreate feature is deprecated since 4.5.');
}
return FALSE;
}
示例10: versionizeRecord
/**
* Creates a new version of a record
* (Requires support in the table)
*
* @param string $table Table name
* @param integer $id Record uid to versionize
* @param string $label Version label
* @param boolean $delete If TRUE, the version is created to delete the record.
* @return integer Returns the id of the new version (if any)
* @see copyRecord()
* @todo Define visibility
*/
public function versionizeRecord($table, $id, $label, $delete = FALSE)
{
$id = intval($id);
// Stop any actions if the record is marked to be deleted:
// (this can occur if IRRE elements are versionized and child elements are removed)
if ($this->isElementToBeDeleted($table, $id)) {
return NULL;
}
if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['versioningWS'] && $id > 0) {
if ($this->doesRecordExist($table, $id, 'show')) {
// Select main record:
$row = $this->recordInfo($table, $id, 'pid,t3ver_id,t3ver_state');
if (is_array($row)) {
// Record must be online record
if ($row['pid'] >= 0) {
// Record must not be placeholder for moving.
if ($row['t3ver_state'] != 3) {
if (!$delete || !$this->cannotDeleteRecord($table, $id)) {
// Look for next version number:
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('t3ver_id', $table, '((pid=-1 && t3ver_oid=' . $id . ') OR uid=' . $id . ')' . $this->deleteClause($table), '', 't3ver_id DESC', '1');
list($highestVerNumber) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
$GLOBALS['TYPO3_DB']->sql_free_result($res);
// Look for version number of the current:
$subVer = $row['t3ver_id'] . '.' . ($highestVerNumber + 1);
// Set up the values to override when making a raw-copy:
$overrideArray = array('t3ver_id' => $highestVerNumber + 1, 't3ver_oid' => $id, 't3ver_label' => $label ? $label : $subVer . ' / ' . date('d-m-Y H:m:s'), 't3ver_wsid' => $this->BE_USER->workspace, 't3ver_state' => $delete ? 2 : 0, 't3ver_count' => 0, 't3ver_stage' => 0, 't3ver_tstamp' => 0);
if ($GLOBALS['TCA'][$table]['ctrl']['editlock']) {
$overrideArray[$GLOBALS['TCA'][$table]['ctrl']['editlock']] = 0;
}
// Checking if the record already has a version in the current workspace of the backend user
$workspaceCheck = TRUE;
if ($this->BE_USER->workspace !== 0) {
// Look for version already in workspace:
$workspaceCheck = \TYPO3\CMS\Backend\Utility\BackendUtility::getWorkspaceVersionOfRecord($this->BE_USER->workspace, $table, $id, 'uid') ? FALSE : TRUE;
}
if ($workspaceCheck) {
// Create raw-copy and return result:
// The information of the label to be used for the workspace record
// as well as the information whether the record shall be removed
// must be forwarded (creating remove placeholders on a workspace are
// done by copying the record and override several fields).
$workspaceOptions = array();
if ($delete) {
$workspaceOptions['delete'] = $delete;
$workspaceOptions['label'] = $label;
}
return $this->copyRecord_raw($table, $id, -1, $overrideArray, $workspaceOptions);
} else {
$this->newlog('Record "' . $table . ':' . $id . '" you wanted to versionize was already a version in the workspace (wsid=' . $this->BE_USER->workspace . ')!', 1);
}
} else {
$this->newlog('Record cannot be deleted: ' . $this->cannotDeleteRecord($table, $id), 1);
}
} else {
$this->newlog('Record cannot be versioned because it is a placeholder for a moving operation', 1);
}
} else {
$this->newlog('Record "' . $table . ':' . $id . '" you wanted to versionize was already a version in archive (pid=-1)!', 1);
}
} else {
$this->newlog('Record "' . $table . ':' . $id . '" you wanted to versionize did not exist!', 1);
}
} else {
$this->newlog('You didnt have correct permissions to make a new version (copy) of this record "' . $table . '" / ' . $id, 1);
}
} else {
$this->newlog('Versioning is not supported for this table "' . $table . '" / ' . $id, 1);
}
}
示例11: workspaceAllowAutoCreation
/**
* Evaluates if auto creation of a version of a record is allowed.
*
* @param string $table Table of the record
* @param int $id UID of record
* @param int $recpid PID of record
* @return bool TRUE if ok.
*/
public function workspaceAllowAutoCreation($table, $id, $recpid)
{
// Auto-creation of version: In offline workspace, test if versioning is
// enabled and look for workspace version of input record.
// If there is no versionized record found we will create one and save to that.
if ($this->workspace !== 0 && $GLOBALS['TCA'][$table]['ctrl']['versioningWS'] && $recpid >= 0 && !BackendUtility::getWorkspaceVersionOfRecord($this->workspace, $table, $id, 'uid')) {
// There must be no existing version of this record in workspace.
return true;
}
return false;
}
示例12: getWorkspacedUids
/**
* Substitute given list of uids in child table with workspace uid if needed
*
* @param array $connectedUids List of connected uids
* @param string $childTableName Name of child table
* @return array List of uids in workspace
*/
protected function getWorkspacedUids(array $connectedUids, $childTableName)
{
$backendUser = $this->getBackendUser();
$newConnectedUids = [];
foreach ($connectedUids as $uid) {
// Fetch workspace version of a record (if any):
// @todo: Needs handling
if ($backendUser->workspace !== 0 && BackendUtility::isTableWorkspaceEnabled($childTableName)) {
$workspaceVersion = BackendUtility::getWorkspaceVersionOfRecord($backendUser->workspace, $childTableName, $uid, 'uid,t3ver_state');
if ($workspaceVersion !== false) {
$versionState = VersionState::cast($workspaceVersion['t3ver_state']);
if ($versionState->equals(VersionState::DELETE_PLACEHOLDER)) {
return [];
}
$uid = $workspaceVersion['uid'];
}
}
$newConnectedUids[] = $uid;
}
return $newConnectedUids;
}
示例13: getRecord
/**
* Get a single record row for a TCA table from the database.
* \TYPO3\CMS\Backend\Form\DataPreprocessor is used for "upgrading" the
* values, especially the relations.
* Used in inline context
*
* @param string $table The table to fetch data from (= foreign_table)
* @param string $uid The uid of the record to fetch, or the pid if a new record should be created
* @param string $cmd The command to perform, empty or 'new'
* @return array A record row from the database post-processed by \TYPO3\CMS\Backend\Form\DataPreprocessor
* @internal
*/
public function getRecord($table, $uid, $cmd = '')
{
$backendUser = $this->getBackendUserAuthentication();
// Fetch workspace version of a record (if any):
if ($cmd !== 'new' && $backendUser->workspace !== 0 && BackendUtility::isTableWorkspaceEnabled($table)) {
$workspaceVersion = BackendUtility::getWorkspaceVersionOfRecord($backendUser->workspace, $table, $uid, 'uid,t3ver_state');
if ($workspaceVersion !== FALSE) {
$versionState = VersionState::cast($workspaceVersion['t3ver_state']);
if ($versionState->equals(VersionState::DELETE_PLACEHOLDER)) {
return FALSE;
}
$uid = $workspaceVersion['uid'];
}
}
/** @var $trData DataPreprocessor */
$trData = GeneralUtility::makeInstance(DataPreprocessor::class);
$trData->addRawData = TRUE;
$trData->lockRecords = 1;
// If a new record should be created
$trData->fetchRecord($table, $uid, $cmd === 'new' ? 'new' : '');
$rec = reset($trData->regTableItems_data);
return $rec;
}
示例14: main
/**
* Main function, rendering the document with the iFrame with the RTE in.
*
* @return void
*/
public function main()
{
// Translate id to the workspace version:
if ($versionedRecord = BackendUtility::getWorkspaceVersionOfRecord($this->getBackendUserAuthentication()->workspace, $this->P['table'], $this->P['uid'], 'uid')) {
$this->P['uid'] = $versionedRecord['uid'];
}
// If all parameters are available:
if ($this->P['table'] && $this->P['field'] && $this->P['uid'] && $this->checkEditAccess($this->P['table'], $this->P['uid'])) {
// Getting the raw record (we need only the pid-value from here...)
$rawRecord = BackendUtility::getRecord($this->P['table'], $this->P['uid']);
BackendUtility::fixVersioningPid($this->P['table'], $rawRecord);
// override the default jumpToUrl
$this->doc->JScodeArray['jumpToUrl'] = '
function jumpToUrl(URL,formEl) {
if (document.editform) {
if (!TBE_EDITOR.isFormChanged()) {
window.location.href = URL;
} else if (formEl) {
if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
}
} else {
window.location.href = URL;
}
}
';
// Setting JavaScript of the pid value for viewing:
if ($this->popView) {
$this->doc->JScode = $this->doc->wrapScriptTags(BackendUtility::viewOnClick($rawRecord['pid'], '', BackendUtility::BEgetRootLine($rawRecord['pid'])));
}
// Initialize FormEngine - for rendering the field:
/** @var FormEngine $formEngine */
$formEngine = GeneralUtility::makeInstance(FormEngine::class);
// SPECIAL: Disables all wizards - we are NOT going to need them.
$formEngine->disableWizards = 1;
// Fetching content of record:
/** @var DataPreprocessor $dataPreprocessor */
$dataPreprocessor = GeneralUtility::makeInstance(DataPreprocessor::class);
$dataPreprocessor->lockRecords = 1;
$dataPreprocessor->fetchRecord($this->P['table'], $this->P['uid'], '');
// Getting the processed record content out:
$processedRecord = reset($dataPreprocessor->regTableItems_data);
$processedRecord['uid'] = $this->P['uid'];
$processedRecord['pid'] = $rawRecord['pid'];
// TSconfig, setting width:
$fieldTSConfig = FormEngineUtility::getTSconfigForTableRow($this->P['table'], $processedRecord, $this->P['field']);
if ((string) $fieldTSConfig['RTEfullScreenWidth'] !== '') {
$width = $fieldTSConfig['RTEfullScreenWidth'];
} else {
$width = '100%';
}
// Get the form field and wrap it in the table with the buttons:
$formContent = $formEngine->getSoloField($this->P['table'], $processedRecord, $this->P['field']);
$formContent = '
<!-- RTE wizard: -->
<table border="0" cellpadding="0" cellspacing="0" width="' . $width . '" id="typo3-rtewizard">
<tr>
<td width="' . $width . '" colspan="2" id="c-formContent">' . $formContent . '</td>
<td></td>
</tr>
</table>';
// Adding hidden fields:
$formContent .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($this->R_URI) . '" />
<input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />' . FormEngine::getHiddenTokenField('tceAction');
// Finally, add the whole setup:
$this->content .= $formEngine->printNeededJSFunctions_top() . $formContent . $formEngine->printNeededJSFunctions();
} else {
// ERROR:
$this->content .= $this->doc->section($this->getLanguageService()->getLL('forms_title'), '<span class="text-danger">' . $this->getLanguageService()->getLL('table_noData', TRUE) . '</span>', 0, 1);
}
// Setting up the buttons and markers for docHeader
$docHeaderButtons = $this->getButtons();
$markers['CONTENT'] = $this->content;
// Build the <body> for the module
$this->content = $this->doc->startPage('');
$this->content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markers);
$this->content .= $this->doc->endPage();
$this->content = $this->doc->insertStylesAndJS($this->content);
}
示例15: renderQuickEdit
/**
* Rendering the quick-edit view.
*
* @return string
*/
public function renderQuickEdit()
{
$databaseConnection = $this->getDatabaseConnection();
$beUser = $this->getBackendUser();
$lang = $this->getLanguageService();
// Set the edit_record value for internal use in this function:
$edit_record = $this->edit_record;
// If a command to edit all records in a column is issue, then select all those elements, and redirect to FormEngine
if (substr($edit_record, 0, 9) == '_EDIT_COL') {
$res = $databaseConnection->exec_SELECTquery('*', 'tt_content', 'pid=' . (int) $this->id . ' AND colPos=' . (int) substr($edit_record, 10) . ' AND sys_language_uid=' . (int) $this->current_sys_language . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : BackendUtility::BEenableFields('tt_content')) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'sorting');
$idListA = array();
while ($cRow = $databaseConnection->sql_fetch_assoc($res)) {
$idListA[] = $cRow['uid'];
}
$url = BackendUtility::getModuleUrl('record_edit', array('edit[tt_content][' . implode(',', $idListA) . ']' => 'edit', 'returnUrl' => $this->local_linkThisScript(array('edit_record' => ''))));
HttpUtility::redirect($url);
}
// If the former record edited was the creation of a NEW record, this will look up the created records uid:
if ($this->new_unique_uid) {
$res = $databaseConnection->exec_SELECTquery('*', 'sys_log', 'userid=' . (int) $beUser->user['uid'] . ' AND NEWid=' . $databaseConnection->fullQuoteStr($this->new_unique_uid, 'sys_log'));
$sys_log_row = $databaseConnection->sql_fetch_assoc($res);
if (is_array($sys_log_row)) {
$edit_record = $sys_log_row['tablename'] . ':' . $sys_log_row['recuid'];
}
}
$edit_record = $this->makeQuickEditMenu($edit_record);
// Splitting the edit-record cmd value into table/uid:
$this->eRParts = explode(':', $edit_record);
$tableName = $this->eRParts[0];
// Delete-button flag?
$this->deleteButton = MathUtility::canBeInterpretedAsInteger($this->eRParts[1]) && $edit_record && ($tableName !== 'pages' && $this->EDIT_CONTENT || $tableName === 'pages' && $this->CALC_PERMS & Permission::PAGE_DELETE);
// If undo-button should be rendered (depends on available items in sys_history)
$this->undoButton = false;
$undoRes = $databaseConnection->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $databaseConnection->fullQuoteStr($tableName, 'sys_history') . ' AND recuid=' . (int) $this->eRParts[1], '', 'tstamp DESC', '1');
if ($this->undoButtonR = $databaseConnection->sql_fetch_assoc($undoRes)) {
$this->undoButton = true;
}
// Setting up the Return URL for coming back to THIS script (if links take the user to another script)
$R_URL_parts = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
$R_URL_getvars = GeneralUtility::_GET();
unset($R_URL_getvars['popView']);
unset($R_URL_getvars['new_unique_uid']);
$R_URL_getvars['edit_record'] = $edit_record;
$this->R_URI = $R_URL_parts['path'] . '?' . GeneralUtility::implodeArrayForUrl('', $R_URL_getvars);
// Creating editing form:
if ($edit_record) {
// Splitting uid parts for special features, if new:
list($uidVal, $neighborRecordUid, $ex_colPos) = explode('/', $this->eRParts[1]);
if ($uidVal === 'new') {
$command = 'new';
// Page id of this new record
$theUid = $this->id;
if ($neighborRecordUid) {
$theUid = $neighborRecordUid;
}
} else {
$command = 'edit';
$theUid = $uidVal;
// Convert $uidVal to workspace version if any:
$draftRecord = BackendUtility::getWorkspaceVersionOfRecord($beUser->workspace, $tableName, $theUid, 'uid');
if ($draftRecord) {
$theUid = $draftRecord['uid'];
}
}
// @todo: Hack because DatabaseInitializeNewRow reads from _GP directly
$GLOBALS['_GET']['defVals'][$tableName] = array('colPos' => (int) $ex_colPos, 'sys_language_uid' => (int) $this->current_sys_language);
/** @var TcaDatabaseRecord $formDataGroup */
$formDataGroup = GeneralUtility::makeInstance(TcaDatabaseRecord::class);
/** @var FormDataCompiler $formDataCompiler */
$formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup);
/** @var NodeFactory $nodeFactory */
$nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
try {
$formDataCompilerInput = ['tableName' => $tableName, 'vanillaUid' => (int) $theUid, 'command' => $command];
$formData = $formDataCompiler->compile($formDataCompilerInput);
if ($command !== 'new') {
BackendUtility::lockRecords($tableName, $formData['databaseRow']['uid'], $tableName === 'tt_content' ? $formData['databaseRow']['pid'] : 0);
}
$formData['renderType'] = 'outerWrapContainer';
$formResult = $nodeFactory->create($formData)->render();
$panel = $formResult['html'];
$formResult['html'] = '';
/** @var FormResultCompiler $formResultCompiler */
$formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class);
$formResultCompiler->mergeResult($formResult);
$row = $formData['databaseRow'];
$new_unique_uid = '';
if ($command === 'new') {
$new_unique_uid = $row['uid'];
}
// Add hidden fields:
if ($uidVal == 'new') {
$panel .= '<input type="hidden" name="data[' . $tableName . '][' . $row['uid'] . '][pid]" value="' . $row['pid'] . '" />';
}
$redirect = $uidVal == 'new' ? BackendUtility::getModuleUrl($this->moduleName, ['id' => $this->id, 'new_unique_uid' => $new_unique_uid, 'returnUrl' => $this->returnUrl]) : $this->R_URI;
//.........這裏部分代碼省略.........