📄 index.php
字号:
// Unsetting the target fields allows us to mark all originals without a version in the subtree (see ->markupNewOriginals()) unset($this->targets['orig_'.$origId.'_'.$tN.'_'.$rec[$origUidFields]]); } else { // No original record, so must be new: $tdParams = ' class="typo3-ver-new"'; } } } else { // If no original uid column is supported for this table we are forced NOT to display any diff or highlighting. $tdParams = ' class="typo3-ver-noComp"'; } // Compile the cell: $tCell[] = ' <tr'.$tdParams.'> <td class="iconTitle">'. $HTMLdata. ($iconMode < 2 ? '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/join'.($iconMode ? 'bottom' : '').'.gif','width="18" height="16"').' alt="" />'. t3lib_iconWorks::getIconImage($tN, $rec, $this->doc->backPath,'') : ''). t3lib_BEfunc::getRecordTitle($tN, $rec, TRUE). '</td> <td class="cmdCell">'. $this->displayWorkspaceOverview_commandLinksSub($tN,$rec,$origId). '</td>'.($origId ? '<td class="diffCell">'. $diffCode. '</td>':'').' </tr>'; } /** * JavaScript code to mark up new records that are online (in sub element lists) * * @return string HTML javascript section */ function markupNewOriginals() { if (count($this->targets)) { $scriptCode = ''; foreach($this->targets as $key => $rec) { $scriptCode.=' document.getElementById(\''.$key.'\').attributes.getNamedItem("class").nodeValue = \'typo3-ver-new\'; '; } return $this->doc->wrapScriptTags($scriptCode); } } /** * Create visual difference view of two records. Using t3lib_diff library * * @param string Table name * @param array New version record (green) * @param array Old version record (red) * @return array Array with two keys (0/1) with HTML content / percentage integer (if -1, then it means N/A) indicating amount of change */ function createDiffView($table, $diff_1_record, $diff_2_record) { global $TCA; // Initialize: $pctChange = 'N/A'; // Check that records are arrays: if (is_array($diff_1_record) && is_array($diff_2_record)) { // Load full table description and initialize diff-object: t3lib_div::loadTCA($table); $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff'); // Add header row: $tRows = array(); $tRows[] = ' <tr class="bgColor5 tableheader"> <td>Fieldname:</td> <td width="98%" nowrap="nowrap">Colored diff-view:</td> </tr> '; // Initialize variables to pick up string lengths in: $allStrLen = 0; $diffStrLen = 0; // Traversing the first record and process all fields which are editable: foreach($diff_1_record as $fN => $fV) { if ($TCA[$table]['columns'][$fN] && $TCA[$table]['columns'][$fN]['config']['type']!='passthrough' && !t3lib_div::inList('t3ver_label',$fN)) { // Check if it is files: $isFiles = FALSE; if (strcmp(trim($diff_1_record[$fN]),trim($diff_2_record[$fN])) && $TCA[$table]['columns'][$fN]['config']['type']=='group' && $TCA[$table]['columns'][$fN]['config']['internal_type']=='file') { // Initialize: $uploadFolder = $TCA[$table]['columns'][$fN]['config']['uploadfolder']; $files1 = array_flip(t3lib_div::trimExplode(',', $diff_1_record[$fN],1)); $files2 = array_flip(t3lib_div::trimExplode(',', $diff_2_record[$fN],1)); // Traverse filenames and read their md5 sum: foreach($files1 as $filename => $tmp) { $files1[$filename] = @is_file(PATH_site.$uploadFolder.'/'.$filename) ? md5(t3lib_div::getUrl(PATH_site.$uploadFolder.'/'.$filename)) : $filename; } foreach($files2 as $filename => $tmp) { $files2[$filename] = @is_file(PATH_site.$uploadFolder.'/'.$filename) ? md5(t3lib_div::getUrl(PATH_site.$uploadFolder.'/'.$filename)) : $filename; } // Implode MD5 sums and set flag: $diff_1_record[$fN] = implode(' ',$files1); $diff_2_record[$fN] = implode(' ',$files2); $isFiles = TRUE; } // If there is a change of value: if (strcmp(trim($diff_1_record[$fN]),trim($diff_2_record[$fN]))) { // Get the best visual presentation of the value and present that: $val1 = t3lib_BEfunc::getProcessedValue($table,$fN,$diff_2_record[$fN],0,1); $val2 = t3lib_BEfunc::getProcessedValue($table,$fN,$diff_1_record[$fN],0,1); // Make diff result and record string lenghts: $diffres = $t3lib_diff_Obj->makeDiffDisplay($val1,$val2,$isFiles?'div':'span'); $diffStrLen+= $t3lib_diff_Obj->differenceLgd; $allStrLen+= strlen($val1.$val2); // If the compared values were files, substituted MD5 hashes: if ($isFiles) { $allFiles = array_merge($files1,$files2); foreach($allFiles as $filename => $token) { if (strlen($token)==32 && strstr($diffres,$token)) { $filename = t3lib_BEfunc::thumbCode(array($fN=>$filename),$table,$fN,$this->doc->backPath). $filename; $diffres = str_replace($token,$filename,$diffres); } } } // Add table row with result: $tRows[] = ' <tr class="bgColor4"> <td>'.htmlspecialchars($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($table,$fN))).'</td> <td width="98%">'.$diffres.'</td> </tr> '; } else { // Add string lengths even if value matched - in this was the change percentage is not high if only a single field is changed: $allStrLen+=strlen($diff_1_record[$fN].$diff_2_record[$fN]); } } } // Calculate final change percentage: $pctChange = $allStrLen ? ceil($diffStrLen*100/$allStrLen) : -1; // Create visual representation of result: if (count($tRows)>1) { $content.= '<table border="0" cellpadding="1" cellspacing="1" class="diffTable">'.implode('',$tRows).'</table>'; } else { $content.= '<span class="nobr">'.$this->doc->icons(1).'Complete match on editable fields.</span>'; } } else $content.= $this->doc->icons(3).'ERROR: Records could strangely not be found!'; // Return value: return array($content,$pctChange); } /** * Links to stage change of a version * * @param string Table name * @param array Offline record (version) * @return string HTML content, mainly link tags and images. */ function displayWorkspaceOverview_stageCmd($table,&$rec_off) {#debug($rec_off['t3ver_stage']); switch((int)$rec_off['t3ver_stage']) { case 0: $sId = 1; $sLabel = 'Editing'; $color = '#666666'; $label = 'Comment for Reviewer:'; $titleAttrib = 'Send to Review'; break; case 1: $sId = 10; $sLabel = 'Review'; $color = '#6666cc'; $label = 'Comment for Publisher:'; $titleAttrib = 'Approve for Publishing'; break; case 10: $sLabel = 'Publish'; $color = '#66cc66'; break; case -1: $sLabel = $this->doc->icons(2).'Rejected'; $sId = 0; $color = '#ff0000'; $label = 'Comment:'; $titleAttrib = 'Reset stage'; break; default: $sLabel = 'Undefined'; $sId = 0; $color = ''; break; }#debug($sId); $raiseOk = !$GLOBALS['BE_USER']->workspaceCannotEditOfflineVersion($table,$rec_off); if ($raiseOk && $rec_off['t3ver_stage']!=-1) { $onClick = 'var commentTxt=window.prompt("Please explain why you reject:",""); if (commentTxt!=null) {window.location.href="'.$this->doc->issueCommand( '&cmd['.$table.']['.$rec_off['uid'].'][version][action]=setStage'. '&cmd['.$table.']['.$rec_off['uid'].'][version][stageId]=-1' ).'&cmd['.$table.']['.$rec_off['uid'].'][version][comment]="+escape(commentTxt);}'. ' return false;'; // Reject: $actionLinks.= '<a href="#" onclick="'.htmlspecialchars($onClick).'">'. '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/down.gif','width="14" height="14"').' alt="" align="top" title="Reject" />'. '</a>'; } else { // Reject: $actionLinks.= '<img src="'.$this->doc->backPath.'gfx/clear.gif" width="14" height="14" alt="" align="top" title="" />'; } $actionLinks.= '<span style="background-color: '.$color.'; color: white;">'.$sLabel.'</span>'; // Raise if ($raiseOk) { $onClick = 'var commentTxt=window.prompt("'.$label.'",""); if (commentTxt!=null) {window.location.href="'.$this->doc->issueCommand( '&cmd['.$table.']['.$rec_off['uid'].'][version][action]=setStage'. '&cmd['.$table.']['.$rec_off['uid'].'][version][stageId]='.$sId ).'&cmd['.$table.']['.$rec_off['uid'].'][version][comment]="+escape(commentTxt);}'. ' return false;'; if ($rec_off['t3ver_stage']!=10) { $actionLinks.= '<a href="#" onclick="'.htmlspecialchars($onClick).'">'. '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/up.gif','width="14" height="14"').' alt="" align="top" title="'.htmlspecialchars($titleAttrib).'" />'. '</a>'; $this->stageIndex[$sId][$table][] = $rec_off['uid']; $this->recIndex[$table][$rec_off['uid']] = $sId; } } return $actionLinks; } /** * Links to publishing etc of a version * * @param string Table name * @param array Online record * @param array Offline record (version) * @param string Swap type, "branch", "page" or "element" * @return string HTML content, mainly link tags and images. */ function displayWorkspaceOverview_commandLinks($table,&$rec_on,&$rec_off,$vType) { if ($this->publishAccess && (!($GLOBALS['BE_USER']->workspaceRec['publish_access']&1) || (int)$rec_off['t3ver_stage']===10)) { $actionLinks = '<a href="'.htmlspecialchars($this->doc->issueCommand( '&cmd['.$table.']['.$rec_on['uid'].'][version][action]=swap'. '&cmd['.$table.']['.$rec_on['uid'].'][version][swapWith]='.$rec_off['uid'] )).'">'. '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/insert1.gif','width="14" height="14"').' alt="" align="top" title="Publish" />'. '</a>'; if ($GLOBALS['BE_USER']->workspaceSwapAccess() && (int)$rec_on['t3ver_state']!==1 && (int)$rec_off['t3ver_state']!==2) { $actionLinks.= '<a href="'.htmlspecialchars($this->doc->issueCommand( '&cmd['.$table.']['.$rec_on['uid'].'][version][action]=swap'. '&cmd['.$table.']['.$rec_on['uid'].'][version][swapWith]='.$rec_off['uid']. '&cmd['.$table.']['.$rec_on['uid'].'][version][swapIntoWS]=1' )).'">'. '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/swap.png','width="14" height="14"').' alt="" align="top" title="Swap" />'. '</a>'; } } if (!$GLOBALS['BE_USER']->workspaceCannotEditOfflineVersion($table,$rec_off)) { // Release $actionLinks.= '<a href="'.htmlspecialchars($this->doc->issueCommand('&cmd['.$table.']['.$rec_off['uid'].'][version][action]=clearWSID')).'" onclick="return confirm(\'Remove from workspace?\');">'. '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/group_clear.gif','width="14" height="14"').' alt="" align="top" title="Remove from workspace" />'. '</a>'; // Edit if ($table==='pages' && $vType!=='element') { $tempUid = ($vType==='branch' || $GLOBALS['BE_USER']->workspace===0 ? $rec_off['uid'] : $rec_on['uid']); $actionLinks.= '<a href="#" onclick="top.loadEditId('.$tempUid.');top.goToModule(\''.$this->pageModule.'\'); return false;">'. '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,t3lib_extMgm::extRelPath('cms').'layout/layout.gif','width="14" height="12"').' title="Edit page" alt="" />'. '</a>'; } else { $params = '&edit['.$table.']['.$rec_off['uid'].']=edit'; $actionLinks.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->doc->backPath)).'">'. '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/edit2.gif','width="12" height="12"').' title="Edit element" alt="" />'. '</a>'; } } // History/Log $actionLinks.= '<a href="'.htmlspecialchars($this->doc->backPath.'show_rechis.php?element='.rawurlencode($table.':'.$rec_off['uid']).'&returnUrl='.rawurlencode($this->REQUEST_URI)).'">'. '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/history2.gif','width="13" height="12"').' title="Show Log" alt="" />'. '</a>'; // View if ($table==='pages') { $tempUid = ($vType==='branch' || $GLOBALS['BE_USER']->workspace===0 ? $rec_off['uid'] : $rec_on['uid']); $actionLinks.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($tempUid,$this->doc->backPath,t3lib_BEfunc::BEgetRootLine($tempUid))).'">'. '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/zoom.gif','width="12" height="12"').' title="" alt="" />'. '</a>'; } return $actionLinks; } /** * Links to publishing etc of a version * * @param string Table name * @param array Record * @param integer The uid of the online version of $uid. If zero it means we are drawing a row for the online version itself while a value means we are drawing display for an offline version. * @return string HTML content, mainly link tags and images. */ function displayWorkspaceOverview_commandLinksSub($table,$rec,$origId) { $uid = $rec['uid']; if ($origId || $GLOBALS['BE_USER']->workspace===0) { if (!$GLOBALS['BE_USER']->workspaceCannotEditRecord($table,$rec)) { // Edit if ($table==='
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -