Xataface 2.0
Xataface Application Framework
actions/view_history_record_details.php
Go to the documentation of this file.
00001 <?php
00002 class dataface_actions_view_history_record_details {
00003         function handle(&$params){
00004                 $app =& Dataface_Application::getInstance();
00005                 if ( !@$_GET['history__id'] ){
00006                         return PEAR::raiseError('No history id supplied', DATAFACE_E_ERROR);
00007                 }
00008                 $historyid = $_GET['history__id'];
00009                 $query =& $app->getQuery();
00010                 $table = $query['-table'];
00011                 
00012                 import('Dataface/HistoryTool.php');
00013                 $ht = new Dataface_HistoryTool();
00014                 if ( @$_GET['-show_changes'] ){
00015                         $record = $ht->getDiffs($table, $historyid);
00016                 } else {
00017                         $record = $ht->getRecordById($table, $historyid);
00018                 }
00019                 if ( !$record ) return PEAR::raiseError("No history record for table {$table} with history id {$historyid} could be found", DATAFACE_E_ERROR);
00020                 if ( PEAR::isError($record) ) return $record;
00021                 
00022                 $context = array('history_record'=>&$record);
00023                 
00024                 $t =& Dataface_Table::loadTable($table);
00025                 $numfields = count($t->fields());
00026                 $pts = 0;
00027                 $ppf = array();
00028                 foreach ($t->fields() as $field){
00029                         if ( $t->isText($field['name']) ){
00030                                 $pts+=5;
00031                                 $ppf[$field['name']] = $pts;
00032                         } else {
00033                                 $pts++;
00034                                 $ppf[$field['name']] = $pts;
00035                         }
00036                 }
00037                 
00038                 $firstField = null;
00039                 $threshold = floatval(floatval($pts)/floatval(2));
00040                 foreach ( $t->fields()  as $field){
00041                         if ( $ppf[$field['name']] >= $threshold ){
00042                                 $firstField = $field['name'];
00043                                 break;
00044                         }
00045                 }
00046                 
00047                 $context['first_field_second_col'] = $firstField;
00048                 $context['changes'] = @$_GET['-show_changes'];
00049                 $context['table'] =& $t;
00050                 df_display($context, 'Dataface_HistoryRecordDetails.html');
00051                 
00052         }
00053 
00054 }
00055 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations