<?php

	/**
	 * The Legend of Z
	 *
	 * @author	Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
	 * @copyright	2014 Heinrich-Heine-Universität Düsseldorf
	 * @license	http://www.gnu.org/licenses/gpl.html
	 * @link	https://bitbucket.org/coderkun/the-legend-of-z
	 */
	
	namespace hhu\z\agents\toplevel;
	
	
	/**
	 * Agent to display a HTML-page.
	 * 
	 * @author	Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
	 */
	class HtmlAgent extends \hhu\z\agents\ToplevelAgent
	{
		
		
		
		
		protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
		{
			parent::__construct($request, $response, $log);
			
			
			$this->setLanguage($request);
		}
		
		
		/**
		 * Action: index.
		 */
		public function index(\nre\core\Request $request, \nre\core\Response $response)
		{
			// Add menu
			$this->addSubAgent('Menu');
			
			// Add Seminary sidebar
			$this->addSubAgent('Seminarybar');
		}
		
		
		
		
		private function setLanguage(\nre\core\Request $request)
		{
			// Set domain
			$domain = \nre\configs\AppConfig::$app['genericname'];
			
			// Get language
			$locale = $request->getGetParam('lang', 'language');
			if(is_null($locale)) {
				return;
			}
			
			// Load translation
			putenv("LC_ALL=$locale");
			setlocale(LC_ALL, $locale);
			bindtextdomain($domain, ROOT.DS.\nre\configs\AppConfig::$dirs['locale']);
			textdomain($domain);
		}
		
	}

?>
