<?php
/**
 * @package linea21.core
 * @subpackage system
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

//////////// Check Inclusion de pages //////////// 
if (!function_exists('AuthenthificationProcess')) {
	include_once ("../lib/lib_common.php");
	ReloadIndex('admin');
}
$config_file = new config_file;
$config_file->__construct($GLOBALS['authorized_release_sections'],$GLOBALS['authorized_db_sections'],$GLOBALS['authorized_theme_sections']);
$config_file->loadParams();
$hidden=false; //variable pour cacher ou non les champs de formulaire
$link_mod=$rub_link."&amp;todo=mod&amp;type=";
$updatable=true;//le formulaire est en modification ou en visualisation

if (isset($_GET['type']))	$type=$_GET['type'];
if (isset($_POST['type'])) $type=$_POST['type'];

if(isset($_POST['valider'])) {
	$updatable=false;
	$hidden=true;
	$config_file->setParams($type,$_POST);
}
if(isset($_POST['enregistrer'])) {
	
	$config_file->setParams($type,$_POST);
	$link_confirm="confirm.php?rub=".$rub."&todo=".$todo;
	//ok on écrit les paramètres en fichiers
	if($type == 'define_release' || $type == 'theme') $result=$config_file->writeReleaseParams();
	else if($type == 'define_db') $result=$config_file->writeDbParams();
	if($result) header("Location: ".$link_confirm);
	else  system_error();
}

?>

<div id="chemin">
	<ul>
		<li>
			<a href="index.php"><? echo $GLOBALS['lang']['way']['home'] ?></a>
		</li>
		<li>
			<a href="<?php echo $rub_link; ?>"><? echo $GLOBALS['lang']['menu']['system']?></a>
		</li>
		<li>
			<span><? echo $GLOBALS['lang']['system']['mod'] ?></span>
		</li>
	</ul>
</div>

  <!--end barre haute -->
<?php
include_once ("quickicons.php");
?>
<div class="contentcontainer">
<?php include_once($dir . "/menurub.php");?>
<div id="content">
<h2><? echo $GLOBALS['lang']['system']['mod']; ?></h2>
<form id="<? echo $type; ?>" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post" <?if(isset($_POST['valider'])) {?>onsubmit="if(!confirm('<? echo $GLOBALS['lang']['system']['confirm_mod_js']; ?>')) return false;"<?}?>>
	<?php 
	switch ($type) 
	{	
		case 'define_release':
		echo $config_file->getReleaseParams($updatable,$hidden);
		break;
		case 'define_db':
	    echo $config_file->getDbParams($updatable,$hidden);
		break;
		case 'theme':
	    echo $config_file->getThemeParams($updatable,$hidden);
		break;
		default:
		echo $config_file->getReleaseParams($updatable,$hidden);					
	}
	?>
	<div>
	<input name="type" type="hidden" value="<?php echo $type; ?>" id="type" />
	<input name="rub" type="hidden" value="<?php echo $rub; ?>" id="rub" />
	<input name="todo" type="hidden" value="<?php echo $todo; ?>" id="todo" />
				
	<?php 
	if(!isset($_POST['valider']) && !isset($_POST['enregistrer'])){
		echo cancel_button('javascript:history.go(-1);'); 
	?>
	<input name="valider" type="submit" value="<? echo $GLOBALS['lang']['btn']['valid'] ?>" class="button" id="valider" />
	<? } 
	else if(isset($_POST['valider'])){?>
		<?php echo cancel_button('?rub=system&amp;todo=list'); ?>
		<input name="retour" type="button" value="<? echo $GLOBALS['lang']['btn']['preview'] ?>" class="button" id="retour" onclick="history.go(-1);" />
		<input name="enregistrer" type="submit" value="<? echo $GLOBALS['lang']['btn']['save'] ?>" class="button" id="enregistrer" />		
	<?}?>
	</div>
</form>
</div>
<?php include_once($dir . "/help.php");?>
</div>
  
