![]() |
Xataface 2.0
Xataface Application Framework
|
00001 <?php 00002 class dataface_actions_ajax_get_event_details { 00003 00004 function handle(&$params){ 00005 00006 $app =& Dataface_Application::getInstance(); 00007 $query =& $app->getQuery(); 00008 00009 $record_id = $query['--record_id']; 00010 if ( !$record_id ) trigger_error("No record id provided", E_USER_ERROR); 00011 00012 $record =& df_get_record_by_id($record_id); 00013 00014 $fields =& $record->_table->fields(false, true); 00015 00016 header('Content-type: text/json; charset='.$app->_conf['oe']); 00017 00018 //$out = ''; 00019 00020 //$out .= '<table class="record-view-table"><tbody>'; 00021 $dl = array(); 00022 foreach ( $fields as $field ){ 00023 //if ( !$record->val($field['name']) ) continue; 00024 00025 if ( !$record->checkPermission('view', array('field'=>$field['name'])) ) continue; 00026 if ( $field['visibility']['browse'] == 'hidden' ) continue; 00027 $val = $record->htmlValue($field['name']); 00028 if ( @$app->_conf['_prefs']['calendar.edit.inline'] and $record->checkPermission('edit', array('field'=>$field['name'])) and in_array($field['name'], array_keys($record->_table->fields())) ){ 00029 $class = 'df__editable_wrapper'; 00030 } else { 00031 $class = ''; 00032 } 00033 $dl[] = array('fielddef'=>&$field, 'tdid'=> 'td-'.rand(), 'value'=>$val, 'tdclass'=>$class); 00034 //$out .= '<tr><th>'.htmlspecialchars($field['widget']['label']).'</th><td id="td-'.rand().'" class="'.$class.'">'.$val.'</td></tr>'; 00035 unset($field); 00036 } 00037 //$out .= '</tbody></table>'; 00038 //import('Dataface/Ontology.php'); 00039 00040 //Dataface_Ontology::registerType('Event', 'Dataface/Ontology/Event.php', 'Dataface_Ontology_Event'); 00041 //$ontology =& Dataface_Ontology::newOntology('Event', $query['-table']); 00042 00043 //$event =& $ontology->newIndividual($record); 00044 00045 ob_start(); 00046 df_display(array('fields'=>&$dl, 'event'=>&$record), 'Dataface_AjaxEventDetails.html'); 00047 $out = ob_get_contents(); 00048 ob_end_clean(); 00049 00050 $response = array('record_id'=>$record_id, 'details'=>$out); 00051 00052 import('Services/JSON.php'); 00053 $json = new Services_JSON; 00054 echo $json->encode($response); 00055 exit; 00056 00057 00058 } 00059 00060 }