|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 /** 00028 * Contains class for display of backend log 00029 * 00030 * $Id: class.t3lib_bedisplaylog.php 10121 2011-01-18 20:15:30Z ohader $ 00031 * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj 00032 * XHTML compliant 00033 * 00034 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00035 */ 00036 /** 00037 * [CLASS/FUNCTION INDEX of SCRIPT] 00038 * 00039 * 00040 * 00041 * 81: class t3lib_BEDisplayLog 00042 * 106: function initArray() 00043 * 123: function getTimeLabel($code) 00044 * 139: function getUserLabel($code,$workspace=0) 00045 * 154: function getTypeLabel($code) 00046 * 168: function getActionLabel($code) 00047 * 186: function getDetails($code,$text,$data,$sys_log_uid=0) 00048 * 220: function reset() 00049 * 234: function getErrorFormatting($sign, $error=0) 00050 * 244: function formatDetailsForList($row) 00051 * 261: function stripPath($inArr) 00052 * 00053 * TOTAL FUNCTIONS: 10 00054 * (This index is automatically created/updated by the extension "extdeveval") 00055 * 00056 */ 00057 00058 00059 /** 00060 * This class holds some functions used to display the sys_log table-content. 00061 * Used in the status-scripts and the log-module. 00062 * 00063 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00064 * @package TYPO3 00065 * @subpackage t3lib 00066 * @see tx_belog_webinfo, SC_mod_tools_log_index 00067 */ 00068 class t3lib_BEDisplayLog { 00069 var $lastTimeLabel = ''; 00070 var $lastUserLabel = ''; 00071 var $lastTypeLabel = ''; 00072 var $lastActionLabel = ''; 00073 00074 var $detailsOn = 1; // If detailsOn, %s is substituted with values from the data-array (see getDetails()) 00075 var $stripPath = 1; // This strips the path from any value in the data-array when the data-array is parsed through stripPath() 00076 var $errorSign = Array( 00077 1 => '!', 00078 2 => 'Sys!', 00079 3 => 'Security!' 00080 ); 00081 var $wsArray = array( 00082 0 => 'LIVE', 00083 -1 => 'Draft', 00084 ); 00085 00086 var $be_user_Array = array(); // Username array (set externally) 00087 00088 /** 00089 * Initialize the log table array with header labels. 00090 * 00091 * @return array 00092 */ 00093 function initArray() { 00094 $codeArr = array(); 00095 $codeArr[0][] = 'Time'; // Time 00096 $codeArr[0][] = 'User'; 00097 $codeArr[0][] = 'Type'; 00098 $codeArr[0][] = 'Error'; 00099 $codeArr[0][] = 'Action'; 00100 $codeArr[0][] = 'Details'; 00101 return $codeArr; 00102 } 00103 00104 /** 00105 * Get time label for log listing 00106 * 00107 * @param integer Timestamp to display 00108 * @return string If the timestamp was also shown last time, then "." is returned. Otherwise the new timestamp formatted with ->doc->formatTime() 00109 */ 00110 function getTimeLabel($code) { 00111 #$t=$GLOBALS['SOBE']->doc->formatTime($code,1); 00112 $t = date('H:i:s', $code); 00113 00114 if ($this->lastTimeLabel != $t) { 00115 $this->lastTimeLabel = $t; 00116 return $t; 00117 } else { 00118 return '.'; 00119 } 00120 00121 } 00122 00123 /** 00124 * Get user name label for log listing 00125 * 00126 * @param integer be_user uid 00127 * @param integer Workspace ID 00128 * @return string If username is different from last username then the username, otherwise "." 00129 */ 00130 function getUserLabel($code, $workspace = 0) { 00131 if ($this->lastUserLabel != $code . '_' . $workspace) { 00132 $this->lastUserLabel = $code . '_' . $workspace; 00133 $label = $this->be_user_Array[$code]['username']; 00134 $ws = $this->wsArray[$workspace]; 00135 return ($label ? htmlspecialchars($label) : '[' . $code . ']') . '@' . ($ws ? $ws : $workspace); 00136 } else { 00137 return '.'; 00138 } 00139 } 00140 00141 /** 00142 * Get type label for log listing 00143 * 00144 * @param string Key for the type label in locallang 00145 * @return string If labe is different from last type label then the label is returned, otherwise "." 00146 */ 00147 function getTypeLabel($code) { 00148 if ($this->lastTypeLabel != $code) { 00149 $this->lastTypeLabel = $code; 00150 $label = $GLOBALS['LANG']->getLL('type_' . $code); 00151 return $label ? $label : '[' . $code . ']'; 00152 } else { 00153 return '.'; 00154 } 00155 } 00156 00157 /** 00158 * Get action label for log listing 00159 * 00160 * @param string Key for the action label in locallang 00161 * @return string If label is different from last action label then the label is returned, otherwise "." 00162 */ 00163 function getActionLabel($code) { 00164 if ($this->lastActionLabel != $code) { 00165 $this->lastActionLabel = $code; 00166 $label = $GLOBALS['LANG']->getLL('action_' . $code); 00167 return $label ? htmlspecialchars($label) : '[' . $code . ']'; 00168 } else { 00169 return '.'; 00170 } 00171 } 00172 00173 /** 00174 * Get details for the log entry 00175 * 00176 * @param string Suffix to "msg_" to get label from locallang. 00177 * @param string Details text 00178 * @param array Data array 00179 * @param integer sys_log uid number 00180 * @return string Text string 00181 * @see formatDetailsForList() 00182 */ 00183 function getDetails($code, $text, $data, $sys_log_uid = 0) { 00184 // $code is used later on to substitute errormessages with language-corrected values... 00185 if (is_array($data)) { 00186 if ($this->detailsOn) { 00187 if (is_object($GLOBALS['LANG'])) { 00188 # $label = $GLOBALS['LANG']->getLL('msg_'.$code); 00189 } else { 00190 list($label) = explode(',', $text); 00191 } 00192 if ($label) { 00193 $text = $label; 00194 } 00195 $text = sprintf($text, htmlspecialchars($data[0]), htmlspecialchars($data[1]), htmlspecialchars($data[2]), htmlspecialchars($data[3]), htmlspecialchars($data[4])); 00196 } else { 00197 $text = str_replace('%s', '', $text); 00198 } 00199 } 00200 $text = htmlspecialchars($text); 00201 00202 // Finding the history for the record 00203 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,fieldlist', 'sys_history', 'sys_log_uid=' . intval($sys_log_uid)); 00204 $newRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 00205 if (is_array($newRow)) { 00206 $text .= ' ' . sprintf($GLOBALS['LANG']->getLL('changesInFields'), '<em>' . $newRow['fieldlist'] . '</em>'); 00207 $text .= ' <a href="' . htmlspecialchars($GLOBALS['BACK_PATH'] . 'show_rechis.php?sh_uid=' . $newRow['uid'] . 00208 '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' . 00209 t3lib_iconWorks::getSpriteIcon( 00210 'actions-document-history-open', 00211 array('title' => $GLOBALS['LANG']->getLL('showHistory')) 00212 ) . 00213 '</a>'; 00214 } 00215 00216 return $text; 00217 } 00218 00219 /** 00220 * Reset all internal "last..." variables to blank string. 00221 * 00222 * @return void 00223 */ 00224 function reset() { 00225 $this->lastTimeLabel = ''; 00226 $this->lastUserLabel = ''; 00227 $this->lastTypeLabel = ''; 00228 $this->lastActionLabel = ''; 00229 } 00230 00231 /** 00232 * Formats input string in red-colored font tags 00233 * 00234 * @param string Input value 00235 * @param integer Error value 00236 * @return string Input wrapped in red font-tag and bold 00237 */ 00238 function getErrorFormatting($sign, $error = 0) { 00239 return $GLOBALS['SOBE']->doc->icons($error >= 2 ? 3 : 2) . ' ' . $sign; 00240 } 00241 00242 /** 00243 * Formatting details text for the sys_log row inputted 00244 * 00245 * @param array sys_log row 00246 * @return string Details string 00247 */ 00248 function formatDetailsForList($row) { 00249 $data = unserialize($row['log_data']); 00250 if ($row['type'] == 2) { 00251 $data = $this->stripPath($data); 00252 } 00253 00254 return $this->getDetails($row['type'] . '_' . $row['action'] . '_' . $row['details_nr'], $row['details'], $data, $row['uid']) . ($row['details_nr'] > 0 ? ' (msg#' . $row['type'] . '.' . $row['action'] . '.' . $row['details_nr'] . ')' : ''); 00255 } 00256 00257 /** 00258 * For all entries in the $inArray (expected to be filepaths) the basename is extracted and set as value (if $this->stripPath is set) 00259 * This is done for log-entries from the FILE modules 00260 * 00261 * @param array Array of file paths 00262 * @return array 00263 * @see formatDetailsForList() 00264 */ 00265 function stripPath($inArr) { 00266 if ($this->stripPath && is_array($inArr)) { 00267 foreach ($inArr as $key => $val) { 00268 $inArr[$key] = basename($val); 00269 } 00270 } 00271 return $inArr; 00272 } 00273 } 00274 00275 00276 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_bedisplaylog.php'])) { 00277 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_bedisplaylog.php']); 00278 } 00279 ?>
1.8.0