Project

General

Profile

Bug #12325 » 12325v2.patch

Tolleiv Nietsch, 2011-01-20 09:06

View differences:

Classes/ExtDirect/ActionHandler.php (working copy)
/**
* Generates a view link for a page.
*
* @param string $pid
* @param string $table
* @param string $uid
* @return void
*/
public function viewSingleRecord($pid) {
return t3lib_BEfunc::viewOnClick($pid);
public function viewSingleRecord($table, $uid) {
return tx_Workspaces_Service_Workspaces::viewSingleRecord($table, $uid);
}
Classes/Service/GridData.php (working copy)
$limit = isset($parameter->limit) ? intval($parameter->limit) : 10;
$this->sort = isset($parameter->sort) ? $parameter->sort : 't3ver_oid';
$this->sortDir = isset($parameter->dir) ? $parameter->dir : 'ASC';
if (is_int($currentWorkspace)) {
$this->currentWorkspace = $currentWorkspace;
} else {
......
protected function generateDataArray(array $versions, $filterTxt) {
/** @var $stagesObj Tx_Workspaces_Service_Stages */
$stagesObj = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages');
/** @var $workspacesObj Tx_Workspaces_Service_Workspaces */
$workspacesObj = t3lib_div::makeInstance('Tx_Workspaces_Service_Workspaces');
$availableWorkspaces = $workspacesObj->getAvailableWorkspaces();
......
// check for dataArray in cache
if ($this->getDataArrayFromCache($versions, $filterTxt) == FALSE) {
$stagesObj = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages');
foreach ($versions as $table => $records) {
$versionArray = array('table' => $table);
foreach ($records as $record) {
$origRecord = t3lib_BEFunc::getRecord($table, $record['t3ver_oid']);
$versionRecord = t3lib_BEFunc::getRecord($table, $record['uid']);
if (isset($GLOBALS['TCA'][$table]['columns']['hidden'])) {
$recordState = $this->workspaceState($versionRecord['t3ver_state'], $origRecord['hidden'], $versionRecord['hidden']);
} else {
$recordState = $this->workspaceState($versionRecord['t3ver_state']);
}
$isDeletedPage = ($table == 'pages' && $recordState == 'deleted');
$viewUrl = tx_Workspaces_Service_Workspaces::viewSingleRecord($table, $record['t3ver_oid'], $origRecord);
$pctChange = $this->calculateChangePercentage($table, $origRecord, $versionRecord);
$versionArray['uid'] = $record['uid'];
......
$versionArray['allowedAction_swap'] = $GLOBALS['BE_USER']->workspaceSwapAccess();
$versionArray['allowedAction_delete'] = TRUE;
// preview and editing of a deleted page won't work ;)
$versionArray['allowedAction_view'] = !$isDeletedPage;
$versionArray['allowedAction_view'] = !$isDeletedPage && $viewUrl;
$versionArray['allowedAction_edit'] = !$isDeletedPage;
$versionArray['allowedAction_editVersionedPage'] = !$isDeletedPage;
......
}
}
$this->sortDataArray();
$this->setDataArrayIntoCache($versions, $filterTxt);
}
$this->sortDataArray();
......
/**
* Initialize the workspace cache
*
*
* @return void
*/
protected function initializeWorkspacesCachingFramework() {
......
} catch (t3lib_cache_exception_DuplicateIdentifier $e) {
// do nothing, a workspace cache already exists
}
$this->workspacesCache = $GLOBALS['typo3CacheManager']->getCache('workspaces_cache');
}
}
......
/**
* Put the generated dataArray into the workspace cache.
*
*
* @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid, t3ver_oid and t3ver_swapmode fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid"
* @param string $filterTxt The given filter text from the grid.
*/
......
if (TYPO3_UseCachingFramework === TRUE) {
$hash = $this->calculateHash($versions, $filterTxt);
$content = serialize($this->dataArray);
$this->workspacesCache->set($hash, $content, array($this->currentWorkspace));
}
}
/**
* Checks if a cache entry is given for given versions and filter text and tries to load the data array from cache.
*
*
* @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid, t3ver_oid and t3ver_swapmode fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid"
* @param string $filterTxt The given filter text from the grid.
*/
protected function getDataArrayFromCache (array $versions, $filterTxt) {
$cacheEntry = FALSE;
if (TYPO3_UseCachingFramework === TRUE) {
$hash = $this->calculateHash($versions, $filterTxt);
$content = $this->workspacesCache->get($hash);
if ($content != FALSE) {
$this->dataArray = unserialize($content);
$cacheEntry = TRUE;
}
}
return $cacheEntry;
}
/**
* Calculate the hash value of the used workspace, the user id, the versions array, the filter text, the sorting attribute, the workspace selected in grid and the sorting direction.
*
*
* @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid, t3ver_oid and t3ver_swapmode fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid"
* @param string $filterTxt The given filter text from the grid.
*/
......
$this->sortDir,
$this->currentWorkspace);
$hash = md5(serialize($hashArray));
return $hash;
}
Classes/Service/Workspaces.php (working copy)
}
return $isNewPage;
}
/**
* 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($uid);
} elseif ($table == 'pages_language_oderlay' || $table == 'tt_content') {
$elementRecord = is_array($record) ? $record : t3lib_BEfunc::getRecord($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;
}
}
Resources/Public/JavaScript/actions.js (working copy)
TYPO3.Workspaces.MainStore.load();
});
},
viewSingleRecord: function(pid) {
TYPO3.Workspaces.ExtDirectActions.viewSingleRecord(pid, function(response) {
viewSingleRecord: function(table, uid) {
TYPO3.Workspaces.ExtDirectActions.viewSingleRecord(table, uid, function(response) {
eval(response);
});
},
Resources/Public/JavaScript/configuration.js (working copy)
,tooltip: TYPO3.lang["tooltip.viewElementAction"]
,handler: function(grid, rowIndex, colIndex) {
var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
if (record.json.table == 'pages') {
TYPO3.Workspaces.Actions.viewSingleRecord(record.json.t3ver_oid);
} else {
TYPO3.Workspaces.Actions.viewSingleRecord(record.json.livepid);
}
TYPO3.Workspaces.Actions.viewSingleRecord(record.json.table, record.json.livepid);
},
getClass: function(v, meta, rec) {
if(!rec.json.allowedAction_view) {
......
}
},
getClass: function(v, meta, rec) {
if(!rec.json.allowedAction_editVersionedPage) {
if(!rec.json.allowedAction_editVersionedPage || !top.TYPO3.configuration.pageModule) {
return 'icon-hidden';
} else {
return '';
(3-3/3)