<?php defined('SYSPATH') or die('No direct access allowed.');

/**
 * lnApp User Main home page controller
 *
 * @package    lnApp
 * @subpackage Page/Admin
 * @category   Controllers
 * @author     Deon George
 * @copyright  (c) 2010 Deon George
 * @license    http://dev.leenooks.net/license.html
 */
class Controller_TemplateDefault_Admin extends Controller_TemplateDefault_User {
	protected function setup(array $config_items=array()) {
		$module = Request::current()->controller();

		if ($_POST AND isset($_POST['module_config'][$module]))
			Config::instance()->so->module_config($module,$_POST['module_config'][$module])->save();

		if ($config_items) {
			$output = '';
			$mc = Config::instance()->so->module_config($module);

			$output .= Form::open();
			$output .= View::factory('setup/admin/module/head');

			foreach ($config_items as $k=>$v)
				$output .= View::factory('setup/admin/module/body')
					->set('module',$module)
					->set('mc',$mc)
					->set('key',$k)
					->set('info',$v)
					->set('val',isset($mc[$k]) ? $mc[$k] : '');

			$output .= View::factory('setup/admin/module/foot');

			$output .= Form::submit('submit',_('Submit'),array('class'=>'form_button'));
			$output .= Form::close();

			Block::add(array(
				'title'=>sprintf('%s: %s',strtoupper($module),_('Configuration')),
				'body'=>$output,
			));
		}
	}
}
?>
