/** * Renders the display of Template Objects. * * @return void */ function renderTO() { if (intval($this->displayUid)>0) { $row = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj',$this->displayUid); if (is_array($row)) { $tRows=array(); $tRows[]=' <tr class="bgColor5"> <td colspan="2"><strong>' . $GLOBALS['LANG']->getLL('renderTO_toDetails') . ':</strong>'. $this->cshItem('xMOD_tx_templavoila','mapping_to',$this->doc->backPath,''). '</td> </tr>'; // Get title and icon: $icon = t3lib_iconWorks::getSpriteIconForRecord('tx_templavoila_tmplobj', $row); $title = t3lib_BEfunc::getRecordTitle('tx_templavoila_tmplobj', $row); $title = t3lib_BEFunc::getRecordTitlePrep($GLOBALS['LANG']->sL($title)); $tRows[]=' <tr class="bgColor4"> <td>'.$GLOBALS['LANG']->getLL('templateObject').':</td> <td>' . $this->doc->wrapClickMenuOnIcon($icon, 'tx_templavoila_tmplobj', $row['uid'], 1) . $title . '</td> </tr>'; // Session data $sessionKey = $this->MCONF['name'] . '_validatorInfo:' . $row['uid']; $sesDat = array('displayFile' => $row['fileref']); $GLOBALS['BE_USER']->setAndSaveSessionData($sessionKey, $sesDat); // Find the file: $theFile = t3lib_div::getFileAbsFileName($row['fileref'],1); if ($theFile && @is_file($theFile)) { $relFilePath = substr($theFile,strlen(PATH_site)); $onCl = 'return top.openUrlInWindow(\''.t3lib_div::getIndpEnv('TYPO3_SITE_URL').$relFilePath.'\',\'FileView\');'; $tRows[]=' <tr class="bgColor4"> <td rowspan="2">'.$GLOBALS['LANG']->getLL('templateFile').':</td> <td><a href="#" onclick="'.htmlspecialchars($onCl).'">'.htmlspecialchars($relFilePath).'</a></td> </tr> <tr class="bgColor4"> <td> <a href="#" onclick ="openValidator(\'' . $sessionKey . '\');return false;"> ' . t3lib_iconWorks::getSpriteIcon('extensions-templavoila-htmlvalidate') . ' ' . $GLOBALS['LANG']->getLL('validateTpl') . ' </a> </td> </tr>'; // Finding Data Structure Record: $DSOfile=''; $dsValue = $row['datastructure']; if ($row['parent']) { $parentRec = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj',$row['parent'],'datastructure'); $dsValue=$parentRec['datastructure']; } if (tx_templavoila_div::canBeInterpretedAsInteger($dsValue)) { $DS_row = t3lib_BEfunc::getRecordWSOL('tx_templavoila_datastructure',$dsValue); } else { $DSOfile = t3lib_div::getFileAbsFileName($dsValue); } if (is_array($DS_row) || @is_file($DSOfile)) { // Get main DS array: if (is_array($DS_row)) { // Get title and icon: $icon = t3lib_iconWorks::getSpriteIconForRecord('tx_templavoila_datastructure',$DS_row); $title = t3lib_BEfunc::getRecordTitle('tx_templavoila_datastructure', $DS_row); $title = t3lib_BEFunc::getRecordTitlePrep($GLOBALS['LANG']->sL($title)); $tRows[]=' <tr class="bgColor4"> <td>' . $GLOBALS['LANG']->getLL('renderTO_dsRecord') . ':</td> <td>' . $this->doc->wrapClickMenuOnIcon($icon, 'tx_templavoila_datastructure', $DS_row['uid'] , 1) . $title . '</td> </tr>'; // Link to updating DS/TO: $onCl = 'index.php?file=' . rawurlencode($theFile) . '&_load_ds_xml=1&_load_ds_xml_to=' . $row['uid'] . '&uid=' . $DS_row['uid'] . '&returnUrl=' . $this->returnUrl; $onClMsg = ' if (confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('renderTO_updateWarningConfirm')) . ')) { document.location=\''.$onCl.'\'; } return false; '; $tRows[]=' <tr class="bgColor4"> <td> </td> <td><input type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('renderTO_editDSTO') . '" onclick="'.htmlspecialchars($onClMsg).'"/>'. $this->cshItem('xMOD_tx_templavoila','mapping_to_modifyDSTO',$this->doc->backPath,''). '</td> </tr>'; // Read Data Structure: $dataStruct = $this->getDataStructFromDSO($DS_row['dataprot']); } else { // Show filepath of external XML file: $relFilePath = substr($DSOfile,strlen(PATH_site)); $onCl = 'return top.openUrlInWindow(\''.t3lib_div::getIndpEnv('TYPO3_SITE_URL').$relFilePath.'\',\'FileView\');'; $tRows[]=' <tr class="bgColor4"> <td>' . $GLOBALS['LANG']->getLL('renderTO_dsFile') . ':</td> <td><a href="#" onclick="'.htmlspecialchars($onCl).'">'.htmlspecialchars($relFilePath).'</a></td> </tr>'; $onCl = 'index.php?file=' . rawurlencode($theFile) . '&_load_ds_xml=1&_load_ds_xml_to=' . $row['uid'] . '&uid=' . rawurlencode($DSOfile) . '&returnUrl=' . $this->returnUrl; $onClMsg = ' if (confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('renderTO_updateWarningConfirm')) . ')) { document.location=\''.$onCl.'\'; } return false; '; $tRows[]=' <tr class="bgColor4"> <td> </td> <td><input type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('renderTO_editDSTO') . '" onclick="'.htmlspecialchars($onClMsg).'"/>'. $this->cshItem('xMOD_tx_templavoila','mapping_to_modifyDSTO',$this->doc->backPath,''). '</td> </tr>'; // Read Data Structure: $dataStruct = $this->getDataStructFromDSO('',$DSOfile); } // Write header of page: $content.= ' <!-- Template Object Header: --> <h3>' . $GLOBALS['LANG']->getLL('renderTO_toInfo') . ':</h3> <table border="0" cellpadding="2" cellspacing="1" id="c-toHeader"> '.implode('',$tRows).' </table> '; // If there is a valid data structure, draw table: if (is_array($dataStruct)) { // Working on Header and Body of HTML source: // -- Processing the header editing -- list($editContent,$currentHeaderMappingInfo) = $this->renderTO_editProcessing($dataStruct,$row,$theFile, 1); // Determine if DS is a template record and if it is a page template: $showBodyTag = !is_array($DS_row) || $DS_row['scope']==1 ? TRUE : FALSE; $parts = array(); $parts[] = array( 'label' => $GLOBALS['LANG']->getLL('tabTODetails'), 'content' => $content ); // -- Processing the head editing $headerContent.=' <!-- HTML header parts selection: --> <h3>'.$GLOBALS['LANG']->getLL('mappingHeadParts').': '.$this->cshItem('xMOD_tx_templavoila','mapping_to_headerParts',$this->doc->backPath,'').'</h3> '.$this->renderHeaderSelection($theFile,$currentHeaderMappingInfo,$showBodyTag,$editContent); $parts[] = array( 'label' => $GLOBALS['LANG']->getLL('tabHeadParts'), 'content' => $headerContent ); // -- Processing the body editing -- list($editContent,$currentMappingInfo) = $this->renderTO_editProcessing($dataStruct,$row,$theFile, 0); $bodyContent.=' <!-- Data Structure mapping table: --> <h3>'.$GLOBALS['LANG']->getLL('mappingBodyParts').':</h3> '.$this->renderTemplateMapper($theFile,$this->displayPath,$dataStruct,$currentMappingInfo,$editContent); $parts[] = array( 'label' => $GLOBALS['LANG']->getLL('tabBodyParts'), 'content' => $bodyContent ); } else $content.= $GLOBALS['LANG']->getLL('error') . ': ' . sprintf($GLOBALS['LANG']->getLL('errorNoDSfound'), $dsValue); } else $content.= $GLOBALS['LANG']->getLL('error') . ': ' . sprintf($GLOBALS['LANG']->getLL('errorNoDSfound'), $dsValue); } else $content.= $GLOBALS['LANG']->getLL('error') . ': ' . sprintf($GLOBALS['LANG']->getLL('errorFileNotFound'), $row['fileref']); } else $content.= $GLOBALS['LANG']->getLL('error') . ': ' . sprintf($GLOBALS['LANG']->getLL('errorNoTOfound'), $this->displayUid); $parts[0]['content'] = $content; } else { $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('templateObject').' '.$GLOBALS['LANG']->getLL('error'), $GLOBALS['LANG']->getLL('errorNoUidFound'),0,1,3); } // show tab menu if (is_array($parts)) { $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('mappingTitle'), ''. $this->doc->getDynTabMenu($parts,'TEMPLAVOILA:templateModule:'.$this->id, 0,0,300) ,0,1); } }
/** * 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(); }