/** * Builds a complete node including children * * @param \t3lib_tree_Node|\TYPO3\CMS\Backend\Tree\TreeNode $basicNode * @param NULL|t3lib_tree_tca_DatabaseNode $parent * @param integer $level * @param bool $restriction * @return t3lib_tree_tca_DatabaseNode node */ protected function buildRepresentationForNode(t3lib_tree_Node $basicNode, t3lib_tree_tca_DatabaseNode $parent = NULL, $level = 0, $restriction = FALSE) { /**@param $node t3lib_tree_tca_DatabaseNode */ $node = t3lib_div::makeInstance('t3lib_tree_tca_DatabaseNode'); $row = array(); if ($basicNode->getId() == 0) { $node->setSelected(FALSE); $node->setExpanded(TRUE); $node->setLabel($GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->tableName]['ctrl']['title'])); } else { $row = t3lib_BEfunc::getRecordWSOL($this->tableName, $basicNode->getId(), '*', '', FALSE); if ($this->getLabelField() !== '') { $label = Tx_News_Service_CategoryService::translateCategoryRecord($row[$this->getLabelField()], $row); $node->setLabel($label); } else { $node->setLabel($basicNode->getId()); } $node->setSelected(t3lib_div::inList($this->getSelectedList(), $basicNode->getId())); $node->setExpanded($this->isExpanded($basicNode)); $node->setLabel($node->getLabel()); } $node->setId($basicNode->getId()); // Break to force single category activation if ($parent != NULL && $level != 0 && $this->isSingleCategoryAclActivated() && !$this->isCategoryAllowed($node)) { return NULL; } $node->setSelectable(!t3lib_div::inList($this->getNonSelectableLevelList(), $level) && !in_array($basicNode->getId(), $this->getItemUnselectableList())); $node->setSortValue($this->nodeSortValues[$basicNode->getId()]); $node->setIcon(t3lib_iconWorks::mapRecordTypeToSpriteIconClass($this->tableName, $row)); $node->setParentNode($parent); if ($basicNode->hasChildNodes()) { $node->setHasChildren(TRUE); $childNodes = t3lib_div::makeInstance('t3lib_tree_SortedNodeCollection'); $foundSomeChild = FALSE; foreach ($basicNode->getChildNodes() as $child) { // Change in custom TreeDataProvider by adding the if clause if ($restriction || $this->isCategoryAllowed($child)) { $returnedChild = $this->buildRepresentationForNode($child, $node, $level + 1, TRUE); if (!is_null($returnedChild)) { $foundSomeChild = TRUE; $childNodes->append($returnedChild); } else { $node->setParentNode(NULL); $node->setHasChildren(FALSE); } } // Change in custom TreeDataProvider end } if ($foundSomeChild) { $node->setChildNodes($childNodes); } } return $node; }
/** * Fetch futher information to current selected worspace record. * * @param object $parameter * @return array $data */ public function getRowDetails($parameter) { global $TCA, $BE_USER; $diffReturnArray = array(); $liveReturnArray = array(); $t3lib_diff = t3lib_div::makeInstance('t3lib_diff'); $stagesService = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages'); $liveRecord = t3lib_BEfunc::getRecord($parameter->table, $parameter->t3ver_oid); $versionRecord = t3lib_BEfunc::getRecord($parameter->table, $parameter->uid); $icon_Live = t3lib_iconWorks::mapRecordTypeToSpriteIconClass($parameter->table, $liveRecord); $icon_Workspace = t3lib_iconWorks::mapRecordTypeToSpriteIconClass($parameter->table, $versionRecord); $stagePosition = $stagesService->getPositionOfCurrentStage($parameter->stage); $fieldsOfRecords = array_keys($liveRecord); // get field list from TCA configuration, if available if ($TCA[$parameter->table]) { if ($TCA[$parameter->table]['interface']['showRecordFieldList']) { $fieldsOfRecords = $TCA[$parameter->table]['interface']['showRecordFieldList']; $fieldsOfRecords = t3lib_div::trimExplode(',', $fieldsOfRecords, 1); } } foreach ($fieldsOfRecords as $fieldName) { // check for exclude fields if ($GLOBALS['BE_USER']->isAdmin() || $TCA[$parameter->table]['columns'][$fieldName]['exclude'] == 0 || t3lib_div::inList($BE_USER->groupData['non_exclude_fields'], $parameter->table . ':' . $fieldName)) { // call diff class only if there is a difference if (strcmp($liveRecord[$fieldName], $versionRecord[$fieldName]) !== 0) { // Select the human readable values before diff $liveRecord[$fieldName] = t3lib_BEfunc::getProcessedValue($parameter->table, $fieldName, $liveRecord[$fieldName], 0, 1); $versionRecord[$fieldName] = t3lib_BEfunc::getProcessedValue($parameter->table, $fieldName, $versionRecord[$fieldName], 0, 1); $fieldTitle = $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($parameter->table, $fieldName)); if ($TCA[$parameter->table]['columns'][$fieldName]['config']['type'] == 'group' && $TCA[$parameter->table]['columns'][$fieldName]['config']['internal_type'] == 'file') { $versionThumb = t3lib_BEfunc::thumbCode($versionRecord, $parameter->table, $fieldName, ''); $liveThumb = t3lib_BEfunc::thumbCode($liveRecord, $parameter->table, $fieldName, ''); $diffReturnArray[] = array('label' => $fieldTitle, 'content' => $versionThumb); $liveReturnArray[] = array('label' => $fieldTitle, 'content' => $liveThumb); } else { $diffReturnArray[] = array('label' => $fieldTitle, 'content' => $t3lib_diff->makeDiffDisplay($liveRecord[$fieldName], $versionRecord[$fieldName])); $liveReturnArray[] = array('label' => $fieldTitle, 'content' => $liveRecord[$fieldName]); } } } } $commentsForRecord = $this->getCommentsForRecord($parameter->uid, $parameter->table); return array('total' => 1, 'data' => array(array('diff' => $diffReturnArray, 'live_record' => $liveReturnArray, 'path_Live' => $parameter->path_Live, 'label_Stage' => $parameter->label_Stage, 'stage_position' => $stagePosition['position'], 'stage_count' => $stagePosition['count'], 'comments' => $commentsForRecord, 'icon_Live' => $icon_Live, 'icon_Workspace' => $icon_Workspace))); }
/** * Builds a complete node including childs * * @param t3lib_tree_Node $basicNode * @param null|t3lib_tree_tca_DatabaseNode $parent * @param int $level * @return A|object */ protected function buildRepresentationForNode(t3lib_tree_Node $basicNode, t3lib_tree_tca_DatabaseNode $parent = NULL, $level = 0) { $node = t3lib_div::makeInstance('t3lib_tree_tca_DatabaseNode'); $row = array(); if ($basicNode->getId() == 0) { $node->setSelected(FALSE); $node->setExpanded(TRUE); $node->setLabel($GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->tableName]['ctrl']['title'])); } else { $row = t3lib_BEfunc::getRecordWSOL($this->tableName, $basicNode->getId(), '*', '', FALSE); if ($this->getLabelField() !== '') { $node->setLabel($row[$this->getLabelField()]); } else { $node->setLabel($basicNode->getId()); } $node->setSelected(t3lib_div::inList($this->getSelectedList(), $basicNode->getId())); $node->setExpanded($this->isExpanded($basicNode)); } $node->setId($basicNode->getId()); $node->setSelectable(!t3lib_div::inList($this->getNonSelectableLevelList(), $level)); $node->setSortValue($this->nodeSortValues[$basicNode->getId()]); $node->setIcon(t3lib_iconWorks::mapRecordTypeToSpriteIconClass($this->tableName, $row)); $node->setParentNode($parent); if ($basicNode->hasChildNodes()) { $node->setHasChildren(TRUE); $childNodes = t3lib_div::makeInstance('t3lib_tree_SortedNodeCollection'); foreach ($basicNode->getChildNodes() as $child) { $childNodes->append($this->buildRepresentationForNode($child, $node, $level + 1)); } $node->setChildNodes($childNodes); } return $node; }
/** * Generates grid list array from given versions. * * @param array $versions * @param string $filterTxt * @return void */ 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 { $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['workspace'] = $versionRecord['t3ver_id']; $versionArray['label_Workspace'] = htmlspecialchars($versionRecord[$GLOBALS['TCA'][$table]['ctrl']['label']]); $versionArray['label_Live'] = htmlspecialchars($origRecord[$GLOBALS['TCA'][$table]['ctrl']['label']]); $versionArray['label_Stage'] = htmlspecialchars($stagesObj->getStageTitle($versionRecord['t3ver_stage'])); $versionArray['change'] = $pctChange; $versionArray['path_Live'] = htmlspecialchars(t3lib_BEfunc::getRecordPath($record['livepid'], '', 999)); $versionArray['path_Workspace'] = htmlspecialchars(t3lib_BEfunc::getRecordPath($record['wspid'], '', 999)); $versionArray['workspace_Title'] = htmlspecialchars(tx_Workspaces_Service_Workspaces::getWorkspaceTitle($versionRecord['t3ver_wsid'])); $versionArray['workspace_Tstamp'] = $versionRecord['tstamp']; $versionArray['workspace_Formated_Tstamp'] = t3lib_BEfunc::datetime($versionRecord['tstamp']); $versionArray['t3ver_oid'] = $record['t3ver_oid']; $versionArray['livepid'] = $record['livepid']; $versionArray['stage'] = $versionRecord['t3ver_stage']; $versionArray['icon_Live'] = t3lib_iconWorks::mapRecordTypeToSpriteIconClass($table, $origRecord); $versionArray['icon_Workspace'] = t3lib_iconWorks::mapRecordTypeToSpriteIconClass($table, $versionRecord); $versionArray['allowedAction_nextStage'] = $stagesObj->isNextStageAllowedForUser($versionRecord['t3ver_stage']); $versionArray['allowedAction_prevStage'] = $stagesObj->isPrevStageAllowedForUser($versionRecord['t3ver_stage']); 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 && $viewUrl; $versionArray['allowedAction_edit'] = !$isDeletedPage; $versionArray['allowedAction_editVersionedPage'] = !$isDeletedPage; $versionArray['state_Workspace'] = $recordState; if ($filterTxt == '' || $this->isFilterTextInVisibleColumns($filterTxt, $versionArray)) { $this->dataArray[] = $versionArray; } } } $this->sortDataArray(); $this->setDataArrayIntoCache($versions, $filterTxt); } $this->sortDataArray(); }