Location: PHPKode > projects > ZZ/OSS Installer > zic-1.1.0dev1/installer/applications.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: applications.php,v 1.24 2004/04/06 19:51:09 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';
	
    /***************************************************************************   
    * INSTALLER FRAMEWORK FUNCTIONS                                            *   
    ***************************************************************************/   
	
	function zi_process()
	{
        global $zi_registry;
        
        if(strlen($_FILES['bundle']['tmp_name'])){
            $data_dir = $zi_registry->getDir();
            $data_dir_dev = 'bundles'.DIRECTORY_SEPARATOR;
            if(isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'dev'){
                $data_dir_dev .= $dat_dir_dev.'dev'.DIRECTORY_SEPARATOR;
            }
            if (move_uploaded_file($_FILES['bundle']['tmp_name'], $data_dir.$_FILES['bundle']['name'] )) {
                // Extract the bundled installer.
                require_once 'ZZOSS_Package/Package.php';
                ZZOSS_Package::extractBundle($data_dir.$_FILES['bundle']['name'], $data_dir, $data_dir_dev);
            }
        }
	}

    // Check for actions
    if(isset($_REQUEST['action']) && strlen($_REQUEST['action'])){
        $action_redirect = '';
        
        switch($_REQUEST['action']){
            case  'install':
                $action_redirect = 'application_install.php'.zi_form_querystr();
                break;
            case 'options':
                 $procedures = array(
                    'packages_build'=> 'on',
                    '_dest'         => 'applications.php'.zi_form_querystr()
                    );
                $zi_registry->setProcedures($procedures);
                $action_redirect = 'plugins_process.php'.zi_form_querystr().'&step=0';
            break;
            case  'remove':
                $action_redirect = 'application_delete.php'.zi_form_querystr();
                break;
            case 'update':
                $action_redirect = 'application_update.php'.zi_form_querystr();
                break;
            case 'plugins':
                $procedures = array(
                    'plugins_manager' => 'on',
                    'plugins_confirm' => 'on',
                    'plugins_register' => 'rm_installed',
                    'plugins_fileroles' => 'on',
                    'plugins_build' => 'on'
                    );
                $zi_registry->setProcedures($procedures);
                $_REQUEST['type'] = 'plugin';
                $action_redirect = 'packages.php'.zi_form_querystr();
                break;
            case 'packages':
                $procedures = array(
                    'packages_manager' => 'on',
                    'packages_confirm' => 'on',
                    'packages_register' => 'rm_installed',
                    'packages_fileroles' => 'on',
                    'packages_build' => 'on'
                    );
                $zi_registry->setProcedures($procedures);
                $action_redirect = 'packages.php'.zi_form_querystr();
                break;
            case 'bundle':
                $action_redirect = 'dev_bundle.php'.zi_form_querystr();
                break;
            case 'descriptors':
                $action_redirect = 'dev_application_import.php'.zi_form_querystr();
                break;
        }
        
        header('Location: '.$action_redirect);
        exit;
    }
    
    /***************************************************************************   
    * PAGE CONTENT                                                             *   
    ***************************************************************************/   
	
	require_once 'themes/'.$GLOBALS['ZI']['theme'].'/header.php';
    
    if(isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'dev') {
        ?><h1>Develop Applications</h1><?php
    } else {
        ?><h1>Manage Applications</h1><?php
    }
    
    // Single Distribution Mode
    if(strlen($GLOBALS['ZI']['distribution'])){
        $distribution = $zi_registry->getDistribution($GLOBALS['ZI']['distribution']);
        $distributions[$distribution['name']] = $distribution;
    } else {
        $distributions = $zi_registry->getDistributions();
    }
    
        
    $hasApplications = false;
      
    if(is_array($distributions) && count($distributions)){
        
        // iterate distributions and show their applications
        foreach($distributions as $distribution){
            $applications = $zi_registry->getApplications($distribution['name'].'-'.$distribution['release']['version']);
            if(!count($applications)){
                // delete this distribution because there are no applications
                // available for it.
                $zi_registry->removeDistribution($distribution['name'].'-'.$distribution['release']['version']);
            } else {
                $hasApplications = true;
                ob_start();
                ?>
                <h2><a href="info.php?mode=<?php echo $_REQUEST['mode']; ?>&type=distribution&distribution=<?php echo $distribution['name'].' '.$distribution['release']['version']; ?>" onclick="javascript:window.open('info.php?mode=<?php echo $_REQUEST['mode']; ?>&type=distribution&distribution=<?php echo $distribution['name'].' '.$distribution['release']['version']; ?>', 'DistributionInformation', 'width=500,height=500,resizable=1,status=0,scrollbars=1,toolbar=0,location=0,directories=0,menubar=0,dependent=0');void(0);javascript:return(false);" target="_blank"><?php echo $distribution['summary'].' '.$distribution['release']['version']; ?></a></h2>
                <table class="list">
                    <tr>
                        <th align="left">Application</th>
                        <th align="center">Available</th>
                        <th align="center">Installed</th>
                        <th align="center">Actions</th>
                    </tr>
                    <?php
                $list_header = ob_get_contents();
                ob_end_clean();
                
                ob_start();
                foreach($applications as $application) {
                    $highlight = '';
                    // only display this application if it is not hidden
                    if($application['hidden']){
                        // Is it the only application in this distribution?
                        // Then we should delete the whole distribution.
                        if(count($applications) == 1){
                            $hasApplications = false;
                            $zi_registry->removeDistribution($distribution['name'].'-'.$distribution['release']['version']);
                            unset($applications[$application['name'].'-'.$application['release']['version']]);
                        } else {
                            // Hidden application is a relict from an unfinished update,
                            // so delete it.
                            $zi_registry->removeApplication($application['name'].'-'.$application['release']['version']);
                        }
                    } elseif (
                            $GLOBALS['ZI']['mode'] != 'setup' &&
                            $GLOBALS['ZI']['installer_dev'] == false &&
                            (isset($_REQUEST['mode']) && $_REQUEST['mode'] != 'dev') &&
                            $GLOBALS['ZI']['installer_distribution'] == $distribution['name'].'-'.$distribution['release']['version'] &&
                            $GLOBALS['ZI']['installer_application'] == $application['name'].'-'.$application['release']['version']
                            ){
                            // Don't show the installer
                            if(count($applications) == 1){
                                // The installer is the only application in this distribution, so don't show the
                                // distribution.
                                $hasApplications = false;
                            }
                    } else {
                        $options = array();
                        $installed = false;
                                             
                        if(
                            isset($application["installed"]) &&
                            $application["installed"] == $application["release"]["version"]
                            ) {
                            $installed = true;
                        }
                        
                        // detect development mode
                        $is_dev = false;
                        if(isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'dev'){
                            $is_dev = true;
                        }
                        
                        if($installed){
                            $highlight = ' class="highlight"';
                        } else {
                            $application["installed"] = '-';
                        }
                        echo '<tr>';
                            
                                ?>
                                <td<?php echo $highlight; ?>>
                                    <a href="info.php?mode=<?php echo $_REQUEST['mode']; ?>&type=application&application=<?php echo $application["name"].'-'.$application['release']['version']; ?>&distribution=<?php echo rawurlencode($distribution['name'].'-'.$distribution['release']['version']); ?>" onclick="javascript:window.open('info.php?mode=<?php echo $_REQUEST['mode']; ?>&type=application&application=<?php echo $application["name"].'-'.$application['release']['version']; ?>&distribution=<?php echo rawurlencode($distribution['name'].'-'.$distribution['release']['version']); ?>', 'ApplicationInformation', 'width=500,height=500,resizable=1,status=0,scrollbars=1,toolbar=0,location=0,directories=0,menubar=0,dependent=0');void(0);javascript:return(false);" target="_blank" title="<?php echo $application["summary"]; ?>"><?php echo $application["summary"]; ?></a>
                                </td>
                            <!-- <td<?php echo $highlight; ?>><?php echo $distribution['summary']; ?></td> -->
                        <?php
                            echo '<td'.$highlight.'>'.$application["release"]["version"].'</td>';
                            echo '<td'.$highlight.'>';
                            if(isset($application["installed"])){
                                echo $application["installed"];
                            }
                            
                            echo '</td>';
                            ?>
                            <td align="left"<?php echo $highlight; ?> width="120px">
                                <div class="actions">
                                    <?php
                                    $querystr = '?application='.$application['name'].'-'.$application['release']['version'].'&distribution='.$distribution['name'].'-'.$distribution['release']['version'];
                                    if(isset($_REQUEST['mode'])){
                                        $querystr .= '&mode='.$_REQUEST['mode'];
                                    }
                                    
                                    if($is_dev || !$installed){
                                        ?>
                                        <a href="<?php echo $_SERVER['PHP_SELF'].$querystr; ?>&action=install" title="Install">
                                        <img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/run.gif" align="absmiddle" border="0" alt="Install"></a><?php
                                    }
                                    ?> <?php
                                    if($installed){
                                        ?>
                                        <a href="<?php echo $_SERVER['PHP_SELF'].$querystr; ?>&action=options" title="Options">
                                        <img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/package_settings.gif" align="absmiddle" border="0" alt="Options"></a><?php
                                    }
                                    ?> <?php
                                    if($installed && /*(*/$is_dev/* || $zi_registry->hasPkgs('plugin', $application['name'].'-'.$application['release']['version']))*/){
                                        ?>
                                        <a href="<?php echo $_SERVER['PHP_SELF'].$querystr; ?>&action=plugins" title="Plugins">
                                        <img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/blockdevice.gif" align="absmiddle" border="0" alt="Plugins"></a><?php
                                    }
                                    if($installed){
                                        ?>
                                        <a href="<?php echo $_SERVER['PHP_SELF'].$querystr; ?>&action=packages" title="Packages">
                                        <img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/package.gif" align="absmiddle" border="0" alt="Packages"></a><?php
                                    }
                                    ?> <?php
                                    if($installed){
                                        ?>
                                        <a href="<?php echo $_SERVER['PHP_SELF'].$querystr; ?>&action=update" title="Update">
                                        <img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/rebuild.gif" align="absmiddle" border="0" alt="Update"></a><?php
                                    }
                                    ?> <?php
                                    if($is_dev){
                                        ?>
                                        <a href="<?php echo $_SERVER['PHP_SELF'].$querystr; ?>&action=descriptors" title="Descriptors">
                                        <img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/make.gif" align="absmiddle" border="0" alt="Descriptors"></a><?php
                                    }
                                    ?>  <?php
                                    if($is_dev && $installed){
                                        ?>
                                        <a href="<?php echo 'dev_bundle.php'.$querystr; ?>" title="Bundles">
                                        <img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/kpackage.gif" align="absmiddle" border="0" alt="Bundles"></a><?php
                                    }
                                    ?> <?php
                                    if($installed){
                                        $app_settings = $zi_registry->getApplicationSettings($application['name'].'-'.$application['release']['version']);
                                        ?> <a href="<?php echo $app_settings['application_url']; ?>" title="View Application" target="_blank"><img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/window_new.gif" border="0" alt="View Application" align="absmiddle"></a>
                                        <a title="Installation Log" href="log.php?mode=<?php echo $_REQUEST['mode']; ?>&type=application&application=<?php echo $application["name"].'-'.$application["release"]['version']; ?>&distribution=<?php echo rawurlencode($distribution['name'].'-'.$distribution['release']['version']); ?>" onclick="javascript:window.open('log.php?mode=<?php echo $_REQUEST['mode']; ?>&type=application&application=<?php echo $application["name"].'-'.$application["release"]['version']; ?>&distribution=<?php echo rawurlencode($distribution['name'].'-'.$distribution['release']['version']); ?>', 'LogFile', 'width=500,height=500,resizable=1,status=0,scrollbars=1,toolbar=0,location=0,directories=0,menubar=0,dependent=0');void(0);javascript:return(false);" target="_blank" title="Log File"><img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/log.gif" border="0" alt="Installation Log" align="absmiddle"></a><?php
                                    }
                                    if($GLOBALS['ZI']['mode'] != 'setup'){
                                        ?> <a href="<?php echo $_SERVER['PHP_SELF'].$querystr; ?>&action=remove" title="Remove">
                                        <img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/trashcan_empty.gif" border="0" alt="Remove" align="absmiddle"></a>
                                        <?php
                                    }
                                    ?>
                                </div>
                            </td>
                            <?php
                        echo '</tr>';
                        ?>
                        <?php
                    }
                }
                $list_content = ob_get_contents();
                ob_end_clean();
                
                if($hasApplications){
                    echo $list_header;
                    echo $list_content;
                    ?>
                    </table>
                    <?php
                }
            }
           // $zi_buttons['next'] = "applications.php".zi_form_querystr();
        }
    }
    
    if(!$hasApplications){
        ?><p>No distribution nor application available.</p><p><?php
         //$zi_buttons['next'] = "applications.php".zi_form_querystr();
    }
        
	require_once 'themes/'.$GLOBALS['ZI']['theme'].'/footer.php';

?>
Return current item: ZZ/OSS Installer