本文整理汇总了PHP中t3lib_BEfunc::getLiveVersionOfRecord方法的典型用法代码示例。如果您正苦于以下问题:PHP t3lib_BEfunc::getLiveVersionOfRecord方法的具体用法?PHP t3lib_BEfunc::getLiveVersionOfRecord怎么用?PHP t3lib_BEfunc::getLiveVersionOfRecord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类t3lib_BEfunc
的用法示例。
在下文中一共展示了t3lib_BEfunc::getLiveVersionOfRecord方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processDatamap_afterDatabaseOperations
/**
* Hook for updating translation index when records are edited (hooks into TCEmain)
*
* @param [type] $status: ...
* @param [type] $table: ...
* @param [type] $id: ...
* @param [type] $fieldArray: ...
* @param [type] $pObj: ...
* @return [type] ...
*/
function processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, &$pObj)
{
global $TCA;
// Check if
# debug(array($status, $table, $id));
// Map id for new records:
if ($status == "new") {
$id = $pObj->substNEWwithIDs[$id];
# echo "New fixed<br>";
}
// Find live record if any:
if (!($liveRecord = t3lib_BEfunc::getLiveVersionOfRecord($table, $id))) {
// If it was a version we find live...
$liveRecord = t3lib_BEfunc::getRecord($table, $id);
// Otherwise we load live record.
# echo "Live version<br>";
}
if (is_array($liveRecord)) {
// Now, see if this record is a translation of another one:
$t8ToolsObj = t3lib_div::makeInstance('t3lib_transl8tools');
if ($t8ToolsObj->isTranslationInOwnTable($table) && $liveRecord[$TCA[$table]['ctrl']['transOrigPointerField']]) {
// So it had a translation pointer - lets look for the root record then:
$liveRecord = t3lib_BEfunc::getRecord($table, $liveRecord[$TCA[$table]['ctrl']['transOrigPointerField']], 'uid');
# echo "Finding root version<br>";
} elseif ($TCA[$table]['ctrl']['transOrigPointerTable'] && $liveRecord[$TCA[$table]['ctrl']['transOrigPointerField']]) {
$fld = $TCA[$table]['ctrl']['transOrigPointerField'];
$table = $TCA[$table]['ctrl']['transOrigPointerTable'];
// Changeing table value here on purpose!
$liveRecord = t3lib_BEfunc::getRecord($table, $liveRecord[$fld], 'uid');
}
$languageID = tx_l10nmgr_l10nBaseService::getTargetLanguageID();
if (is_array($liveRecord)) {
# echo "indexing id ".$liveRecord['uid'];
// Finally, we have found the "root record" and will check it:
$t8Tools = t3lib_div::makeInstance('tx_l10nmgr_tools');
$t8Tools->verbose = FALSE;
// Otherwise it will show records which has fields but none editable.
# debug($t8Tools->indexDetailsRecord($table,$liveRecord['uid']));
$t8Tools->updateIndexTableFromDetailsArray($t8Tools->indexDetailsRecord($table, $liveRecord['uid'], $languageID));
}
}
}
示例2: resolvePid
/**
* Get the final pid based on $table and $pid ($destPid type... pos/neg)
*
* @param string Table name
* @param integer "Destination pid" : If the value is >= 0 it's just returned directly (through intval() though) but if the value is <0 then the method looks up the record with the uid equal to abs($pid) (positive number) and returns the PID of that record! The idea is that negative numbers point to the record AFTER WHICH the position is supposed to be!
* @return integer
*/
function resolvePid($table, $pid)
{
global $TCA;
$pid = intval($pid);
if ($pid < 0) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pid', $table, 'uid=' . abs($pid));
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
// Look, if the record UID happens to be an offline record. If so, find its live version. Offline uids will be used when a page is versionized as "branch" so this is when we must correct - otherwise a pid of "-1" and a wrong sort-row number is returned which we don't want.
if ($lookForLiveVersion = t3lib_BEfunc::getLiveVersionOfRecord($table, abs($pid), 'pid')) {
$row = $lookForLiveVersion;
}
$pid = intval($row['pid']);
} elseif ($this->BE_USER->workspace !== 0 && $TCA[$table]['ctrl']['versioning_followPages']) {
// PID points to page, the workspace is an offline space and the table follows page during versioning: This means we must check if the PID page has a version in the workspace with swapmode set to 0 (zero = page+content) and if so, change the pid to the uid of that version.
if ($WSdestPage = t3lib_BEfunc::getWorkspaceVersionOfRecord($this->BE_USER->workspace, 'pages', $pid, 'uid,t3ver_swapmode')) {
// Looks for workspace version of page.
if ($WSdestPage['t3ver_swapmode'] == 0) {
// if swapmode is zero, then change pid value.
$pid = $WSdestPage['uid'];
}
}
}
return $pid;
}
示例3: version_clearWSID
/**
* Release version from this workspace (and into "Live" workspace but as an offline version).
*
* @param string $table Table name
* @param integer $id Record UID
* @param boolean $flush If set, will completely delete element
* @param t3lib_TCEmain $tcemainObj TCEmain object
* @return void
*/
protected function version_clearWSID($table, $id, $flush = FALSE, t3lib_TCEmain $tcemainObj)
{
global $TCA;
if ($errorCode = $tcemainObj->BE_USER->workspaceCannotEditOfflineVersion($table, $id)) {
$tcemainObj->newlog('Attempt to reset workspace for record failed: ' . $errorCode, 1);
} elseif ($tcemainObj->checkRecordUpdateAccess($table, $id)) {
if ($liveRec = t3lib_BEfunc::getLiveVersionOfRecord($table, $id, 'uid,t3ver_state')) {
// Clear workspace ID:
$updateData = array('t3ver_wsid' => 0);
$GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($id), $updateData);
// Clear workspace ID for live version AND DELETE IT as well because it is a new record!
if ((int) $liveRec['t3ver_state'] == 1 || (int) $liveRec['t3ver_state'] == 2) {
$GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($liveRec['uid']), $updateData);
// THIS assumes that the record was placeholder ONLY for ONE record (namely $id)
$tcemainObj->deleteEl($table, $liveRec['uid'], TRUE);
}
// If "deleted" flag is set for the version that got released
// it doesn't make sense to keep that "placeholder" anymore and we delete it completly.
$wsRec = t3lib_BEfunc::getRecord($table, $id);
if ($flush || ((int) $wsRec['t3ver_state'] == 1 || (int) $wsRec['t3ver_state'] == 2)) {
$tcemainObj->deleteEl($table, $id, TRUE, TRUE);
}
// Remove the move-placeholder if found for live record.
if ((int) $TCA[$table]['ctrl']['versioningWS'] >= 2) {
if ($plhRec = t3lib_BEfunc::getMovePlaceholder($table, $liveRec['uid'], 'uid')) {
$tcemainObj->deleteEl($table, $plhRec['uid'], TRUE, TRUE);
}
}
}
} else {
$tcemainObj->newlog('Attempt to reset workspace for record failed because you do not have edit access', 1);
}
}
示例4: viewSingleRecord
/**
* Generates a view link for a page.
*
* @static
* @param $table
* @param $uid
* @param $record
* @return string
*/
public static function viewSingleRecord($table, $uid, $record = null)
{
$viewUrl = '';
if ($table == 'pages') {
$viewUrl = t3lib_BEfunc::viewOnClick(t3lib_BEfunc::getLiveVersionIdOfRecord('pages', $uid));
} elseif ($table == 'pages_language_oderlay' || $table == 'tt_content') {
$elementRecord = is_array($record) ? $record : t3lib_BEfunc::getLiveVersionOfRecord($table, $uid);
$viewUrl = t3lib_BEfunc::viewOnClick($elementRecord['pid']);
} else {
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['viewSingleRecord'])) {
$_params = array('table' => $table, 'uid' => $uid, 'record' => $record);
$_funcRef = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['viewSingleRecord'];
$viewUrl = t3lib_div::callUserFunction($_funcRef, $_params, null);
}
}
return $viewUrl;
}
示例5: init
/**
* Initialization of the class.
*
* @return void
*/
function init()
{
// Init GPvars:
$this->P = t3lib_div::_GP('P');
$this->returnEditConf = t3lib_div::_GP('returnEditConf');
// Get this record
$origRow = t3lib_BEfunc::getRecord($this->P['table'], $this->P['uid']);
// Set table:
$this->table = $this->P['params']['table'];
// Get TSconfig for it.
$TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($this->P['table'], is_array($origRow) ? $origRow : array('pid' => $this->P['pid']));
// Set [params][pid]
if (substr($this->P['params']['pid'], 0, 3) == '###' && substr($this->P['params']['pid'], -3) == '###') {
$this->pid = intval($TSconfig['_' . substr($this->P['params']['pid'], 3, -3)]);
} else {
$this->pid = intval($this->P['params']['pid']);
}
// Return if new record as parent (not possibly/allowed)
if (!strcmp($this->pid, '')) {
t3lib_utility_Http::redirect(t3lib_div::sanitizeLocalUrl($this->P['returnUrl']));
}
// Else proceed:
if ($this->returnEditConf) {
// If a new id has returned from a newly created record...
$eC = unserialize($this->returnEditConf);
if (is_array($eC[$this->table]) && t3lib_div::testInt($this->P['uid'])) {
// Getting id and cmd from returning editConf array.
reset($eC[$this->table]);
$this->id = intval(key($eC[$this->table]));
$cmd = current($eC[$this->table]);
// ... and if everything seems OK we will register some classes for inclusion and instruct the object to perform processing later.
if ($this->P['params']['setValue'] && $cmd == 'edit' && $this->id && $this->P['table'] && $this->P['field'] && $this->P['uid']) {
if ($LiveRec = t3lib_BEfunc::getLiveVersionOfRecord($this->table, $this->id, 'uid')) {
$this->id = $LiveRec['uid'];
}
$this->include_once[] = PATH_t3lib . 'class.t3lib_loaddbgroup.php';
$this->include_once[] = PATH_t3lib . 'class.t3lib_transferdata.php';
$this->include_once[] = PATH_t3lib . 'class.t3lib_tcemain.php';
$this->processDataFlag = 1;
}
}
}
}
示例6: execute
/**
* Executes action for selected elements, if any is sent:
*/
function execute()
{
$post = t3lib_div::_POST();
# debug($post);
if ($post['_with_selected_do']) {
if (is_array($post['items']) && count($post['items'])) {
$cmdArray = array();
foreach ($post['items'] as $item => $v) {
list($table, $uid) = explode(':', $item, 2);
if ($GLOBALS['TCA'][$table] && t3lib_div::testInt($uid)) {
switch ($post['_with_selected_do']) {
case "stage_-1":
$cmdArray[$table][$uid]['version']['action'] = 'setStage';
$cmdArray[$table][$uid]['version']['stageId'] = -1;
break;
case "stage_0":
$cmdArray[$table][$uid]['version']['action'] = 'setStage';
$cmdArray[$table][$uid]['version']['stageId'] = 0;
break;
case "stage_1":
$cmdArray[$table][$uid]['version']['action'] = 'setStage';
$cmdArray[$table][$uid]['version']['stageId'] = 1;
break;
case "stage_10":
$cmdArray[$table][$uid]['version']['action'] = 'setStage';
$cmdArray[$table][$uid]['version']['stageId'] = 10;
break;
case "publish":
if ($onlineRec = t3lib_BEfunc::getLiveVersionOfRecord($table, $uid, 'uid')) {
$cmdArray[$table][$onlineRec['uid']]['version']['action'] = 'swap';
$cmdArray[$table][$onlineRec['uid']]['version']['swapWith'] = $uid;
}
break;
case "swap":
if ($onlineRec = t3lib_BEfunc::getLiveVersionOfRecord($table, $uid, 'uid')) {
$cmdArray[$table][$onlineRec['uid']]['version']['action'] = 'swap';
$cmdArray[$table][$onlineRec['uid']]['version']['swapWith'] = $uid;
$cmdArray[$table][$onlineRec['uid']]['version']['swapIntoWS'] = 1;
}
break;
case "release":
$cmdArray[$table][$uid]['version']['action'] = 'clearWSID';
break;
case "flush":
$cmdArray[$table][$uid]['version']['action'] = 'flush';
break;
}
}
}
# debug($cmdArray);
$tce = t3lib_div::makeInstance('t3lib_TCEmain');
$tce->stripslashes_values = 0;
$tce->start(array(), $cmdArray);
$tce->process_cmdmap();
}
}
}