<?php
// $Id: index.php,v 1.6 2005/10/22 08:10:52 ohwada Exp $

// 2005-10-01 K.OHWADA
// change index.php to class

//=========================================================
// What's New Module
// admin config
// 2005-10-01 K.OHWADA
//=========================================================

include_once 'admin_header.php';

$DIR_CONFIG = XOOPS_ROOT_PATH."/modules/whatsnew/cache";

// class
$class_config =& admin_config::getInstance();

$op = get_post_get('op');

if ($op == 'save')
{
	if( !check_token() ) 
	{
		xoops_cp_header();
		xoops_error("Token Error");
	}
	else
	{
		$class_config->save();
		redirect_header("index.php", 2, _WHATSNEW_CONFIG_SAVED);
	}
}
elseif ($op == 'init')
{
	if( !check_token() ) 
	{
		xoops_cp_header();
		xoops_error("Token Error");
	}
	else
	{
		$class_config->init();
		redirect_header("index.php", 2, _WHATSNEW_CONFIG_SAVED);
	}
}
elseif ($op == 'upgrade')
{
	if( !check_token() ) 
	{
		xoops_cp_header();
		xoops_error("Token Error");
	}
	else
	{
		$class_config->upgrade();
		redirect_header("index.php", 2, _WHATSNEW_CONFIG_SAVED);
	}
}
else
{
	xoops_cp_header();
}

print_header();

if ( !$class_config->is_exist() )
{
	xoops_error( _WHATSNEW_INIT_NOT );
	$class_config->print_form_init();
}
elseif ( !$class_config->is_version( _WHATSNEW_VERSION ) )
{
	$title = sprintf( _WHATSNEW_VERSION_NOT, _WHATSNEW_VERSION );
	xoops_error( $title );
	$class_config->print_form_upgrade();
}
elseif ( !is_writable($DIR_CONFIG) )
{
	xoops_error( _WHATSNEW_WARNING_NOT_WRITABLE );
	echo "<br />\n";
	echo "$DIR_CONFIG <br /><br />\n";
}
else
{
	print_menu();
	echo "<h4>"._MI_WHATSNEW_ADMENU1."</h4>\n";
	echo "<h4>"._WHATSNEW_CONFIG_BLOCK."</h4>\n";
	$class_config->show_form();

	echo _WHATSNEW_NOTE_RSS_MARK."<br />\n";

	echo "<h4>"._WHATSNEW_ICON_LIST."</h4>\n";
	$class_config->show_icon_list();
}

print_footer();
xoops_cp_footer();
exit();
// --- main end ---


?>