public function Render(Renderer $renderer)
 {
     try {
         $errorReporting = error_reporting(null);
         GetApplication()->SetOperation(OPERATION_COMMIT_DELETE);
         $this->grid->SetState(OPERATION_COMMIT_DELETE);
         $this->grid->GetState()->SetUseGetToExtractPrimaryKeys(true);
         $this->grid->ProcessMessages();
         header('Content-Type: text/xml');
         if ($this->grid->GetErrorMessage() != '') {
             $xmlWriter = XMLWriterFactory::CreateXMLWriter();
             $xmlWriter->StartDocument('1.0', 'UTF-8');
             $xmlWriter->StartElement('response');
             $xmlWriter->WriteElement('type', 'error');
             $xmlWriter->WriteElement('error_message', $this->grid->GetErrorMessage());
             $xmlWriter->EndElement('response');
             echo $xmlWriter->GetResult();
         } else {
             $xmlWriter = XMLWriterFactory::CreateXMLWriter();
             $xmlWriter->StartDocument('1.0', 'UTF-8');
             $xmlWriter->StartElement('response');
             $xmlWriter->WriteElement('type', 'OK');
             $xmlWriter->EndElement('response');
             echo $xmlWriter->GetResult();
         }
         error_reporting($errorReporting);
     } catch (Exception $e) {
         echo '<?xml version="1.0" encoding="UTF-8"?><response><type>error</type><error_message>' . htmlspecialchars($e->getMessage()) . '</error_message></response>';
     }
 }
示例#2
0
 public static function ToXML($data, $startElement = 'fx_request', $xml_version = '1.0', $xml_encoding = 'UTF-8')
 {
     $xmlWriter = XMLWriterFactory::CreateXMLWriter();
     $xmlWriter->StartDocument($xml_version, $xml_encoding);
     $xmlWriter->StartElement($startElement);
     function write(IPGXMLWriter $xmlWriter, $data)
     {
         foreach ($data as $key => $value) {
             if (is_array($value)) {
                 $xmlWriter->StartElement($key);
                 write($xmlWriter, $value);
                 $xmlWriter->EndElement($key);
                 continue;
             }
             $xmlWriter->WriteElement($key, $value);
         }
     }
     write($xmlWriter, $data);
     $xmlWriter->EndElement($startElement);
     return $xmlWriter->GetResult();
 }