This repository has been archived by the owner on Nov 26, 2017. It is now read-only.
/
xml.php
94 lines (83 loc) · 1.73 KB
/
xml.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* @package Joomla.Platform
* @subpackage Document
*
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
jimport('joomla.document.document');
/**
* DocumentXML class, provides an easy interface to parse and display XML output
*
* @package Joomla.Platform
* @subpackage Document
* @since 11.1
*/
class JDocumentXml extends JDocument
{
/**
* Document name
*
* @var string
* @since 11.1
*/
protected $_name = 'joomla';
/**
* Class constructor
*
* @param array $options Associative array of options
*
* @since 11.1
*/
public function __construct($options = array())
{
parent::__construct($options);
//set mime type
$this->_mime = 'application/xml';
//set document type
$this->_type = 'xml';
}
/**
* Render the document.
*
* @param boolean $cache If true, cache the output
* @param array $params Associative array of attributes
*
* @return The rendered data
*
* @since 11.1
*/
public function render($cache = false, $params = array())
{
parent::render();
JResponse::setHeader('Content-disposition', 'inline; filename="' . $this->getName() . '.xml"', true);
return $this->getBuffer();
}
/**
* Returns the document name
*
* @return string
*
* @since 11.1
*/
public function getName()
{
return $this->_name;
}
/**
* Sets the document name
*
* @param string $name Document name
*
* @return JDocumentXml instance of $this to allow chaining
*
* @since 11.1
*/
public function setName($name = 'joomla')
{
$this->_name = $name;
return $this;
}
}