<?php

	namespace Mocha\UI\Pages;
	
	use Mocha\Core\KnownAttributeGuids;
	use Mocha\Core\KnownClassGuids;
	use Mocha\Core\KnownInstanceGuids;
	use Mocha\Core\KnownRelationshipGuids;

	use Mocha\Core\OmsContext;
	
	use Mocha\UI\Renderers\HTML\HTMLRenderer;
	use Phast\RenderingEventArgs;
	use Phast\System;
	use Phast\WebPage;

	use Mocha\Oms\MySQLDatabaseOms;


	class HomePage extends WebPage
	{

		protected function OnRendering(RenderingEventArgs $re)
		{
			parent::OnRendering($re);

			/**
			 * @var MySQLDatabaseOms
			 */
			$oms = mocha_get_oms();

			mocha_init_spot_timer($this->Page);

			$context = new OmsContext();
			
			$renderer = new HTMLRenderer($context);
			
			$pageElement = $oms->getInstanceByGlobalIdentifier(KnownInstanceGuids::Element__HomePage);
			if ($pageElement === null)
			{
				print ("could not find element 'HomePage'");
				die();
			}

			$renderer->IsPostback = $this->Page->IsPostback;
			if ($this->Page->IsPostback)
			{
				$renderer->processPostback($pageElement);
			}
			$renderer->renderInitialElement($pageElement);
			exit();

			/*
			mocha_init_spot_timer($this);

			$this->Page->GetControlByID("litUserNameForUserMenu")->Content = "zq-developer / Developer Generic User";

			$litDashboard = $this->Page->GetControlByID("litDashboard");
			$litDashboard->Content = "<div class=\"mcx-element\" data-iid=\"32$126\">" .
			"<div class=\"mcx-element-content\" data-ecid=\"6$134202\"><label>Name</label><input type=\"text\" name=\"ec_6$134202\" /></div>" .
			"</div>";
			*/
		}

	}
?>