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

// dependencies

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


	var $media = array(
		"hide"	=> array(
			"list"	=> array(
				"item_show",
			),
			"edit"	=> array(
				"item_show",
				"author",
			)
		),

		"path"	=> "./gallery/",

		"image"	=> array(
			"width"		=> "720",
			"height"	=> ""
		),
		
		"tn"	=> array(
			"width"		=> "720",
			"height"	=> ""
		),

		"tn2"	=> array(
			"width"		=> "720",
			"height"	=> "480"
		)

	);


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

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



		if ($_GET["mod"] == "gallery") {
			//read the module
			$this->tpl_module = $this->module->plugins["modules"]->getModuleInfo($_GET["module_id"]);
			$this->plugins["modules"]->ValidateModule($this->tpl_module);

			parent::DoEvents();

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


			switch ($sub) {


				case "landing":
					$_GET["sub"] = $sub = "cats";
//				case "cats.images":
				case "cats":
					//media compatibility fix
					$_GET["item_id"] = $_GET["cat_id"];

					$data = new CSQLAdmin($sub, $this->__parent_templates,$this->db,$this->tables,$extra);
					$data->setAclMod($this->tpl_module);
					$this->PrepareFields($data->forms["forms"]);


					$data->functions = array( 
							"ondelete" => array(&$this , "DeleteCat"),
					);					
					
					return $data->DoEvents();
				break;


				case "texts":
					return $this->__adminTexts();
				break;

			}
		}
	}


	
	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function onDelete($module_data) {

		$tables  = array(
			"plugin:gallery_cats" , 
			"plugin:gallery_cats_lang",
		);

		foreach ($tables as $key => $val) {
			$this->db->Query(
				"DELETE FROM " . $this->tables[$val] . " WHERE module_id={$module_data[mod_id]}"
			);
		}

		parent::onDelete($module_data);	
	}
	
	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function onCreate($module_data) {

		$this->CreatePageTitleBlock(array(
			"module_id"	=> $module_data["mod_id"],
			"title"		=> $module_data["mod_name"],
			"subtitle"	=> "You can edit this section in the Module Head tab",
			"show"		=> 1,
		));
	}

	
	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function DeleteCat($record) {

	}
	
}

?>