📄 index.php
字号:
$onClick = 'window.location.href = "'.$this->REQUEST_URI.'";'; $actionLinks.= $this->doc->wrapScriptTags($onClick); } else $actionLinks = ''; return $actionLinks; } /************************************** * * Helper functions (REDUNDANT FROM user/ws/index.php - someone could refactor this...) * *************************************/ /** * Formatting the version number for HTML output * * @param integer Version number * @return string Version number for output */ function formatVerId($verId) { return '1.'.$verId; } /** * Formatting workspace ID into a visual label * * @param integer Workspace ID * @return string Workspace title */ function formatWorkspace($wsid) { // Render, if not cached: if (!isset($this->formatWorkspace_cache[$wsid])) { switch($wsid) { case -1: $this->formatWorkspace_cache[$wsid] = '[Offline]'; break; case 0: $this->formatWorkspace_cache[$wsid] = ''; // Does not output anything for ONLINE because it might confuse people to think that the elemnet IS online which is not the case - only that it exists as an offline version in the online workspace... break; default: list($titleRec) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('title','sys_workspace','uid='.intval($wsid).t3lib_BEfunc::deleteClause('sys_workspace')); $this->formatWorkspace_cache[$wsid] = '['.$wsid.'] '.$titleRec['title']; break; } } return $this->formatWorkspace_cache[$wsid]; } /** * Format publishing count for version (lifecycle state) * * @param integer t3ver_count value (number of times it has been online) * @return string String translation of count. */ function formatCount($count) { // Render, if not cached: if (!isset($this->formatCount_cache[$count])) { switch($count) { case 0: $this->formatCount_cache[$count] = 'Draft'; break; case 1: $this->formatCount_cache[$count] = 'Archive'; break; default: $this->formatCount_cache[$count] = 'Published '.$count.' times'; break; } } return $this->formatCount_cache[$count]; } /** * Looking for versions of a record in other workspaces than the current * * @param string Table name * @param integer Record uid * @return string List of other workspace IDs */ function versionsInOtherWS($table,$uid) { // Check for duplicates: // Select all versions of record NOT in this workspace: $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 't3ver_wsid', $table, 'pid=-1 AND t3ver_oid='.intval($uid).' AND t3ver_wsid!='.intval($GLOBALS['BE_USER']->workspace).' AND (t3ver_wsid=-1 OR t3ver_wsid>0)'. t3lib_BEfunc::deleteClause($table), '', 't3ver_wsid', '', 't3ver_wsid' ); if (count($rows)) { return implode(',',array_keys($rows)); } } /** * Looks up stage changes for version and displays a formatted view on mouseover. * * @param string Table name * @param integer Record ID * @param string HTML string to wrap the mouseover around (should be stage change links) * @return string HTML code. */ function showStageChangeLog($table,$id,$stageCommands) { $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 'log_data,tstamp,userid', 'sys_log', 'action=6 and details_nr=30 AND tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_log').' AND recuid='.intval($id) ); $entry = array(); foreach($rows as $dat) { $data = unserialize($dat['log_data']); $username = $this->be_user_Array[$dat['userid']] ? $this->be_user_Array[$dat['userid']]['username'] : '['.$dat['userid'].']'; switch($data['stage']) { case 1: $text = 'sent element to "Review"'; break; case 10: $text = 'approved for "Publish"'; break; case -1: $text = 'rejected element!'; break; case 0: $text = 'reset to "Editing"'; break; default: $text = '[undefined]'; break; } $text = t3lib_BEfunc::dateTime($dat['tstamp']).': "'.$username.'" '.$text; $text.= ($data['comment']?'<br/>User Comment: <em>'.htmlspecialchars($data['comment']).'</em>':''); $entry[] = $text; } return count($entry) ? '<span onmouseover="document.getElementById(\'log_'.$table.$id.'\').style.visibility = \'visible\';" onmouseout="document.getElementById(\'log_'.$table.$id.'\').style.visibility = \'hidden\';">'.$stageCommands.' ('.count($entry).')</span>'. '<div class="logLayer" style="visibility: hidden; position: absolute;" id="log_'.$table.$id.'">'.implode('<hr/>',array_reverse($entry)).'</div>' : $stageCommands; } /** * 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; if (!$this->details && ($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($this->REQUEST_URI)).'">'. '<span class="typo3-dimmed"><em>[Sub elements, click for details]</em><span></a>' : '<span class="typo3-dimmed"><em>[Sub elements]</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; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -