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


class CWidgetsWidgetTestimonialsWCarousel extends CWidget {

	/**
	* description
	*
	* @var type
	*
	* @access type
	*/
	var $meta = array(
		"type"	=> "16",
		"name"	=> "Testimonials w/ Carousel",
		"module"	=> array(
			"name"	=> "",
			"id"	=> "",
			"type"	=> "",
		)
	);

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

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

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


		switch ($widget["settings"]["set_style"]) {
			default:  $block = "Large"; break;
			case "2":  $block = "Small"; break;

		}

		$elements = explode("," , $widget["settings"]["set_elements"]);
		
		foreach ($items as $key => $val) {

			$val["link"] = 	$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"]
			));

			$items[$key]["image"] = in_array("image" , $elements) ? $this->tpl->blockReplace($block . ($val["item_image"] ? "Image" : "NoImage"), $val) : "";				
			$items[$key]["_name"] = $this->tpl->blockReplace($val["link"] ? "NameLink" : "NameNoLink" , $val);
			$items[$key]["_company"] = $val["item_company"] ? $this->tpl->blockReplace("Company" , $val) : "";
		}		

		return $this->tpl->blockReplace(
			$block ."Main" , 
			array(
				"items"	=> $base->html->Table(
					$this->tpl , 
					$block . "" , 
					$items
				),
			),
			array(
				"class_2" => in_array("image" , $elements) ? "" : "no-avatar",
				"class"	=> $this->tpl->blockreplace($widget["settings"]["set_carousel"] ? "Carousel" :"List"),
			),
			$widget["settings"],
			$widget
		);	

	}
			

}


?>