<?php
class Page {
	protected static $_instance = null;
	private $title, $stylesheets=array(), 
		$javascripts=array(),
		$_plugin=array(),
		$set=array(),
		$desc,$keyword,$main,$load,$atas,$menu,$module,
		$maintop,$banner,$tengahtop,$tengahmid1,$tengahmid2,$tengahmid3,$tengahmid4,
		$tengahfull,
		$tengah,$bawah,$judul,$fclass=array(),$plugins,$icon,$menuatas,$modatas,$modulekiri,$modulekanan,
		$footer,
		$midtengah,
		$halamanatas;
		
    public static function getInstance()
    {
        if (null === self::$_instance) {
            self::$_instance = new self();
        }
        return self::$_instance;
    }
	function setIcon($icon) {
		$this->icon = $icon;
	}
	function setTitle($title) {
		$this->title = $title;
	}
	
	function setJudul($title) {
		$this->judul = $title;
	}
	function setDec($title) {
		$this->desc = $title;
	}
	function setKeyword($title) {
		$this->keyword = $title;
	}
	
	function addSet($setload) {
		$this->set[] = $setload.";";
	}
	
	function addCSS($path) {
		$this->stylesheets[] = NPAGE.$path;
	}
	
	function addPlugin($plg) {
		$this->_plugin[] = $plg;
	}
	
	function getPlugin() {
		return $this->_plugin;
	}
	
	function tbCss($nama,$mode=0) {
		$mod=explode('_', $nama);
		switch($mod[0])
		{
			case 'hal':
				if($mode==0){
					$this->stylesheets[] = NPAGE.'halaman/'.$nama.'/css/'.$nama.'.css';
				}else if($mode==1){
					$this->stylesheets[] = NPAGE.'kadmin/halaman/'.$nama.'/css/'.$nama.'.css';
				}
				break;
			case 'mod':
				if($mode==0){
					$this->stylesheets[] = NPAGE.'module/'.$nama.'/css/'.$nama.'.css';
				}else if($mode==1){
					$this->stylesheets[] = NPAGE.'kadmin/module/'.$nama.'/css/'.$nama.'.css';
				}
				
				break;
			case 'plg':
				if($mode==0){
					$this->stylesheets[] = NPAGE.'plugins/'.$nama.'/css/'.$nama.'.css';
				}else if($mode==1){
					$this->stylesheets[] = NPAGE.'kadmin/plugins/'.$nama.'/css/'.$nama.'.css';
				}
				break;
		}
		
	}
	function tbJs($nama,$mode=0) {
		$mod=explode('_', $nama);
		switch($mod[0])
		{
			case 'hal':
				if($mode==0){
					$this->javascripts[] = NPAGE.'halaman/'.$nama.'/js/'.$nama.'.js';
				}else if($mode==1){
					$this->javascripts[] = NPAGE.'kadmin/halaman/'.$nama.'/js/'.$nama.'.js';
				}
				break;
			case 'mod':
				if($mode==0){
					$this->javascripts[] = NPAGE.'module/'.$nama.'/js/'.$nama.'.js';
				}else if($mode==1){
					$this->javascripts[] = NPAGE.'kadmin/module/'.$nama.'/js/'.$nama.'.js';
				}
				break;
			case 'plg':
				if($mode==0){
					$this->javascripts[] = NPAGE.'plugins/'.$nama.'/js/'.$nama.'.js';
				}else if($mode==1){
					$this->javascripts[] = NPAGE.'kadmin/plugins/'.$nama.'/js/'.$nama.'.js';
				}
				break;
		}
		
	}
	function addClass($nama,$file){
		ob_start();
		$mod=explode('_', $nama);
		switch($mod[0]){
			case 'hal':
				$this->fclass[]='halaman/'.$nama.'/class/'.$file.'.php';
				break;
			case 'mod':
				$this->fclass[]='module/'.$nama.'/class/'.$file.'.php';
				break;
			case 'plg':
				$this->fclass[]='plugins/'.$nama.'/class/'.$file.'.php';
				break;
		}
		
		return ob_get_clean();
	}
	function addLoad($jsload) {
		$this->load[] = $jsload.";";
	}
	function addJs($path) {
		$this->javascripts[] = NPAGE.$path;
	}
	
	function sMaintop() {
		ob_start();
	}
	
	function eMaintop() {
		$this->maintop = ob_get_clean();
	}
	function sAtas() {
		ob_start();
	}
	
	function eAtas() {
		$this->atas = ob_get_clean();
	}
	
	function shalamanAtas() {
		ob_start();
	}
	
	function ehalamanAtas() {
		$this->halamanatas = ob_get_clean();
	}
	function stengahtop() {
		ob_start();
	}
	
	function etengahtop() {
		$this->tengahtop = ob_get_clean();
	}
	function stengahfull() {
		ob_start();
	}
	
	function etengahfull() {
		$this->tengahfull = ob_get_clean();
	}
	
	function stengahmid() {
		ob_start();
	}
	
	function etengahmid() {
		$this->tengahmid1 = ob_get_clean();
	}
	
	function stengahmid2() {
		ob_start();
	}
	
	function etengahmid2() {
		$this->tengahmid2 = ob_get_clean();
	}
	
	function stengahmid3() {
		ob_start();
	}
	
	function etengahmid3() {
		$this->tengahmid3 = ob_get_clean();
	}
	
	function stengahmid4() {
		ob_start();
	}
	
	function etengahmid4() {
		$this->tengahmid4 = ob_get_clean();
	}
	
	function shalamanTengah() {
		ob_start();
	}
	
	function ehalamanTengah() {
		$this->midtengah = ob_get_clean();
	}
	
	function sBanner() {
		ob_start();
	}
	
	function eBanner() {
		$this->banner = ob_get_clean();
	}
	function sPagettl() {
		ob_start();
	}
	function sModatas() {
		ob_start();
	}
	
	function eModatas() {
		$this->modatas = ob_get_clean();
	}
	function sMenu() {
		ob_start();
	}
	
	function eMenu() {
		$this->menu = ob_get_clean();
	}
	function sMenuatas() {
		ob_start();
	}
	
	function eMenuatas() {
		$this->menuatas = ob_get_clean();
	}
	
	function sMain() {
		ob_start();
	}
	
	function eMain() {
		$this->main = ob_get_clean();
	}
	function sModule() {
		ob_start();
	}
	
	function eModule() {
		$this->module= ob_get_clean();
	}
	
	function sKiri() {
		ob_start();
	}
	
	function eKiri() {
		$this->modulekiri = ob_get_clean();
	}
	
	function sKanan() {
		ob_start();
	}
	
	function eKanan() {
		$this->modulekanan = ob_get_clean();
	}
	function sTengah() {
		ob_start();
	}
	
	function eTengah() {
		$this->tengah = ob_get_clean();
	}
	function sFooterutama() {
		ob_start();
	}
	
	function eFooterutama() {
		$this->footer = ob_get_clean();
	}
	
	function sFooter() {
		ob_start();
	}
	
	function eFooter() {
		$this->bawah = ob_get_clean();
	}
	function sPlug() {
		ob_start();
	}
	function ePlug() {
		$this->plugins = ob_get_clean();
	}
	
	function render($path) {
		ob_start();
		include($path);
		return ob_get_clean();
	}

}