[zi-cvs] packages/com.zzoss.zic plugins_re.php,NONE,1.1
Sandro Zic <[email protected]> Wed, 07 Apr 2004 06:01:01 +0000
| Newsgroups | gmane.comp.php.zzoss.installer.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/zzossinstaller/packages/com.zzoss.zic
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10856/com.zzoss.zic
Added Files:
plugins_re.php
Log Message:
plugins runtime environment
--- NEW FILE: plugins_re.php ---
<?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: plugins_re.php,v 1.1 2004/04/07 06:00:59 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
*/
/*
This script is in fact part of the plugins Runtime Environment (RE).
Hence, we have to keep things simple and make sure that we include only
the minimal set of classes needed to execute plugins.
This is why the installer framework (inc/init.php) in the RE mode by setting
the constant ZI_INIT_MODE to 'RE'. Otherwise
the framework could conflict with classes needed by a plugin in the RE (e.g. PEAR).
In the plugins RE, you can access the following functions, classes, variables, files:
- all native PHP functions
- ZZOSS_InstallerSetup via $zi_setup
- ZZOSS_InstallerRegistry via $zi_registry
- ZZOSS_InstallerUtils
- ZZOSS_Plugin
- $GLOBALS['ZI']
- the theme's header and footer (header.php, footer.php)
The following methods of the above classes are not available:
- ZZOSS_InstallerRegistry::refreshDistributions()
- ZZOSS_InstallerRegistry::setApplicationInstalledById()
- ZZOSS_InstallerRegistry::refreshApplications()
- ZZOSS_InstallerRegistry::getPackageRemoteInfo()
- ZZOSS_InstallerRegistry::refreshPackages()
- ZZOSS_InstallerRegistry::getPackageDescr()
- ZZOSS_InstallerRegistry::replacePackage()
For example, use trigger_error() instead of PEAR::raiseError(), because the
latter is not available.
*/
@set_time_limit(0);
// set framework mode to RE
define('ZI_INIT_MODE', 'RE');
// execute init file
require_once 'inc/init.php';
// plugin library
require_once 'ZZOSS_Plugin/Plugin.php';
function zi_process()
{
if(isset($_REQUEST['re_type']) && $_REQUEST['re_type'] == 'filerole'){
return true;
}
global $zi_registry;
$pkg_type = 'package';
if(isset($_REQUEST['type'])){
$pkg_type = $_REQUEST['type'];
}
$zi_registry->setPackageType($pkg_type);
// Create the install destination directory.
$app_settings = $zi_registry->getApplicationSettings();
//echo 'settings: '.$app_settings['application_root'];
if(!isset($_REQUEST['package'])){
if($pkg_type == 'plugin'){
// Location of plugins runtime environment
$pkgs_root = $zi_registry->getApplicationPath().'plugins_re'.DIRECTORY_SEPARATOR;
} else {
$pkgs_root = $app_settings['application_root'];
}
// Location where plugins store their data
$pkgs_data = $zi_registry->getApplicationPath().'data'.DIRECTORY_SEPARATOR.$pkg_type.DIRECTORY_SEPARATOR;
$queue = $zi_registry->getPackagesQueue();
} else {
if(!$plugin_dev = $zi_registry->getPluginsDev($_REQUEST['package'])){
trigger_error('No settings for plugin \''.$_REQUEST['package'].'\'');
}
$pkgs_root = $plugin_dev['install_dir'];
$pkgs_data = $plugin_dev['data_dir'];
$queue = array(0 => array($_REQUEST['package'] => $plugin_dev['action']));
}
include_once 'ZZOSS_Plugin/Plugin.php';
$plugin = new ZZOSS_Plugin;
$plugin->setDestDir($pkgs_root);
if(!is_dir($pkgs_data)){
ZZOSS_InstallerUtils::mkdir($pkgs_data);
}
$plugin->setDataDir($pkgs_data);
if(isset($app_settings['source_1'])){
$plugin->setSource($app_settings['source_1']);
}
if(isset($app_settings['source_2'])){
$plugin->setSource($app_settings['source_2']);
}
if(isset($app_settings['source_3'])){
$plugin->setSource($app_settings['source_3']);
}
if(isset($app_settings['source_4'])){
$plugin->setSource($app_settings['source_4']);
}
if(isset($app_settings['source_5'])){
$plugin->setSource($app_settings['source_5']);
}
$plugin->setSource($zi_registry->getApplicationPath().DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR);
$plugin->setQueue($queue);
$plugin->setRegistry($zi_registry);
$plugin->exec('build', $_REQUEST["step"], 'post');
/*
echo '<pre>';
echo $plugin->log;
echo '</pre>';
*/
// write installation log
$fp = fopen($zi_registry->getApplicationPath().'installer'.DIRECTORY_SEPARATOR.'packages.log',"a");
fputs($fp,$plugin->getLog());
fclose($fp);
// Display errors.
echo $plugin->getOutput();
/*
$queue = $zi_registry->getPackagesQueue();
$plugin = new ZZOSS_Plugin;
$plugin->setQueue($queue);
$plugin->setRegistry($zi_registry);
$plugin->exec('build', $_REQUEST["step"]);
*/
}
// check step
if(!isset($_REQUEST["step"])) {
$step = 0;
} else {
$step = $_REQUEST["step"];
}
$pkg_type = 'package';
if(isset($_REQUEST['type'])){
$pkg_type = $_REQUEST['type'];
}
$zi_registry->setPackageType($pkg_type);
// Create the install destination directory.
$app_settings = $zi_registry->getApplicationSettings();
//echo 'settings: '.$app_settings['application_root'];
if(!isset($_REQUEST['package'])){
if($pkg_type == 'plugin'){
// Location of plugins runtime environment
$pkgs_root = $zi_registry->getApplicationPath().'plugins_re'.DIRECTORY_SEPARATOR;
} else {
$pkgs_root = $app_settings['application_root'];
}
// Location where plugins store their data
$pkgs_data = $zi_registry->getApplicationPath().'data'.DIRECTORY_SEPARATOR.$pkg_type.DIRECTORY_SEPARATOR;
$queue = $zi_registry->getPackagesQueue();
} else {
if(!$plugin_dev = $zi_registry->getPluginsDev($_REQUEST['package'])){
trigger_error('No settings for plugin \''.$_REQUEST['package'].'\'');
}
$pkgs_root = $plugin_dev['install_dir'];
// Location where plugins store their data
$pkgs_data = $plugin_dev['data_dir'];
$queue = array(0 => array($_REQUEST['package'] => $plugin_dev['action']));
$_REQUEST["step"] = 0;
}
if(!is_dir($pkgs_root)){
ZZOSS_InstallerUtils::mkdir($pkgs_root);
//System::mkdir(array('-p', $pkgs_root));
}
$plugin = new ZZOSS_Plugin;
$plugin->setDestDir($pkgs_root);
// Location where plugins store their data
if(!is_dir($pkgs_data)){
ZZOSS_InstallerUtils::mkdir($pkgs_data);
}
$plugin->setDataDir($pkgs_data);
if(!isset($_REQUEST['package'])){
if(isset($app_settings['source_1'])){
$plugin->setSource($app_settings['source_1']);
}
if(isset($app_settings['source_2'])){
$plugin->setSource($app_settings['source_2']);
}
if(isset($app_settings['source_3'])){
$plugin->setSource($app_settings['source_3']);
}
if(isset($app_settings['source_4'])){
$plugin->setSource($app_settings['source_4']);
}
if(isset($app_settings['source_5'])){
$plugin->setSource($app_settings['source_5']);
}
}
$plugin->setSource($zi_registry->getApplicationPath().DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR);
$plugin->setQueue($queue);
$plugin->setRegistry($zi_registry);
// execute plugins
if($_REQUEST['re_type'] == 'filerole'){
$plugin->exec('role', $step);
} elseif($_REQUEST['re_type'] == 'build') {
if(!isset($_REQUEST['package'])){
$plugin->exec('build', $_REQUEST["step"], 'pre');
} else {
$plugin->exec('build', 0, 'pre', $_REQUEST['package'], $plugin_dev['build_dir']);
}
}
// write log file
if(!isset($_REQUEST['package'])){
// write installation log
$fp = fopen($zi_registry->getApplicationPath().'installer'.DIRECTORY_SEPARATOR.'packages.log',"a");
fputs($fp,$plugin->getLog());
fclose($fp);
}
// now that the plugins have been executed,
// the suppressed classes can be loaded.
//require_once 'ZZOSS_Config/Config.php'; (redeclare problem if it has been included in plugin!)
// decide on workflow
if($_REQUEST['re_type'] == 'filerole'){
if(!strlen($plugin->getOutput())){
$url_next = 'plugins_process.php'.zi_form_querystr().'&step='.$step;
header('Location: '.$url_next);
exit;
} else {
include 'themes/'.$GLOBALS['ZI']['theme'].'/header.php';
$application = $zi_registry->getApplication();
?>
<a name="top"></a>
<h1>Build Packages</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>
<h2>Output from Filerole Plugins</h2>
<?php
if(!isset($_REQUEST['mode']) || $_REQUEST['mode'] != 'dev'){
?>
<div class="warning">Internal Error: Filerole plugins must not have any output.</div>
<?php
} else {
?>
<div class="warning">Make sure that the plugins you develop do not output anything once you deploy them. Output is not allowed for filerole plugins, use it only for debugging.</div>
<?php
}
echo $plugin->getOutput();
?>
<input type="hidden" name="re_type" value="filerole">
<?php
if(!isset($_REQUEST['mode']) || $_REQUEST['mode'] != 'dev'){
$zi_buttons['cancel'] = 'index.php';
} else {
$procedures = array(
/*'plugins_manager' => 'on',
'plugins_confirm' => 'on',*/
'plugins_register' => 'rm_installed',
'plugins_fileroles' => 'on',
'plugins_build' => 'on',
'packages_register' => 'rm_installed',
'packages_fileroles' => 'on',
'packages_build' => 'on'
);
$zi_registry->setProcedures($procedures);
$_REQUEST['type'] = 'plugin';
$url_next = 'packages_reset.php'.zi_form_querystr();
$zi_buttons['reload'] = $url_next;
}
include 'themes/'.$GLOBALS['ZI']['theme'].'/footer.php';
exit;
}
} elseif($_REQUEST['re_type'] == 'build') {
$step = $_REQUEST["step"];
$step_next = $step + 1;
if($plugin->isStep($step_next)) {
$url_next = 'packages_process.php'.zi_form_querystr().'&step='.$step_next;
} else {
if(isset($_REQUEST['type']) && $_REQUEST['type'] == 'plugin'){
if(!isset($_REQUEST['package'])){
$_REQUEST['type'] = 'package';
$url_next = 'packages_reset.php'.zi_form_querystr();
$_REQUEST['type'] = 'plugin';
} else {
$zi_buttons['back'] = 'dev_plugin.php'.zi_form_querystr();
$url_next = $_SERVER['PHP_SELF'].zi_form_querystr();
}
} else {
$url_next = 'application_done.php'.zi_form_querystr();
}
}
}
/***************************************************************************
* PAGE CONTENT *
***************************************************************************/
// if nothing is there to configure post a message
if(!isset($_REQUEST['package']) && !strlen($plugin->getOutput())) {
/*
echo $plugin->getLog();
echo $zi_registry->getApplicationPath();
die('here');
*/
// maybe some plugin just want to exec ...
zi_process();
header('Location: '.$url_next);
exit;
} elseif(!isset($_REQUEST['package']) && strlen($plugin->getOutput())) {
include 'themes/'.$GLOBALS['ZI']['theme'].'/header.php';
$application = $zi_registry->getApplication();
?>
<a name="top"></a>
<h1>Build Packages</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 echo $plugin->getOutput(); ?>
<input type="hidden" name="step" value="<?php echo $_REQUEST["step"]; ?>">
<a name="bottom"></a>
<?php
$zi_buttons['next'] = $url_next;
include 'themes/'.$GLOBALS['ZI']['theme'].'/footer.php';
} else {
include 'themes/'.$GLOBALS['ZI']['theme'].'/header.php';
$application = $zi_registry->getApplication();
?>
<a name="top"></a>
<h1>Build Package</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>
<pre><?php echo $plugin->getLog(); ?></pre>
<?php echo $plugin->getOutput(); ?>
<input type="hidden" name="step" value="<?php echo $_REQUEST["step"]; ?>">
<a name="bottom"></a>
<?php
$zi_buttons['reload'] = $url_next;
include 'themes/'.$GLOBALS['ZI']['theme'].'/footer.php';
}
?>
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click