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']->quoteStr($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']->quoteStr($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']->quoteStr($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']->quoteStr($table, 'sys_history').'"
00365 AND sys_history.recuid='.intval($elParts[1]),
00366 '',
00367 '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']->quoteStr($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']->quoteStr($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 $cRecTypes[$col] = $GLOBALS['TYPO3_DB']->sql_field_type($res,$c);
00643 $c++;
00644 }
00645 }
00646
00647 $GLOBALS['TYPO3_DB']->sql_free_result($res);
00648
00649 return array($currentRecord,$cRecTypes);
00650 }
00651
00660 function cmp($changeStatus,$oldRecord) {
00661
00662
00663 $changes=array();
00664
00665
00666 foreach($oldRecord as $fN => $fV) {
00667 if (isset($changeStatus[$fN]) && strcmp($fV,$changeStatus[$fN])) {
00668 $changes['oldRecord'][$fN]=$changeStatus[$fN];
00669 $changes['newRecord'][$fN]=$fV;
00670 }
00671 }
00672 return $changes;
00673 }
00674
00683 function removeFilefields($table,$dataArray) {
00684 global $TCA;
00685
00686 if ($TCA[$table]) {
00687 t3lib_div::loadTCA($table);
00688
00689 foreach($TCA[$table]['columns'] as $field => $config) {
00690 if ($config['config']['type']=='group' && $config['config']['internal_type']=='file') {
00691 unset($dataArray[$field]);
00692 }
00693 }
00694 }
00695 return $dataArray;
00696 }
00697
00706 function renderEntry($entry,$table) {
00707 global $SOBE, $LANG, $TCA;
00708
00709 $lines=array();
00710 if (is_array($entry['newRecord'])) {
00711
00712 $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
00713
00714 $fieldsToDisplay = array_keys($entry['newRecord']);
00715 foreach($fieldsToDisplay as $fN) {
00716 if (is_array($TCA[$table]['columns'][$fN]) && $TCA[$table]['columns'][$fN]['config']['type']!='passthrough') {
00717
00718
00719 $diffres = $t3lib_diff_Obj->makeDiffDisplay(
00720 t3lib_BEfunc::getProcessedValue($table,$fN,$entry['oldRecord'][$fN],0,1),
00721 t3lib_BEfunc::getProcessedValue($table,$fN,$entry['newRecord'][$fN],0,1)
00722 );
00723
00724
00725 switch($this->listType) {
00726 case 1:
00727 $lines[]='
00728 <tr class="bgColor4">
00729 <td><em>'.$LANG->sl(t3lib_BEfunc::getItemLabel($table,$fN),1).'</em></td>
00730 <td>'.nl2br($diffres).'</td>
00731 <td> </td>
00732 </tr>';
00733 break;
00734 case 2:
00735 $lines[]='
00736 <tr class="bgColor4">
00737 <td><em>'.$LANG->sl(t3lib_BEfunc::getItemLabel($table,$fN)).'</em></td>
00738 <td>'.htmlspecialchars(t3lib_BEfunc::getProcessedValue($table,$fN,$entry['oldRecord'][$fN])).'</td>
00739 <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>
00740 <td>'.htmlspecialchars(t3lib_BEfunc::getProcessedValue($table,$fN,$entry['newRecord'][$fN])).'</td>
00741 <td>'.nl2br($diffres).'</td>
00742 </tr>';
00743 break;
00744 default:
00745 $lines[]='
00746 <tr class="bgColor4">
00747 <td><em>'.$LANG->sl(t3lib_BEfunc::getItemLabel($table,$fN)).'</em></td>
00748 <td>'.htmlspecialchars(t3lib_BEfunc::getProcessedValue($table,$fN,$entry['oldRecord'][$fN])).'</td>
00749 <td>'.htmlspecialchars(t3lib_BEfunc::getProcessedValue($table,$fN,$entry['newRecord'][$fN])).'</td>
00750 <td>'.nl2br($diffres).'</td>
00751 </tr>';
00752 break;
00753 }
00754 }
00755 }
00756 }
00757 return $lines;
00758 }
00759
00766 function listHeader() {
00767 global $SOBE, $LANG;
00768
00769 switch($this->listType) {
00770 case 1:
00771 $out='
00772 <tr class="bgColor5 c-head">
00773 <td>'.$LANG->getLL('fieldName',1).':</td>
00774 <td>'.$LANG->getLL('difference',1).':</td>
00775 <td> </td>
00776 </tr>';
00777 break;
00778 case 2:
00779 $out='
00780 <tr class="bgColor5 c-head">
00781 <td>'.$LANG->getLL('fieldName',1).':</td>
00782 <td>'.$LANG->getLL('oldValue',1).':</td>
00783 <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>
00784 <td>'.$LANG->getLL('currentValue',1).':</td>
00785 <td>'.$LANG->getLL('difference',1).':</td>
00786 </tr>';
00787 break;
00788 default:
00789 $out='
00790 <tr class="bgColor5 c-head">
00791 <td>'.$LANG->getLL('fieldName',1).':</td>
00792 <td>'.$LANG->getLL('oldValue',1).':</td>
00793 <td>'.$LANG->getLL('newValue',1).':</td>
00794 <td>'.$LANG->getLL('difference',1).':</td>
00795 </tr>';
00796 break;
00797 }
00798 return $out;
00799 }
00800
00810 function linkPage($str,$inparams=array(),$anchor='') {
00811
00812
00813 $params['sh_uid']=$this->sh_uid;
00814 $params['sumUp']=$this->sumUp;
00815 $params['element']=$this->element;
00816 $params['returnUrl']=$this->returnUrl;
00817
00818
00819 $params = array_merge($params,$inparams);
00820
00821
00822 $Ahref = 'show_rechis.php?'.t3lib_div::implodeArrayForUrl('',$params).($anchor?'#'.$anchor:'');
00823 $link = '<a href="'.htmlspecialchars($Ahref).'">'.$str.'</a>';
00824
00825
00826 return $link;
00827 }
00828
00838 function getChangesSinceRecord($element,$hisUid=0,$hisUid_Stop=0) {
00839 global $TCA;
00840
00841
00842 $sumChangesArray=array();
00843 $sumChangesArray['changes']=array();
00844 $elParts = explode(':',$element);
00845
00846
00847 if ($TCA[$elParts[0]]) {
00848 $times = array();
00849
00850
00851 $addWhere = ' AND sys_history.uid>='.$hisUid;
00852 if ($hisUid_Stop) $addWhere.= ' AND sys_history.uid<='.$hisUid_Stop;
00853
00854 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00855 'sys_history.*,sys_log.userid',
00856 'sys_history,sys_log',
00857 'sys_history.sys_log_uid=sys_log.uid
00858 AND sys_history.tablename="'.$GLOBALS['TYPO3_DB']->quoteStr($elParts[0], 'sys_history').'"
00859 AND sys_history.recuid='.intval($elParts[1]).$addWhere,
00860 '',
00861 'uid DESC'
00862 );
00863
00864
00865 while ($newRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00866 $hisDat = unserialize($newRow['history_data']);
00867 if (is_array($hisDat['newRecord']) && is_array($hisDat['oldRecord'])) {
00868 $sumChangesArray['changes']=array_merge($sumChangesArray['changes'],$hisDat['oldRecord']);
00869 $sumChangesArray['counter']++;
00870 $sumChangesArray['tstamp'][]=$newRow['tstamp'];
00871 $sumChangesArray['userList'][]=$newRow['userid'];
00872 } else {
00873 debug('ERROR!');
00874 }
00875
00876 }
00877 }
00878 return $sumChangesArray;
00879 }
00880 }
00881
00882 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.show_rechis.inc']) {
00883 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.show_rechis.inc']);
00884 }
00885 ?>