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


class CWidgetsWidgetCounter extends CWidget {

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

		

	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function Render($widget) {
		$items = explode("\n" , $widget["settings"]["lang_body"]);
		$count = min(4, count($items));

		if (!$count) {
			return "";
		}
		

		for ($i = 0 ; $i < $count; $i ++ ) {

			if (trim($items[$i])) {
				$tmp = explode("|" , $items[$i]);					

				$_items[$i] = array(
					"no"	=> trim($tmp[0]),
					"text"	=> trim($tmp[1]),
				);			
			}			
		}

		$items = $_items;

		$count = count($items);
		

		for ($i = 0 ; $i < $count; $i ++ ) {
			$content .= $this->tpl->blockReplace(
				"Body" . $count,
				array(
					"data"	=> $this->tpl->blockReplace("Item" , $items[$i])
				)
			);
		}

		return $this->tpl->blockReplace(
			"Widget" ,
			array(
				"content"	=> $content,
			),
			$this->module->WidgetButtons($widget , $this->tpl),
			$widget
		
		);

	}
	
}


?>