<?php
/*=====================================================================*\
|| ###################################################################
|| # Kalens [#]version[#]
|| # Copyright ©2002-[#]year[#] Iris Studios, Inc.
|| #
|| # This program is free software; you can redistribute it and/or modify
|| # it under the terms of the GNU General Public License as published by
|| # the Free Software Foundation; version [#]gpl[#] of the License.
|| #
|| # This program 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 General Public License for
|| # more details.
|| #
|| # You should have received a copy of the GNU General Public License along
|| # with this program; if not, write to the Free Software Foundation, Inc.,
|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|| ###################################################################
\*=====================================================================*/

// ######################### REQUIRE BACKEND #########################
define('SVN', '$Id$');
require_once('./global.php');

// ######################## START MAIN SCRIPT ########################

if (empty($_REQUEST['do']))
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?= $lang->string('Administration') ?></title>
</head>

<script type="text/javascript">
<!--
	document.write('<frameset cols="200,*" frameborder="no" border="0" framespacing="0">');
	document.write('	<frame src="index.php?do=nav" name="left" scrolling="auto" noresize="noresize" />');
	document.write('	<frame src="index.php?do=main" name="main" />');
	document.write('</frameset>');
	document.write('<noframes>');
	document.write('<body>');
	document.write('<?= $lang->string('Your browser does not support frames. Please get one that does!') ?>');
	document.write('</body>');
	document.write('</noframes>');
-->
</script>
<noscript>
<body>

	<?= $lang->string('JavaScript is required to browse and use the admin control panel. Please make sure it is enabled and try again.') ?>


</body>
</noscript>

</html>
<?php
}

if ($_REQUEST['do'] == 'main')
{
	$admin->page_start(sprintf($lang->string('%1$s Panel'), $lang->string('Administration')));

	$admin->table_start();
	$admin->table_head(sprintf($lang->string('%1$s Panel'), $lang->string('Administration')), 2);
	$admin->row_span($lang->string('Welcome to the ProCal Administration Panel. Here you can setup all of the various options that ProCal has to offer. If you have any problems using this panel, consult the <a href="http://docs.iris-studios.com/" target="_blank">online manual</a>.'), 'alt1');
	$admin->table_end();
	$admin->form_end();

	$admin->page_end();
}

if ($_REQUEST['do'] == 'nav')
{
	define('ISSO_PRINTER_HIDE_SETUP', true);

	$navigation = array(
		$lang->string('Kalens Settings')	=> array(
			'&raquo; ' . $lang->string('New Setting Group')		=> 'options.php?do=newgroup', // debug
			$lang->string('XML Import/Export')					=> 'options.php?do=io',
			// ... and here are all of the option groups
		),

		$lang->string('Language Manager')	=> array(
		),

		$lang->string('Template Manager')	=> array(
			$lang->string('Manage Styles')						=> 'styles.php',
			'&raquo; ' . $lang->string('MASETR STYLE')			=> 'templates.php?do=modify&amp;styleid=-1', // debug
			// ... a list of all the styles
		),

		$lang->string('User Manager')		=> array(
			$lang->string('Add User')							=> 'users.php?do=add',
			$lang->string('Search')								=> 'users.php?do=search',
			$lang->string('Show All Users')						=> 'users.php?do=results&amp;id=-1'
		)
	);

	// extra setting groups
	$get_settings = $db->query("SELECT * FROM " . TABLE_PREFIX . "settinggroup ORDER BY displayorder ASC");
	while ($setting = $db->fetch_array($get_settings))
	{
		if ($setting['shortname'] == 'untouchable' AND !DEVDEBUG)
		{
			continue;
		}
		$navigation[ $lang->string('Kalens Settings') ]["$setting[groupname]"] = "options.php?do=settings&amp;group=$setting[shortname]";
	}

	// get styles
	$get_styles = $db->query("SELECT * FROM " . TABLE_PREFIX . "style ORDER BY stylename");
	while ($style = $db->fetch_array($get_styles))
	{
		$navigation[ $lang->string('Template Manager') ][ '&raquo;&nbsp;' . $style['stylename'] ] = "templates.php?do=modify&amp;styleid=$style[styleid]";
	}

	// -------------------------------------------------------------------

	$admin->page_start($lang->string('Navigation'), 'nav_body');

	$admin->page_code("\n<div align=\"center\"><img src=\"../images/admin/logo.gif\" title=\"\" border=\"0\" /></div>\n");
	$admin->page_code("<br />\n<br />\n\n<!-- cp main link -->\n<div align=\"center\">\n\t<a href=\"index.php?do=main\" class=\"smallfont\" target=\"main\">" . $lang->string('Index') . "</a> | <a href=\"../login.php?do=cplogout\" class=\"smallfont\" target=\"_parent\">" . $lang->string('Logout') . "</a>\n</div>\n<!-- / cp main link -->\n<br />\n");

	foreach ($navigation AS $group => $links)
	{
		echo "\n" . "<div class=\"nav_title\"><strong>$group</strong></div>";
		echo "\n" . "<div class=\"nav_group\">";

		foreach ($links AS $name => $location)
		{
			echo "\n\t" . "<div class=\"nav_item\"><a href=\"$location\" target=\"main\">$name</a></div>";
		}
		echo "\n</div>";
	}

	$admin->page_end();
}

/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>