Location: PHPKode > projects > ZZ/OSS Installer > zic-1.1.0dev1/installer/info.php
<?php   
    /*
    Copyright (C) 2001-2004 ZZOSS GbR, http://www.zzoss.com

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    */
    
    /**
    @version $Id: info.php,v 1.7 2004/04/05 10:17:56 ordnas Exp $
    @copyright Copyright &copy; 2001-2004 ZZ/OSS GbR, http://www.zzoss.com
    @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
    */
	
	// execute init file
	require_once 'inc/init.php';
    include 'inc/info.php';
	
    $widget_type = '_popup';
    
    if(isset($_REQUEST['widget_type'])){
        if($_REQUEST['widget_type'] == '_self'){
            $widget_type = '';
        } else {
            $widget_type = '_popup';
        }
    }
	include 'themes/'.$GLOBALS['ZI']['theme'].'/header'.$widget_type.'.php';
?>
<h1>Information</h1>
<?php
	
    switch($_REQUEST['type']){
        case 'distribution_remote':
            $header = 'Distribution';
            
            // load selected distribution
            $file = $GLOBALS['ZI']['installer_data_dir'].'installer/remote_distributions.xml';
            $distributions_xml = new ZZOSS_Config(array('numeric' => array('distribution')));
            $distributions_xml->setFile($file);
            $distributions = $distributions_xml->query('/distributions/distribution');
            $distribution = $distributions[$_REQUEST["id"]];
            $file = $GLOBALS['ZI']['installer_data_dir'].'installer/remote_distribution.xml';
            if(file_exists($file)) {
                unlink($file);
            }
            $items = array('Distribution XML');
            $label = 'Downloading';
            
            require_once 'ZZOSS_Html/Progress.php';
            $bar = new ZZOSS_HtmlProgress();
            $bar->prepareListHorizontal($items, 'Downloading');
            
            require_once 'ZZOSS_File/Download.php';
            $download = new ZZOSS_FileDownload();
            $download->setCallback(array(&$bar, '_downloadCallback'));
            
            $download->download($distribution["filelist"]["descriptor"]["#"], $file);

            if(file_exists($file)) {
                $distribution_config = new ZZOSS_Config(array('cache' => true, 'numeric' => array('license','maintainer','holder')));
                $distribution_config->setFile($file); 
                $info = $distribution_config->query('/distribution');
            }
            break;
        case 'distribution':
            $header = 'Distribution';
            
            // load selected package
            $distribution = $zi_registry->getDistribution($_REQUEST["distribution"]);
            // make those items a numeric array where more than one element with the same name occurs
            // on the same level
            require_once 'ZZOSS_Config/Config.php';
            $info = ZZOSS_Config::prepareNumeric($distribution, array('license', 'maintainer', 'holder'));
            break;
        case 'application_remote':
            $header = 'Application';
        	// download application.xml
            $file =  $GLOBALS['ZI']['installer_data_dir'].'installer/remote_applications.xml';
            $file_application =  $GLOBALS['ZI']['installer_data_dir'].'installer/remote_application.xml';
            if(file_exists($file_application)) {
                unlink($file_application);
            }
            $remote_applications_xml = new ZZOSS_Config(array('numeric' => array('application','descriptor')));
            $remote_applications_xml->setFile($file);
            $remote_applications = $remote_applications_xml->query('/applications/application');
            $remote_application = $remote_applications[$_REQUEST["id"]];
            
            $items = array('Application XML');
            $label = 'Downloading';
            
            require_once 'ZZOSS_Html/Progress.php';
            $bar = new ZZOSS_HtmlProgress();
            $bar->prepareListHorizontal($items, 'Downloading');
            
            require_once 'ZZOSS_File/Download.php';
            $download = new ZZOSS_FileDownload();
            $download->setCallback(array(&$bar, '_downloadCallback'));
        
            // download application.xml and packages.xml
            if(is_array($remote_application["filelist"]["descriptor"])) {
                foreach($remote_application["filelist"]["descriptor"] as $descriptor) {
                    if($descriptor["@"]["role"] == 'application') {
                        $download->download($descriptor["#"], $file_application);
                    }
                }
            }

            if(file_exists($file_application)) {
                $application_config = new ZZOSS_Config(array('numeric' => array('license','maintainer','holder')));
                $application_config->setFile($file_application);
                $info = $application_config->query('/application');
            }
            break;
        case 'application':
            $header = 'Application';
            // load selected package
            if(isset($_REQUEST["id"])){
                $application = $zi_registry->getApplicationById($_REQUEST["id"]);
            } elseif(isset($_REQUEST['distribution']) && isset($_REQUEST['application'])){
                $application = $zi_registry->getApplication($_REQUEST['application'], $_REQUEST['distribution']);
            } else {
                PEAR::raiseError('Cannot identify application');
            }
            // make those items a numeric array where more than one element with the same name occurs
            // on the same level
            require_once 'ZZOSS_Config/Config.php';
            $info = ZZOSS_Config::prepareNumeric($application, array('license', 'maintainer', 'holder'));
            break;
        case 'plugin':
        case 'package':
            $header = 'Package';
            $zi_registry->setPackageType($_REQUEST['type']);
            $info = $zi_registry->getPackageById($_REQUEST["id"]);
            if($info["install"]["type"] == 'remote') {
                $zi_registry->unsetPackageRemoteInfo();
                
                $items = array('Package XML');
                $label = 'Downloading';
                
                require_once 'ZZOSS_Html/Progress.php';
                $bar = new ZZOSS_HtmlProgress();
                $bar->prepareListHorizontal($items, 'Downloading');
                
                require_once 'ZZOSS_File/Download.php';
                $download = new ZZOSS_FileDownload();
                $download->setCallback(array(&$bar, '_downloadCallback'));
            
                $file = $zi_registry->getApplicationPath().'installer'.DIRECTORY_SEPARATOR.'remote_package.xml';
                $package = $zi_registry->getPackageById($_REQUEST['id']);
                $download->download($package["filelist"]["descriptor"]["#"], $file);

                $info = $zi_registry->getPackageRemoteInfo();
            }
            $info = ZZOSS_Config::prepareNumeric($info, array('license','maintainer','holder'));
            break;
    }
	
    if(isset($info["changelog"]) && is_array($info["changelog"])) {
        $zi_buttons['next'] = 'info_changelog.php'.zi_form_querystr();
    }
    
    $content = '';
    // Show the installation paths if it is an installed application
    if($_REQUEST['type'] == 'application' && isset($info['installed'])){
        $settings = $zi_registry->getApplicationSettings($info['name'].'-'.$info['release']['version'], $_REQUEST['distribution']);
        $content .= zi_info_td('Install Root', $settings['application_root']);
        $content .= zi_info_td('Install URL', '<a href="'.$settings['application_url'].'" target="_blank">'.$settings['application_url'].'</a>');
    }
    $content .= zi_info_td('Description', zi_info_text($info["description"]) );
	$content .= zi_info_td('Distinguished Name', $info["name"] );
    if($_REQUEST['type'] == 'package'){
        $application = $zi_registry->getApplication();
        $content  .= zi_info_td('Application', $application['summary'].' '.$application['release']['version']);
    }
    if($_REQUEST['type'] != 'distribution'){
        $distribution = $zi_registry->getDistribution();
        $content  .= zi_info_td('Distribution', $distribution['summary'].' '.$distribution['release']['version']);
    }
	$content .= zi_info_td('Version', $info["release"]["version"] );
	$content .= zi_info_td('Release Date', $info["release"]["date"] );
	$content .= zi_info_td('State', zi_info_text($info["release"]["state"]) );
    if(isset($info['homepage'])){
        $content .= zi_info_td('Homepage', zi_info_text($info['homepage']) );
    }
	$content .= zi_info_td('Licenses', zi_info_licenses($info["release"]["license"]) );
    if(isset($info["release"]["copyright"]['holder'])){
        $content .= zi_info_td('Copyrights', zi_info_copyrights($info["release"]["copyright"]['holder']) );
    }
    if(isset($info["maintainers"]["maintainer"])){
        $content .= zi_info_td('Maintainers', zi_info_maintainers($info["maintainers"]["maintainer"]) );
    }
	$content .= zi_info_td('Notes', zi_info_text($info["release"]["notes"]) );
    if($_REQUEST['type'] == 'package'){
        $header = $info['name'].'-'.$info["release"]["version"].'<br/>'.$info["summary"];
    } else {
        $header = $info["summary"].' '. $info["release"]["version"];
    }
	echo zi_info_table($header, $content);
    ?>
    <div class="contextlink">
        <?php
            if(isset($info["changelog"]) && is_array($info["changelog"])) {
                ?>
                [ <a href="info_changelog.php<?php echo zi_form_querystr(); ?>">Older Versions</a> ]
                <?php
            }
        ?>
    </div>
<?php
	include 'themes/'.$GLOBALS['ZI']['theme'].'/footer'.$widget_type.'.php';
?>
Return current item: ZZ/OSS Installer