[ Index ]
 

Code source de Typo3 4.1.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/t3lib/ -> class.t3lib_bedisplaylog.php (source)

   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: class.t3lib_bedisplaylog.php 1421 2006-04-10 09:27:15Z mundaun $
  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   *  106:     function initArray()
  43   *  123:     function getTimeLabel($code)
  44   *  139:     function getUserLabel($code,$workspace=0)
  45   *  154:     function getTypeLabel($code)
  46   *  168:     function getActionLabel($code)
  47   *  186:     function getDetails($code,$text,$data,$sys_log_uid=0)
  48   *  220:     function reset()
  49   *  234:     function getErrorFormatting($sign, $error=0)
  50   *  244:     function formatDetailsForList($row)
  51   *  261:     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      var $wsArray = array(
  95          0 => 'LIVE',
  96          -1 => 'Draft',
  97      );
  98  
  99      var $be_user_Array = array();        // Username array (set externally)
 100  
 101      /**
 102       * Initialize the log table array with header labels.
 103       *
 104       * @return    array
 105       */
 106  	function initArray()    {
 107          $codeArr=Array();
 108          $codeArr[0][]='Time';    // Time
 109          $codeArr[0][]='User';
 110          $codeArr[0][]='Type';
 111          $codeArr[0][]='E';
 112          $codeArr[0][]='Action';
 113          $codeArr[0][]='Details';
 114          return $codeArr;
 115      }
 116  
 117      /**
 118       * Get time label for log listing
 119       *
 120       * @param    integer        Timestamp to display
 121       * @return    string        If the timestamp was also shown last time, then "." is returned. Otherwise the new timestamp formatted with ->doc->formatTime()
 122       */
 123  	function getTimeLabel($code)    {
 124          $t=$GLOBALS['SOBE']->doc->formatTime($code,1);
 125          if ($this->lastTimeLabel!=$t)    {
 126              $this->lastTimeLabel=$t;
 127              return $t;
 128          } else return '.';
 129  
 130      }
 131  
 132      /**
 133       * Get user name label for log listing
 134       *
 135       * @param    integer        be_user uid
 136       * @param    integer        Workspace ID
 137       * @return    string        If username is different from last username then the username, otherwise "."
 138       */
 139  	function getUserLabel($code,$workspace=0)    {
 140          if ($this->lastUserLabel!=$code.'_'.$workspace)    {
 141              $this->lastUserLabel=$code.'_'.$workspace;
 142              $label = $this->be_user_Array[$code]['username'];
 143              $ws = $this->wsArray[$workspace];
 144              return ($label ? $label : '['.$code.']').'@'.($ws?$ws:$workspace);
 145          } else return '.';
 146      }
 147  
 148      /**
 149       * Get type label for log listing
 150       *
 151       * @param    string        Key for the type label in locallang
 152       * @return    string        If labe is different from last type label then the label is returned, otherwise "."
 153       */
 154  	function getTypeLabel($code)    {
 155          if ($this->lastTypeLabel!=$code)    {
 156              $this->lastTypeLabel=$code;
 157              $label=$GLOBALS['LANG']->getLL('type_'.$code);
 158              return $label ? $label : '['.$code.']';
 159          } else return '.';
 160      }
 161  
 162      /**
 163       * Get action label for log listing
 164       *
 165       * @param    string        Key for the action label in locallang
 166       * @return    string        If labe is different from last action label then the label is returned, otherwise "."
 167       */
 168  	function getActionLabel($code)    {
 169          if ($this->lastActionLabel!=$code)    {
 170              $this->lastActionLabel=$code;
 171              $label=$GLOBALS['LANG']->getLL('action_'.$code);
 172              return $label ? $label : '['.$code.']';
 173          } else return '.';
 174      }
 175  
 176      /**
 177       * Get details for the log entry
 178       *
 179       * @param    string        Suffix to "msg_" to get label from locallang.
 180       * @param    string        Details text
 181       * @param    array        Data array
 182       * @param    integer        sys_log uid number
 183       * @return    string        Text string
 184       * @see formatDetailsForList()
 185       */
 186  	function getDetails($code,$text,$data,$sys_log_uid=0)    {
 187              // $code is used later on to substitute errormessages with language-corrected values...
 188          if (is_array($data))    {
 189              if ($this->detailsOn)    {
 190                  if (is_object($GLOBALS['LANG']))    {
 191                      $label = $GLOBALS['LANG']->getLL('msg_'.$code);
 192                  } else {
 193                      list($label) = explode(',',$text);
 194                  }
 195                  if ($label)    {$text=$label;}
 196                  $text = sprintf($text, htmlspecialchars($data[0]),htmlspecialchars($data[1]),htmlspecialchars($data[2]),htmlspecialchars($data[3]),htmlspecialchars($data[4]));
 197              } else {
 198                  $text = str_replace('%s','',$text);
 199              }
 200          }
 201  
 202              // Finding the history for the record
 203          $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,fieldlist', 'sys_history', 'sys_log_uid='.intval($sys_log_uid));
 204          $newRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
 205          if (is_array($newRow))    {
 206              $text.=' Changes in fields: <em>'.$newRow['fieldlist'].'</em>.';
 207              $text.=' <a href="'.htmlspecialchars($GLOBALS['BACK_PATH'].'show_rechis.php?sh_uid='.$newRow['uid'].'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
 208                      '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/history2.gif','width="13" height="12"').' title="Show History" alt="" />'.
 209                      '</a>';
 210          }
 211  
 212          return $text;
 213      }
 214  
 215      /**
 216       * Reset all internal "last..." variables to blank string.
 217       *
 218       * @return    void
 219       */
 220  	function reset()    {
 221          $this->lastTimeLabel='';
 222          $this->lastUserLabel='';
 223          $this->lastTypeLabel='';
 224          $this->lastActionLabel='';
 225      }
 226  
 227      /**
 228       * Formats input string in red-colored font tags
 229       *
 230       * @param    string        Input value
 231       * @param    integer        Error value
 232       * @return    string        Input wrapped in red font-tag and bold
 233       */
 234  	function getErrorFormatting($sign, $error=0)    {
 235          return $GLOBALS['SOBE']->doc->icons($error>=2 ? 3:2).$sign;
 236      }
 237  
 238      /**
 239       * Formatting details text for the sys_log row inputted
 240       *
 241       * @param    array        sys_log row
 242       * @return    string        Details string
 243       */
 244  	function formatDetailsForList($row)    {
 245          $data = unserialize($row['log_data']);
 246          if ($row['type']==2)    {
 247              $data=$this->stripPath($data);
 248          }
 249  
 250          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'].')':'');
 251      }
 252  
 253      /**
 254       * For all entries in the $inArray (expected to be filepaths) the basename is extracted and set as value (if $this->stripPath is set)
 255       * This is done for log-entries from the FILE modules
 256       *
 257       * @param    array        Array of file paths
 258       * @return    array
 259       * @see formatDetailsForList()
 260       */
 261  	function stripPath($inArr)    {
 262          if ($this->stripPath && is_array($inArr))    {
 263              while(list($key,$val)=each($inArr))    {
 264                  $inArr[$key]=basename($val);
 265              }
 266          }
 267          return $inArr;
 268      }
 269  }
 270  
 271  
 272  if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_bedisplaylog.php'])    {
 273      include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_bedisplaylog.php']);
 274  }
 275  ?>


Généré le : Sun Nov 25 17:13:16 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics