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


class CWidgetsWidgetAccordion extends CWidget {

	/**
	* description
	*
	* @var type
	*
	* @access type
	*/
	var $meta = array(
		"type"	=> "4",
		"name"	=> "Accordion",
		"module"	=> array(
			"name"	=> "",
			"id"	=> "",
			"type"	=> "",
		)
	);

	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function Render($widget) {
		global $base;

		if (!is_array($widget)) {
			return "";
		}

		$items = $this->module->GetStaticItems($widget);

		if (!is_array($items)) {
			return "";
		}

		global $base;

		foreach ($items as $key => $val) {


			$more = $this->plugins["modules"]->BuildLink(array(
				"type"	=> $val["item_link_type"],
				"link"	=> $val["item_link_link"],
				"module"=> $val["item_link_module"],
				"global"=> $val["item_link_global"],
			));

			if ($more) {
				$more = $this->tpl->blockReplace(
					"Link" ,
					array(
						"link"	=> $more,
						"size"	=> $val["item_link_size"],
						"target"=> $val["item_link_target"],
						"text"	=> $val["item_link_text"],
						"rel"		=> $val["item_link_rel"],
						"style"		=> $val["item_link_style"],

					)
				);
			} else {
				$more = "";
			}
			

			$items[$key]["link"] = $more;

			$items[$key]["icon"] = $this->tpl->blockReplace($val["item_icon"] ? "Icon" : "NoIcon" , $val);
			
		}
		
		return $this->tpl->blockReplace(
			"Main" , 
			array(
				"items"	=> $base->html->table(
					$this->tpl , 
					"",	
					$items,
					array(
						"collapsed"	=> $widget["settings"]["set_first"] ? "true" : "false",
					)

				)
			),
			$widget 
		);

	}
			

}


?>