Initial revision
[Packages/TYPO3.CMS.git] / typo3 / class.show_rechis.inc
1 <?php
2 /***************************************************************
3 *  Copyright notice
4 *  
5 *  (c) 1999-2003 Kasper Skårhøj (kasper@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  * Class for the record history display script (show_rechis.php)
29  *
30  * @author      Kasper Skårhøj <kasper@typo3.com>
31  * @package TYPO3
32  * @subpackage core
33  *
34  */
35
36 class recordHistory {
37         var $listType = 0;
38         var $maxSteps=20;
39         
40         function getChangesSinceRecord($element,$hisUid=0,$hisUid_Stop=0)       {
41                 global $TCA;
42
43                 $sumChangesArray=array();
44                 $sumChangesArray["changes"]=array();
45                 $elParts = explode(":",$element);
46                 if ($TCA[$elParts[0]])  {
47                         $addWhere = " AND sys_history.uid>=".$hisUid;
48                         if ($hisUid_Stop)       $addWhere.= " AND sys_history.uid<=".$hisUid_Stop;
49                         $query="SELECT sys_history.*,sys_log.userid FROM sys_history,sys_log WHERE 
50                                 sys_history.sys_log_uid=sys_log.uid
51                                 AND sys_history.tablename='".$elParts[0]."' 
52                                 AND sys_history.recuid=".intval($elParts[1]).$addWhere." 
53                                 ORDER BY uid DESC";
54
55                         $res = mysql(TYPO3_db,$query);
56                         $times=array();
57                         while ($newRow = mysql_fetch_assoc($res))       {
58                                 $hisDat = unserialize($newRow["history_data"]);
59                                 if (is_array($hisDat["newRecord"]) && is_array($hisDat["oldRecord"]))   {
60 //                                      if ($newRow["uid"]!=$hisUid)    {       // Overlay the old-record values... 
61 //debug($hisDat["oldRecord"]);
62                                                 $sumChangesArray["changes"]=array_merge($sumChangesArray["changes"],$hisDat["oldRecord"]);
63         //                              } else {        // ... unless the record is the one we're waiting for..
64                 //                              $sumChangesArray["changes"]=array_merge($sumChangesArray["changes"],$hisDat["newRecord"]);
65                         //              }
66                                         $sumChangesArray["counter"]++;
67                                         $sumChangesArray["tstamp"][]=$newRow["tstamp"];
68                                         $sumChangesArray["userList"][]=$newRow["userid"];
69                                 } else {
70                                         debug("ERROR!");
71                                 }
72                                 
73                         }
74                 }       
75                 return $sumChangesArray;
76         }
77         function nextHisUid($element,$hisUid)   {
78                 $elParts = explode(":",$element);
79                 // Prev:
80                         $query="SELECT uid FROM sys_history WHERE 
81                                 tablename='".$elParts[0]."' 
82                                 AND recuid=".intval($elParts[1])." 
83                                 AND uid<".intval($hisUid)."
84                                 ORDER BY uid DESC LIMIT 1";
85                         $res = mysql(TYPO3_db,$query);
86                         if ($row = mysql_fetch_assoc($res))     {
87                                 $prevUid=$row["uid"];
88                         }
89                 // Next         
90                         $query="SELECT uid FROM sys_history WHERE 
91                                 tablename='".$elParts[0]."' 
92                                 AND recuid=".intval($elParts[1])." 
93                                 AND uid>".intval($hisUid)."
94                                 ORDER BY uid LIMIT 1";
95                         $res = mysql(TYPO3_db,$query);
96                         if ($row = mysql_fetch_assoc($res))     {
97                                 $nextUid=$row["uid"];
98                         }
99
100                 return array($prevUid,$nextUid);
101         }
102         function compareChangesWithCurrent($element,$changeRec,$discardFileLists=0)     {
103                 global $TCA;
104
105                 $sumChangesArray=array();
106                 $elParts = explode(":",$element);
107                 $newChangeRec=array();
108                 if ($TCA[$elParts[0]])  {
109                         $currentRecord = t3lib_BEfunc::getRecord($elParts[0],$elParts[1]);
110                                                         // list($currentRecord,$DB_fieldTypes) = $this->readFieldTypes($elParts[0],$elParts[1]);
111                                                 // || ($cRecTypes[$col]=="int" && $currentRecord[$col]==0 && !strcmp($val,"")
112                         if (is_array($currentRecord) && is_array($changeRec["changes"]))        {
113                                 reset($changeRec["changes"]);
114                                 while(list($fN,$fV)=each($changeRec["changes"]))        {
115                                         if (strcmp($fV,$currentRecord[$fN]))    {
116                                                 $newChangeRec["oldRecord"][$fN]=$fV;
117                                                 $newChangeRec["newRecord"][$fN]=$currentRecord[$fN];
118                                         }
119                                 }
120                                 $newChangeRec["tstamp"]=min($changeRec["tstamp"]);
121                                 $newChangeRec["counter"]=$changeRec["counter"];
122                                 $newChangeRec["userList"]=array_unique($changeRec["userList"]);
123                         } else {
124                                 return false;   // No arrays, possibly no record
125                         }
126                 }       
127                 
128                 return $newChangeRec;
129         }
130         function readFieldTypes($table,$id)     {
131                 $res = mysql(TYPO3_db,"SELECT * FROM $table WHERE uid=".intval($id));
132                         // Fetch the types of the fields.
133                 if (mysql_num_rows($res))       {
134                         $currentRecord = mysql_fetch_assoc($res);
135                         $c=0;
136                         reset($currentRecord);
137                         $cRecTypes=array();
138                         while (list($col,$val)=each($currentRecord))    {
139                                 $cRecTypes[$col]=mysql_field_type($res,$c);
140                                 $c++;
141                         }
142                 }
143                 return array($currentRecord,$cRecTypes);
144         }
145         function cmp($changeStatus,$oldRecord)  {
146                 reset($oldRecord);
147                 $changes=array();
148                 while(list($fN,$fV)=each($oldRecord))   {
149                         if (isset($changeStatus[$fN]) && strcmp($fV,$changeStatus[$fN]))        {
150                                 $changes["oldRecord"][$fN]=$changeStatus[$fN];
151                                 $changes["newRecord"][$fN]=$fV;
152                         }
153                 }
154                 return $changes;
155         }
156         function revertToPreviousValues($element,$field)        {
157                 $sumUp = t3lib_div::GPvar("sumUp");
158
159                 $elParts = explode(":",$element);
160                 $redirect=intval(t3lib_div::GPvar("doReturn"));
161                 if ($sumUp==-1) {       // Undo/Redo
162                         $query="SELECT uid FROM sys_history WHERE 
163                                 sys_history.tablename='".$elParts[0]."' 
164                                 AND sys_history.recuid=".intval($elParts[1])." 
165                                 ORDER BY uid DESC LIMIT 1";
166                         $res = mysql(TYPO3_db,$query);
167                         if ($row = mysql_fetch_assoc($res))     {
168                                 $sumUp=$row["uid"];
169                         }
170                         $redirect=1;
171                 }
172                 if ($sumUp!=-1) {
173                         $changeRec=$this->compareChangesWithCurrent($element,$this->getChangesSinceRecord($element,$sumUp));
174
175                         $data =array();
176                         if (t3lib_BEfunc::getRecord($elParts[0],$elParts[1]))   {
177                                 if ($field=="ALL_FIELDS")       {
178                                         $data=$changeRec["oldRecord"];
179                                 } elseif(substr($field,0,6)=="field:") {
180                                         $data[substr($field,6)]=$changeRec["oldRecord"][substr($field,6)];
181                                 }
182                                 $data = $this->removeFilefields($elParts[0],$data);
183                                 if (count($data))       {
184                                         $inData=array();
185                                         $inData[$elParts[0]][$elParts[1]]=$data;
186                                         $tce = t3lib_div::makeInstance("t3lib_TCEmain");
187                                         $tce->stripslashes_values=0;
188                                         $tce->debug=0;
189                                         $tce->dontProcessTransformations=1;
190                                         $tce->start($inData,array());
191                                         $tce->process_datamap();
192                                 }
193                         }
194                 }
195
196                 if ($redirect)  {
197                         Header ("Location: ".t3lib_div::locationHeaderUrl(t3lib_div::GPvar("returnUrl")));
198                         exit;
199                 }
200         }
201         function saveState($element,$sumUp)     {
202                 $elParts = explode(":",$element);
203
204                 $changeRec = $this->getChangesSinceRecord($element,$sumUp);
205
206                 $query="SELECT history_data FROM sys_history WHERE 
207                         sys_history.tablename='".$elParts[0]."' 
208                         AND sys_history.recuid=".intval($elParts[1])." 
209                         ORDER BY uid DESC LIMIT 1";
210                 $res = mysql(TYPO3_db,$query);
211                 if ($row = mysql_fetch_assoc($res))     {
212                         $lastestData = unserialize($row["history_data"]);
213 //                      debug($lastestData);
214                 }
215
216
217                 $historyRecords=array();
218                 $historyRecords["oldRecord"] = $changeRec["changes"];
219                 $historyRecords["newRecord"] = array();
220                 reset($historyRecords["oldRecord"]);
221                 while(list($kk)=each($historyRecords["oldRecord"]))     {
222                         $historyRecords["newRecord"][$kk]=$lastestData["newRecord"][$kk];
223                 }
224
225                 $updateID = $GLOBALS["BE_USER"]->writelog(3,1,0,1,"Saved state","");
226                 
227                 $fields_values=array();
228                 $fields_values["history_data"]=serialize($historyRecords);
229                 $fields_values["fieldlist"]=implode(",",array_keys($historyRecords["oldRecord"]));
230                 $fields_values["tstamp"]=time();
231                 $fields_values["tablename"]=$elParts[0];
232                 $fields_values["recuid"]=$elParts[1];
233                 $fields_values["sys_log_uid"]=$updateID;
234                 $fields_values["snapshot"]=1;
235                 $query = t3lib_BEfunc::DBcompileInsert("sys_history",$fields_values);
236                 $res = mysql(TYPO3_db,$query);
237         }
238         function removeFilefields($table,$dataArray)    {
239                 global $TCA;
240                 if ($TCA[$table])       {
241                         t3lib_div::loadTCA($table);
242                         reset($TCA[$table]["columns"]);
243                         while(list($field,$config)=each($TCA[$table]["columns"]))       {
244                                 if ($config["config"]["type"]=="group" && $config["config"]["internal_type"]=="file")   {
245                                         unset($dataArray[$field]);
246                                 }
247                         }
248                 }
249                 return $dataArray;
250         }
251         function displayHistory($element)       {
252                 global $SOBE, $LANG, $TCA;
253                 
254                 $elParts = explode(":",$element);
255                 $table = $elParts[0];
256                 if ($TCA[$table])       {
257                         $mainQBody = "FROM sys_history,sys_log WHERE 
258                                 sys_history.sys_log_uid=sys_log.uid
259                                 AND sys_history.tablename='".$table."' 
260                                 AND sys_history.recuid=".intval($elParts[1]);
261                         $query="SELECT count(*) ".$mainQBody; 
262                         $res = mysql(TYPO3_db,$query);
263                         list($Rcount)=mysql_fetch_row($res);
264
265                         $max = $this->maxSteps; // How many steps back...
266                         $query="SELECT sys_history.*,sys_log.userid ".$mainQBody." 
267                                 ORDER BY uid LIMIT ".t3lib_div::intInRange($Rcount-$max,0).",".$max;
268                         $res = mysql(TYPO3_db,$query);
269
270                         $changesArray=array();
271                         $changeLog=array();
272                         while ($newRow = mysql_fetch_assoc($res))       {
273                                 $hisDat = unserialize($newRow["history_data"]);
274                                 if (is_array($hisDat["newRecord"]) && is_array($hisDat["oldRecord"]))   {
275                                                 // If intermedia changes:
276                                         $intermediaChanges = $this->cmp($changesArray,$hisDat["oldRecord"]);
277                                         if (count($intermediaChanges) && !$newRow["snapshot"])  {
278                                                 $changeLog[]=$intermediaChanges;
279                                         }
280
281                                                 // Add hisDat to the changeLog
282                                         $hisDat["uid"]=$newRow["uid"];
283                                         $hisDat["tstamp"]=$newRow["tstamp"];
284                                         $hisDat["user"]=$newRow["userid"];
285                                         $hisDat["snapshot"]=$newRow["snapshot"];
286                                         $changeLog[]=$hisDat;
287
288                                                 // Update change array
289                                                 // this is used to detect if any intermedia changes has been made.
290                                         $changesArray = array_merge($changesArray,$hisDat["newRecord"]);
291                                 } else {
292                                         debug("ERROR: [displayHistory]");
293                                 }
294                         }
295                         
296                         $lines=array();
297                         $darkerBgColor = t3lib_div::modifyHTMLcolor($SOBE->doc->bgColor4,-30,-30,-30);
298                         $darkerBgColor_interM = "#cccccc";
299                         if (t3lib_div::GPvar("sumUp"))  {
300                                 
301                                 $changeLog=array();
302                                 $changeLog[]=$this->compareChangesWithCurrent($element,$this->getChangesSinceRecord($element,t3lib_div::GPvar("sumUp")));
303                                 $this->listType=2;
304                                 $lines[]=$this->listHeader();
305                                 $be_users = t3lib_BEfunc::getUserNames();
306                                 
307                                 list($prevHisUid,$nextHisUid) = $this->nextHisUid($element,t3lib_div::GPvar("sumUp"));
308                                 
309                                 $linkPack=      ($prevHisUid ? $this->linkPage('<img src="gfx/pilup.gif" width="14" height="14" hspace=1 border="0" title="'.$LANG->getLL("prev").'">', array("sumUp"=>$prevHisUid)) : "").
310                                 ($nextHisUid ? $this->linkPage('<img src="gfx/pildown.gif" width="14" height="14" hspace=1 border="0" title="'.$LANG->getLL("next").'">', array("sumUp"=>$nextHisUid)) : "").
311                                 '<BR>'.$this->linkPage('<img src="gfx/history2.gif" width="13" height="12" hspace=1 vspace=3 border="0" title="'.$LANG->getLL("historyList").'">', array("sumUp"=>""), "uid_".t3lib_div::GPvar("sumUp")).
312                                 
313                                 $this->linkPage('<img src="gfx/savesnapshot.gif" width="17" height="12" hspace=1 vspace=3 border="0" title="'.$LANG->getLL("saveState").'">', array("saveState"=>t3lib_div::GPvar("sumUp"),"sumUp"=>""), "latest");
314                                 
315                                 reset($changeLog);
316                                 while(list(,$entry)=each($changeLog))   {
317                                         if (!is_array($entry["userList"]))      $entry["userList"]=array();
318                                         reset($entry["userList"]);
319                                         while(list($uLk,$uV)=each($entry["userList"]))  {
320                                                 $entry["userList"][$uLk]=$be_users[$uV]["username"];
321                                         }
322                                         
323                                         $lines[]='<tr bgColor="'.$darkerBgColor.'">
324                                                 <td valign=top>'.$linkPack.'</td>
325                                                 <td colspan=4><B>'.$LANG->getLL("time").':</B> '.t3lib_BEfunc::datetime($entry["tstamp"]).', '.t3lib_BEfunc::calcAge(time()-$entry["tstamp"],$GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears")).' &nbsp; - &nbsp; <B>'.$LANG->getLL("changeCount").':</B> '.$entry["counter"].'<BR>
326                                                         <B>'.$LANG->getLL("users").':</B> '.implode(", ",$entry["userList"]).' 
327                                                 </td>
328                                         </tr>';
329                                         if (isset($entry["oldRecord"]) && isset($entry["newRecord"]))   {
330                                                 $lines = array_merge($lines,$this->renderEntry($entry,$table));
331                                         } else {
332                                                 $lines[]='<tr bgColor="'.$SOBE->doc->bgColor4.'"><td colspan=5 align=center><BR><B>'.$LANG->getLL("similar").'</B><BR><BR></td></tr>';
333                                         }
334                                 }
335                         } else {                        
336                                         // Change Log:
337                                 $this->listType=1;
338                                 $be_users = t3lib_BEfunc::getUserNames();
339                                 $lines[]=$this->listHeader();
340                                 reset($changeLog);
341                                 
342                                 while(list($c,$entry)=each($changeLog)) {
343                                         $lines[]='<tr><td colspan=3>&nbsp;</td></tr>';
344                                         $lastAnchor = ($c+1==count($changeLog)?'<a name="latest"></a>':"");
345                                         if ($entry["uid"])      {
346                                                 $theTime = $this->linkPage(t3lib_BEfunc::datetime($entry["tstamp"]),array("sh_uid"=>$entry["uid"],"element"=>""));
347                                                 $lines[]='<tr bgColor="'.($entry["snapshot"]?$SOBE->doc->bgColor2:$darkerBgColor).'">
348                                                         <td colspan=2>'.$lastAnchor.'<a name="uid_'.$entry["uid"].'"></a>'.($entry["snapshot"]?'<img src="gfx/napshot.gif" width="12" height="12" border="0" align=top>':'').'<B>'.$LANG->getLL("time").':</B> '.$theTime.', '.t3lib_BEfunc::calcAge(time()-$entry["tstamp"],$GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears")).' &nbsp; - &nbsp; <B>'.$LANG->getLL("user").':</B> '.$be_users[$entry["user"]]["username"].'</td>
349                                                         <td>'.
350                                                         $this->linkPage('<img src="gfx/history.gif" width="13" height="12" hspace=2 border="0" title="'.$LANG->getLL("revertAllFields").'">', array("revert"=>"ALL_FIELDS","sumUp"=>$entry["uid"],"doReturn"=>1)).
351                                                         $this->linkPage('<img src="gfx/history_details.gif" width="12" height="12" hspace=2 border="0" title="'.$LANG->getLL("sumUpChanges").'">', array("sumUp"=>$entry["uid"])).'</td>
352                                                 </tr>';
353                                         } else {
354                                                 $lines[]='<tr bgColor="'.$darkerBgColor_interM.'">
355                                                         <td colspan=3><strong>'.$LANG->getLL("externalChange").'</strong></td>
356                                                         </tr>';
357                                         }
358                                         $lines = array_merge($lines,$this->renderEntry($entry,$table));
359                                 }
360                         }
361                         
362                         $theCode='<table border=0 cellpadding=2 cellspacing=2>'.implode("",$lines).'</table>';
363                         $theCode.='<BR><img src="gfx/icon_note.gif" width="18" height="16" border="0" align="top">'.$LANG->getLL("differenceMsg")."<BR><BR>";
364                         return $SOBE->doc->section($LANG->getLL("changes"),$theCode,0,1);
365                 }
366         }
367         function renderEntry($entry,$table)     {
368                 global $SOBE, $LANG, $TCA;
369                 $lines=array();
370                 if (is_array($entry["newRecord"]))      {
371                         $fieldsToDisplay = array_keys($entry["newRecord"]);
372                         reset($fieldsToDisplay);
373                         $t3lib_diff_Obj = t3lib_div::makeInstance("t3lib_diff");
374                         while(list(,$fN)=each($fieldsToDisplay))        {
375                                 $diffres = $t3lib_diff_Obj->makeDiffDisplay(
376                                         t3lib_BEfunc::getProcessedValue($table,$fN,$entry["oldRecord"][$fN],0,1),
377                                         t3lib_BEfunc::getProcessedValue($table,$fN,$entry["newRecord"][$fN],0,1)
378                                 );
379
380                                 switch($this->listType) {
381                                         case 1:
382                                                 $lines[]='<tr bgColor="'.$SOBE->doc->bgColor4.'">
383                                                         <td valign=top>'.$LANG->sl(t3lib_BEfunc::getItemLabel($table,$fN,"<i>|</i>")).'</td>
384                                                         <td valign=top>'.nl2br($diffres).'</td>
385                                                         <td valign=top>&nbsp;</td>
386                                                 </tr>';
387                                         break;
388                                         case 2:
389                                                 $lines[]='<tr bgColor="'.$SOBE->doc->bgColor4.'">
390                                                         <td valign=top>'.$LANG->sl(t3lib_BEfunc::getItemLabel($table,$fN,"<i>|</i>")).'</td>
391                                                         <td valign=top>'.t3lib_BEfunc::getProcessedValue($table,$fN,$entry["oldRecord"][$fN]).'</td>
392                                                         <td valign=top>'.$this->linkPage('<img src="gfx/history.gif" width="13" height="12" border="0" title="'.$LANG->getLL("revertField").'">', array("revert"=>"field:".$fN)).'</td>
393                                                         <td valign=top>'.t3lib_BEfunc::getProcessedValue($table,$fN,$entry["newRecord"][$fN]).'</td>
394                                                         <td valign=top>'.nl2br($diffres).'</td>
395                                                 </tr>';
396                                         break;
397                                         default:
398                                                 $lines[]='<tr bgColor="'.$SOBE->doc->bgColor4.'">
399                                                         <td valign=top>'.$LANG->sl(t3lib_BEfunc::getItemLabel($table,$fN,"<i>|</i>")).'</td>
400                                                         <td valign=top>'.t3lib_BEfunc::getProcessedValue($table,$fN,$entry["oldRecord"][$fN]).'</td>
401                                                         <td valign=top>'.t3lib_BEfunc::getProcessedValue($table,$fN,$entry["newRecord"][$fN]).'</td>
402                                                         <td valign=top>'.nl2br($diffres).'</td>
403                                                 </tr>';
404                                         break;
405                                 }
406                         }
407                 }
408                 return $lines;
409         }
410         function displaySysHistoryEntry($sh_uid)        {
411                 global $SOBE, $LANG, $TCA;
412
413                 $query="SELECT * FROM sys_history WHERE uid=".intval($sh_uid);
414                 $res = mysql(TYPO3_db,$query);
415                 $newRow = mysql_fetch_assoc($res);
416                 if (is_array($newRow))  {
417                         $this->listType=0;
418                         $lines=array();
419
420                         $recIdentString = $LANG->sL($TCA[$newRow["tablename"]]["ctrl"]["title"])."/".$newRow["recuid"];
421                         $recIdentString = $this->linkPage($recIdentString,array("sh_uid"=>"","element"=>$newRow["tablename"].":".$newRow["recuid"]),"uid_".$sh_uid);
422                         $lines[]='<tr bgColor="'.$SOBE->doc->bgColor5.'">
423                                 <td colspan=4>
424                                         <strong>'.$LANG->getLL("tableUid").':</strong> '.$recIdentString.'<br>
425                                         <strong>'.$LANG->getLL("time").':</strong> '.t3lib_BEfunc::datetime($newRow["tstamp"]).', '.t3lib_BEfunc::calcAge(time()-$newRow["tstamp"],$GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears")).'<br>
426                                         </td>
427                         </tr>';
428
429                         $lines[]=$this->listHeader();
430
431                         $historyData = unserialize($newRow["history_data"]);
432                         $lines = array_merge($lines,$this->renderEntry($historyData,$newRow["tablename"]));
433                         
434                         $theCode='<table border=0 cellpadding=2 cellspacing=2>'.implode("",$lines).'</table>';
435                         $theCode.='<BR><img src="gfx/icon_note.gif" width="18" height="16" border="0" align="top">'.$LANG->getLL("differenceMsg")."<BR><BR>";
436                         $content.=$SOBE->doc->section($LANG->getLL("changes"),$theCode,0,1);
437                 }
438                 return $content;
439         }
440         function listHeader()   {
441                 global $SOBE, $LANG, $TCA;
442
443                 switch($this->listType) {
444                         case 1:
445                                 $out='<tr bgColor="'.$SOBE->doc->bgColor5.'">
446                                         <td valign=top nowrap><strong>'.$LANG->getLL("fieldName").':</strong></td>
447                                         <td valign=top nowrap><strong>'.$LANG->getLL("difference").':</strong></td>
448                                         <td valign=top>&nbsp;</td>
449                                 </tr>'; 
450                         break;
451                         case 2:
452                                 $out='<tr bgColor="'.$SOBE->doc->bgColor5.'">
453                                         <td valign=top nowrap><strong>'.$LANG->getLL("fieldName").':</strong></td>
454                                         <td valign=top nowrap><strong>'.$LANG->getLL("oldValue").':</strong></td>
455                                         <td valign=top nowrap><strong>'.$this->linkPage('<img src="gfx/history.gif" width="13" height="12" border="0" title="'.$LANG->getLL("revertAllFields").'">', array("revert"=>"ALL_FIELDS")).'</strong></td>
456                                         <td valign=top nowrap><strong>'.$LANG->getLL("currentValue").':</strong></td>
457                                         <td valign=top nowrap><strong>'.$LANG->getLL("difference").':</strong></td>
458                                 </tr>'; 
459                         break;
460                         default:
461                                 $out='<tr bgColor="'.$SOBE->doc->bgColor5.'">
462                                         <td valign=top nowrap><strong>'.$LANG->getLL("fieldName").':</strong></td>
463                                         <td valign=top nowrap><strong>'.$LANG->getLL("oldValue").':</strong></td>
464                                         <td valign=top nowrap><strong>'.$LANG->getLL("newValue").':</strong></td>
465                                         <td valign=top nowrap><strong>'.$LANG->getLL("difference").':</strong></td>
466                                 </tr>'; 
467                         break;
468                 }
469                 return $out;
470         }
471         function linkPage($str,$inparams=array(),$anchor="")    {
472                 $params["sh_uid"]=t3lib_div::GPvar("sh_uid");
473                 $params["sumUp"]=t3lib_div::GPvar("sumUp");
474                 $params["element"]=t3lib_div::GPvar("element");
475                 $params["returnUrl"]=t3lib_div::GPvar("returnUrl");
476                 $params = array_merge($params,$inparams);                       // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
477                 $link = '<a href="show_rechis.php?'.t3lib_div::implodeArrayForUrl("",$params).($anchor?"#".$anchor:"").'">'.$str.'</a>';
478                 return $link;
479         }
480 }
481
482 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/class.show_rechis.inc"])     {
483         include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/class.show_rechis.inc"]);
484 }
485
486 ?>