[TASK] Convert XLIFF files to Tab indentation
[Packages/TYPO3.CMS.git] / typo3 / sysext / belog / class.tx_belog_webinfo.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (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 * Extension classes for log display in Web > Info and Tools > Log modules
29 *
30 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
31 */
32
33
34
35 /**
36 * Extending for Tools > Log. Just setting labels correctly
37 *
38 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
39 * @package TYPO3
40 * @subpackage tx_belog
41 */
42 class logFunctions_ext extends t3lib_BEDisplayLog {
43
44 /**
45 * Initialize the log table array with header labels.
46 *
47 * @return array
48 */
49 function initArray() {
50 $codeArr = array();
51 $codeArr[0][] = $GLOBALS['LANG']->getLL('chLog_l_time');
52 $codeArr[0][] = $GLOBALS['LANG']->getLL('chLog_l_user');
53 $codeArr[0][] = $GLOBALS['LANG']->getLL('chLog_l_error');
54 $codeArr[0][] = $GLOBALS['LANG']->getLL('chLog_l_action');
55 $codeArr[0][] = $GLOBALS['LANG']->getLL('chLog_l_table');
56 $codeArr[0][] = $GLOBALS['LANG']->getLL('chLog_l_details');
57 return $codeArr;
58 }
59 }
60
61
62
63
64 /**
65 * Extending for Web>Info
66 *
67 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
68 * @package TYPO3
69 * @subpackage tx_belog
70 */
71 class tx_belog_webinfo extends t3lib_extobjbase {
72 var $localLangFile = 'locallang.php';
73
74 /**
75 * Setting up function menu
76 *
77 * @return array Menu items
78 */
79 function modMenu() {
80
81 return array(
82 'log_users' => array(
83 0 => $GLOBALS['LANG']->getLL('chLog_users_0'),
84 '-1' => $GLOBALS['LANG']->getLL('chLog_users_-1')
85 ),
86 'log_time' => array(
87 0 => $GLOBALS['LANG']->getLL('chLog_time_0'),
88 1 => $GLOBALS['LANG']->getLL('chLog_time_1'),
89 2 => $GLOBALS['LANG']->getLL('chLog_time_2'),
90 10 => $GLOBALS['LANG']->getLL('chLog_time_10'),
91 11 => $GLOBALS['LANG']->getLL('chLog_time_11'),
92 12 => $GLOBALS['LANG']->getLL('chLog_time_12'),
93 20 => $GLOBALS['LANG']->getLL('chLog_time_20')
94 ),
95 'depth' => array(
96 0 => $GLOBALS['LANG']->getLL('depth_0'),
97 1 => $GLOBALS['LANG']->getLL('depth_1'),
98 2 => $GLOBALS['LANG']->getLL('depth_2'),
99 3 => $GLOBALS['LANG']->getLL('depth_3')
100 )
101 );
102 }
103
104 /**
105 * Include locallang file
106 *
107 * @return void
108 */
109 function localLang() {
110 $LOCAL_LANG = $GLOBALS['LANG']->includeLLFile('EXT:belog/mod/locallang.xml',FALSE);
111
112 $GLOBALS['LOCAL_LANG']=t3lib_div::array_merge_recursive_overrule($GLOBALS['LOCAL_LANG'],$LOCAL_LANG);
113 }
114
115 /**
116 * Show the log entries for page
117 *
118 * @return string HTML output
119 */
120 function main() {
121
122 $this->localLang();
123
124 $displayLogInstance = t3lib_div::makeInstance('logFunctions_ext');
125
126 $theOutput='';
127 $menu='';
128 $menu .= '&nbsp;' . $GLOBALS['LANG']->getLL('chLog_menuUsers') . ': ' .
129 t3lib_BEfunc::getFuncMenu(
130 $this->pObj->id,
131 'SET[log_users]',
132 $this->pObj->MOD_SETTINGS['log_users'],
133 $this->pObj->MOD_MENU['log_users']
134 );
135 $menu .= '&nbsp;' . $GLOBALS['LANG']->getLL('chLog_menuDepth') . ': ' .
136 t3lib_BEfunc::getFuncMenu(
137 $this->pObj->id,
138 'SET[depth]',
139 $this->pObj->MOD_SETTINGS['depth'],
140 $this->pObj->MOD_MENU['depth']
141 );
142 $menu .= '&nbsp;' . $GLOBALS['LANG']->getLL('chLog_menuTime') . ': ' .
143 t3lib_BEfunc::getFuncMenu(
144 $this->pObj->id,
145 'SET[log_time]',
146 $this->pObj->MOD_SETTINGS['log_time'],
147 $this->pObj->MOD_MENU['log_time']
148 );
149 $theOutput .= $this->pObj->doc->section(
150 $GLOBALS['LANG']->getLL('chLog_title'),
151 '<span class="nobr">' . $menu . '</span>',
152 0,
153 1
154 );
155
156 // Build query
157 $where_part='';
158
159 // Get the id-list of pages for the tree structure.
160 $tree = t3lib_div::makeInstance('t3lib_pageTree');
161 $tree->init('AND '.$this->pObj->perms_clause);
162 $tree->makeHTML=0;
163 $tree->fieldArray = array('uid');
164 if ($this->pObj->MOD_SETTINGS['depth']) {
165 $tree->getTree($this->pObj->id, $this->pObj->MOD_SETTINGS['depth'], '');
166 }
167 $tree->ids[]=$this->pObj->id;
168 $idList = implode($tree->ids,',');
169
170 $where_part.=' AND (event_pid in ('.$idList.'))'; // DB
171
172 // Time:
173 $starttime=0;
174 $endtime = $GLOBALS['EXEC_TIME'];
175 switch($this->pObj->MOD_SETTINGS['log_time']) {
176 case 0:
177 // This week
178 $week = (date('w') ? date('w') : 7)-1;
179 $starttime = mktime (0,0,0)-$week*3600*24;
180 break;
181 case 1:
182 // Last week
183 $week = (date('w') ? date('w') : 7)-1;
184 $starttime = mktime (0,0,0)-($week+7)*3600*24;
185 $endtime = mktime (0,0,0)-$week*3600*24;
186 break;
187 case 2:
188 // Last 7 days
189 $starttime = mktime (0,0,0)-7*3600*24;
190 break;
191 case 10:
192 // This month
193 $starttime = mktime (0,0,0, date('m'),1);
194 break;
195 case 11:
196 // Last month
197 $starttime = mktime (0,0,0, date('m')-1,1);
198 $endtime = mktime (0,0,0, date('m'),1);
199 break;
200 case 12:
201 // Last 31 days
202 $starttime = mktime (0,0,0)-31*3600*24;
203 break;
204 }
205 if ($starttime) {
206 $where_part.=' AND tstamp>='.$starttime.' AND tstamp<'.$endtime;
207 }
208
209 $where_part.=' AND type=1'; // DB
210
211
212 // Users
213 $this->pObj->be_user_Array = t3lib_BEfunc::getUserNames();
214 if (!$this->pObj->MOD_SETTINGS['log_users']) { // All users
215 // Get usernames and groupnames
216 if (!$GLOBALS['BE_USER']->isAdmin()) {
217 $groupArray = explode(',',$GLOBALS['BE_USER']->user['usergroup_cached_list']);
218 $this->pObj->be_user_Array = t3lib_BEfunc::blindUserNames($this->pObj->be_user_Array,$groupArray,1);
219 }
220
221 if (is_array($this->pObj->be_user_Array)) {
222 foreach ($this->pObj->be_user_Array as $val) {
223 $selectUsers[]=$val['uid'];
224 }
225 }
226 $selectUsers[] = $GLOBALS['BE_USER']->user['uid'];
227 $where_part.=' AND userid in ('.implode($selectUsers,',').')';
228 } else {
229 $where_part.=' AND userid='.$GLOBALS['BE_USER']->user['uid']; // Self user
230 }
231 $displayLogInstance->be_user_Array = &$this->pObj->be_user_Array;
232
233 if ($GLOBALS['BE_USER']->workspace!==0) {
234 $where_part.=' AND workspace='.intval($GLOBALS['BE_USER']->workspace);
235 }
236
237
238 // Select 100 recent log entries:
239 $log = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', '1=1'.$where_part, '', 'uid DESC', 100);
240
241 $codeArr = $displayLogInstance->initArray();
242 $oldHeader = '';
243 $i = 0;
244 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($log)) {
245 $header = $this->pObj->doc->formatTime($row['tstamp'],10);
246 if (!$oldHeader) $oldHeader = $header;
247
248 if ($header!=$oldHeader) {
249 $theOutput.=$this->pObj->doc->spacer(10);
250 $theOutput.=$this->pObj->doc->section($oldHeader,$this->pObj->doc->table($codeArr));
251 $codeArr = $displayLogInstance->initArray();
252 $oldHeader=$header;
253 $displayLogInstance->reset();
254 }
255
256 $i++;
257 $codeArr[$i][] = $displayLogInstance->getTimeLabel($row['tstamp']);
258 $codeArr[$i][] = $displayLogInstance->getUserLabel($row['userid'], $row['workspace']);
259 $codeArr[$i][] = $row['error'] ? $displayLogInstance->getErrorIcon($row['error']) : '';
260 $codeArr[$i][] = $displayLogInstance->getActionLabel($row['type'] . '_' . $row['action']);
261 $codeArr[$i][] = $row['tablename'];
262 $codeArr[$i][] = $displayLogInstance->formatDetailsForList($row);
263 }
264 $theOutput.=$this->pObj->doc->spacer(10);
265 $theOutput.=$this->pObj->doc->section($header,$this->pObj->doc->table($codeArr));
266
267 $GLOBALS['TYPO3_DB']->sql_free_result($log);
268
269 return $theOutput;
270 }
271 }
272
273 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/belog/class.tx_belog_webinfo.php'])) {
274 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/belog/class.tx_belog_webinfo.php']);
275 }
276
277 ?>