<?php
/*
	DevSaver Web Framework
	Copyright (c) 2002-2018 DevSaver. 
	All rights reserved.
		web:  www.devsaver.com
		mail: support@devsaver.com
*/

if (!defined("STPBase")) {
	die("This file can't be accessed directly!");
}
// dependencies

/**
* description
*
* @library	
* @author	
* @since	
*/
class CPHPMiniAdmin extends CPlugin{
	
	var $tplvars; 

	function __construct() {
		//$this->CPlugin($db, $tables , $templates);

		$this->name = "phpminiadmin";

		if ($_GET["mod"] == "pma") {
			$_GET["mod"] = "phpminiadmin";
		}
		
	}

	function DoEvents(){
		global $base, $_CONF, $_TSM , $_VARS , $_USER , $_BASE , $_SESS;

		if (($_GET["mod"] == "phpminiadmin") || ($_GET["mod"] == "pma")) {

			$this->tpl_module = array(
				"module_code"	=> $this->name,
				"module_name"	=> "MySQL Adminer"
			);

			parent::doEvents();

			$sub = $_GET["sub"];
			$action = $_GET["action"];

			//$this->__install();

			$tpl = new CTemplateDynamic($this->tpl_path . "main.htm");
			return $tpl->blockReplace("Main");

			return $base->htmlElements->Widget(
				array(
					"title"		=> "PhpMiniAdmin",
					"icon"		=> "settings",
					"skin"		=> "Blue",
					"height"	=> "",

					"content"	=> "<iframe src='modules/phpminiadmin/loader.php' style='width:100%; height: 650px;'></iframe>",

				)
			);
		}


		parent::DoEvents();

	}



	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function Browser() {
		global $base;
		
		$tpl = new CTemplateDynamic($this->tpl_path . "codes.htm");

		$items = $this->db->QFetchRowArray("SELECT * FROM {$this->tables['plugin:shortcodes']}");

		if (is_array($items)) {
			foreach ($items as $key => $val) {
				$items[$key]["cnt"] = ++$cnt;

				$tmp = explode("," , $val["shortcode_device"]);
				$data = "";


				if (in_array("1" , $tmp))
					$data[] = '<span class="f16 sign sign-desktop"></span>';

				if (in_array("2" , $tmp))
					$data[] = '<span class="f16 sign sign-tablet"></span>';

				if (in_array("3" , $tmp))
					$data[] = '<span class="f16 sign sign-mobile"></span>';

				
				if (is_Array($data)) {
					$items[$key]["devices"] = implode(", " , $data);
				} else {
					$items[$key]["devices"] = "";
				}
				
				
			}
			
		}

		echo $base->html->Table(
			$tpl , 
			"" , 
			$items
		);

		die();
	}
	
}

?>