Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
feed.php
Go to the documentation of this file.
1 <?php
13 
17  function handle(&$params){
18  import('Dataface/FeedTool.php');
20  $ft = new Dataface_FeedTool();
21 
22 
23  $query = $app->getQuery();
24  if ( @$query['-relationship'] ){
25  $record =& $app->getRecord();
26  $perms = $record->getPermissions(array('relationship'=>$query['-relationship']));
27  if ( !@$perms['related records feed'] ) return Dataface_Error::permissionDenied('You don\'t have permission to view this relationship.');
28 
29 
30  }
31 
32  header("Content-Type: application/xml; charset=".$app->_conf['oe']);
33  $conf = $ft->getConfig();
34 
35  $query['-skip'] = 0;
36  if ( !isset($query['-sort']) and !@$query['-relationship']){
37  $table =& Dataface_Table::loadTable($query['-table']);
38  $modifiedField = $table->getLastUpdatedField(true);
39  if ( $modifiedField ){
40  $query['-sort'] = $modifiedField.' desc';
41  }
42  }
43 
44  if ( !isset($query['-limit']) and !@$query['-relationship']){
45  $default_limit = $conf['default_limit'];
46  if ( !$default_limit ){
47  $default_limit = 60;
48  }
49  $query['-limit'] = $default_limit;
50  }
51 
52  if ( isset($query['--format']) ){
53  $format = $query['--format'];
54  } else {
55  $format = 'RSS1.0';
56  }
57  echo $ft->getFeedXML($query,$format);
58  exit;
59  }
60 }
61 
62 ?>