SHOW:
|
|
- or go back to the newest paste.
| 1 | public function handleExportToCockatrice() | |
| 2 | - | public function handleExportToCockatrice() {
|
| 2 | + | {
|
| 3 | - | header('Content-type: text/xml');
|
| 3 | + | $template = $this->createTemplate(); |
| 4 | - | header('Pragma: public');
|
| 4 | + | $template->setFile('...');
|
| 5 | - | header('Cache-control: private');
|
| 5 | + | |
| 6 | - | header('Expires: -1');
|
| 6 | + | $cards = $this->db->table("cards");
|
| 7 | - | header("Content-disposition: attachment;filename=\"cardsTcg.xml\"");
|
| 7 | + | |
| 8 | - | $this->setLayout("xml");
|
| 8 | + | |
| 9 | $cardsPath[$card->id] = $url . "cards/" . Nette\Utils\Strings::webalize($card->name) . ".png"; | |
| 10 | - | $cards = $this->db->table("cards");
|
| 10 | + | |
| 11 | ||
| 12 | $template->cardsXml = $cards; | |
| 13 | - | $fileName = str_replace(array('ě', 'š', 'č', "ř", "ž", "ý", "á", "í", "é"), array('e', 's', 'c', "r", "z", "y", "a", "i", "e"), $card->name);
|
| 13 | + | $template->paths = $cardsPath; |
| 14 | - | $fileName = preg_replace('/[^a-z0-9]+/', '_', strtolower($fileName));
|
| 14 | + | |
| 15 | - | $url = $this->getContext()->httpRequest->getUrl()->getBaseUrl(); |
| 15 | + | $tmpFile = $this->context->expand('%tempDir%/cardXml/' . $this->user->id '.xml');
|
| 16 | $template->save($tmpFile); | |
| 17 | - | $cardsPath[$card->id] = $url . "cards/" . $fileName . ".png"; |
| 17 | + | |
| 18 | $this->sendResponse(new FileReponse($tmpFile)); | |
| 19 | } |