index.php
来自「Typo3, 开源里边最强大的」· PHP 代码 · 共 1,589 行 · 第 1/5 页
PHP
1,589 行
'<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($uid,$this->doc->backPath,t3lib_BEfunc::BEgetRootLine($uid))).'">'. '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/zoom.gif','width="12" height="12"').' title="" alt="" />'. '</a>'; } return $actionLinks; } /** * Building up of the $pArray variable which is a hierarchical storage of table-rows arranged according to the level in the rootline the element was found * (Internal) * Made for recursive calling * * @param array Array that is built up with the page tree structure * @param array Root line for element (table / row); The element is stored in pArray according to this root line. * @param string Table name * @param array Table row * @return void $pArray is passed by reference and modified internally */ function displayWorkspaceOverview_setInPageArray(&$pArray,$rlArr,$table,$row) { // Initialize: ksort($rlArr); reset($rlArr); if (!$rlArr[0]['uid']) array_shift($rlArr); // Get and remove first element in root line: $cEl = current($rlArr); $pUid = $cEl['t3ver_oid'] ? $cEl['t3ver_oid'] : $cEl['uid']; // Done to pile up "false versions" in the right branch... $pArray[$pUid] = $cEl['title']; array_shift($rlArr); // If there are elements left in the root line, call this function recursively (to build $pArray in depth) if (count($rlArr)) { if (!isset($pArray[$pUid.'.'])) $pArray[$pUid.'.'] = array(); $this->displayWorkspaceOverview_setInPageArray($pArray[$pUid.'.'],$rlArr,$table,$row); } else { // If this was the last element, set the value: $pArray[$pUid.'_'][$table][$row['t3ver_oid']][] = $row; } } /** * Creates display of sub elements of a page when the swap mode is either "Page" or "Branch" (0 / ALL) * * @param integer Page uid (for either online or offline version, but it MUST have swapmode/treeLevel set to >0 (not -1 indicating element versioning) * @param integer The treeLevel value, >0 indicates "branch" while 0 means page+content. (-1 would have meant element versioning, but that should never happen for a call to this function!) * @param integer For offline versions; This is t3ver_oid, the original ID of the online page. * @return string HTML content. */ function subElements($uid,$treeLevel,$origId=0) { global $TCA, $LANG; if ($GLOBALS['BE_USER']->workspace===0 || !$this->MOD_SETTINGS['expandSubElements']) { // In online workspace we have a reduced view because otherwise it will bloat the listing: return '<br/> <img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/ol/joinbottom.gif','width="18" height="16"').' align="top" alt="" title="" />'. ($origId ? '<a href="'.htmlspecialchars($this->doc->backPath.t3lib_extMgm::extRelPath('version').'cm1/index.php?id='.$uid.'&details='.rawurlencode('pages:'.$uid).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'. '<span class="typo3-dimmed"><em>['.$LANG->getLL('label_subelementsdetails').']</em><span></a>' : '<span class="typo3-dimmed"><em>['.$LANG->getLL('label_subelements').']</em><span>'); } else { // For an offline workspace, show sub elements: $tCell = array(); // Find records that follow pages when swapping versions: $recList = array(); foreach($TCA as $tN => $tCfg) { if ($tN!='pages' && ($treeLevel>0 || $TCA[$tN]['ctrl']['versioning_followPages'])) { $this->subElements_getNonPageRecords($tN, $uid, $recList); } } // Render records collected above: $elCount = count($recList)-1; foreach($recList as $c => $comb) { list($tN,$rec) = $comb; $this->subElements_renderItem( $tCell, $tN, $uid, $rec, $origId, $c==$elCount && $treeLevel==0 ? 1 : 0, // If true, will show bottom-join icon. '' ); } // For branch, dive into the subtree: if ($treeLevel>0) { // Drawing tree: $tree = t3lib_div::makeInstance('t3lib_pageTree'); $tree->init('AND '.$GLOBALS['BE_USER']->getPagePermsClause(1)); $tree->makeHTML = 2; // 2=Also rendering depth-data into the result array $tree->getTree($uid, 99, ''); // Traverse page tree: foreach($tree->tree as $data) { // Render page in table cell: $this->subElements_renderItem( $tCell, 'pages', $uid, t3lib_BEfunc::getRecord('pages',$data['row']['uid']), // Needs all fields, at least more than what is given in $data['row']... $origId, 2, // 2=the join icon and icon for the record is not rendered for pages (where all is in $data['HTML'] $data['HTML'] ); // Find all records from page and collect in $recList: $recList = array(); foreach($TCA as $tN => $tCfg) { if ($tN!=='pages') { $this->subElements_getNonPageRecords($tN, $data['row']['uid'], $recList); } } // Render records collected above: $elCount = count($recList)-1; foreach($recList as $c => $comb) { list($tN,$rec) = $comb; $this->subElements_renderItem( $tCell, $tN, $uid, $rec, $origId, $c==$elCount?1:0, // If true, will show bottom-join icon. $data['HTML_depthData'] ); } } } return ' <!-- Sub-element tree for versions --> <table border="0" cellpadding="0" cellspacing="1" class="ver-subtree"> '.implode('',$tCell).' </table>'; } } /** * Select records from a table and add them to recList * * @param string Table name (from TCA) * @param integer PID to select records from * @param array Array where records are accumulated, passed by reference * @return void */ function subElements_getNonPageRecords($tN, $uid, &$recList) { global $TCA; $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( '*', $tN, 'pid='.intval($uid). ($TCA[$tN]['ctrl']['versioningWS'] ? ' AND t3ver_state=0' : ''). t3lib_BEfunc::deleteClause($tN), '', $TCA[$tN]['ctrl']['sortby'] ? $TCA[$tN]['ctrl']['sortby'] : $GLOBALS['TYPO3_DB']->stripOrderBy($TCA[$tN]['ctrl']['default_sortby']) ); foreach($records as $rec) { $recList[] = array($tN,$rec); } } /** * Render a single item in a subelement list into a table row: * * @param array Table rows, passed by reference * @param string Table name * @param integer Page uid for which the subelements are selected/shown * @param array Row of element in list * @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. * @param integer Mode of icon display: 0=not the last, 1= is the last in list (make joinbottom icon then), 2=do not shown icons are all (for pages from the page tree already rendered) * @param string Prefix HTML data (icons for tree rendering) * @return void (Content accumulated in $tCell!) */ function subElements_renderItem(&$tCell,$tN,$uid,$rec,$origId,$iconMode,$HTMLdata) { global $TCA; // Initialize: $origUidFields = $TCA[$tN]['ctrl']['origUid']; $diffCode = ''; if ($origUidFields) { // If there is a field for this table with original uids we will use that to connect records: if (!$origId) { // In case we are displaying the online originals: $this->targets['orig_'.$uid.'_'.$tN.'_'.$rec['uid']] = $rec; // Build up target array (important that $tdParams = ' id="orig_'.$uid.'_'.$tN.'_'.$rec['uid'].'" class="typo3-ver"'; // Setting ID of the table row } else { // Version branch: if ($this->targets['orig_'.$origId.'_'.$tN.'_'.$rec[$origUidFields]]) { // If there IS a corresponding original record...: // Prepare Table row parameters: $tdParams = ' onmouseover="hlSubelements(\''.$origId.'_'.$tN.'_'.$rec[$origUidFields].'\', \''.$uid.'_'.$tN.'_'.$rec[$origUidFields].'\', 1, '.($this->MOD_SETTINGS['diff']==2?1:0).');"'. ' onmouseout="hlSubelements(\''.$origId.'_'.$tN.'_'.$rec[$origUidFields].'\', \''.$uid.'_'.$tN.'_'.$rec[$origUidFields].'\', 0, '.($this->MOD_SETTINGS['diff']==2?1:0).');"'. ' id="ver_'.$uid.'_'.$tN.'_'.$rec[$origUidFields].'" class="typo3-ver"'; // Create diff view: if ($this->MOD_SETTINGS['diff']) { list($diffHTML,$diffPct) = $this->createDiffView($tN, $rec, $this->targets['orig_'.$origId.'_'.$tN.'_'.$rec[$origUidFields]]); if ($this->MOD_SETTINGS['diff']==2) { $diffCode = ($diffPct ? '<span class="nobr">'.$diffPct.'% change</span>' : '-'). '<div style="visibility: hidden; position: absolute;" id="diff_'.$uid.'_'.$tN.'_'.$rec[$origUidFields].'" class="diffLayer">'. $diffHTML. '</div>'; } else { $diffCode = ($diffPct<0 ? 'N/A' : ($diffPct ? $diffPct.'% change:' : '')). $diffHTML; } } // 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, $LANG; // 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>' . $LANG->getLL('diffview_label_field_name') . '</td> <td width="98%" nowrap="nowrap">' . $LANG->getLL('diffview_label_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) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?