Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
ajax_get_event_details.php
Go to the documentation of this file.
1 <?php
3 
4  function handle(&$params){
5 
7  $query =& $app->getQuery();
8 
9  $record_id = $query['--record_id'];
10  if ( !$record_id ) trigger_error("No record id provided", E_USER_ERROR);
11 
12  $record =& df_get_record_by_id($record_id);
13 
14  $fields =& $record->_table->fields(false, true);
15 
16  header('Content-type: application/json; charset='.$app->_conf['oe']);
17 
18  //$out = '';
19 
20  //$out .= '<table class="record-view-table"><tbody>';
21  $dl = array();
22  foreach ( $fields as $field ){
23  //if ( !$record->val($field['name']) ) continue;
24 
25  if ( !$record->checkPermission('view', array('field'=>$field['name'])) ) continue;
26  if ( $field['visibility']['browse'] == 'hidden' ) continue;
27  $val = $record->htmlValue($field['name']);
28  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())) ){
29  $class = 'df__editable_wrapper';
30  } else {
31  $class = '';
32  }
33  $dl[] = array('fielddef'=>&$field, 'tdid'=> 'td-'.rand(), 'value'=>$val, 'tdclass'=>$class);
34  //$out .= '<tr><th>'.htmlspecialchars($field['widget']['label']).'</th><td id="td-'.rand().'" class="'.$class.'">'.$val.'</td></tr>';
35  unset($field);
36  }
37  //$out .= '</tbody></table>';
38  //import('Dataface/Ontology.php');
39 
40  //Dataface_Ontology::registerType('Event', 'Dataface/Ontology/Event.php', 'Dataface_Ontology_Event');
41  //$ontology =& Dataface_Ontology::newOntology('Event', $query['-table']);
42 
43  //$event =& $ontology->newIndividual($record);
44 
45  ob_start();
46  df_display(array('fields'=>&$dl, 'event'=>&$record), 'Dataface_AjaxEventDetails.html');
47  $out = ob_get_contents();
48  ob_end_clean();
49 
50  $response = array('record_id'=>$record_id, 'details'=>$out);
51 
52  import('Services/JSON.php');
53  $json = new Services_JSON;
54  echo $json->encode($response);
55  exit;
56 
57 
58  }
59 
60 }