public function render(Grid_Abstract $grid) { header("Content-Type: text/xml;charset=utf-8"); //$xw->startDocument ( '1.0', 'UTF-8' ); //$xw->endDtd (); //print_r($this->ExtFields); $Record = $grid->query(); $pkId = $grid->getFieldRowId(); $pgoto = $grid->pgoto(); $stop = $grid->getPagelen(); $Begin = $pgoto + 1; $End = $pgoto + $stop; $fields = array(); $fieldtypes = array(); foreach ($grid->ExtFields as $obt) { $fields[] = $this->fieldNameFormat($obt['field']); $fieldtypes[] = $this->fieldNameFormat($obt['type']); } $xml = '<?xml version="1.0"?>'; $xml .= "<data>"; $xml .= "<header>"; $xml .= $this->writeElement('field', (string) count($grid->ExtFields), 'integer'); //$Extfields $xml .= $this->writeElement('numberOfResults', (string) count($Record), 'integer'); $xml .= $this->writeElement('totalRecords', (string) $grid->getTotalrecord(), 'integer'); $xml .= $this->writeElement('orderBy', (string) $grid->getOrder(), 'integer'); $xml .= $this->writeElement('orderFieldName', (string) $grid->ExtFields[$grid->getOrder()]['field'], 'integer'); $xml .= $this->writeElement('orderType', (string) $grid->getType(), 'integer'); $xml .= $this->writeElement('page', (string) $grid->pageselected(), 'integer'); $xml .= $this->writeElement('totalpage', (string) $grid->getTotalpage(), 'integer'); $xml .= $this->writeElement('pagelen', (string) $grid->getPagelen(), 'integer'); $xml .= $this->writeElement('filter', (string) $grid->get_textSearch()); $xml .= $this->writeElement('viewingRows', $Begin . ' - ' . $End); $xml .= $this->writeElement('fields', join(',', $fields)); $xml .= $this->writeElement('fieldtypes', join(',', $fieldtypes)); $xml .= $this->writeElement('pk', $pkId); $xml .= $this->writeElement('uri', $grid->getAllparam()); //$xml .= $this->writeElement ( 'table',$this->strTable); $xml .= $this->writeElement('sql', $grid->getFullSql()); //$xml .= $this->writeElement ( 'url', $_SERVER['REQUEST_URI'] ); $time_end = microtime_float(); $processTimeSec = $time_end - PROCESS_TIME_START; $xml .= $this->writeElement('processtime', $processTimeSec); $xml .= "</header>"; //print_r($Record); //echo $this->intTotalrecords; //echo count($Record); if (count($Record) > 0) { $xml .= "<items>"; foreach ($Record as $rs) { $xml .= "<" . $grid->getObjName() . " id='" . $rs[$pkId] . "' " . ">"; $i = 0; while (isset($grid->ExtFields[$i]['field'])) { //if(){ // continue; //} $strcell = ''; if (trim($grid->ExtFields[$i]['function']) != '') { $funcName = $grid->ExtFields[$i]['function']; $data = $rs; if (function_exists($funcName)) { $strcell .= call_user_func($funcName, $data); } else { $strcell .= "griderror : NoFuncDefined"; } } else { $strcell .= $rs[$grid->ExtFields[$i]['field']]; } $xml .= $this->writeElement($fields[$i], $strcell, $grid->ExtFields[$i]['type']); ++$i; //$xml .= "</".$this->objName.">"; } $xml .= "</" . $grid->getObjName() . ">"; } $xml .= "</items>"; } else { $xml .= "<items/>"; } $xml .= "</data>"; return $xml; }