![]() |
Xataface 2.0
Xataface Application Framework
|
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 */ 00021 class dataface_actions_ajax_view_record_details { 00022 function handle(&$params){ 00023 $app =& Dataface_Application::getInstance(); 00024 00025 $query =& $app->getQuery(); 00026 $record =& $app->getRecord(); 00027 00028 if ( !$record ) return PEAR::raiseError("No record could be found that matches the query.", DATAFACE_E_ERROR); 00029 if ( PEAR::isError($record) ) return $record; 00030 00031 $context = array('record'=>&$record); 00032 00033 $t =& $record->_table; 00034 $fields = array(); 00035 foreach ( $t->fields(false,true) as $field){ 00036 if ( $record->checkPermission('view', array('field'=>$field['name']))){ 00037 $fields[$field['name']] = $field; 00038 } 00039 } 00040 $numfields = count($fields); 00041 $pts = 0; 00042 $ppf = array(); 00043 foreach (array_keys($fields) as $field){ 00044 if ( $t->isText($field) ){ 00045 $pts+=5; 00046 $ppf[$field] = $pts; 00047 } else { 00048 $pts++; 00049 $ppf[$field] = $pts; 00050 } 00051 } 00052 00053 $firstField = null; 00054 $threshold = floatval(floatval($pts)/floatval(2)); 00055 foreach ( array_keys($fields) as $field){ 00056 if ( $ppf[$field] >= $threshold ){ 00057 $firstField = $field; 00058 break; 00059 } 00060 } 00061 00062 $context['first_field_second_col'] = $firstField; 00063 $context['table'] =& $t; 00064 $context['fields'] =& $fields; 00065 header('Content-type: text/html; charset='.$app->_conf['oe']); 00066 df_display($context, 'Dataface_AjaxRecordDetails.html'); 00067 00068 } 00069 00070 } 00071 ?>