<?php defined('SYSPATH') OR die('No direct access allowed.');

class template_Core {


	/**
	 * Get template url
	 *
	 * @param   string   file in the template dir
	 * @return  string
	 */
	public static function url($str="")
	{
		// Force the string to be a string
		$str = (string) $str;
		$str = url::base()."themes/".Kohana::config('site.template').'/'.$str;
		return $str;
	}
	
	/**
	 * Get template dir
	 *
	 * @param   string   file in the template dir
	 * @return  string
	 */
	public static function dir($str="")
	{
		// Force the string to be a string
		$str = (string) $str;
		$str = DOCROOT."themes\\".Kohana::config('site.template').'\\'.$str;
		return $str;
	}
	
	/**
	 * Get image in images folder
	 *
	 * @param   string   image
	 * @return  string
	 */
	public static function img($image="", $attributes="")
	{
		// Force the string to be a string
		$image = (string) $image;
		$image = url::base()."themes/".Kohana::config('site.template').'/images/'.$image;
		return html::image($image, $attributes);
	}
	/**
	 * Get image link in images folder
	 *
	 * @param   string   link
	 * @return  string
	 */
	public static function aimg($link, $image, $attributes="")
	{
		$alt = "";
		// Force the string to be a string
		$image = (string) $image;
		$image = url::base()."themes/".Kohana::config('site.template').'/images/'.$image;
		if(isset($attributes['alt']))
		{
			$alt = array('alt' => gcb::lang($attributes['alt']));
			if($attributes['alt'] == "delete")
				$attributes['title'] = $alt['alt']." ".$attributes['title'];
			else
				$attributes['title'] = $alt['alt'];
			unset($attributes["alt"]);
		}
		$img =  html::image($image, $alt);
		
		return html::anchor($link, $img, $attributes);
	}
	
	public static function hlink($link, $name, $image=NULL)
	{
		if(!$image)
			$image = $name;
		$img = template::img($image.".gif");
		return '<span style="float:right">'.html::anchor($link, $img.gcb::lang($name)).'</span>';
	}


} // End template
