<?php

/*
 * Description de l'entite
 */

namespace Apps\Cms\Entity;

use Core\Entity\Entity\Entity;
use Core\Entity\Entity\Property;
use Core\Entity\Entity\EntityProperty;

class CmsPage extends Entity {

    //Constructeur
    function __construct($core) {
        //Version
        $this->Version = "2.0.0.0";

        //Nom de la table
        $this->Core = $core;
        $this->TableName = "CmsPage";
        $this->Alias = "CmsPage";

        $this->CmsId = new Property("CmsId", "CmsId", NUMERICBOX, true, $this->Alias);
        $this->Name = new Property("Name", "Name", TEXTBOX, true, $this->Alias);
        $this->Title = new Property("Title", "Title", TEXTBOX, true, $this->Alias);
        $this->Description = new Property("Description", "Description", TEXTAREA, true, $this->Alias);
        $this->Content = new Property("Content", "Content", TEXTAREA, false, $this->Alias);

        //Creation de l entité
        $this->Create();
    }


    /***
     * Get elemnt in the current LAng
     */
    function GetLangElement(){
    
        if(!isset($this->LangElement)){
            
            $entityLangElement = \Apps\Lang\Helper\ElementHelper::GetEntityLangElement($this->Core,
            "CmsPage", 
             $this->IdEntite, 
             $this->Core->GetLang("Id"));

             $this->LangElement = $entityLangElement;
        } 
    
        return $this->LangElement;
    }

    /***
     * Return name article in the current lang
     */
    function GetLangTitle(){

        $entityLangElement = $this->GetLangElement();
    
        if($entityLangElement){
            return $entityLangElement->Title->Value;
        }

        return $this->Title->Value;
    }
    
    /***
     * Return name article in the current lang
     */
    function GetLangDescription(){

        $entityLangElement = $this->GetLangElement();
    
        if($entityLangElement){
            return $entityLangElement->Description->Value;
        }

        return $this->Description->Value;
    }
}

?>
