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 /**
13 * Joomla! Package Manifest File
14 *
15 * @since 3.1
16 */
17 class JInstallerManifestPackage extends JInstallerManifest
18 {
19 /**
20 * Unique name of the package
21 *
22 * @var string
23 * @since 3.1
24 */
25 public $packagename = '';
26
27 /**
28 * Website for the package
29 *
30 * @var string
31 * @since 3.1
32 */
33 public $url = '';
34
35 /**
36 * Scriptfile for the package
37 *
38 * @var string
39 * @since 3.1
40 */
41 public $scriptfile = '';
42
43 /**
44 * Flag if the package blocks individual child extensions from being uninstalled
45 *
46 * @var boolean
47 * @since 3.7.0
48 */
49 public $blockChildUninstall = false;
50
51 /**
52 * Apply manifest data from a SimpleXMLElement to the object.
53 *
54 * @param SimpleXMLElement $xml Data to load
55 *
56 * @return void
57 *
58 * @since 3.1
59 */
60 protected function loadManifestFromData(SimpleXMLElement $xml)
61 {
62 $this->name = (string) $xml->name;
63 $this->packagename = (string) $xml->packagename;
64 $this->update = (string) $xml->update;
65 $this->authorurl = (string) $xml->authorUrl;
66 $this->author = (string) $xml->author;
67 $this->authoremail = (string) $xml->authorEmail;
68 $this->description = (string) $xml->description;
69 $this->packager = (string) $xml->packager;
70 $this->packagerurl = (string) $xml->packagerurl;
71 $this->scriptfile = (string) $xml->scriptfile;
72 $this->version = (string) $xml->version;
73
74 if (isset($xml->blockChildUninstall))
75 {
76 $value = (string) $xml->blockChildUninstall;
77
78 if ($value === '1' || $value === 'true')
79 {
80 $this->blockChildUninstall = true;
81 }
82 }
83
84 if (isset($xml->files->file) && count($xml->files->file))
85 {
86 foreach ($xml->files->file as $file)
87 {
88 // NOTE: JInstallerExtension doesn't expect a string.
89 // DO NOT CAST $file
90 $this->filelist[] = new JInstallerExtension($file);
91 }
92 }
93
94 // Handle cases where package contains folders
95 if (isset($xml->files->folder) && count($xml->files->folder))
96 {
97 foreach ($xml->files->folder as $folder)
98 {
99 // NOTE: JInstallerExtension doesn't expect a string.
100 // DO NOT CAST $folder
101 $this->filelist[] = new JInstallerExtension($folder);
102 }
103 }
104 }
105 }
106