Xataface 2.0
Xataface Application Framework
actions/RecordBrowser_data.php
Go to the documentation of this file.
00001 <?php
00002 /*-------------------------------------------------------------------------------
00003  * Xataface Web Application Framework
00004  * Copyright (C) 2005-2008 Web Lite Solutions Corp (shannah@sfu.ca)
00005  * 
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  * 
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019  *-------------------------------------------------------------------------------
00020  */
00068 class dataface_actions_RecordBrowser_data {
00069         function handle(&$params){
00070                 $app =& Dataface_Application::getInstance();
00071                 //$out = array();
00072                 $query =& $app->getQuery();
00073                 $records = df_get_records_array($query['-table'], $query);
00074                 header("Content-type: text/html; charset=".$app->_conf['oe']);
00075                 foreach ($records as $record){
00076                 
00077                         // First lets get the value that we are using for this option
00078                         $value = null;
00079                         if ( @$query['-value'] == '__id__' ){
00080                                 // Use the record id as the value
00081                                 $value = $record->getId();
00082                         } else if ( @$query['-value'] ){
00083                                 // We have an explicitly specified column to use as the key.
00084                                 $value = $record->val($query['-value']);
00085                                 
00086                         } else if ( count($record->_table->keys()) > 1 ){
00087                                 // This record has a compound key and no value column was specified
00088                                 // so we use the record id.
00089                                 $value = $record->getId();
00090                         } else {
00091                                 // This record has a single key column so we return its value
00092                                 $value = $record->val(reset(array_keys($record->_table->keys())));
00093                                 
00094                         }
00095                         
00096                         // Now let's get the text that we are using for this option
00097                         $text = null;
00098                         switch (strval(@$query['-text'])){
00099                                 case '':
00100                                 case '__title__':
00101                                         $text = $record->getTitle();
00102                                         break;
00103                                 default:
00104                                         $text = $record->display($query['-text']);
00105                                         break;
00106                         
00107                         }
00108                         echo '<option value="'.htmlspecialchars($value).'">'.htmlspecialchars($text).'</option>'."\n";
00109                         
00110                 }
00111                 exit;
00112                 
00113                 
00114         }
00115 }
 All Data Structures Namespaces Files Functions Variables Enumerations