<?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: packages_dependencies.php,v 1.14 2004/04/07 14:21:53 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';
/***************************************************************************
* SCRIPT SPECIFIC FUNCTIONS *
***************************************************************************/
function zi_process()
{
global $zi_registry;
$pkg_type = 'package';
if(isset($_REQUEST['type'])){
$pkg_type = $_REQUEST['type'];
}
$zi_registry->setPackageType($pkg_type);
$action_deps = $zi_registry->getPackagesActionsDeps();
$zi_registry->updatePackagesActions($action_deps);
}
/***************************************************************************
* STARTUP *
***************************************************************************/
// compose actions if full or minimum installation
$app_settings = $zi_registry->getApplicationSettings();
if(!$zi_registry->isInstalledApplication() && $app_settings["application_profile"] != 'custom') {
$zi_registry->setPkgsActionsPreselect($app_settings["application_profile"]);
}
// default next link
$link_next = 'packages_process.php'.zi_form_querystr();
$pkg_type = 'package';
if(isset($_REQUEST['type'])){
$pkg_type = $_REQUEST['type'];
}
$zi_registry->setPackageType($pkg_type);
$packages = $zi_registry->getPackages();
// no packages?
if(!is_array($packages) || !count($packages)){
if($pkg_type == 'plugin'){
$_REQUEST['type'] = 'package';
header('Location: packages_reset.php'.zi_form_querystr());
exit;
} else {
PEAR::raiseError('No packages');
}
}
$packages_resolve = $zi_registry->getPackagesResolve();
$packages_versions = $zi_registry->getPackagesVersions();
// check if we should install already installed packages
if(
isset($_REQUEST['mode']) &&
$_REQUEST['mode'] == 'dev' &&
$zi_registry->getProcedure($pkg_type.'s_deps') == 'installed'){
$actions = array();
// iterate packages and distill those that are already installed
foreach($packages as $package){
if(isset($package['installed']) && $package["installed"] == $package["release"]["version"]) {
$actions[$package['id']] = 'I';
}
}
// if no packages are supposed to be installed,
// we redirect.
if(!count($actions)){
$zi_registry->setProcedure($pkg_type.'s_manager');
$zi_registry->setProcedure($pkg_type.'s_confirm');
$url_next = 'packages.php'.zi_form_querystr();
header('Location: '.$url_next);
exit;
}
$zi_registry->setPackagesActions($actions);
} else {
// load previous selection
$actions = $zi_registry->getPackagesActions();
}
/*
echo '<h3>Packages Versions</h3>';
echo '<pre>';
echo print_r($packages_versions);
echo '</pre>';
*/
/*
echo '<h3>Actions</h3>';
echo '<pre>';
echo print_r($actions);
echo '</pre>';
*/
// main func here
require_once 'ZZOSS_Package/Dependency.php';
$zi_deps = new ZZOSS_PackageDependency;
$queue = $zi_deps->run($packages, $packages_resolve, $packages_versions, $actions);
if($zi_deps->isError()){
// catch errors
$error = $zi_deps->getError();
}
/*
echo '<pre>';
echo '<h3>Queue</h3>';
echo print_r($queue);
echo '</pre>';
*/
/*
echo '<pre>';
echo '<h3>Deps By Name</h3>';
echo print_r($zi_deps->getDepsByName());
echo '</pre>';
*/
// default next link
$link_next = 'packages_download.php'.zi_form_querystr();
// save process queue
$zi_registry->updatePackagesQueue($queue);
if(!$zi_deps->isError() && !$zi_deps->hasPendingDeps()) {
header("Location: ".$link_next);
exit;
}
/***************************************************************************
* PAGE CONTENT *
***************************************************************************/
include 'themes/'.$GLOBALS['ZI']['theme'].'/header.php';
$application = $zi_registry->getApplication();
?>
<h1>Packages Dependencies</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
if($zi_deps->isError()){
?>
<div class="warning">FATAL ERROR<br/><?php echo $error; ?></div>
<?php
}
// Was an error thrown because of packages not defined in the application.xml?
if($zi_deps->hasUndefinedPackages()){
$pkgs_pending = $zi_deps->getUndefinedPackages();
} else {
$pkgs_pending = $zi_deps->getPending();
}
/*
echo '<pre>';
echo '<h3>getPending()</h3>';
echo print_r($pkgs_pending);
echo '</pre>';
*/
if(is_array($pkgs_pending) && count($pkgs_pending)){
/*
echo '<pre>';
echo '<h3>getDeps()</h3>';
echo print_r($zi_deps->getDeps());
echo '</pre>';
echo '<pre>';
echo '<h3>getCheckedNames()</h3>';
echo print_r($zi_deps->getCheckedNames());
echo '</pre>';
echo '<pre>';
echo '<h3>getDepsByName()</h3>';
echo print_r($zi_deps->getDepsByName());
echo '</pre>';
*/
//zi_show_deps($zi_deps->getDeps(), $queue);
?>
<table class="list">
<tr>
<th align="left">Package</th>
<th align="center">Version</th>
<th align="center">Needed By</th>
</tr>
<?php
foreach($pkgs_pending as $pkg_name => $pkgs_needed_by){
if(!$zi_deps->hasUndefinedPackages()){
$package = $packages[$pkg_name];
// temporarily assign package action
$actions_deps[$package['id']] = 'I';
} else {
//print_r($pkgs_needed_by);
$package['name'] = $pkgs_needed_by['name'];
$package["release"]["version"] = $pkgs_needed_by['version'];
//$pkgs_needed_by = $pkgs_needed_by['needed_by'];
}
$package_name_full = $package['name'];
if(strlen($package_name_full) > 32){
$package_name_short = substr($package_name_full, 0, 29).'...';
} else {
$package_name_short = $package_name_full;
}
?>
<tr>
<td><?php
if(!$zi_deps->hasUndefinedPackages()){
?>
<a title="<?php echo $package_name_full.'-'.$package['release']['version']; ?>" href="info.php?mode=<?php echo $_REQUEST['mode']; ?>&type=<?php echo $pkg_type; ?>&id=<?php echo $package['id']; ?>&application=<?php echo $_REQUEST['application']; ?>&distribution=<?php echo $_REQUEST['distribution']; ?>" onclick="javascript:window.open('info.php?mode=<?php echo $_REQUEST['mode']; ?>&type=<?php echo $pkg_type; ?>&id=<?php echo $package['id']; ?>&application=<?php echo $_REQUEST['application']; ?>&distribution=<?php echo $_REQUEST['distribution']; ?>', 'PackageInformation', '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 $package_name_short;
if(!$zi_deps->hasUndefinedPackages()){
?></a><br/><?php echo $package['summary'];
}
?>
</td>
<td align="center"><?php
echo $package["release"]["version"];
if($package["release"]["version"]=="") {
echo 'any';
}
if(!$zi_deps->hasUndefinedPackages()){
echo ' <img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/network.gif" align="absmiddle" border="0" alt="remote package" title="Download">';
}
?></td>
<td align="left"><?php
$pkgs_needed = $pkgs_needed_by['needed_by'];
foreach($pkgs_needed as $pkg_needed){
$package = $packages[key($pkg_needed)];
$package_name_full = $package['name'];
if(strlen($package_name_full) > 32){
$package_name_short = substr($package_name_full, 0, 29).'...';
} else {
$package_name_short = $package_name_full;
}
?>
<a title="<?php echo $package_name_full.'-'.$package['release']['version']; ?>" href="info.php?mode=<?php echo $_REQUEST['mode']; ?>&type=<?php echo $pkg_type; ?>&id=<?php echo $package['id']; ?>&application=<?php echo $_REQUEST['application']; ?>&distribution=<?php echo $_REQUEST['distribution']; ?>" onclick="javascript:window.open('info.php?mode=<?php echo $_REQUEST['mode']; ?>&type=<?php echo $pkg_type; ?>&id=<?php echo $package['id']; ?>&application=<?php echo $_REQUEST['application']; ?>&distribution=<?php echo $_REQUEST['distribution']; ?>', 'PackageInformation', '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 $package_name_short.'-'.$package['release']['version']; ?></a><br/><?php
}
?>
</td>
</tr>
<?php
}
/*
echo '<pre>';
echo '<h3>Actions Deps</h3>';
echo print_r($actions_deps);
echo '</pre>';
*/
?>
</table>
<?php
}
if(!$zi_deps->isError()){
// remember new package actions for dependencies
$zi_registry->setPackagesActionsDeps($actions_deps);
}
$link_back = "packages.php".zi_form_querystr();
if(!$error){
if(!$zi_deps->hasPendingDeps()) {
$zi_buttons['next'] = $link_next;
} else {
$zi_buttons['ok'] = 'packages_download.php'.zi_form_querystr();
}
}
$zi_buttons['back'] = $link_back;
include 'themes/'.$GLOBALS['ZI']['theme'].'/footer.php';
?>