![]() |
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 */ 00067 class dataface_actions_ajax_nav_tree_node { 00068 00069 function handle(&$params){ 00070 00071 $app =& Dataface_Application::getInstance(); 00072 $record =& $app->getRecord(); 00073 if ( !$record ){ 00074 echo '{}'; 00075 } 00076 00077 $relationships = $record->_table->getRelationshipsAsActions(); 00078 if ( isset($_GET['-relationship']) ){ 00079 $relationships = array($relationships[$_GET['-relationship']]); 00080 } 00081 $outerOut = array(); 00082 foreach ($relationships as $relationship){ 00083 $innerOut = array(); 00084 $relatedRecords = $record->getRelatedRecordObjects($relationship['name'],0,60); 00085 foreach ($relatedRecords as $relatedRecord){ 00086 $domainRecord = $relatedRecord->toRecord(); 00087 $innerOut[] = "'".$domainRecord->getId()."': ".$domainRecord->toJS(array()); 00088 } 00089 if ( count($relationships) > 1 ){ 00090 $outerOut[] = "'".$relationship['name']."': {'__title__': '".$relationship['label']."', '__url__': '".$record->getURL('-action=related_records_list&-relationship='.urlencode($relationship['name']))."','records': {".implode(',',$innerOut)."}}"; 00091 } else { 00092 $outerOut[] = implode(',',$innerOut); 00093 } 00094 00095 } 00096 echo '{'.implode(',',$outerOut).'}'; 00097 exit; 00098 00099 } 00100 }