Project

General

Profile

Bug #12308 ยป 12308.patch

Tolleiv Nietsch, 2011-01-20 00:48

View differences:

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();
$workspaceAccess = $GLOBALS['BE_USER']->checkWorkspace($GLOBALS['BE_USER']->workspace);
$swapStage = ($workspaceAccess['publish_access'] & 1) ? Tx_Workspaces_Service_Stages::STAGE_PUBLISH_ID : 0;
$swapAccess = $GLOBALS['BE_USER']->workspacePublishAccess($GLOBALS['BE_USER']->workspace) &&
$GLOBALS['BE_USER']->workspaceSwapAccess();
$this->initializeWorkspacesCachingFramework();
// 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 {
......
$versionArray['allowedAction_nextStage'] = $stagesObj->isNextStageAllowedForUser($versionRecord['t3ver_stage']);
$versionArray['allowedAction_prevStage'] = $stagesObj->isPrevStageAllowedForUser($versionRecord['t3ver_stage']);
// @todo hide the actions if the user is not allowed to edit the current stage
$versionArray['allowedAction_swap'] = $GLOBALS['BE_USER']->workspaceSwapAccess();
if ($swapAccess && $swapStage != 0 && $versionRecord['t3ver_stage'] == $swapStage) {
$versionArray['allowedAction_swap'] = $stagesObj->isNextStageAllowedForUser($swapStage);
} else if ($swapAccess && $swapStage == 0) {
$versionArray['allowedAction_swap'] = TRUE;
} else {
$versionArray['allowedAction_swap'] = FALSE;
}
$versionArray['allowedAction_delete'] = TRUE;
// preview and editing of a deleted page won't work ;)
$versionArray['allowedAction_view'] = !$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;
}
    (1-1/1)