Location: PHPKode > projects > ZZ/OSS Installer > zic-1.1.0dev1/installer/package_add.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: package_add.php,v 1.1 2004/03/05 14:25:25 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';
	
	function zi_process()
	{
        // TODO:
        // - validate input (e.g. relative path for baseinstalldir)
        // - check that only one src has been specified for package
        // - check if package already exists and ask if it should be overwritten
        
        global $zi_registry;
        
        // In case the application is not registered yet, then we create the data directories.
        if(!is_dir($zi_registry->getApplicationPath())){
            ZZOSS_InstallerRegistry::mkDirsApplication($zi_registry->getApplicationPath());
        }
        
        if(isset($_FILES['ZI_VALUES']['tmp_name']['archive_local']) && strlen($_FILES['ZI_VALUES']['tmp_name']['archive_local'])){
            $data_dir = $zi_registry->getApplicationPath().'downloads'.DIRECTORY_SEPARATOR;
            if (!move_uploaded_file($_FILES['ZI_VALUES']['tmp_name']['archive_local'], $data_dir.$_FILES['ZI_VALUES']['name']['archive_local'] )) {
                // raise error
                PEAR::raiseError('Cannot move uploaded file.');
            }
        } elseif(isset($_REQUEST['ZI_VALUES']['src_local'])){
            // Check if there's a package.xml
            // TODO: check if package.xml is valid
            if(!file_exists($_REQUEST['ZI_VALUES']['src_local'].DIRECTORY_SEPARATOR.'package.xml')){
                $_REQUEST['ZI_LOCATION_NEXT'] = $_SERVER['PHP_SELF'].zi_form_querystr()
                    .'&warning='.rawurlencode('Package XML is missing')
                    .'&ZI_VALUES[src_local]='.$_REQUEST['ZI_VALUES']['src_local'];
            }
        }
	}
	
	/***************************************************************************   
    * STARTUP                                                             	   *   
    ***************************************************************************/   
    
	include 'themes/'.$GLOBALS['ZI']['theme'].'/header.php';
    //print_r($_REQUEST);
    
    $is_app = true;
    
    // WORKAROUND: We explicitly need to set the application name from query string here,
    // otherwise, always the first application in the applications array will be returned.
    if(!$application = $zi_registry->getApplication($_REQUEST['application'])){
        // The application data path does not exits.
        // This is usually caused when the installer itself is developed without
        // having it not yet installed properly, i.e. without plugins installed.
        $is_app = false;
    }
    //$application = $zi_registry->getApplicationById($_REQUEST['id']);
    //$zi_registry->setApplication($application['name'].' '.$application['release']['version']);
    $pkg_type = NULL;
    if(isset($_REQUEST['type'])){
        $pkg_type = $_REQUEST['type'];
    }
    if($pkg_type == 'plugins'){
        ?>
        <h1>Add Plugin</h1>
        <?php
    } else {
        ?>
        <h1>Add Package</h1>
        <?php
    }
    
    if(isset($_REQUEST['warning'])){
        ?>
        <div class="warning"><?php echo $_REQUEST['warning']; ?></div>
        <?php
    }
    
    if(!$is_app){
        ?>
        <div class="warning">Application not registered.</div>
        <?php
    } else {
        ?>
        <h2><a href="info.php?mode=<?php echo $_REQUEST['mode']; ?>&type=application&distribution=<?php echo $_REQUEST['distribution']; ?>&application=<?php echo $_REQUEST['application']; ?>" onclick="javascript:window.open('info.php?mode=<?php echo $_REQUEST['mode']; ?>&type=application&distribution=<?php echo $_REQUEST['distribution']; ?>&application=<?php echo $_REQUEST['application']; ?>', '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"].' '.$application['release']['version']; ?>"><?php echo $application["summary"].' '.$application['release']['version']; ?></a></h2>
        <?php
    }
    
    // installer widget class
	require_once 'ZZOSS_Installer/Widget.php';
	$zi_widget = new ZZOSS_InstallerWidget;
?>
    <table class="form">
    <?php
    echo $zi_widget->add('text', 'Base Install Directory:', 'baseinstalldir', array('info' => 'The build directory. Please specify a relative path or leave empty.'));
    echo $zi_widget->add('file', 'Local Archive:', 'archive_local', array('info' => 'Upload a package .tgz from your local harddisc ...'));
    if($GLOBALS['ZI']['mode'] == 'dev') {
        echo $zi_widget->add('text', 'Remote Archive:', 'archive_remote', array('info' => '... or download a package .tgz ...'));
        echo $zi_widget->add('text', 'Local Source:', 'src_local', array('info' => '... or specify the path to the local package sources.'));
    }
        ?>
    </table>
<br clear="all"/>
<?php
	$zi_buttons['next'] = "packages.php".zi_form_querystr();
	include 'themes/'.$GLOBALS['ZI']['theme'].'/footer.php';
?>
Return current item: ZZ/OSS Installer