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


class CBlogWidgetAuthors extends CWidget {

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

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

		$authors = $this->db->QFetchRowArray(
			"SELECT * FROM 
				{$this->tables['plugin:blog_authors']} as a,
				{$this->tables['plugin:blog_authors_lang']} as al

			WHERE 
				a.author_id = al.author_id AND 
				al.lang_id = {$widget[lang_id]} AND 
				a.module_id = {$widget[mod_id]}

			ORDER BY 
				a.author_name ASC
			"
		);

		if (is_array($authors)) {

			global $base;

			foreach ($authors as $key => $val) {
				$authors[$key]["image"] = $this->tpl->blockReplace($val["author_image"] ? "Image" : "NoImage" , $val);
				$authors[$key]["link"] = $widget["link"] . "authors/{$val[author_url]}/";

				//if (strlen($val["author_brief"]) > $widget["settings"]["set_chars"])
					//$authors[$key]["author_brief"] = substr(strip_tags($val["author_brief"]) , 0, $widget["settings"]["set_chars"]) . "[...]";

			}

			return $this->tpl->blockReplace(
				"Main" ,
				array(

					"authors"	=> $base->html->Table(
						$this->tpl, 
						"", 
						$authors
					),

					"widget_title"	=> $widget["widget_name"],
					
				),
				$widget["mod_settings"]

			);
		}		
	}
	
}


?>