<?php
/*
 * DON'T REMOVE THE FOLLOWING LICENSE
 *           INFORMATION!
 * ----------------------------------
 * Copyright by
 * Global Cube Business Solutions
 * Author: Dennis Ritz
 * info@global-cube.de
 * 2007-2008
 * ----------------------------------
 */
class MISModel extends App {
	
	public function __construct() {
		parent::__construct(__file__);
	}
	
	/*
	 * init
	 * ----
	 * This function sets the main workaround for this class.
	 */
	public function __init() {
		return $this->__MODEL();
	}
	
	/*
	 * getModel
	 * --------
	 * This function sets the main HTML Base.
	 * Please see manual for detail description.
	 */
	public function getModel() {
		$MISConfig = new MISConfig();
		$projectDOM = new DOMDocument('1.0', 'utf-8');
		$projectDOM->load($MISConfig->getConfigFile());
		$projectXpath = new DOMXpath($projectDOM);
		$configName = $projectXpath->query("/Configuration")->item(0)->getAttribute("Name");

        $tpl = $this->Template();
        $tpl->assign("TITLE",$configName." - ".$this->_getI18N("title"));
        $tpl->assign("CONFIG",$configName);
        $tpl->assign("PUBLISHER","&copy;&nbsp;".$this->_getI18N("publisher"));
        $tpl->assign("LANG",$this->_getLang());
if($this->getAuth())
        $tpl->assign("USER",$this->getUsername()." ".$this->_getI18N("logout"));
else 
        $tpl->assign("USER",$this->_getI18N("login"));
        print $tpl->fetch('model.html');
	}
	
	public function getHead() {
		global $Core;
		
		$p_args = func_get_args();
		$p_comp = array_shift($p_args);
		return $Core->callComp($p_comp,"getMain",$p_args);	
	}

	public function getLeftbar() {
		global $Core;
		
		$p_args = func_get_args();
		$p_comp = array_shift($p_args);
		return $Core->callComp($p_comp,"getMain",$p_args);		
	}

	public function getMain($p_comp = null) {
		if($this->getAuth()) {
			global $Core;
			
			$p_args = func_get_args();
			$p_comp = array_shift($p_args);
			$res = $Core->callComp($p_comp,"getMain",$p_args);				

			return array(
$res[0]		
,'
Browser.setDisplay(Browser.getElementById("leftdivider"),true);
Browser.setDisplay(Browser.getElementById("leftbar"),true);
xonresize();
'.$res[1]);
		} elseif($p_comp == "MISAuth") {
			$MISAuth = new MISAuth();
			return $MISAuth->getMain();			
		} else {
			return array(''
,'
Browser.setDisplay(Browser.getElementById("leftdivider"),false);
Browser.setDisplay(Browser.getElementById("leftbar"),false);
xonresize();CMgr.getMODEL().getMain(\'MISAuth\');');
		}
	}
	
	public function getFoot() {
		return '&copy; Global Cube Business Solutions 2007-2008. All rights reserved. ';
	}
	
	public function getRetrieveInput(){
		if($this->getAuth()) {
			global $Core;
			
			$p_args = func_get_args();
			$p_comp = array_shift($p_args);
			$res = $Core->callComp($p_comp,"getRetrieveInput",$p_args);	
			return array(
$res[0]		
,''.$res[1]);			
		} else {
			return array(''
,'
CMgr.getMODEL().__construct();
');
		}
	}
}
?>