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
00083 class recordHistory {
00084
00085
00086 var $maxSteps=20;
00087
00088
00089 var $listType = 0;
00090
00091
00092 var $sh_uid;
00093 var $element;
00094 var $saveState;
00095 var $returnUrl;
00096 var $revert;
00097 var $sumUp;
00098 var $doReturn;
00099
00100
00106 function recordHistory() {
00107
00108
00109 $this->sh_uid = t3lib_div::_GP('sh_uid');
00110 $this->element = t3lib_div::_GP('element');
00111 $this->saveState = t3lib_div::_GP('saveState');
00112 $this->returnUrl = t3lib_div::_GP('returnUrl');
00113 $this->revert = t3lib_div::_GP('revert');
00114 $this->sumUp = t3lib_div::_GP('sumUp');
00115 $this->doReturn = t3lib_div::_GP('doReturn');
00116 }
00117
00124 function main() {
00125
00126 $content='';
00127
00128
00129
00130 if ($this->sh_uid) {
00131 $content.=$this->displaySysHistoryEntry($this->sh_uid);
00132 }
00133
00134
00135 if ($this->element) {
00136 if ($this->revert && $this->sumUp) {
00137 $content.=$this->revertToPreviousValues($this->element,$this->revert);
00138 }
00139 if ($this->saveState) {
00140 $content.=$this->saveState($this->element,$this->saveState);
00141 }
00142 $content.=$this->displayHistory($this->element);
00143 }
00144
00145
00146 return $content;
00147 }
00148
00155 function displaySysHistoryEntry($sh_uid) {
00156 global $SOBE, $LANG, $TCA;
00157
00158
00159 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_history', 'uid='.intval($sh_uid));
00160 $newRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00161
00162
00163 if (is_array($newRow)) {
00164
00165
00166 $this->listType=0;
00167 $lines=array();
00168
00169
00170 $recIdentString = $LANG->sL($TCA[$newRow['tablename']]['ctrl']['title']).'/'.$newRow['recuid'];
00171 $recIdentString = $this->linkPage(htmlspecialchars($recIdentString),array('sh_uid'=>'','element'=>$newRow['tablename'].':'.$newRow['recuid']),'uid_'.$sh_uid);
00172 $theTime = t3lib_BEfunc::datetime($newRow['tstamp']).', '.t3lib_BEfunc::calcAge(time()-$newRow['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'));
00173 $lines[]='
00174 <tr class="bgColor5">
00175 <td colspan="4">
00176 <strong>'.$LANG->getLL('tableUid',1).':</strong> '.$recIdentString.'<br />
00177 <strong>'.$LANG->getLL('time',1).':</strong> '.htmlspecialchars($theTime).'<br />
00178 </td>
00179 </tr>';
00180
00181
00182 $lines[]=$this->listHeader();
00183
00184
00185 $historyData = unserialize($newRow['history_data']);
00186 $lines = array_merge($lines,$this->renderEntry($historyData,$newRow['tablename']));
00187
00188
00189 $theCode='
00190
00191 <!--
00192 History for item:
00193 -->
00194 <table border="0" cellpadding="2" cellspacing="2" id="typo3-history-item">
00195 '.implode('',$lines).'
00196 </table>';
00197
00198 $theCode.='
00199 <br /><img'.t3lib_iconWorks::skinImg('','gfx/icon_note.gif','width="18" height="16"').' align="top" alt="" />'.$LANG->getLL('differenceMsg').'<br /><br />';
00200
00201
00202 $theCode.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'history_entry', $GLOBALS['BACK_PATH'],'');
00203
00204
00205 $content.=$SOBE->doc->section($LANG->getLL('changes'),$theCode,0,1);
00206 }
00207
00208
00209 return $content;
00210 }
00211
00219 function revertToPreviousValues($element,$field) {
00220 $sumUp = $this->sumUp;
00221
00222 $elParts = explode(':',$element);
00223 $redirect = intval($this->doReturn);
00224 if ($sumUp==-1) {
00225 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00226 'uid',
00227 'sys_history',
00228 'sys_history.tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($elParts[0], 'sys_history').'
00229 AND sys_history.recuid='.intval($elParts[1]),
00230 '',
00231 'uid DESC',
00232 '1'
00233 );
00234 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00235 $sumUp=$row['uid'];
00236 }
00237 $redirect = 1;
00238 }
00239 if ($sumUp!=-1) {
00240 $changeRec=$this->compareChangesWithCurrent($element,$this->getChangesSinceRecord($element,$sumUp));
00241
00242 $data =array();
00243 if (t3lib_BEfunc::getRecord($elParts[0],$elParts[1])) {
00244
00245
00246 if ($field=='ALL_FIELDS') {
00247 $data=$changeRec['oldRecord'];
00248 } elseif(substr($field,0,6)=='field:') {
00249 $data[substr($field,6)]=$changeRec['oldRecord'][substr($field,6)];
00250 }
00251
00252 $data = $this->removeFilefields($elParts[0],$data);
00253
00254
00255 if (count($data)) {
00256
00257
00258 $inData=array();
00259 $inData[$elParts[0]][$elParts[1]]=$data;
00260
00261
00262 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00263 $tce->stripslashes_values=0;
00264 $tce->debug=0;
00265 $tce->dontProcessTransformations=1;
00266 $tce->start($inData,array());
00267 $tce->process_datamap();
00268 }
00269 }
00270 }
00271
00272 if ($redirect) {
00273 Header ('Location: '.t3lib_div::locationHeaderUrl($this->returnUrl));
00274 exit;
00275 }
00276 }
00277
00285 function saveState($element,$sumUp) {
00286 $elParts = explode(':',$element);
00287
00288
00289 $changeRec = $this->getChangesSinceRecord($element,$sumUp);
00290
00291
00292 $lastestData = array();
00293 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00294 'history_data',
00295 'sys_history',
00296 'sys_history.tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($elParts[0], 'sys_history').'
00297 AND sys_history.recuid='.intval($elParts[1]),
00298 '',
00299 'uid DESC',
00300 '1'
00301 );
00302 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00303 $lastestData = unserialize($row['history_data']);
00304 }
00305
00306
00307 $historyRecords=array();
00308 $historyRecords['oldRecord'] = $changeRec['changes'];
00309 $historyRecords['newRecord'] = array();
00310
00311 reset($historyRecords['oldRecord']);
00312 while(list($kk)=each($historyRecords['oldRecord'])) {
00313 $historyRecords['newRecord'][$kk]=$lastestData['newRecord'][$kk];
00314 }
00315
00316
00317 $updateID = $GLOBALS['BE_USER']->writelog(3,1,0,1,'Saved state','');
00318
00319
00320 $fields_values = array(
00321 'history_data' => serialize($historyRecords),
00322 'fieldlist' => implode(',',array_keys($historyRecords['oldRecord'])),
00323 'tstamp' => time(),
00324 'tablename' => $elParts[0],
00325 'recuid' => $elParts[1],
00326 'sys_log_uid' => $updateID,
00327 'snapshot' => 1
00328 );
00329
00330 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_history', $fields_values);
00331 }
00332
00339 function displayHistory($element) {
00340 global $SOBE, $LANG, $TCA;
00341
00342
00343 $elParts = explode(':',$element);
00344 $table = $elParts[0];
00345
00346
00347 if ($TCA[$table]) {
00348
00349
00350 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00351 'COUNT(*)',
00352 'sys_history,sys_log',
00353 'sys_history.sys_log_uid=sys_log.uid
00354 AND sys_history.tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_history').'
00355 AND sys_history.recuid='.intval($elParts[1])
00356 );
00357 list($Rcount) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00358
00359
00360 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00361 'sys_history.*,sys_log.userid',
00362 'sys_history,sys_log',
00363 'sys_history.sys_log_uid=sys_log.uid
00364 AND sys_history.tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_history').'
00365 AND sys_history.recuid='.intval($elParts[1]),
00366 '',
00367 'sys_log.uid',
00368 t3lib_div::intInRange($Rcount-$this->maxSteps,0).','.$this->maxSteps
00369 );
00370
00371
00372 $changesArray=array();
00373 $changeLog=array();
00374 while ($newRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00375 $hisDat = unserialize($newRow['history_data']);
00376 if (is_array($hisDat['newRecord']) && is_array($hisDat['oldRecord'])) {
00377
00378 $intermediaChanges = $this->cmp($changesArray,$hisDat['oldRecord']);
00379 if (count($intermediaChanges) && !$newRow['snapshot']) {
00380 $changeLog[]=$intermediaChanges;
00381 }
00382
00383
00384 $hisDat['uid']=$newRow['uid'];
00385 $hisDat['tstamp']=$newRow['tstamp'];
00386 $hisDat['user']=$newRow['userid'];
00387 $hisDat['snapshot']=$newRow['snapshot'];
00388 $changeLog[]=$hisDat;
00389
00390
00391
00392 $changesArray = array_merge($changesArray,$hisDat['newRecord']);
00393 } else {
00394 debug('ERROR: [displayHistory]');
00395 }
00396 }
00397
00398
00399 $lines=array();
00400 $darkerBgColor_interM = '#cccccc';
00401 if ($this->sumUp) {
00402
00403
00404 $changeLog=array();
00405 $changeLog[]=$this->compareChangesWithCurrent($element,$this->getChangesSinceRecord($element,$this->sumUp));
00406 $this->listType=2;
00407 $lines[]=$this->listHeader();
00408 $be_users = t3lib_BEfunc::getUserNames();
00409
00410
00411 list($prevHisUid,$nextHisUid) = $this->nextHisUid($element,$this->sumUp);
00412
00413
00414 $linkPack =
00415 ($prevHisUid ? $this->linkPage('<img'.t3lib_iconWorks::skinImg('','gfx/pilup.gif','width="14" height="14"').' title="'.$LANG->getLL('prev',1).'" alt="" />', array('sumUp'=>$prevHisUid)) : '').
00416 ($nextHisUid ? $this->linkPage('<img'.t3lib_iconWorks::skinImg('','gfx/pildown.gif','width="14" height="14"').' title="'.$LANG->getLL('next',1).'" alt="" />', array('sumUp'=>$nextHisUid)) : '').
00417 '<br />'.$this->linkPage('<img'.t3lib_iconWorks::skinImg('','gfx/history2.gif','width="13" height="12"').' title="'.$LANG->getLL('historyList',1).'" alt="" />', array('sumUp'=>''), 'uid_'.$this->sumUp).
00418 $this->linkPage('<img'.t3lib_iconWorks::skinImg('','gfx/savesnapshot.gif','width="17" height="12"').' title="'.$LANG->getLL('saveState',1).'" alt="" />', array('saveState'=>$this->sumUp,'sumUp'=>''), 'latest');
00419
00420
00421 foreach($changeLog as $entry) {
00422
00423
00424 if (!is_array($entry['userList'])) $entry['userList']=array();
00425 foreach($entry['userList'] as $uLk => $uV) {
00426 $entry['userList'][$uLk]=$be_users[$uV]['username'];
00427 }
00428
00429
00430 $theTime = t3lib_BEfunc::datetime($entry['tstamp']).', '.t3lib_BEfunc::calcAge(time()-$entry['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'));
00431 $lines[]='
00432 <tr class="bgColor4-20">
00433 <td valign="top">'.$linkPack.'</td>
00434 <td colspan="4"><b>'.$LANG->getLL('time',1).':</b> '.htmlspecialchars($theTime).' - <b>'.$LANG->getLL('changeCount',1).':</b> '.$entry['counter'].'<br />
00435 <b>'.$LANG->getLL('users',1).':</b> '.implode(', ',$entry['userList']).'
00436 </td>
00437 </tr>';
00438
00439
00440 if (isset($entry['oldRecord']) && isset($entry['newRecord'])) {
00441 $lines = array_merge($lines,$this->renderEntry($entry,$table));
00442 } else {
00443 $lines[]='
00444 <tr class="bgColor4">
00445 <td colspan="5" align="center"><br /><b>'.$LANG->getLL('similar',1).'</b><br /><br /></td>
00446 </tr>';
00447 }
00448 }
00449 } else {
00450
00451
00452 $this->listType=1;
00453 $be_users = t3lib_BEfunc::getUserNames();
00454 $lines[]=$this->listHeader();
00455
00456
00457 foreach($changeLog as $c => $entry) {
00458
00459
00460 $lines[]='
00461 <tr>
00462 <td colspan="3"> </td>
00463 </tr>';
00464
00465
00466 $lastAnchor = ($c+1==count($changeLog)?'<a name="latest"></a>':'');
00467
00468
00469 if ($entry['uid']) {
00470 $theTime = $this->linkPage(t3lib_BEfunc::datetime($entry['tstamp']),array('sh_uid'=>$entry['uid'],'element'=>''));
00471 $theAge = ', '.t3lib_BEfunc::calcAge(time()-$entry['tstamp'],$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'));
00472 $bgColorClass = $entry['snapshot'] ? 'bgColor2' : 'bgColor4-20';
00473 $lines[]='
00474 <tr class="'.$bgColorClass.'">
00475 <td colspan="2">'.
00476 $lastAnchor.
00477 '<a name="uid_'.$entry['uid'].'"></a>'.
00478 ($entry['snapshot'] ? '<img'.t3lib_iconWorks::skinImg('','gfx/snapshot.gif','width="12" height="12"').' alt="" />':'').
00479 '<b>'.$LANG->getLL('time',1).':</b> '.$theTime.htmlspecialchars($theAge).' - <b>'.$LANG->getLL('user',1).':</b> '.$be_users[$entry['user']]['username'].
00480 '</td>
00481 <td>'.
00482 $this->linkPage('<img'.t3lib_iconWorks::skinImg('','gfx/history.gif','width="13" height="12"').' title="'.$LANG->getLL('revertAllFields',1).'" alt="" />', array('revert'=>'ALL_FIELDS','sumUp'=>$entry['uid'],'doReturn'=>1)).
00483 $this->linkPage('<img'.t3lib_iconWorks::skinImg('','gfx/history_details.gif','width="12" height="12"').' title="'.$LANG->getLL('sumUpChanges',1).'" alt="" />', array('sumUp'=>$entry['uid'])).
00484 '</td>
00485 </tr>';
00486 } else {
00487 $lines[]='
00488 <tr bgcolor="'.$darkerBgColor_interM.'">
00489 <td colspan="3"><strong>'.$LANG->getLL('externalChange',1).'</strong></td>
00490 </tr>';
00491 }
00492
00493 $lines = array_merge($lines,$this->renderEntry($entry,$table));
00494 }
00495 }
00496
00497
00498 $theCode='
00499
00500 <!--
00501 Item history (either list or single):
00502 -->
00503 <table border="0" cellpadding="2" cellspacing="2" id="typo3-history">
00504 '.implode('',$lines).'
00505 </table>';
00506
00507
00508 $theCode.= '<br /><img'.t3lib_iconWorks::skinImg('','gfx/icon_note.gif','width="18" height="16"').' align="top" alt="" />'.$LANG->getLL('differenceMsg').'<br /><br />';
00509
00510
00511 $theCode.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'history_'.($this->sumUp ? 'sum' : 'log'), $GLOBALS['BACK_PATH'],'');
00512
00513
00514 return $SOBE->doc->section($LANG->getLL('changes'),$theCode,0,1);
00515 }
00516 }
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00540 function nextHisUid($element,$hisUid) {
00541 $elParts = explode(':',$element);
00542
00543
00544 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00545 'uid',
00546 'sys_history',
00547 'tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($elParts[0], 'sys_history').'
00548 AND recuid='.intval($elParts[1]).'
00549 AND uid<'.intval($hisUid),
00550 '',
00551 'uid DESC',
00552 '1'
00553 );
00554 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00555 $prevUid = $row['uid'];
00556 }
00557
00558
00559 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00560 'uid',
00561 'sys_history',
00562 'tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($elParts[0], 'sys_history').'
00563 AND recuid='.intval($elParts[1]).'
00564 AND uid>'.intval($hisUid),
00565 '',
00566 'uid',
00567 '1'
00568 );
00569 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00570 $nextUid = $row['uid'];
00571 }
00572
00573
00574 return array($prevUid,$nextUid);
00575 }
00576
00586 function compareChangesWithCurrent($element,$changeRec) {
00587 global $TCA;
00588
00589
00590 $sumChangesArray=array();
00591 $elParts = explode(':',$element);
00592 $newChangeRec=array();
00593
00594
00595 if ($TCA[$elParts[0]]) {
00596
00597
00598 $currentRecord = t3lib_BEfunc::getRecord($elParts[0],$elParts[1]);
00599
00600
00601 if (is_array($currentRecord) && is_array($changeRec['changes'])) {
00602
00603
00604 foreach($changeRec['changes'] as $fN => $fV) {
00605 if (strcmp($fV,$currentRecord[$fN])) {
00606 $newChangeRec['oldRecord'][$fN]=$fV;
00607 $newChangeRec['newRecord'][$fN]=$currentRecord[$fN];
00608 }
00609 }
00610
00611 $newChangeRec['tstamp']=min($changeRec['tstamp']);
00612 $newChangeRec['counter']=$changeRec['counter'];
00613 $newChangeRec['userList']=array_unique($changeRec['userList']);
00614 } else {
00615 return false;
00616 }
00617 }
00618
00619
00620 return $newChangeRec;
00621 }
00622
00631 function readFieldTypes($table,$id) {
00632
00633
00634 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid='.intval($id));
00635
00636
00637 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
00638 $currentRecord = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00639 $c=0;
00640 $cRecTypes=array();
00641 foreach($currentRecord as $col => $val) {
00642
00643
00644 $cRecTypes[$col] = $GLOBALS['TYPO3_DB']->sql_field_type($res,$c);
00645 $c++;
00646 }
00647 }
00648
00649 $GLOBALS['TYPO3_DB']->sql_free_result($res);
00650
00651 return array($currentRecord,$cRecTypes);
00652 }
00653
00662 function cmp($changeStatus,$oldRecord) {
00663
00664
00665 $changes=array();
00666
00667
00668 foreach($oldRecord as $fN => $fV) {
00669 if (isset($changeStatus[$fN]) && strcmp($fV,$changeStatus[$fN])) {
00670 $changes['oldRecord'][$fN]=$changeStatus[$fN];
00671 $changes['newRecord'][$fN]=$fV;
00672 }
00673 }
00674 return $changes;
00675 }
00676
00685 function removeFilefields($table,$dataArray) {
00686 global $TCA;
00687
00688 if ($TCA[$table]) {
00689 t3lib_div::loadTCA($table);
00690
00691 foreach($TCA[$table]['columns'] as $field => $config) {
00692 if ($config['config']['type']=='group' && $config['config']['internal_type']=='file') {
00693 unset($dataArray[$field]);
00694 }
00695 }
00696 }
00697 return $dataArray;
00698 }
00699
00708 function renderEntry($entry,$table) {
00709 global $SOBE, $LANG, $TCA;
00710
00711 $lines=array();
00712 if (is_array($entry['newRecord'])) {
00713
00714 $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
00715
00716 $fieldsToDisplay = array_keys($entry['newRecord']);
00717 foreach($fieldsToDisplay as $fN) {
00718 t3lib_div::loadTCA($table);
00719 if (is_array($TCA[$table]['columns'][$fN]) && $TCA[$table]['columns'][$fN]['config']['type']!='passthrough') {
00720
00721
00722 $diffres = $t3lib_diff_Obj->makeDiffDisplay(
00723 t3lib_BEfunc::getProcessedValue($table,$fN,$entry['oldRecord'][$fN],0,1),
00724 t3lib_BEfunc::getProcessedValue($table,$fN,$entry['newRecord'][$fN],0,1)
00725 );
00726
00727
00728 switch($this->listType) {
00729 case 1:
00730 $lines[]='
00731 <tr class="bgColor4">
00732 <td><em>'.$LANG->sl(t3lib_BEfunc::getItemLabel($table,$fN),1).'</em></td>
00733 <td>'.nl2br($diffres).'</td>
00734 <td> </td>
00735 </tr>';
00736 break;
00737 case 2:
00738 $lines[]='
00739 <tr class="bgColor4">
00740 <td><em>'.$LANG->sl(t3lib_BEfunc::getItemLabel($table,$fN)).'</em></td>
00741 <td>'.htmlspecialchars(t3lib_BEfunc::getProcessedValue($table,$fN,$entry['oldRecord'][$fN])).'</td>
00742 <td>'.$this->linkPage('<img'.t3lib_iconWorks::skinImg('','gfx/history.gif','width="13" height="12"').' title="'.$LANG->getLL('revertField',1).'" alt="" />', array('revert'=>'field:'.$fN)).'</td>
00743 <td>'.htmlspecialchars(t3lib_BEfunc::getProcessedValue($table,$fN,$entry['newRecord'][$fN])).'</td>
00744 <td>'.nl2br($diffres).'</td>
00745 </tr>';
00746 break;
00747 default:
00748 $lines[]='
00749 <tr class="bgColor4">
00750 <td><em>'.$LANG->sl(t3lib_BEfunc::getItemLabel($table,$fN)).'</em></td>
00751 <td>'.htmlspecialchars(t3lib_BEfunc::getProcessedValue($table,$fN,$entry['oldRecord'][$fN])).'</td>
00752 <td>'.htmlspecialchars(t3lib_BEfunc::getProcessedValue($table,$fN,$entry['newRecord'][$fN])).'</td>
00753 <td>'.nl2br($diffres).'</td>
00754 </tr>';
00755 break;
00756 }
00757 }
00758 }
00759 }
00760 return $lines;
00761 }
00762
00769 function listHeader() {
00770 global $SOBE, $LANG;
00771
00772 switch($this->listType) {
00773 case 1:
00774 $out='
00775 <tr class="bgColor5 c-head">
00776 <td>'.$LANG->getLL('fieldName',1).':</td>
00777 <td>'.$LANG->getLL('difference',1).':</td>
00778 <td> </td>
00779 </tr>';
00780 break;
00781 case 2:
00782 $out='
00783 <tr class="bgColor5 c-head">
00784 <td>'.$LANG->getLL('fieldName',1).':</td>
00785 <td>'.$LANG->getLL('oldValue',1).':</td>
00786 <td>'.$this->linkPage('<img'.t3lib_iconWorks::skinImg('','gfx/history.gif','width="13" height="12"').' title="'.$LANG->getLL('revertAllFields',1).'" alt="" />', array('revert'=>'ALL_FIELDS')).'</td>
00787 <td>'.$LANG->getLL('currentValue',1).':</td>
00788 <td>'.$LANG->getLL('difference',1).':</td>
00789 </tr>';
00790 break;
00791 default:
00792 $out='
00793 <tr class="bgColor5 c-head">
00794 <td>'.$LANG->getLL('fieldName',1).':</td>
00795 <td>'.$LANG->getLL('oldValue',1).':</td>
00796 <td>'.$LANG->getLL('newValue',1).':</td>
00797 <td>'.$LANG->getLL('difference',1).':</td>
00798 </tr>';
00799 break;
00800 }
00801 return $out;
00802 }
00803
00813 function linkPage($str,$inparams=array(),$anchor='') {
00814
00815
00816 $params['sh_uid']=$this->sh_uid;
00817 $params['sumUp']=$this->sumUp;
00818 $params['element']=$this->element;
00819 $params['returnUrl']=$this->returnUrl;
00820
00821
00822 $params = array_merge($params,$inparams);
00823
00824
00825 $Ahref = 'show_rechis.php?'.t3lib_div::implodeArrayForUrl('',$params).($anchor?'#'.$anchor:'');
00826 $link = '<a href="'.htmlspecialchars($Ahref).'">'.$str.'</a>';
00827
00828
00829 return $link;
00830 }
00831
00841 function getChangesSinceRecord($element,$hisUid=0,$hisUid_Stop=0) {
00842 global $TCA;
00843
00844
00845 $sumChangesArray=array();
00846 $sumChangesArray['changes']=array();
00847 $elParts = explode(':',$element);
00848
00849
00850 if ($TCA[$elParts[0]]) {
00851 $times = array();
00852
00853
00854 $addWhere = ' AND sys_history.uid>='.$hisUid;
00855 if ($hisUid_Stop) $addWhere.= ' AND sys_history.uid<='.$hisUid_Stop;
00856
00857 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00858 'sys_history.*,sys_log.userid',
00859 'sys_history,sys_log',
00860 'sys_history.sys_log_uid=sys_log.uid
00861 AND sys_history.tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($elParts[0], 'sys_history').'
00862 AND sys_history.recuid='.intval($elParts[1]).$addWhere,
00863 '',
00864 'uid DESC'
00865 );
00866
00867
00868 while ($newRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00869 $hisDat = unserialize($newRow['history_data']);
00870 if (is_array($hisDat['newRecord']) && is_array($hisDat['oldRecord'])) {
00871 $sumChangesArray['changes']=array_merge($sumChangesArray['changes'],$hisDat['oldRecord']);
00872 $sumChangesArray['counter']++;
00873 $sumChangesArray['tstamp'][]=$newRow['tstamp'];
00874 $sumChangesArray['userList'][]=$newRow['userid'];
00875 } else {
00876 debug('ERROR!');
00877 }
00878
00879 }
00880 }
00881 return $sumChangesArray;
00882 }
00883 }
00884
00885 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.show_rechis.inc']) {
00886 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.show_rechis.inc']);
00887 }
00888 ?>