Project

General

Profile

Bug #22410 » 14050_cleaning_t3lib_bedisplaylog.patch

Administrator Admin, 2010-11-24 00:05

View differences:

t3lib/class.t3lib_bedisplaylog.php (revision )
<?php
/***************************************************************
* Copyright notice
*
* (c) 1999-2010 Kasper Sk?rh?j (kasperYYYY@typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* Copyright notice
*
* (c) 1999-2010 Kasper Sk?rh?j (kasperYYYY@typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Contains class for display of backend log
*
......
*
*
* 81: class t3lib_BEDisplayLog
* 106: function initArray()
* 106: function initArray()
* 123: function getTimeLabel($code)
* 123: function getTimeLabel($code)
* 139: function getUserLabel($code,$workspace=0)
* 139: function getUserLabel($code,$workspace=0)
* 154: function getTypeLabel($code)
* 154: function getTypeLabel($code)
* 168: function getActionLabel($code)
* 168: function getActionLabel($code)
* 186: function getDetails($code,$text,$data,$sys_log_uid=0)
* 186: function getDetails($code,$text,$data,$sys_log_uid=0)
* 220: function reset()
* 220: function reset()
* 234: function getErrorFormatting($sign, $error=0)
* 234: function getErrorFormatting($sign, $error=0)
* 244: function formatDetailsForList($row)
* 244: function formatDetailsForList($row)
* 261: function stripPath($inArr)
* 261: function stripPath($inArr)
*
* TOTAL FUNCTIONS: 10
* (This index is automatically created/updated by the extension "extdeveval")
......
*/
/**
* This class holds some functions used to display the sys_log table-content.
* Used in the status-scripts and the log-module.
......
var $lastTypeLabel = '';
var $lastActionLabel = '';
var $detailsOn = 1; // If detailsOn, %s is substituted with values from the data-array (see getDetails())
var $detailsOn = 1; // If detailsOn, %s is substituted with values from the data-array (see getDetails())
var $stripPath = 1; // This strips the path from any value in the data-array when the data-array is parsed through stripPath()
var $stripPath = 1; // This strips the path from any value in the data-array when the data-array is parsed through stripPath()
var $errorSign = Array(
1 => '!',
2 => 'Sys!',
......
-1 => 'Draft',
);
var $be_user_Array = array(); // Username array (set externally)
var $be_user_Array = array(); // Username array (set externally)
/**
* Initialize the log table array with header labels.
*
* @return array
*/
function initArray() {
function initArray() {
$codeArr=Array();
$codeArr = array();
$codeArr[0][]='Time'; // Time
$codeArr[0][] = 'Time'; // Time
$codeArr[0][]='User';
$codeArr[0][] = 'User';
$codeArr[0][]='Type';
$codeArr[0][] = 'Type';
$codeArr[0][]='Error';
$codeArr[0][] = 'Error';
$codeArr[0][]='Action';
$codeArr[0][] = 'Action';
$codeArr[0][]='Details';
$codeArr[0][] = 'Details';
return $codeArr;
}
......
* @param integer Timestamp to display
* @return string If the timestamp was also shown last time, then "." is returned. Otherwise the new timestamp formatted with ->doc->formatTime()
*/
function getTimeLabel($code) {
function getTimeLabel($code) {
#$t=$GLOBALS['SOBE']->doc->formatTime($code,1);
$t = date('H:i:s',$code);
$t = date('H:i:s', $code);
if ($this->lastTimeLabel!=$t) {
if ($this->lastTimeLabel != $t) {
$this->lastTimeLabel=$t;
$this->lastTimeLabel = $t;
return $t;
} else {
return '.';
......
* @param integer Workspace ID
* @return string If username is different from last username then the username, otherwise "."
*/
function getUserLabel($code,$workspace=0) {
function getUserLabel($code, $workspace = 0) {
if ($this->lastUserLabel!=$code.'_'.$workspace) {
if ($this->lastUserLabel != $code . '_' . $workspace) {
$this->lastUserLabel=$code.'_'.$workspace;
$this->lastUserLabel = $code . '_' . $workspace;
$label = $this->be_user_Array[$code]['username'];
$ws = $this->wsArray[$workspace];
return ($label ? htmlspecialchars($label) : '['.$code.']').'@'.($ws?$ws:$workspace);
return ($label ? htmlspecialchars($label) : '[' . $code . ']') . '@' . ($ws ? $ws : $workspace);
} else return '.';
} else {
return '.';
}
}
}
/**
* Get type label for log listing
......
* @param string Key for the type label in locallang
* @return string If labe is different from last type label then the label is returned, otherwise "."
*/
function getTypeLabel($code) {
function getTypeLabel($code) {
if ($this->lastTypeLabel!=$code) {
if ($this->lastTypeLabel != $code) {
$this->lastTypeLabel=$code;
$this->lastTypeLabel = $code;
$label=$GLOBALS['LANG']->getLL('type_'.$code);
$label = $GLOBALS['LANG']->getLL('type_' . $code);
return $label ? $label : '['.$code.']';
return $label ? $label : '[' . $code . ']';
} else return '.';
} else {
return '.';
}
}
}
/**
* Get action label for log listing
......
* @param string Key for the action label in locallang
* @return string If label is different from last action label then the label is returned, otherwise "."
*/
function getActionLabel($code) {
function getActionLabel($code) {
if ($this->lastActionLabel!=$code) {
if ($this->lastActionLabel != $code) {
$this->lastActionLabel=$code;
$this->lastActionLabel = $code;
$label=$GLOBALS['LANG']->getLL('action_'.$code);
$label = $GLOBALS['LANG']->getLL('action_' . $code);
return $label ? htmlspecialchars($label) : '['.$code.']';
return $label ? htmlspecialchars($label) : '[' . $code . ']';
} else return '.';
} else {
return '.';
}
}
}
/**
* Get details for the log entry
......
* @return string Text string
* @see formatDetailsForList()
*/
function getDetails($code,$text,$data,$sys_log_uid=0) {
function getDetails($code, $text, $data, $sys_log_uid = 0) {
// $code is used later on to substitute errormessages with language-corrected values...
if (is_array($data)) {
if (is_array($data)) {
if ($this->detailsOn) {
if ($this->detailsOn) {
if (is_object($GLOBALS['LANG'])) {
if (is_object($GLOBALS['LANG'])) {
# $label = $GLOBALS['LANG']->getLL('msg_'.$code);
# $label = $GLOBALS['LANG']->getLL('msg_'.$code);
} else {
list($label) = explode(',',$text);
list($label) = explode(',', $text);
}
if ($label) {
if ($label) {
$text=$label;
$text = $label;
}
$text = sprintf($text, htmlspecialchars($data[0]),htmlspecialchars($data[1]),htmlspecialchars($data[2]),htmlspecialchars($data[3]),htmlspecialchars($data[4]));
$text = sprintf($text, htmlspecialchars($data[0]), htmlspecialchars($data[1]), htmlspecialchars($data[2]), htmlspecialchars($data[3]), htmlspecialchars($data[4]));
} else {
$text = str_replace('%s','',$text);
$text = str_replace('%s', '', $text);
}
}
$text = htmlspecialchars($text);
// Finding the history for the record
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,fieldlist', 'sys_history', 'sys_log_uid='.intval($sys_log_uid));
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,fieldlist', 'sys_history', 'sys_log_uid=' . intval($sys_log_uid));
$newRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
if (is_array($newRow)) {
if (is_array($newRow)) {
$text .= ' ' . sprintf($GLOBALS['LANG']->getLL('changesInFields'), '<em>' . $newRow['fieldlist'] . '</em>');
$text .= ' <a href="' . htmlspecialchars($GLOBALS['BACK_PATH'] . 'show_rechis.php?sh_uid=' . $newRow['uid'] .
'&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
......
*
* @return void
*/
function reset() {
function reset() {
$this->lastTimeLabel='';
$this->lastTimeLabel = '';
$this->lastUserLabel='';
$this->lastUserLabel = '';
$this->lastTypeLabel='';
$this->lastTypeLabel = '';
$this->lastActionLabel='';
$this->lastActionLabel = '';
}
/**
......
* @param integer Error value
* @return string Input wrapped in red font-tag and bold
*/
function getErrorFormatting($sign, $error=0) {
function getErrorFormatting($sign, $error = 0) {
return $GLOBALS['SOBE']->doc->icons($error>=2 ? 3:2).' '.$sign;
return $GLOBALS['SOBE']->doc->icons($error >= 2 ? 3 : 2) . ' ' . $sign;
}
/**
......
* @param array sys_log row
* @return string Details string
*/
function formatDetailsForList($row) {
function formatDetailsForList($row) {
$data = unserialize($row['log_data']);
if ($row['type']==2) {
if ($row['type'] == 2) {
$data=$this->stripPath($data);
$data = $this->stripPath($data);
}
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'].')':'');
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'] . ')' : '');
}
/**
......
* @return array
* @see formatDetailsForList()
*/
function stripPath($inArr) {
function stripPath($inArr) {
if ($this->stripPath && is_array($inArr)) {
if ($this->stripPath && is_array($inArr)) {
foreach ($inArr as $key => $val) {
$inArr[$key]=basename($val);
$inArr[$key] = basename($val);
}
}
return $inArr;
......
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_bedisplaylog.php']) {
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_bedisplaylog.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_bedisplaylog.php']);
}
?>
(8-8/93)