Location: PHPKode > projects > ZZ/OSS Installer > zic-1.1.0dev1/installer/dev_plugin.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: dev_plugin.php,v 1.1 2004/03/18 09:41:39 ordnas Exp $
    @copyright Copyright &copy; 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';
    
    function zi_process()
    {
        global $zi_registry;
        
        $plugin_dev = array(
                        $_REQUEST['package'] => $_REQUEST['ZI_VALUES']
                        );
        $zi_registry->setPluginDev($plugin_dev);
    }

    // assign default values
	function zi_default()
	{
		global $zi_registry;
        
        if(!$_REQUEST['ZI_VALUES'] = $zi_registry->getPluginsDev($_REQUEST['package'])){
            
            $pkg_type = 'package';
            if(isset($_REQUEST['type'])){
                $pkg_type = $_REQUEST['type'];
            }
            
            // if we had a previous installation, we get those values
            $app_settings = $zi_registry->getApplicationSettings();
            $_REQUEST['ZI_VALUES']['install_dir'] = $app_settings['application_root'];
            $_REQUEST['ZI_VALUES']['data_dir'] = $zi_registry->getApplicationPath().'data'.DIRECTORY_SEPARATOR.$pkg_type.DIRECTORY_SEPARATOR;
            $_REQUEST['ZI_VALUES']['action'] = 'I';
        }
        return $_REQUEST;
	}

	include 'themes/'.$GLOBALS['ZI']['theme'].'/header.php';
    
    // installer widget class
	require_once 'ZZOSS_Installer/Widget.php';
	$zi_widget = new ZZOSS_InstallerWidget;
    if(isset($zi_errors)){
        $zi_widget->setErrors($zi_errors);
    }
    
    $application = $zi_registry->getApplication();
?>
<h1>Develop Plugin</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>Plugin Environment</h2>
<table border="0" cellspacing="0" cellpadding="4">
<?php
    echo $zi_widget->add('select', 'Handler', 'handler', array('list' => 'role => Role, build => Build'));
    echo $zi_widget->add('select', 'Mode', 'mode', array('list' => '=> ---, pre => Pre-Install, post => Post-Install'));
    echo $zi_widget->add('select', 'Action', 'action', array('list' => 'I => Install, U => Update, R => Remove'));
?>
</table>
<h2>Test Package</h2>
<table border="0" cellspacing="0" cellpadding="4">
<?php    echo $zi_widget->add('path', 'Build Directory', 'build_dir', array('validation' => 'not empty'));
    echo $zi_widget->add('path', 'Install Directory', 'install_dir', array('validation' => 'not empty'));
    echo $zi_widget->add('path', 'Data Directory', 'data_dir', array('validation' => 'not empty'));
?>
</table>
<?php
if(isset($_REQUEST['posted'])){
    ?>
    <h2>Plugin Log</h2>
    <?php
    $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(!$plugin_dev = $zi_registry->getPluginsDev($_REQUEST['package'])){
        PEAR::raiseError('No settings for plugin \''.$_REQUEST['package'].'\'');
    }
    $pkgs_root = $plugin_dev['install_dir'];
    // Location where plugins store their data
    $pkgs_data = $plugin_dev['data_dir'];
    if(!is_dir($pkgs_data)){
        System::mkdir(array('-p', $pkgs_data));
    }
    
    $_REQUEST["step"] = 0;
    
    require_once 'ZZOSS_Plugin/Plugin.php';
    $plugin = new ZZOSS_Plugin;
    $plugin->setDestDir($pkgs_root); 
    $plugin->setDataDir($pkgs_data);
    $plugin->setSource($zi_registry->getApplicationPath().DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR);
    $plugin->setRegistry($zi_registry);
    $plugin->loadPackage($plugin_dev['build_dir'].DIRECTORY_SEPARATOR.'package.xml', $plugin_dev['action']);
    $plugin->exec($plugin_dev['handler'], 0, $plugin_dev['mode']);
    ?>
    <textarea cols="54" rows="10" wrap="on"><?php echo $plugin->getLog(); ?></textarea>
    
    <h2>Plugin Output</h2>
    
    <?php echo $plugin->getOutput(); ?>
    <input type="hidden" name="step" value="<?php echo $_REQUEST["step"]; ?>">
    <a name="bottom"></a>
    <?php
}

    $zi_buttons['back'] = 'packages.php'.zi_form_querystr();
    if(isset($_REQUEST['posted'])){
        $zi_buttons['reload'] = $_SERVER['PHP_SELF'].zi_form_querystr().'&posted';
    } else {
        $zi_buttons['next'] = $_SERVER['PHP_SELF'].zi_form_querystr().'&posted';
    }
	include 'themes/'.$GLOBALS['ZI']['theme'].'/footer.php';
?>
Return current item: ZZ/OSS Installer