Updated years from 2004 to 2005 + all function indexes. NO actual code changes done!
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_bedisplaylog.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Contains class for display of backend log
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
32 * XHTML compliant
33 *
34 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 *
41 * 81: class t3lib_BEDisplayLog
42 * 102: function initArray()
43 * 119: function getTimeLabel($code)
44 * 134: function getUserLabel($code)
45 * 148: function getTypeLabel($code)
46 * 162: function getActionLabel($code)
47 * 180: function getDetails($code,$text,$data,$sys_log_uid=0)
48 * 212: function reset()
49 * 226: function getErrorFormatting($sign)
50 * 236: function formatDetailsForList($row)
51 * 253: function stripPath($inArr)
52 *
53 * TOTAL FUNCTIONS: 10
54 * (This index is automatically created/updated by the extension "extdeveval")
55 *
56 */
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 /**
73 * This class holds some functions used to display the sys_log table-content.
74 * Used in the status-scripts and the log-module.
75 *
76 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
77 * @package TYPO3
78 * @subpackage t3lib
79 * @see tx_belog_webinfo, SC_mod_tools_log_index
80 */
81 class t3lib_BEDisplayLog {
82 var $lastTimeLabel = '';
83 var $lastUserLabel = '';
84 var $lastTypeLabel = '';
85 var $lastActionLabel = '';
86
87 var $detailsOn = 1; // If detailsOn, %s is substituted with values from the data-array (see getDetails())
88 var $stripPath = 1; // This strips the path from any value in the data-array when the data-array is parsed through stripPath()
89 var $errorSign = Array(
90 1 => '!',
91 2 => 'Sys!',
92 3 => 'Secur!'
93 );
94
95 var $be_user_Array = array(); // Username array (set externally)
96
97 /**
98 * Initialize the log table array with header labels.
99 *
100 * @return array
101 */
102 function initArray() {
103 $codeArr=Array();
104 $codeArr[0][]='Time'; // Time
105 $codeArr[0][]='User';
106 $codeArr[0][]='Type';
107 $codeArr[0][]='E';
108 $codeArr[0][]='Action';
109 $codeArr[0][]='Details';
110 return $codeArr;
111 }
112
113 /**
114 * Get time label for log listing
115 *
116 * @param integer Timestamp to display
117 * @return string If the timestamp was also shown last time, then "." is returned. Otherwise the new timestamp formatted with ->doc->formatTime()
118 */
119 function getTimeLabel($code) {
120 $t=$GLOBALS['SOBE']->doc->formatTime($code,1);
121 if ($this->lastTimeLabel!=$t) {
122 $this->lastTimeLabel=$t;
123 return $t;
124 } else return '.';
125
126 }
127
128 /**
129 * Get user name label for log listing
130 *
131 * @param integer be_user uid
132 * @return string If username is different from last username then the username, otherwise "."
133 */
134 function getUserLabel($code) {
135 if ($this->lastUserLabel!=$code) {
136 $this->lastUserLabel=$code;
137 $label = $this->be_user_Array[$code]['username'];
138 return $label ? $label : '['.$code.']';
139 } else return '.';
140 }
141
142 /**
143 * Get type label for log listing
144 *
145 * @param string Key for the type label in locallang
146 * @return string If labe is different from last type label then the label is returned, otherwise "."
147 */
148 function getTypeLabel($code) {
149 if ($this->lastTypeLabel!=$code) {
150 $this->lastTypeLabel=$code;
151 $label=$GLOBALS['LANG']->getLL('type_'.$code);
152 return $label ? $label : '['.$code.']';
153 } else return '.';
154 }
155
156 /**
157 * Get action label for log listing
158 *
159 * @param string Key for the action label in locallang
160 * @return string If labe is different from last action label then the label is returned, otherwise "."
161 */
162 function getActionLabel($code) {
163 if ($this->lastActionLabel!=$code) {
164 $this->lastActionLabel=$code;
165 $label=$GLOBALS['LANG']->getLL('action_'.$code);
166 return $label ? $label : '['.$code.']';
167 } else return '.';
168 }
169
170 /**
171 * Get details for the log entry
172 *
173 * @param string Suffix to "msg_" to get label from locallang.
174 * @param string Details text
175 * @param array Data array
176 * @param integer sys_log uid number
177 * @return string Text string
178 * @see formatDetailsForList()
179 */
180 function getDetails($code,$text,$data,$sys_log_uid=0) {
181 // $code is used later on to substitute errormessages with language-corrected values...
182 if (is_array($data)) {
183 if ($this->detailsOn) {
184 if (is_object($GLOBALS['LANG'])) {
185 $label = $GLOBALS['LANG']->getLL('msg_'.$code);
186 } else {
187 list($label) = explode(',',$text);
188 }
189 if ($label) {$text=$label;}
190 $text = sprintf($text, htmlspecialchars($data[0]),htmlspecialchars($data[1]),htmlspecialchars($data[2]),htmlspecialchars($data[3]),htmlspecialchars($data[4]));
191 } else {
192 $text = str_replace('%s','',$text);
193 }
194 }
195
196 // Finding the history for the record
197 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,fieldlist', 'sys_history', 'sys_log_uid='.intval($sys_log_uid));
198 $newRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
199 if (is_array($newRow)) {
200 $text.=' Changes in fields: <em>'.$newRow['fieldlist'].'</em>.';
201 $text.=' <a href="'.htmlspecialchars($GLOBALS['BACK_PATH'].'show_rechis.php?sh_uid='.$newRow['uid'].'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'"><b>->His</b></a>';
202 }
203
204 return $text;
205 }
206
207 /**
208 * Reset all internal "last..." variables to blank string.
209 *
210 * @return void
211 */
212 function reset() {
213 $this->lastTimeLabel='';
214 $this->lastUserLabel='';
215 $this->lastTypeLabel='';
216 $this->lastActionLabel='';
217 }
218
219 /**
220 * Formats input string in red-colored font tags
221 *
222 * @param string Input value
223 * @return string Input wrapped in red font-tag and bold
224 * @obsolete
225 */
226 function getErrorFormatting($sign) {
227 return '<font color="red"><b>'.$sign.'</b></font>';
228 }
229
230 /**
231 * Formatting details text for the sys_log row inputted
232 *
233 * @param array sys_log row
234 * @return string Details string
235 */
236 function formatDetailsForList($row) {
237 $data = unserialize($row['log_data']);
238 if ($row['type']==2) {
239 $data=$this->stripPath($data);
240 }
241
242 return $this->getDetails($row['type'].'_'.$row['action'].'_'.$row['details_nr'],$row['details'],$data,$row['uid']).' ('.$row['details_nr'].')';
243 }
244
245 /**
246 * For all entries in the $inArray (expected to be filepaths) the basename is extracted and set as value (if $this->stripPath is set)
247 * This is done for log-entries from the FILE modules
248 *
249 * @param array Array of file paths
250 * @return array
251 * @see formatDetailsForList()
252 */
253 function stripPath($inArr) {
254 if ($this->stripPath && is_array($inArr)) {
255 while(list($key,$val)=each($inArr)) {
256 $inArr[$key]=basename($val);
257 }
258 }
259 return $inArr;
260 }
261 }
262
263
264 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_bedisplaylog.php']) {
265 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_bedisplaylog.php']);
266 }
267 ?>