Esempio n. 1
0
 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();
     $pgoto = $grid->pgoto();
     $stop = $grid->getPagelen();
     $Begin = $pgoto + 1;
     $End = $pgoto + $stop;
     $fields = array();
     foreach ($grid->ExtFields as $obt) {
         $fields[] = lcfirst($obt['field']);
     }
     $xml = '<?xml version="1.0"?>';
     $xml .= "<data>";
     $xml .= "<header>";
     $xml .= $this->writeElement('field', (string) count($grid->ExtFields));
     //$Extfields
     $xml .= $this->writeElement('numberOfResults', (string) count($Record));
     $xml .= $this->writeElement('totalRecords', (string) $grid->getTotalrecord());
     $xml .= $this->writeElement('orderBy', (string) $grid->getOrder());
     $xml .= $this->writeElement('orderType', (string) $grid->getType());
     $xml .= $this->writeElement('page', (string) $grid->pageselected());
     $xml .= $this->writeElement('totalpage', (string) $grid->getTotalpage());
     $xml .= $this->writeElement('pagelen', (string) $grid->getPagelen());
     $xml .= $this->writeElement('filter', (string) $grid->get_textSearch());
     $xml .= $this->writeElement('viewingRows', $Begin . ' - ' . $End);
     $xml .= $this->writeElement('fields', join(',', $fields));
     $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'] );
     $xml .= "</header>";
     //print_r($Record);
     //echo $this->intTotalrecords;
     //echo count($Record);
     if (count($Record) > 0) {
         $xml .= "<items>";
         foreach ($Record as $rs) {
             $xml .= "<" . $grid->getObjName() . " rownumber='" . $rs['rowid'] . "' " . ">";
             $i = 0;
             while (isset($grid->ExtFields[$i]['field'])) {
                 $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($grid->ExtFields[$i]['field'], $strcell);
                 ++$i;
                 //$xml .= "</".$this->objName.">";
             }
             $xml .= "</" . $grid->getObjName() . ">";
         }
         $xml .= "</items>";
     } else {
         $xml .= "<items/>";
     }
     $xml .= "</data>";
     return $xml;
 }