<?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: application_settings.php,v 1.15 2004/04/06 14:45:17 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';
// check if this script is part of installation procedure
if(/*isset($_REQUEST['mode']) && ($_REQUEST['mode'] == 'dev' || $_REQUEST['mode'] == 'instant') && */!$zi_registry->isProcedure('settings')){
header('Location: application_profile.php'.zi_form_querystr());
exit;
}
function zi_process()
{
if(!isset($_REQUEST['dev']) || $_REQUEST['dev'] != 'bundle'){
// should we create the install root?
if($_REQUEST["ZI_VALUES"]['application_root_create'] == 'on'){
if(!System::mkdir(array('-p', $_REQUEST["ZI_VALUES"]['application_root']))){
$_REQUEST['ZI_LOCATION_NEXT'] = 'application_settings.php'.zi_form_querystr().'&error=true';
return false;
}
} else if(!is_writeable($_REQUEST['ZI_VALUES']['application_root'])){
$_REQUEST['ZI_LOCATION_NEXT'] = 'application_settings.php'.zi_form_querystr().'&error=true';
return false;
}
}
global $zi_registry;
// process package sources
$count = 0;
for($i=1;$i<=5;$i++) {
if( (isset($_REQUEST["ZI_VALUES"]["source_".$i]) && strlen($_REQUEST["ZI_VALUES"]["source_".$i])) &&
(is_dir($_REQUEST["ZI_VALUES"]["source_".$i])) ) {
$_REQUEST["ZI_VALUES"]["additional_sources"][$count] = $_REQUEST["ZI_VALUES"]["source_".$i];
$count++;
}
}
// save data
$zi_registry->updateApplicationSettings($_REQUEST["ZI_VALUES"]);
if(!isset($_REQUEST['dev']) || $_REQUEST['dev'] != 'bundle'){
// This is our first, the "virgin" installation.
// So we register it by saying which installer installed it.
// Both are correlated to each other by their absolute root path.
// application_root => installer_root
$zi_registry->setApplicationInstalledBy($_REQUEST['ZI_VALUES']['application_root'], getcwd());
}
}
function default_paths($dev_mode = false)
{
if($GLOBALS['ZI']['mode'] != 'setup'){
$application = $_REQUEST['application'];
if($dev_mode){
$application .= '-dev';
}
} else {
$application = '';
}
// absolute root
$split[0] = substr(dirname($_SERVER['PATH_TRANSLATED']), 0, strrpos(dirname($_SERVER['PATH_TRANSLATED']), '/')).'/';
$_REQUEST['ZI_VALUES']['application_root'] = ZZOSS_InstallerUtils::fixSlashes($split[0].$application.DIRECTORY_SEPARATOR);
$split[0] = substr(dirname($_SERVER['PHP_SELF']), 0, strrpos(dirname($_SERVER['PHP_SELF']), '/')).'/';
$_REQUEST['ZI_VALUES']['application_url_rel'] = $split[0];
if($GLOBALS['ZI']['mode'] != 'setup'){
$_REQUEST['ZI_VALUES']['application_url_rel'] .= $application.'/';
}
// relative path from URL to root
if($_REQUEST['ZI_VALUES']['application_url_rel'][0] != '/'){
// this is a problem with Windows
$_REQUEST['ZI_VALUES']['application_url_rel'] = '/'.$_REQUEST['ZI_VALUES']['application_url_rel'];
}
// URL
$_REQUEST['ZI_VALUES']['application_url'] = 'http://'.$_SERVER['HTTP_HOST'].$_REQUEST['ZI_VALUES']['application_url_rel'];
// Create directory
$_REQUEST["ZI_VALUES"]['application_root_create'] = 'on';
return $_REQUEST;
}
// assign default values
function zi_default()
{
global $zi_registry;
$dev_mode = false;
if(isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'dev'){
$dev_mode = true;
}
// if we had a previous installation, we get those values
if($application_settings = $zi_registry->getApplicationSettings()){
$_REQUEST['ZI_VALUES'] = $application_settings;
if(!isset($_REQUEST['ZI_VALUES']['application_root'])){
return default_paths($dev_mode);
}
return $_REQUEST;
} else {
return default_paths($dev_mode);
}
}
/***************************************************************************
* STARTUP *
***************************************************************************/
$application = $zi_registry->getApplication();
// show unlocked data
if(is_dir($_REQUEST['ZI_VALUES']['application_root'])){
$zi_errors['application_root'] = 'Directory already exists and will be overwritten.';
}
// installer widget class
require_once 'ZZOSS_Installer/Widget.php';
$zi_widget = new ZZOSS_InstallerWidget;
if(isset($zi_errors)){
$zi_widget->setErrors($zi_errors);
}
/***************************************************************************
* PAGE CONTENT *
***************************************************************************/
// we ask for a new installer admin username and password
include 'themes/'.$GLOBALS['ZI']['theme'].'/header.php';
if(isset($_REQUEST['error'])){
?>
<div class="warning">Application root is not writeable.</div>
<?php
}
?>
<?php
if($GLOBALS['ZI']['mode'] == 'setup'){
?>
<h1 align="center">Setup Wizard</h1>
<p>This wizard helps you with setting up the application. You are adviced to remove
the setup wizard after successful installation.</p>
<?php
}
?>
<h1>Installation Paths</h1>
<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
// show only if dev mode allows it
if(!isset($_REQUEST['dev']) || $_REQUEST['dev'] != 'bundle'){
?>
<h2>Application Paths</h2>
<table border="0" cellspacing="0" cellpadding="4">
<?php
// show widgets
$widget = 'path';
echo $zi_widget->add($widget, 'Root', 'application_root', array('validation' => 'not empty'));
echo $zi_widget->add('checkbox', 'Create Directory', 'application_root_create');
echo $zi_widget->add($widget, 'URL', 'application_url', array('validation' => 'not empty'));
echo $zi_widget->add($widget, 'Relative', 'application_url_rel', array('validation' => 'not empty'));
?>
</table>
<?php
}
if(isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'dev' ) {
?>
<h2>Packages Source Paths</h2>
<table border="0" cellspacing="0" cellpadding="4">
<?php
// additional package sources
echo $zi_widget->add('text', 'Source 1', 'source_1');
echo $zi_widget->add('text', 'Source 2', 'source_2');
echo $zi_widget->add('text', 'Source 3', 'source_3');
echo $zi_widget->add('text', 'Source 4', 'source_4');
echo $zi_widget->add('text', 'Source 5', 'source_5');
?>
</table>
<input type="hidden" name="dev" value="<?php if(isset($_REQUEST['dev'])) echo $_REQUEST['dev']; ?>"/>
<?php
}
//$zi_buttons['back'] = 'applications.php'.zi_form_querystr();
if(isset($_REQUEST['dev']) && $_REQUEST['dev'] == 'bundle'){
$zi_buttons['next'] = 'packages_reset.php'.zi_form_querystr();
} else {
$zi_buttons['next'] = 'application_profile.php'.zi_form_querystr();
}
include 'themes/'.$GLOBALS['ZI']['theme'].'/footer.php';
?>