Location: PHPKode > projects > ZZ/OSS Installer > zic-1.1.0dev1/installer/packages_config.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: packages_config.php,v 1.1 2003/12/22 17:19:58 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
    */

	// plugin library
	require_once 'ZZOSS_Plugin/Plugin.php';
	// installer widget library
	require_once 'ZZOSS_Installer/Widget.php';

	// execute init file
	require_once 'inc/init.php';

	/***************************************************************************   
    * INSTALLER FRAMEWORK FUNCTIONS                                       	   *   
    ***************************************************************************/   

	function zi_process()
	{
		global $plugins, $ZZOSS_INSTALLER;
		// save the parameters for later installations
		// TODO: save for each component
		$file = $ZZOSS_INSTALLER["application_path"].'installer/config_components.reg';
		ZZOSS_InstallerUtils::serializeToFile( $file, $_REQUEST );
		
		$_REQUEST = zi_default();
		
		// iterate components
		$components = getComponents();
		if(is_array($components) && count($components)){
		  	foreach($components as $component_name => $component_params){
				// scan directory for plugins
				$dir = $component_params['path'].'zzoss_installer/';
				if($dp = opendir($dir)) {
					while (false !== ($entry = readdir($dp))) { 
						$plugin_dir = $dir.$entry;
						if(($entry != '.')&&($entry != '..')&&(is_dir($plugin_dir))) {
							$plugin_dir .= '/';
							if($plugins[$entry]) {
								$modus = 'change_config';
								$log .= ZZOSS_Plugin::exec($plugins[$entry], $plugin_dir, $component_name, $modus, /*$GLOBALS['ZI_CONFIG']->query('/application/installation/mode'),*/ array('datapath' => $ZZOSS_INSTALLER["application_path"].'modules/'));
							}
						}
				    }
					closedir($dp);
				}
			}
		}
	}
	
	// assign default values
	function zi_default()
	{
		global $ZZOSS_INSTALLER;
	  	$_REQUEST['ZI_VALUES'] = array();
	  	// get global connector values
		$file = $ZZOSS_INSTALLER["application_path"].'installer/config_components.reg';
		if(file_exists($file)){
		  	// create serialized default data
			$params = ZZOSS_InstallerUtils::unserializeFromFile( $file );
			if(is_array($_REQUEST["ZI_VALUES"]) && is_array($params['ZI_VALUES'])) {
				$_REQUEST['ZI_VALUES'] = $_REQUEST['ZI_VALUES'] + $params['ZI_VALUES'];
			}
		} else {
		  	$_REQUEST['ZI_VALUES']['default_api'] = 'ZZOSS::Repository::PEAR::DB';
			$_REQUEST['ZI_VALUES']['default_authorization_api'] = 'ZZOSS::Authorization::PEAR::DB';
		}
	  	// get global paths values
		$file = $ZZOSS_INSTALLER["application_path"].'installer/application_settings.reg';
		if(file_exists($file)){
			$params = ZZOSS_InstallerUtils::unserializeFromFile( $file );
			$_REQUEST['ZI_VALUES'] = $_REQUEST['ZI_VALUES'] + $params['ZI_VALUES'];
		}
	  	// get global connector values
		$file = $ZZOSS_INSTALLER["application_path"].'installer/config_global_connector.reg';
		if(file_exists($file)){
			$params = ZZOSS_InstallerUtils::unserializeFromFile( $file );
			$_REQUEST['ZI_VALUES'] = $_REQUEST['ZI_VALUES'] + $params['ZI_VALUES'];
		}
		
		return $_REQUEST;
	}
	
	/***************************************************************************   
    * SCRIPT SPECIFIC FUNCTIONS                                       	   	   *   
    ***************************************************************************/   
	
	function composeComponentsArray() {
		global $packages;
		if(is_array($packages)) {
			foreach($packages as $package) {
				if(isset($package["installed"])) {
					$components[$package["name"]] = array('path' => $package["install"]["path"] );
				}
			}
		}
		return $components;
	}
	
	function getComponents($components = false) {
		if(!$components) {
			$components = composeComponentsArray();
		}
		$components_select = array();
		if(!is_array($_REQUEST["components_choose"])) {
			// per default select all
			$components_select = $components;
		} else {
			if(is_array($_REQUEST["components_choose"]) && count($_REQUEST["components_choose"])) {
				foreach($_REQUEST["components_choose"] as $val) {
					if($components[$val]) {
						$components_select[$val] = $components[$val];
					}
				}
			}
		}
		return $components_select;
	}
	
	/***************************************************************************   
    * STARTUP                                                             	   *   
    ***************************************************************************/   

	$components = composeComponentsArray();
	$components_select = getComponents($components);
	
	$zi_widget = new ZZOSS_InstallerWidget;
	
	/***************************************************************************   
    * PAGE CONTENT                                                             *   
    ***************************************************************************/   
	
	include 'themes/'.$GLOBALS['ZI']['theme'].'/header.php';
	?>
	<h1>Configure Packages</h1>
	<div class="choices">
	<select size="7" multiple name="components_choose[]">
		<?php
		if(is_array($components) && count($components)) {
			foreach($components as $component_name => $component_params) {
				echo '<option value="'.$component_name.'"';
				if($components_select[$component_name]) {
					echo ' selected';
				}
				echo '>'.$component_name."\n";
			}
		}
		?>
	</select>
	<input type="submit" name="btn_update" value="update view">
	</div>
	<br clear="all"/>
	<?php
	// iterate components for installation
	if(is_array($components_select) && count($components_select)){
		?>
		<a name="top"></a>
		<?php
	  	foreach($components_select as $component_name => $component_params){
			$component_form = '';
			// scan directory for plugins
			$dir = $component_params['path'].'zzoss_installer/';
			if($dp = @opendir($dir)) {
				while (false !== ($entry = readdir($dp))) { 
					$plugin_dir = $dir.$entry;
					if(($entry != '.')&&($entry != '..')&&(is_dir($plugin_dir))) {
						$plugin_dir .= '/';
						if($plugins[$entry]) {
								$component_form .= ZZOSS_Plugin::config($plugins[$entry], $plugin_dir, $component_name, array('datapath' => $ZZOSS_INSTALLER["application_path"].'modules/'));
						}
					}
			    }
				closedir($dp);
			}
			
		  	if(strlen($component_form)>0){
				$shown = true;
			  	//$zi_widget->setHelpPath($component_params['path'].'zzoss_installer/help/');
				//echo 'exists';
				?>
				<hr size="1" noshade/>
				<b><a name="<?php echo $component_name; ?>"></a><?php echo $component_name; ?></b><br/><br/>
				<table border="0" cellspacing="0" cellpadding="4" align="left">
				<?php
		  	  	echo $component_form;
				?>
				</table><br clear="all"/>
				<p align="right"><a href="#top">up</a>&nbsp;|&nbsp;<a href="#bottom">down</a></p>
				<?php
			}
		}
		?>
		<a name="bottom"></a>
	<?php
		$zi_buttons['save'] = $_SERVER['PHP_SELF'];
	}

	include 'themes/'.$GLOBALS['ZI']['theme'].'/footer.php';
?>
Return current item: ZZ/OSS Installer