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

/**
 * lnApp Main home page
 *
 * @package    lnApp
 * @subpackage Page/Home
 * @category   Controllers
 * @author     Deon George
 * @copyright  (c) 2010 Deon George
 * @license    http://dev.leenooks.net/license.html
 */
class Controller_Welcome extends Controller_TemplateDefault {
	protected $auth_required = FALSE;

	public function action_index() {
		if (! Kohana::config('config.client'))
			Request::current()->redirect('guide/app');

		if (! Auth::instance()->logged_in())
			Request::current()->redirect('login');

		Block::add(array(
			'title'=>'Welcome to lnApp (public)!',
			'subtitle'=>'Using lnApp',
			'body'=>'Sample lnApp application',
			'footer'=>'lnApp makes building websites easy! '.time(),
		));

		// @todo Show a login/logout on the breadcrumb
		if (! Auth::instance()->logged_in()) {
			Script::add(array('type'=>'stdin','data'=>'
				$(document).ready(function() {
					$("#ajxbody").click(function() {$("#ajBODY").load("'.URL::site('/login').'",null,function(x,s,r) {}); return false;});
					$("#ajBODY").ajaxSend(function() {$(this).html(\''.sprintf('%s <span class="ajaxmsg">%s<\/span>...',HTML::image('media/img/ajax-progress.gif',array('alt'=>_('Loading Login').'...')),_('Loading Login')).'\');return  true;});
				});'
			));
		}
	}
}
?>
