<?php
/**
 * Define a resource.
 * @author Idleman
 * @category Plugin
 * @license copyright
 */
class Resource extends Entity{
	public $id,$label,$sort,$type,$content,$sketch;
	protected $TABLE_NAME = 'hackpoint_resource';
	public $fields =
	array(
		'id' => 'key',
		'label' => 'string',
		'sort' => 'int',
		'type' => 'string',
		'content' => 'longstring',
		'sketch' => 'int'
	);

	public $links = array(
		'sketch' => 'Sketch'
	);

	public function type(){
		require_once(__DIR__.SLASH.'ResourceType.class.php');
		return ResourceType::types($this->type);
	}

	public function directory(){
		return File::dir().'hackpoint'.SLASH.'sketch'.SLASH.$this->sketch.SLASH.$this->id;
	}

	public function toHtml(){
		$type = $this->type();
		return $type['class']::toHtml($this);
	}
	
}
?>