<?php
/**
 * NoNumber! Extension Manager Details page
 *
 * @package     NoNumber! Extension Manager
 * @version     1.4.0
 *
 * @author      Peter van Westen <peter@nonumber.nl>
 * @link        http://www.nonumber.nl
 * @copyright   Copyright (C) 2010 NoNumber! All Rights Reserved
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 */

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

$ext = JRequest::getVar( 'ext' );

$version = '';

jimport( 'joomla.filesystem.file' );

$xml = '';
if ( JFile::exists( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_'.$ext.DS.'com_'.$ext.'.xml' ) ) {
	$xml = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_'.$ext.DS.'com_'.$ext.'.xml';
} else if ( JFile::exists( JPATH_PLUGINS.DS.'system'.DS.$ext.'.xml' ) ) {
	$xml = JPATH_PLUGINS.DS.'system'.DS.$ext.'.xml';
} else if ( JFile::exists( JPATH_PLUGINS.DS.'editors-xtd'.DS.$ext.'.xml' ) ) {
	$xml = JPATH_PLUGINS.DS.'editors-xtd'.DS.$ext.'.xml';
} else if ( JFile::exists( JPATH_SITE.DS.'modules'.DS.'mod_'.$ext.DS.'mod_'.$ext.'.xml' ) ) {
	$xml = JPATH_SITE.DS.'modules'.DS.'mod_'.$ext.DS.'mod_'.$ext.'.xml';
} else if ( JFile::exists( JPATH_ADMINISTRATOR.DS.'modules'.DS.'mod_'.$ext.DS.'mod_'.$ext.'.xml' ) ) {
	$xml = JPATH_ADMINISTRATOR.DS.'modules'.DS.'mod_'.$ext.DS.'mod_'.$ext.'.xml';
}

if ( $xml ) {
	$xml = JApplicationHelper::parseXMLInstallFile( $xml );
	if ( $xml && isset( $xml['version'] ) ) {
		$version = $xml['version'];
	}
}

echo $version;
exit;