00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00081 class t3lib_BEDisplayLog {
00082 var $lastTimeLabel = '';
00083 var $lastUserLabel = '';
00084 var $lastTypeLabel = '';
00085 var $lastActionLabel = '';
00086
00087 var $detailsOn = 1;
00088 var $stripPath = 1;
00089 var $errorSign = Array(
00090 1 => '!',
00091 2 => 'Sys!',
00092 3 => 'Secur!'
00093 );
00094 var $wsArray = array(
00095 0 => 'LIVE',
00096 -1 => 'Draft',
00097 );
00098
00099 var $be_user_Array = array();
00100
00106 function initArray() {
00107 $codeArr=Array();
00108 $codeArr[0][]='Time';
00109 $codeArr[0][]='User';
00110 $codeArr[0][]='Type';
00111 $codeArr[0][]='E';
00112 $codeArr[0][]='Action';
00113 $codeArr[0][]='Details';
00114 return $codeArr;
00115 }
00116
00123 function getTimeLabel($code) {
00124 $t=$GLOBALS['SOBE']->doc->formatTime($code,1);
00125 if ($this->lastTimeLabel!=$t) {
00126 $this->lastTimeLabel=$t;
00127 return $t;
00128 } else return '.';
00129
00130 }
00131
00139 function getUserLabel($code,$workspace=0) {
00140 if ($this->lastUserLabel!=$code.'_'.$workspace) {
00141 $this->lastUserLabel=$code.'_'.$workspace;
00142 $label = $this->be_user_Array[$code]['username'];
00143 $ws = $this->wsArray[$workspace];
00144 return ($label ? $label : '['.$code.']').'@'.($ws?$ws:$workspace);
00145 } else return '.';
00146 }
00147
00154 function getTypeLabel($code) {
00155 if ($this->lastTypeLabel!=$code) {
00156 $this->lastTypeLabel=$code;
00157 $label=$GLOBALS['LANG']->getLL('type_'.$code);
00158 return $label ? $label : '['.$code.']';
00159 } else return '.';
00160 }
00161
00168 function getActionLabel($code) {
00169 if ($this->lastActionLabel!=$code) {
00170 $this->lastActionLabel=$code;
00171 $label=$GLOBALS['LANG']->getLL('action_'.$code);
00172 return $label ? $label : '['.$code.']';
00173 } else return '.';
00174 }
00175
00186 function getDetails($code,$text,$data,$sys_log_uid=0) {
00187
00188 if (is_array($data)) {
00189 if ($this->detailsOn) {
00190 if (is_object($GLOBALS['LANG'])) {
00191 $label = $GLOBALS['LANG']->getLL('msg_'.$code);
00192 } else {
00193 list($label) = explode(',',$text);
00194 }
00195 if ($label) {$text=$label;}
00196 $text = sprintf($text, htmlspecialchars($data[0]),htmlspecialchars($data[1]),htmlspecialchars($data[2]),htmlspecialchars($data[3]),htmlspecialchars($data[4]));
00197 } else {
00198 $text = str_replace('%s','',$text);
00199 }
00200 }
00201
00202
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.=' Changes in fields: <em>'.$newRow['fieldlist'].'</em>.';
00207 $text.=' <a href="'.htmlspecialchars($GLOBALS['BACK_PATH'].'show_rechis.php?sh_uid='.$newRow['uid'].'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
00208 '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/history2.gif','width="13" height="12"').' title="Show History" alt="" />'.
00209 '</a>';
00210 }
00211
00212 return $text;
00213 }
00214
00220 function reset() {
00221 $this->lastTimeLabel='';
00222 $this->lastUserLabel='';
00223 $this->lastTypeLabel='';
00224 $this->lastActionLabel='';
00225 }
00226
00234 function getErrorFormatting($sign, $error=0) {
00235 return $GLOBALS['SOBE']->doc->icons($error>=2 ? 3:2).$sign;
00236 }
00237
00244 function formatDetailsForList($row) {
00245 $data = unserialize($row['log_data']);
00246 if ($row['type']==2) {
00247 $data=$this->stripPath($data);
00248 }
00249
00250 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'].')':'');
00251 }
00252
00261 function stripPath($inArr) {
00262 if ($this->stripPath && is_array($inArr)) {
00263 while(list($key,$val)=each($inArr)) {
00264 $inArr[$key]=basename($val);
00265 }
00266 }
00267 return $inArr;
00268 }
00269 }
00270
00271
00272 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_bedisplaylog.php']) {
00273 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_bedisplaylog.php']);
00274 }
00275 ?>