<?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_download.php,v 1.7 2004/04/07 11:05:14 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 *
***************************************************************************/
function zi_process()
{
global $zi_registry;
if(!is_array($_REQUEST["ZI_VALUES"]["application"]) || !count($_REQUEST["ZI_VALUES"]["application"])){
return false;
}
$zi_registry->setDir($GLOBALS['ZI']['installer_data_dir']);
$file = $GLOBALS['ZI']['installer_data_dir'].'installer'.DIRECTORY_SEPARATOR.'remote_distribution.xml';
$distribution_xml = new ZZOSS_Config();
$distribution_xml->setFile($file);
$distribution = $distribution_xml->query('/distribution');
$zi_registry->initDistribution($distribution['name'].'-'.$distribution['release']['version']);
// download application.xml
$file = $GLOBALS['ZI']['installer_data_dir'].'installer'.DIRECTORY_SEPARATOR.'remote_applications.xml';
$remote_applications_xml = new ZZOSS_Config(array('numeric' => array('application','descriptor')));
$remote_applications_xml->setFile($file);
$remote_applications = $remote_applications_xml->query('/applications/application');
foreach($_REQUEST["ZI_VALUES"]["application"] as $app_selected){
$remote_application = $remote_applications[$app_selected];
//$distribution_dir = $GLOBALS['ZI']['installer_data_dir'].'distributions/'.$distribution["name"].'-'.$distribution["release"]["version"].'/';
// create directories for distribution if not exists
/*
System::mkdir(array('-p',$distribution_dir.'installer'));
System::mkdir(array('-p',$distribution_dir.'downloads'));
System::mkdir(array('-p',$distribution_dir.'applications'));
System::mkdir(array('-p',$distribution_dir.'cache'));
*/
$zi_registry->initApplication($remote_application["name"].'-'.$remote_application["release"]["version"]);
//$application_dir = $distribution_dir.'applications/'.$remote_application["name"].'-'.$remote_application["release"]["version"].'/';
// copy distribution.xml
$file_src = $GLOBALS['ZI']['installer_data_dir'].'installer'.DIRECTORY_SEPARATOR.'remote_distribution.xml';
$file_dest = $zi_registry->getDistributionPath().'distribution.xml';
if(file_exists($file_dest)) {
unlink($file_dest);
}
copy($file_src, $file_dest);
/*
// create directories
System::mkdir(array('-p',$application_dir));
System::mkdir(array('-p',$application_dir.'installer'));
System::mkdir(array('-p',$application_dir.'downloads'));
System::mkdir(array('-p',$application_dir.'packages'));
System::mkdir(array('-p',$application_dir.'packages_installed'));
System::mkdir(array('-p',$application_dir.'cache'));
System::mkdir(array('-p',$application_dir.'plugins'));
*/
$file_application = $zi_registry->getApplicationPath().'application.xml';
$file_packages = $zi_registry->getApplicationPath().'installer'.DIRECTORY_SEPARATOR.'remote_packages.xml';
// download application.xml and packages.xml
if(is_array($remote_application["filelist"]["descriptor"])) {
include_once 'ZZOSS_File/Download.php';
$download = new ZZOSS_FileDownload();
foreach($remote_application["filelist"]["descriptor"] as $descriptor) {
if($descriptor["@"]["role"] == 'application') {
$download->download($descriptor["#"], $file_application);
}
if($descriptor["@"]["role"] == 'packages') {
$download->download($descriptor["#"], $file_packages);
}
}
}
}
// set rebuild applications flag
$fp = fopen($GLOBALS['ZI']['installer_data_dir']."installer".DIRECTORY_SEPARATOR."distributions.lock","w");
fputs($fp,'dummy');
fclose($fp);
// set rebuild applications flag
$fp = fopen($zi_registry->getDistributionPath()."installer".DIRECTORY_SEPARATOR."applications.lock","w");
fputs($fp,'dummy');
fclose($fp);
@unlink($GLOBALS['ZI']['installer_data_dir']."installer".DIRECTORY_SEPARATOR."distributions.reg");
$_REQUEST["ZI_LOCATION_NEXT"] = 'applications.php';
}
/***************************************************************************
* STARTUP *
***************************************************************************/
$file = $GLOBALS['ZI']['installer_data_dir'].'installer'.DIRECTORY_SEPARATOR.'remote_distribution.xml';
$distribution_xml = new ZZOSS_Config();
$distribution_xml->setFile($file);
$distribution = $distribution_xml->query('/distribution');
/***************************************************************************
* PAGE CONTENT *
***************************************************************************/
include 'themes/'.$GLOBALS['ZI']['theme'].'/header.php';
?>
<h1>Download Applications</h1>
<?php
$file = $GLOBALS['ZI']['installer_data_dir'].'installer'.DIRECTORY_SEPARATOR.'remote_applications.xml';
$items = array('Applications 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);
?>
<br clear="all"/>
<?php
if(!file_exists($file)) {
// error, since file does not exist
$screen = 'error';
} else {
$remote_applications_xml = new ZZOSS_Config(array('numeric' => array('application')));
$remote_applications_xml->setFile($file);
$remote_applications = $remote_applications_xml->query('/applications/application');
}
if(is_array($remote_applications) && count($remote_applications)) {
?>
<h2><?php echo $distribution['summary'].' '.$distribution['release']['version']; ?></h2>
<table class="list">
<tr>
<th align="center" width="30"><img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/run.gif" border="0" alt="Install" title="Install"></th>
<th align="left">Application</th>
<th align="center">Version</th>
<th align="center">State</th>
<th align="center">Release Date</th>
</tr>
<?php
foreach($remote_applications as $key => $application) {
if(!$zi_registry->isRegisteredApplication($application['name'].'-'.$application["release"]["version"], $distribution['name'].'-'.$distribution['release']['version'])){
$disabled = ' ';
$highlight = '';
} else {
$disabled = 'disabled';
$highlight = ' class="highlight"';
}
?>
<tr>
<td valign="top"<?php echo $highlight; ?>>
<input type="checkbox" name="ZI_VALUES[application][]" value="<?php echo $key; ?>" <?php echo $disabled; ?>>
</td>
<td<?php echo $highlight; ?>>
<a href="info.php?type=application_remote&id=<?php echo $key; ?>" onclick="javascript:window.open('info.php?type=application_remote&id=<?php echo $key; ?>', '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"><?php echo htmlspecialchars($application["summary"]); ?></a><br/>
</td>
<td align="center"<?php echo $highlight; ?>><?php echo $application["release"]["version"]; ?></td>
<td align="center"<?php echo $highlight; ?>><?php echo $application["release"]["state"]; ?></td>
<td align="center"<?php echo $highlight; ?>><?php echo $application["release"]["date"]; ?></td>
</tr>
<?php
$checked = '';
}
// activate next button
$zi_buttons['next'] = "applications.php";
?>
</table>
<?php
} else {
?>
Currently no applications available.
<?php
}
?>
<br clear="all"/>
<?php
$zi_buttons['back'] = "distribution_download.php";
include 'themes/'.$GLOBALS['ZI']['theme'].'/footer.php';
?>