<?php
/**
 * Model dla klasy MfProductDescription
 *
 * @author ModGen
 */

class MfProductDescription extends DataObject{


	/**
	 * nazwa tabeli
	 */
	static $tableName = 'mf_product_description';

	/**
	 * nazwa klucza tabeli
	 */
	static $classTablePK = 'id_mf_product_description';

	/**
	 * nazwa klasy
	 */
	static $className = __CLASS__;

	/**
	 * tablica mapująca pola klasy
	 */
	static $fields = array(
		'id_mf_product_description' => 'id',
		'id_mf_product' => 'idMfProduct',
		'name' => 'name',
		'lang' => 'lang',
		'description' => 'description',
		'shortnote' => 'shortnote',
		'publication' => 'publication',
		'id_mf_picture' => 'idPicture',
		'id_mf_picture_mini' => 'idPictureMini',
		'id_mf_image_group' => 'idImageGroup'
	);


	protected $id;
	private $idMfProduct;
	private $name;
	private $lang;
	private $description;
	private $shortnote;
	private $publication;
	private $idPictureMini = 0;
	private $idPicture = 0;
	private $idStructure = 0;
	private $picture;
	private $pictureMini;
	private $idImageGroup;	
	public $arrayImage;



	// -- Konstruktor --


	function __construct( $id = -1 , $idMfProduct = null, $name = null, $lang = null, $description = null, $shortnote = null, $publication = null){
		$this->id = $id;
		$this->idMfProduct = $idMfProduct;
		$this->name = $name;
		$this->lang = $lang;
		$this->description = $description;
		$this->shortnote = $shortnote;
		$this->publication = $publication;
	}



	// -- Get-y i Set-y --

	public function getId(){
		return $this->id;
	}

	public function setId($id){
		$this->id = $id;
	}

	
	public function getIdMfProduct(){
		return $this->idMfProduct;
	}

	public function setIdMfProduct($idMfProduct){
		$this->idMfProduct = $idMfProduct;
	}

	
	public function getName(){
		return $this->name;
	}

	public function setName($name){
		$this->name = $name;
	}

	
	public function getLang(){
		return $this->lang;
	}

	public function setLang($lang){
		$this->lang = $lang;
	}

	
	public function getDescription(){
		return $this->description;
	}

	public function setDescription($description){
		$this->description = $description;
	}

	
	public function getShortnote(){
		return $this->shortnote;
	}

	public function setShortnote($shortnote){
		$this->shortnote = $shortnote;
	}

	
	public function getPublication(){
		return $this->publication;
	}

	public function setPublication($publication){
		$this->publication = $publication;
	}

	
	
	public function SetIdPicture($idPicture) {
		$this->idPicture = $idPicture;
	}

	public function GetIdPicture() {
		return $this->idPicture;
	}
	public function SetIdPictureMini($idPictureMini) {
		$this->idPictureMini = $idPictureMini;
	}

	public function GetIdPictureMini() {
		return $this->idPictureMini;
	}
	
	
	public function SetPicture($picture) {
		$this->picture = $picture;
	}

	public function GetPicture() {
		if (!$this->picture && (int)$this->idPicture > 0) {
			$this->picture = PictureDAL::GetById($this->GetIdPicture());
		}

		return $this->picture;
	}

	public function GetPictureUrl() {
		if ($this->GetPicture()) {
			return Config::Get('URL_STATIC_CONTENT') . '/upload/Product/' . $this->GetPicture()->GetLink();
		} else {
			return null;
		}
	}


	public function SetPictureMini($pictureMini) {
		$this->pictureMini = $pictureMini;
	}

	public function GetPictureMini() {
		if (!$this->pictureMini && (int)$this->idPictureMini > 0) {
			$this->pictureMini = PictureDAL::GetById($this->GetIdPictureMini());
		}

		return $this->pictureMini;
	}

	public function GetPictureMiniUrl() {
		if ($this->GetPictureMini()) {
			return Config::Get('URL_STATIC_CONTENT') . '/upload/Product/' . $this->GetPictureMini()->GetLink();
		} else {
			return null;
		}
	}
	
	
	public function setArrayImage($arrayImage) {
		$this->arrayImage = $arrayImage;
	}

	public function getArrayImage() {
		if (!$this->arrayImage && $this->idImageGroup > 0) {
			//$this->setArrayImage(ImageDAL::GetResultByLink('mf_article', $this->id));
			$this->setArrayImage(ImageDAL::GetResult(array('id_image_group' => $this->idImageGroup, 'size' => 2)));
		}
		return $this->arrayImage;
	}

	public function setIdImageGroup($idImageGroup) {
		$this->idImageGroup = $idImageGroup;
	}

	public function getIdImageGroup() {
		return $this->idImageGroup;
	}





	/**
	* Pobiera nazwę tabeli reprezentującej obiekt w SQL
	* @return string
	*/
	public  function GetTableName(){
	return self::$tableName;
	}

	/**
	* Pobiera nazwę klucza głównego tabeli
	* @return string
	*/
	public function GetClassTablePK() {
		return self::$classTablePK;
	}

	/**
	* Pobiera tablice mapującą pola klasy na pola tabeli
	* @return array
	*/
	public  function GetFields(){
		return self::$fields;
	}

	/**
	* Pobiera nazwę klasy
	* @return string
	*/
	public  function GetClassName(){
		return self::$className;
	}



}

?>