class.t3lib_bedisplaylog.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2008 Kasper Skaarhoj (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 3503 2008-04-01 19:50:18Z stucki $
00031  * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
00032  * XHTML compliant
00033  *
00034  * @author  Kasper Skaarhoj <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 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072 /**
00073  * This class holds some functions used to display the sys_log table-content.
00074  * Used in the status-scripts and the log-module.
00075  *
00076  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00077  * @package TYPO3
00078  * @subpackage t3lib
00079  * @see tx_belog_webinfo, SC_mod_tools_log_index
00080  */
00081 class t3lib_BEDisplayLog {
00082     var $lastTimeLabel = '';
00083     var $lastUserLabel = '';
00084     var $lastTypeLabel = '';
00085     var $lastActionLabel = '';
00086 
00087     var $detailsOn = 1;         // If detailsOn, %s is substituted with values from the data-array (see getDetails())
00088     var $stripPath = 1;         // This strips the path from any value in the data-array when the data-array is parsed through stripPath()
00089     var $errorSign = Array(
00090         1 => '!',
00091         2 => 'Sys!',
00092         3 => 'Security!'
00093     );
00094     var $wsArray = array(
00095         0 => 'LIVE',
00096         -1 => 'Draft',
00097     );
00098 
00099     var $be_user_Array = array();       // Username array (set externally)
00100 
00101     /**
00102      * Initialize the log table array with header labels.
00103      *
00104      * @return  array
00105      */
00106     function initArray()    {
00107         $codeArr=Array();
00108         $codeArr[0][]='Time';   // Time
00109         $codeArr[0][]='User';
00110         $codeArr[0][]='Type';
00111         $codeArr[0][]='Error';
00112         $codeArr[0][]='Action';
00113         $codeArr[0][]='Details';
00114         return $codeArr;
00115     }
00116 
00117     /**
00118      * Get time label for log listing
00119      *
00120      * @param   integer     Timestamp to display
00121      * @return  string      If the timestamp was also shown last time, then "." is returned. Otherwise the new timestamp formatted with ->doc->formatTime()
00122      */
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 
00132     /**
00133      * Get user name label for log listing
00134      *
00135      * @param   integer     be_user uid
00136      * @param   integer     Workspace ID
00137      * @return  string      If username is different from last username then the username, otherwise "."
00138      */
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 
00148     /**
00149      * Get type label for log listing
00150      *
00151      * @param   string      Key for the type label in locallang
00152      * @return  string      If labe is different from last type label then the label is returned, otherwise "."
00153      */
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 
00162     /**
00163      * Get action label for log listing
00164      *
00165      * @param   string      Key for the action label in locallang
00166      * @return  string      If labe is different from last action label then the label is returned, otherwise "."
00167      */
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 
00176     /**
00177      * Get details for the log entry
00178      *
00179      * @param   string      Suffix to "msg_" to get label from locallang.
00180      * @param   string      Details text
00181      * @param   array       Data array
00182      * @param   integer     sys_log uid number
00183      * @return  string      Text string
00184      * @see formatDetailsForList()
00185      */
00186     function getDetails($code,$text,$data,$sys_log_uid=0)   {
00187             // $code is used later on to substitute errormessages with language-corrected values...
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             // 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.=' 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 
00215     /**
00216      * Reset all internal "last..." variables to blank string.
00217      *
00218      * @return  void
00219      */
00220     function reset()    {
00221         $this->lastTimeLabel='';
00222         $this->lastUserLabel='';
00223         $this->lastTypeLabel='';
00224         $this->lastActionLabel='';
00225     }
00226 
00227     /**
00228      * Formats input string in red-colored font tags
00229      *
00230      * @param   string      Input value
00231      * @param   integer     Error value
00232      * @return  string      Input wrapped in red font-tag and bold
00233      */
00234     function getErrorFormatting($sign, $error=0)    {
00235         return $GLOBALS['SOBE']->doc->icons($error>=2 ? 3:2).' '.$sign;
00236     }
00237 
00238     /**
00239      * Formatting details text for the sys_log row inputted
00240      *
00241      * @param   array       sys_log row
00242      * @return  string      Details string
00243      */
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 
00253     /**
00254      * For all entries in the $inArray (expected to be filepaths) the basename is extracted and set as value (if $this->stripPath is set)
00255      * This is done for log-entries from the FILE modules
00256      *
00257      * @param   array       Array of file paths
00258      * @return  array
00259      * @see formatDetailsForList()
00260      */
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 ?>

Generated on Sat Jan 3 04:23:26 2009 for TYPO3 API by  doxygen 1.4.7