<?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: dev_application_import.php,v 1.8 2004/04/04 09:45:36 ordnas Exp $
@copyright Copyright © 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 *
***************************************************************************/
// additional checks
function zi_validate()
{
$errors = array();
if(!file_exists($_REQUEST['ZI_VALUES']['path_application_xml'])) {
$errors["path_application_xml"] = 'file does not exist';
}
if(!file_exists($_REQUEST['ZI_VALUES']['path_distribution_xml'])) {
$errors["path_distribution_xml"] = 'file does not exist';
}
/*
if(!file_exists($_REQUEST['ZI_VALUES']['path_packages_xml'])) {
$errors["path_packages_xml"] = 'file does not exist';
}
*/
return $errors;
}
function zi_process()
{
global $zi_registry, $zi_errors;
if(isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'dev'){
$zi_registry->setDir($GLOBALS['ZI']['installer_data_dir_dev']);
}
require_once 'ZZOSS_Config/Config.php';
$distribution_config = new ZZOSS_Config();
$distribution_config->setFile($_REQUEST['ZI_VALUES']['path_distribution_xml']);
$distribution = $distribution_config->query('/distribution');
if(strlen($distribution["name"])>0) {
$zi_registry->initDistribution($distribution["name"].'-'.$distribution["release"]["version"]);
copy($_REQUEST['ZI_VALUES']['path_distribution_xml'], $zi_registry->getDistributionPath().'distribution.xml');
} else {
$zi_errors['path_distribution_xml'] = 'Invalid XML.';
return false;
}
$application_config = new ZZOSS_Config();
$application_config->setFile($_REQUEST['ZI_VALUES']['path_application_xml']);
$application = $application_config->query('/application');
if(strlen($application["name"])>0) {
$zi_registry->initApplication($application["name"].'-'.$application["release"]["version"]);
copy($_REQUEST['ZI_VALUES']['path_application_xml'], $zi_registry->getApplicationPath().'application.xml');
//copy($_REQUEST['ZI_VALUES']['path_packages_xml'], $zi_registry->getApplicationPath().'installer/remote_packages.xml');
}
// finally set "rebuild application" flag
$fp = fopen($zi_registry->getDistributionPath()."installer/applications.lock","w");
fputs($fp,'dummy');
fclose($fp);
// finally set "rebuild distributions" flag
$fp = fopen($zi_registry->getDistributionPath()."installer/distributions.lock","w");
fputs($fp,'dummy');
fclose($fp);
@unlink($GLOBALS['ZI']['installer_data_dir_dev']."installer/distributions.reg");
$zi_registry->updateApplicationSettings(
$_REQUEST["ZI_VALUES"],
$application["name"].'-'.$application["release"]["version"],
$distribution["name"].'-'.$distribution["release"]["version"]
);
}
function zi_default()
{
global $zi_registry;
$_REQUEST['ZI_VALUES'] = $zi_registry->getApplicationSettings();
return $_REQUEST;
}
/***************************************************************************
* PAGE CONTENT *
***************************************************************************/
include 'themes/'.$GLOBALS['ZI']['theme'].'/header.php';
// initialise widget class of installer
require_once 'ZZOSS_Installer/Widget.php';
$zi_widget = new ZZOSS_InstallerWidget;
if(isset($zi_errors)){
$zi_widget->setErrors($zi_errors);
}
?>
<h1>Add Application</h1>
<?php
if(isset($_REQUEST['distribution']) && isset($_REQUEST['application'])){
// check if we need to display the descriptors from the data directory
if(
!isset($_REQUEST['ZI_VALUES']['path_distribution_xml']) ||
!strlen($_REQUEST['ZI_VALUES']['path_distribution_xml'])){
$distri_xml = $zi_registry->getDistributionPath().'distribution.xml';
if(file_exists($distri_xml)){
$_REQUEST['ZI_VALUES']['path_distribution_xml'] = $distri_xml;
}
}
if(
!isset($_REQUEST['ZI_VALUES']['path_application_xml']) ||
!strlen($_REQUEST['ZI_VALUES']['path_application_xml'])){
$app_xml = $zi_registry->getApplicationPath().'application.xml';
if(file_exists($app_xml)){
$_REQUEST['ZI_VALUES']['path_application_xml'] = $app_xml;
}
}
$application = $zi_registry->getApplication();
?>
<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
}
?>
<table border="0">
<?php
echo $zi_widget->add('text', 'Distribution XML:', 'path_distribution_xml');
echo $zi_widget->add('text', 'Application XML:', 'path_application_xml');
//echo $zi_widget->add('text', 'Packages XML:', 'path_packages_xml');
//echo $zi_widget->add('text', 'path to package source:','path_package_source');
?>
</table>
<?php
//$zi_buttons['back'] = 'applications.php?mode=dev';
$zi_buttons['next'] = 'applications.php?mode=dev';
include 'themes/'.$GLOBALS['ZI']['theme'].'/footer.php';
?>