<?php
$link_retour="<a href='config_modules.php'>".RETOUR."</a>";
//  Couche JS Non intrusif pour oblige a enregistrer la pags si click ailleurs que dans element centraux form
array_push($js_lib, "add_click_onload"); array_push($function_js_init, "add_click_onload('menu','');");
?>
	<div id="menu_inter" class="menu3"><nobr><?php print '<p>'.option_deplie('help_page',HELP_PAGE,true).''.option_deplie('help_mod_develop',DEVELOPP_MOD,true).option_deplie('alertes',ALERTE,true).option_deplie('mod_charger',MOD_CHARGER,true).'</p>';  ?></nobr></div>
	<div id="config">

		<div id="contenu_config">
			<div class="i_box">
				<h1><?php echo LE_TITRE_DE_LA_PAGE ?></h1>
			</div><br />

		<div id='alertes'  style="display:none;"  class="a_box">
			<h2><?php echo ALERTE ?></h2>
			<?php
			if  ( (!defined('MODULES'))OR (MODULES=='false') ) { print "<p class='alerte'>".ALERT_MODULES_OFF."</p>"; array_push($function_js_init, "montre('alertes');");}
			## controles des modules
			include (ADD_PATH_ADMIN.TBL_SYS_CONFIG_MODULES_INC);
			include (ADD_PATH_ADMIN.TBL_DEP_MODULES_INC);
			global $t_dep,$t_conflit;
			$t_dep=$t_conflit=array();
			reset($_PX_config_module);
			while ($r=each($_PX_config_module))
				if ($r['value'] =='true'){
					## control des dependances des modules
					if (isset($dep[$r['key']])&&is_array($dep[$r['key']])) {
						while ($e=each($dep[$r['key']])){
							$key_dep=eregi_replace('_[0-9.]*[a-z0-9.]*$','',$e['value']);
							if (eregi('dep_',$e['key'])&& !in_array($key_dep,$t_dep) && !in_array($key_dep,$t_conflit) ){
								array_push($t_dep,$key_dep);
							}
							elseif (eregi('^conf.*',$e['key'])) {
								array_push($t_conflit,$key_dep);
							}
						}
					}
				}
				## rajout elmeent non dependant mais actif
			reset($_PX_config_module);
			while ($r=each($_PX_config_module))
			if ($r['value'] =='true')
			if (!in_array($r['key'],$t_dep)&& !in_array($r['key'],$t_conflit)) {
						array_push($t_dep,$r['key']);
						}
			if (count($t_conflit)>0){
				reset($t_conflit);
				while ($r = each($t_conflit)){
				if (in_array($r['value'],$t_dep))print "<p class='alerte'> ".CONFLIT.' '.$r['value']."</p>\n";
				elseif(isset($_PX_config_module[$r['value']])&& $_PX_config_module[$r['value']]=='true')print "<p class='alerte'> ".PAQUET_FORCE_OFF.' '.$r['value']."</p>\n";
				}
				array_push($function_js_init,"montre('alertes');");
			}
		?></div>
		<div id='mod_charger'  style="display:none;" class="a_box">
			<h2><?php echo LIST_ETAT_MOD_CHARGEE ?></h2>
			<?php print '<p>'.MOD_CHARGER_TXT.'</p><dl>';
				reset($t_dep);
				include('config/sys_uninstall.php');
				include (ADD_PATH_ADMIN.'include/lib_ext.php');
			      while ($r = each($t_dep))
				if (!in_array($t_dep[$r['key']],$t_conflit) AND !eregi('(admin)',$_PX_uninstall[$r['value']])) {
					print "<dd> ".'<strong>Paquet:</strong> '.$t_dep[$r['key']]."</dd>\n<dt>";
					if (isset($LIB[$r['value']]))
					while ($lib= each($LIB[$r['value']]))
						print '<p style="margin-left:50px">'.$lib['key'].' -- '.$lib['value'].'</p>';
					print '</dt>';
				}
				print '</dl>';
			?>
		</div>
		<div id='help_page'  style="display:none;" class="a_box">
			<h2><?php echo HELP_PAGE ?></h2>
			<p><?php echo LE_TEXTE_1 ?></p>
		</div>
		<br />
		<div id='help_mod_develop'  style="display:none;" class="a_box">
			<h2><?php echo DEVELOPP_MOD ?></h2>
			<p><?php $url=eregi_replace('feed.php','doku.php?id=start:modules:list:paquet:doc_dev',URL_MISSOL_RSS_WIKI);
			print $note =create_link_popup_wiki($url,NOTICE_WIKI_LINK_POPUP,false);/*TXT_DEVELOPP_MOD*/ ?></p><br />
		</div>

		<div class="a_box">
			<h2><?php echo LIST_ETAT_MODULES ?></h2><br />
				<div id='list_etat_module'><p style="text-align:center; margin-top:20px"><?php  print IMG_ONLOAD;?></p></div>
				<script type="text/javascript">
					function list_etat_module (){ upload_ajax('list_etat_module','include/lib/lib.config_modules.php','list_etat_module','',false); }
					<?php array_push($function_js_init, "list_etat_module();"); ?>
				</script>
				<noscript>
					<?php list_etat_module(); ?>
				</noscript>
			<br /><br /></div>
		</div>
	</div> <!-- Fin de articles -->
		<div id="droit" class="a_box">
			<h2><?php print TEXT_ACTION ?></h2>
		<div id="droit_content">
		<?php
		if (isset($_GET['mod'])){  //sys_conf_module
		switch($_GET['conf']){
		  case 'sys':
		    if (isset($_GET['confirm'])){
			    if ($_GET['var']=='install') print install_module($_GET['mod']).$link_retour;
			    else print on_off_module($_GET['mod'],$_GET['var']).$link_retour;
		    }
		    else {
		    if ($_GET['var']=='install')tep_page_confirm('config_modules.php','mod='.$_GET['mod'].'&amp;conf=sys&amp;var=install&amp;confirm=1',CONFIRM_INSTALL_MODULE." ".$_GET['mod'],$_POST,'');
		    elseif ($_GET['var']=='false')tep_page_confirm('config_modules.php','mod='.$_GET['mod'].'&amp;conf=sys&amp;var=false&amp;confirm=1',CONFIRM_OFF_MODULE." ".$_GET['mod'],$_POST,'');
		    elseif($_GET['var']=='true') tep_page_confirm('config_modules.php','mod='.$_GET['mod'].'&amp;conf=sys&amp;var=true&amp;confirm=1',CONFIRM_ON_MODULE." ".$_GET['mod'],$_POST,'');
		    }
		  break;
		  case 'mod': // appel fonction specifique aux modules
		    if (isset($_GET['confirm'])) {
		      include(ADD_PATH_ADMIN.$_PX_uninstall[$_GET['mod']].$_GET['mod']."/admin/up_config.php");
		      print up_config($_POST);
		    }
		    else {
		      include(ADD_PATH_ADMIN.$_PX_uninstall[$_GET['mod']].$_GET['mod']."/admin/form_edit_config.php");
		      print form_edit_config();
		    }
		  break;
		}
		 array_push($function_js_init, "list_etat_module();");
		}
		?>
		</div>
		<div id="droit_nav">
			<?php if (isset($_GET['mod'])) print $link_retour; ?>
		</div>
	</div>
</div>