Development

/plugins/sfDoctrineAdminGeneratorWithShowPlugin/trunk/data/generator/sfDoctrineModule/adminWithShow/parts/xmlAction.php

You must first sign up to be able to contribute.

root/plugins/sfDoctrineAdminGeneratorWithShowPlugin/trunk/data/generator/sfDoctrineModule/adminWithShow/parts/xmlAction.php

Revision 16990, 2.1 kB (checked in by pcahard, 4 years ago)

[sfDoctrineAdminGeneratorWithShowPlugin] fixed some bugs.

Line 
1   public function executeXml(sfWebRequest $request)
2   {
3     $this-><?php echo $this->getPluralName() ?> = Doctrine::getTable('<?php echo $this->getModelClass() ?>')->findAll();
4     $this->exportToXml();
5   }
6  
7   public function executeBatchXml(sfWebRequest $request)
8   {
9  
10     $ids = $request->getParameter('ids');
11
12     $this-><?php echo $this->getPluralName() ?> = Doctrine_Query::create()
13       ->from('<?php echo $this->getModelClass() ?>')
14       ->whereIn('id', $ids)
15       ->execute();
16
17     if ( ! $this-><?php echo $this->getPluralName() ?> )
18     {
19       $this->getUser()->setFlash('error', 'A problem occurs when exporting the selected items.');
20     }else
21     {
22       $this->exportToXml();
23     }
24   }
25  
26   public function exportToXml()
27   {
28     $this->separator = ';';
29    
30     $this->xw = new xmlWriter();
31     $this->xw->openMemory();
32     $this->xw->startDocument('1.0', 'UTF-8');
33     $this->xw->setIndent(1);
34     $this->xw->startElement('root');
35    
36     foreach($this-><?php echo $this->getPluralName() ?> as $<?php echo $this->getSingularName() ?>)
37     {
38       $this->xw->startElement('structure');
39       foreach($this->configuration->getXmlDisplay() as $display)
40       {
41         $this->xw->writeElement($display, $<?php echo $this->getSingularName() ?>->get($display));
42       }
43       $this->xw->endElement();   
44     }
45     $this->xw->endElement();
46     $this->xw->endDtd();
47
48     $this->content = $this->xw->outputMemory(true) ;
49    
50     $this->setLayout(false);
51     $this->setTemplate('export');
52        
53     $this->getResponse()->clearHttpHeaders();
54     $this->getResponse()->setContentType('text/xml');
55     $this->getResponse()->addHttpMeta('content-disposition: ', 'attachment; filename=' . $this->configuration->getXmlFilename() . '.xml', true);
56    
57    
58     if($this->getRequest()->getMethod() == sfWebRequest::POST)
59     {
60       $this->getResponse()->setContent($this->content);
61       $this->getResponse()->send();
62       $this->setTemplate(false);
63       // for an obscure raison, sfResponse return a error with sfView::NONE
64       // so stop with die the script..
65       die;
66       //return sfView::NONE;
67     }       
68        
69   }
70
Note: See TracBrowser for help on using the browser.