1 <?php
2 /**
3 * @package Joomla.Libraries
4 * @subpackage Installer
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 jimport('joomla.filesystem.file');
13
14 /**
15 * Joomla! Package Manifest File
16 *
17 * @since 3.1
18 */
19 abstract class JInstallerManifest
20 {
21 /**
22 * Path to the manifest file
23 *
24 * @var string
25 * @since 3.1
26 */
27 public $manifest_file = '';
28
29 /**
30 * Name of the extension
31 *
32 * @var string
33 * @since 3.1
34 */
35 public $name = '';
36
37 /**
38 * Version of the extension
39 *
40 * @var string
41 * @since 3.1
42 */
43 public $version = '';
44
45 /**
46 * Description of the extension
47 *
48 * @var string
49 * @since 3.1
50 */
51 public $description = '';
52
53 /**
54 * Packager of the extension
55 *
56 * @var string
57 * @since 3.1
58 */
59 public $packager = '';
60
61 /**
62 * Packager's URL of the extension
63 *
64 * @var string
65 * @since 3.1
66 */
67 public $packagerurl = '';
68
69 /**
70 * Update site for the extension
71 *
72 * @var string
73 * @since 3.1
74 */
75 public $update = '';
76
77 /**
78 * List of files in the extension
79 *
80 * @var array
81 * @since 3.1
82 */
83 public $filelist = array();
84
85 /**
86 * Constructor
87 *
88 * @param string $xmlpath Path to XML manifest file.
89 *
90 * @since 3.1
91 */
92 public function __construct($xmlpath = '')
93 {
94 if ($xmlpath !== '')
95 {
96 $this->loadManifestFromXml($xmlpath);
97 }
98 }
99
100 /**
101 * Load a manifest from a file
102 *
103 * @param string $xmlfile Path to file to load
104 *
105 * @return boolean
106 *
107 * @since 3.1
108 */
109 public function loadManifestFromXml($xmlfile)
110 {
111 $this->manifest_file = basename($xmlfile, '.xml');
112
113 $xml = simplexml_load_file($xmlfile);
114
115 if (!$xml)
116 {
117 $this->_errors[] = JText::sprintf('JLIB_INSTALLER_ERROR_LOAD_XML', $xmlfile);
118
119 return false;
120 }
121 else
122 {
123 $this->loadManifestFromData($xml);
124
125 return true;
126 }
127 }
128
129 /**
130 * Apply manifest data from a SimpleXMLElement to the object.
131 *
132 * @param SimpleXMLElement $xml Data to load
133 *
134 * @return void
135 *
136 * @since 3.1
137 */
138 abstract protected function loadManifestFromData(SimpleXmlElement $xml);
139 }
140