<?php
/*
 *  This file is part of phynx.

 *  phynx is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.

 *  phynx is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.

 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 *  2007 - 2020, open3A GmbH - Support@open3A.de
 */
class mCustomizerGUI extends anyC implements iGUIHTMLMP2 {
	function getCollectionOf(){
		return "Customizer";
	}

	public function getHTML($id, $page){
		#mCustomizerGUI::registerCustomizer();
		
		$active = mUserdata::getGlobalSettingValue("activeCustomizer");

		#$_SESSION["BPS"]->setActualClass("CustomizerGUI");
		#$bps = $_SESSION["BPS"]->getAllProperties();
		$bps = $this->getMyBPSData();
		

		#$this->loadMultiPageMode($id, $page, 0);

		#$gui = new HTMLGUIX($this);
		#$gui->version("mCustomizer");
		#$gui->screenHeight();

		#$gui->name("Customizer");
		
		#$gui->attributes(array({PluginCollectionDisplayFields}));
		
		
		$t = new HTMLTable(1);
		
		/*$fbdir = mCustomizerGUI::getLocalCustomizerDir();
		if($fbdir == null) {
			$t->addRow("Keine lokalen Customizer-Einstellungen gefunden!");
			return $t->getHTML();
		}*/
		
		$FB = new FileBrowser();
		$FB->addDir("../specifics");
		$FB->addDir("../customizer");
		
		$customizers = $FB->getAsLabeledArray("iCustomizer",".class.php");
		if(count($customizers) == 0) {
			$t->addRow("Keine lokalen Customizer-Einstellungen gefunden!");
			return $t->getHTML();#.$gui->getBrowserHTML($id);
		}
		
		$t = new HTMLTable(3, "Verfügbare Customizer:");
		$t->setTableStyle("width:100%");
		$t->addColStyle(2, "width:20px;");
		$t->addColStyle(1, "width:20px;");
		$t->maxHeight(400);
		$t->addRow(array("","<img src=\"./images/i2/".($active == null ? "" : "not")."ok.gif\" />", "Customizer deaktiviert"));
		
		if((file_exists(Util::getRootPath()."specifics/CustomizerPakete.class.php") OR file_exists(Util::getRootPath()."customizer/CustomizerPakete.class.php")) AND !isset($bps["showAll"])){
			$BC = new Button("", "./images/i2/edit.png", "icon");
			$BC->onclick("contentManager.loadFrame('contentLeft','Customizer', 'CustomizerPakete', 0,'CustomizerGUI;load:CustomizerPakete');");
			$t->addRow(array($BC,"<img src=\"./images/i2/".($active == "CustomizerPakete" ? "" : "not")."ok.gif\" />", "Pakete"));
			
			$B = new Button("Alle Customizer\nanzeigen", "./plugins/Customizer/customizer.png");
			$B->loadFrame("contentRight", "mCustomizer", "0", "0", "mCustomizerGUI;showAll:true");
			$t->addRow(array("$B"));
			
			$t->addRowColspan(1, 3);
			$t->addRowClass("backgroundColor0");
			
			return $t->getHTML();#.$gui->getBrowserHTML($id);
		}
		
		foreach($customizers as $v => $k){

			$t->addRow(array("<img onclick=\"contentManager.loadFrame('contentLeft','Customizer', '$k', 0,'CustomizerGUI;load:$k');\" class=\"mouseoverFade\" src=\"./images/i2/edit.png\" />","<img src=\"./images/i2/".($active == $k ? "" : "not")."ok.gif\" />", $v));
			#$t->addRowEvent("click","loadFrameV2('contentLeft','Customizer','CustomizerGUI;load:$v');");
			#$t->addRowStyle("cursor:pointer;");
			
			#if($bps != -1 AND isset($bps["load"]) AND $bps["load"] == $v)
			#	$t->addRowClass("backgroundColor1");
		}
		
		#if(!isset($bps["load"])) 
		return $t->getHTML();
		
		#return $t->getHTML()."<div style=\"height:30px;\" ></div><div>".$t2->getHTML()."</div>";
	}
	
	/*public static function getLocalCustomizerDir(){
		return "../specifics/";
		
		$dir = "./".$_SESSION["applications"]->getActiveApplication()."/Customizer/";
		
		if(!file_exists($dir) AND !file_exists(".".$dir))
			return null;
		elseif(file_exists(".".$dir))
			return ".".$dir;
			
		return $dir;
	}*/
}
?>