/**
* Parse a XML install manifest file.
*
* XML Root tag should be 'install' except for languages which use meta file.
*
* @param string $path Full path to XML file.
*
* @return array XML metadata.
*
* @since 3.0.0
*/
public static function parseXMLInstallFile($path)
{
// Check if xml file exists.
if (!file_exists($path)) {
return false;
}
// Read the file to see if it's a valid component XML file
$xml = simplexml_load_file($path);
if (!$xml) {
return false;
}
// Check for a valid XML root tag.
// Extensions use 'extension' as the root tag. Languages use 'metafile' instead
$name = $xml->getName();
if ($name !== 'extension' && $name !== 'metafile') {
unset($xml);
return false;
}
$data = array();
$data['name'] = (string) $xml->name;
// Check if we're a language. If so use metafile.
$data['type'] = $xml->getName() === 'metafile' ? 'language' : (string) $xml->attributes()->type;
$data['creationDate'] = (string) $xml->creationDate ?: Text::_('JLIB_UNKNOWN');
$data['author'] = (string) $xml->author ?: Text::_('JLIB_UNKNOWN');
$data['copyright'] = (string) $xml->copyright;
$data['authorEmail'] = (string) $xml->authorEmail;
$data['authorUrl'] = (string) $xml->authorUrl;
$data['version'] = (string) $xml->version;
$data['description'] = (string) $xml->description;
$data['group'] = (string) $xml->group;
// Child template specific fields.
if (isset($xml->inheritable)) {
$data['inheritable'] = (string) $xml->inheritable === '0' ? false : true;
}
if (isset($xml->parent) && (string) $xml->parent !== '') {
$data['parent'] = (string) $xml->parent;
}
if ($xml->files && \count($xml->files->children())) {
$filename = basename($path);
$data['filename'] = File::stripExt($filename);
foreach ($xml->files->children() as $oneFile) {
if ((string) $oneFile->attributes()->plugin) {
$data['filename'] = (string) $oneFile->attributes()->plugin;
break;
}
}
}
return $data;
}