<?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.php,v 1.10 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
*/
require_once 'ZZOSS_Installer/Utils.php';
/**
* Methods for installer plugins
*/
class ZZOSS_PortletPackage
{
var $registry;
var $has_actions = false;
var $has_downloads = false;
function setRegistry($registry)
{
$this->registry = $registry;
}
function showActions($type = 'package')
{
$this->registry->setPackageType($type);
$this->registry->registerPackages();
$packages_specified = $this->registry->getApplicationPackages();
$packages_display = $this->registry->getPackagesActions();
$packages_resolve = $this->registry->getPackagesResolve();
$packages = $this->registry->getPackages();
if(is_array($packages_display) && count($packages_display)) {
$output = '';
foreach($packages_display as $pkg_id => $action) {
$name = $packages_resolve[$pkg_id];
$package = $packages[$name];
if(
$action == 'I' || $action == 'R' || $action == 'U'
){
$this->has_actions = true;
$package_name_full = $package['name'];
if(strlen($package_name_full) > 72){
$package_name_short = substr($package_name_full, 0, 69).'...';
} else {
$package_name_short = $package_name_full;
}
ob_start();
?>
<tr>
<td>
<a title="<?php echo $package_name_full; ?>" href="info.php?mode=<?php echo $_REQUEST['mode']; ?>&type=<?php echo $type; ?>&id=<?php echo $pkg_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 $type; ?>&id=<?php echo $pkg_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;
?></a><br/><?php echo $package['summary']; ?>
</td>
<td align="center"><?php echo $package["release"]["version"]; ?></td>
<td align="center"><?php
switch($action){
case 'I':
?><img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/run.gif" border="0" alt="Install" title="Install"><?php
break;
case 'U':
?><img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/rebuild.gif" border="0" alt="Update" title="Update"><?php
break;
case 'R':
?><img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/trashcan_empty.gif" border="0" alt="Remove" title="Remove"><?php
break;
}
if(($action == 'I' || $action == 'U') && $package["install"]["type"] == 'remote'){
$this->has_downloads = true;
?> <img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/network.gif" border="0" alt="Download" title="Download"><?php
}
?></td>
</tr>
<?php
$output .= ob_get_contents();
ob_end_clean();
}
}
}
if($this->has_actions){
?>
<table class="list">
<tr>
<th align="left"><?php echo ucfirst($type); ?></th>
<th align="center">Version</th>
<th align="center">Action(s)</th>
</tr>
<?php echo $output; ?>
</table>
<?php
} else {
?>
<div class="warning">No <?php echo $type; ?> action selected.</div>
<?php
}
return $this->has_actions;
}
function hasActions()
{
return $this->has_actions;
}
function hasDownloads()
{
return $this->has_downloads;
}
function showList($type = 'package')
{
$this->registry->setPackageType($type);
$this->registry->registerPackages();
$packages = $this->registry->getPackages();
$a = $this->registry->getPackagesActions();
// loop packages array displaying each package
if(is_array($packages) && count($packages)) {
?>
<table class="list">
<tr>
<th align="center"><img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/run.gif" border="0" alt="Install" title="Install"></th>
<!--<th align="center"><img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/rebuild.gif" border="0" alt="Update" title="Update"></th>
<th align="center"><img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/trashcan_empty.gif" border="0" alt="Remove" title="Remove"></th>-->
<th align="center"> </th>
<th align="left"><?php echo ucfirst($type); ?></th>
<!-- <th align="center">Distribution</th> -->
<th align="center">Available</th>
<th align="center">Installed</th>
<th align="center">Action</th>
</tr>
<?php
foreach($packages as $package) {
$options = array();
$options["install"] = '';
$options["update"] = '';
$options["options"] = '';
$options["remove"] = '';
$options["install_prefix"] = '';
$options["update_prefix"] = '';
$options["options_prefix"] = '';
$options["remove_prefix"] = '';
$options["blank_prefix"] = '';
$options["blank"] = '';
if(is_array($a) && count($a)) {
if(!isset($a[$package["id"]]) || $a[$package["id"]] == 'N'){
$options["blank"] = ' checked ';
} else {
switch($a[$package["id"]]) {
case 'R':
$options["remove"] = ' checked ';
break;
case 'U':
$options["update"] = ' checked ';
break;
case 'I':
$options["install"] = ' checked ';
break;
}
}
}
if(!isset($package["installed"]) || !strlen($package["installed"])) {
$package["installed"] = '-';
$options["update"] = ' disabled';
$options["update_prefix"] = '_disabled';
if(!isset($package["_specified"]) || $package["_specified"]) {
$options["remove"] = ' disabled';
$options["remove_prefix"] = '_disabled';
}
if($package["install"]["required"] == true) {
$options["install"] = ' checked';
$options["blank"] = ' disabled';
$options["blank_prefix"] = '_disabled';
} elseif(!isset($_REQUEST["loadSelection"])) {
$options["blank"] = ' checked ';
}
$modified = true;
} else {
if($package["installed"] == $package["release"]["version"]) {
$modified = false;
/*
$options["update"] = ' disabled';
$options["update_prefix"] = '_disabled';*/
$options["install"] = ' disabled';
$options["install_prefix"] = '_disabled';
if(!isset($_REQUEST["loadSelection"])) {
$options["blank"] = ' checked ';
}
if($package["install"]["required"] == true) {
$options["remove"] = ' disabled';
$options["remove_prefix"] = '_disabled';
}
} else {
$modified = true;
$options["install"] = ' disabled';
$options["install_prefix"] = '_disabled';
if(!isset($_REQUEST["loadSelection"])) {
$options["update"] = ' checked ';
}
}
}
if($modified){
$bgcolor = ' class="highlight"';
} else {
$bgcolor = '';
}
echo '<tr>';
echo '<td align="center" valign="middle"'.$bgcolor.'><input type="radio" name="a'.$options["install_prefix"].'['.$package["id"].']"'.$options["install"].' value="I" title="Install"></td>';
//echo '<td align="center" valign="middle"'.$bgcolor.'><input type="radio" name="a'.$options["update_prefix"].'['.$package["id"].']"'.$options["update"].' value="U" title="Update"></td>';
//echo '<td align="center" valign="middle"'.$bgcolor.'><input type="radio" name="a'.$options["remove_prefix"].'['.$package["id"].']"'.$options["remove"].' value="R" title="Remove"></td>';
echo '<td align="center" valign="middle"'.$bgcolor.'><input type="radio" name="a'.$options["blank_prefix"].'['.$package["id"].']" '.$options["blank"].' value="N" title="Status Quo"></td>';
?>
<td<?php echo $bgcolor; ?>>
<?php
$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 $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 $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;
?></a><br/><?php
echo $package['summary'];
if($GLOBALS['ZI']['mode'] == 'dev' && isset($package['_specified']) && !$package['_specified']){
?><div class="warning-inline">Not specified by application</div><?php
}
?>
</td>
<?php
echo '<td'.$bgcolor.'>'.$package["release"]["version"];
?>
<?php
if($package["installed"] == '-' && $package["install"]["type"] == 'remote') {
echo '<img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/network.gif" align="absmiddle" border="0" alt="Download" title="Download">';
}
echo '</td>';
echo '<td'.$bgcolor.'>'.$package["installed"].'</td>';
?>
<td align="left"<?php echo $bgcolor; ?>>
<div class="actions">
<?php
$querystr = '?type='.$type.'&package='.$package['name'].'-'.$package['release']['version'].'&application='.$_REQUEST['application'].'&distribution='.$_REQUEST['distribution'];
$is_dev = false;
if(isset($_REQUEST['mode'])){
$querystr .= '&mode='.$_REQUEST['mode'];
if($_REQUEST['mode'] == 'dev'){
$is_dev = true;
}
}
$showNbsp = true;
if(!$modified && $is_dev && $type == 'plugin' && isset($package['release']['plugin'])){
$showNbsp = false;
?>
<a href="dev_plugin.php<?php echo $querystr; ?>&action=install"/>
<img src="themes/share/icons/org.kde.icons.crystalsvg/16x16/wizard.gif" align="absmiddle" border="0" alt="Install" title="Install"></a><?php
}
if($showNbsp){
?> <?php
}
?>
</div>
</td>
<?php
echo '</tr>';
}
?>
</table><?php
return true;
}
return false;
}
}
?>