Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
GlanceList.php
Go to the documentation of this file.
1 <?php
3 
4  var $records;
6  function Dataface_GlanceList(array $records){
7  $this->records = $records;
8  $this->origRecords = array();
9  foreach ( array_keys($this->records) as $key){
10  $r = $this->records[$key];
11  if ( is_a($this->records[$key], 'Dataface_RelatedRecord') ){
12  $this->records[$key] = $this->records[$key]->toRecord();
13  }
14  $this->origRecords[$this->records[$key]->getId()] = $r;
15  }
16 
17  }
18 
19  function toHtml(){
20 
21  ob_start();
22  df_display(array('records'=>&$this->records, 'list'=>&$this), 'Dataface_GlanceList.html');
23  $out = ob_get_contents();
24  ob_end_clean();
25  return $out;
26  }
27 
28  function oneLineDescription(&$record){
29  $del =& $record->_table->getDelegate();
30  $origRecord = $this->origRecords[$record->getId()];
31  if ( !$origRecord ) $origRecord = $record;
32 
33  if ( is_a($origRecord, 'Dataface_RelatedRecord') ){
34  $origDel = $origRecord->_record->table()->getDelegate();
35  $method = 'rel_'.$origRecord->_relationshipName.'__'.oneLineDescription;
36  if ( isset($origDel) and method_exists($origDel, $method) ){
37  return $del->$method($origRecord);
38  }
39  }
40  if ( isset($del) and method_exists($del, 'oneLineDescription') ){
41  return $del->oneLineDescription($record);
42  }
43 
45  $adel =& $app->getDelegate();
46  if ( isset($adel) and method_exists($adel, 'oneLineDescription') ){
47  return $adel->oneLineDescription($record);
48  }
49  $out = '<span class="Dataface_GlanceList-oneLineDescription">
50  <span class="Dataface_GlanceList-oneLineDescription-title"><a href="'.htmlspecialchars($record->getURL('-action=view')).'" title="View this record">'.htmlspecialchars($origRecord->getTitle()).'</a></span> ';
51  if ( $creator = $record->getCreator() ){
52  $show = true;
53  if ( isset($app->prefs['hide_posted_by']) and $app->prefs['hide_posted_by'] ) $show = false;
54  if ( isset($record->_table->_atts['__prefs__']['hide_posted_by']) and $record->_table->_atts['__prefs__']['hide_posted_by'] ) $show = false;
55  if ( $show ){
56  $out .=
57  '<span class="Dataface_GlanceList-oneLineDescription-posted-by">Posted by '.htmlspecialchars($creator).'.</span> ';
58  }
59  }
60 
61  if ( $modified = $record->getLastModified() ){
62  $show = true;
63  if ( isset($app->prefs['hide_updated']) and $app->prefs['hide_updated'] ) $show = false;
64  if ( isset($record->_table->_atts['__prefs__']['hide_updated']) and $record->_table->_atts['__prefs__']['hide_updated'] ) $show = false;
65  if ( $show ){
66  $out .= '<span class="Dataface_GlanceList-oneLineDescription-updated">Updated '.htmlspecialchars(df_offset(date('Y-m-d H:i:s', $modified))).'</span>';
67  }
68  }
69  $out .= '
70  </span>';
71  return $out;
72 
73 
74  }
75 }
76