update
This commit is contained in:
346
core/model/MfFile.class.php
Normal file
346
core/model/MfFile.class.php
Normal file
@@ -0,0 +1,346 @@
|
||||
<?php
|
||||
/**
|
||||
* Model pliku
|
||||
*
|
||||
*/
|
||||
class MfFile extends DataObject {
|
||||
|
||||
|
||||
/**
|
||||
* nazwa tabeli
|
||||
*/
|
||||
static $tableName = 'mf_file';
|
||||
|
||||
/**
|
||||
* nazwa klucza tabeli
|
||||
*/
|
||||
static $classTablePK = 'id_mf_file';
|
||||
|
||||
/**
|
||||
* nazwa klasy
|
||||
*/
|
||||
static $className = __CLASS__;
|
||||
|
||||
static $types = array(
|
||||
1 =>'pliki',
|
||||
);
|
||||
|
||||
/**
|
||||
* tabela mapująca pola z bazy SQL na pola klasy.
|
||||
*/
|
||||
static $fields = array(
|
||||
'id_mf_file' =>'id',
|
||||
'date' =>'date' ,
|
||||
'publication' =>'publication' ,
|
||||
'weight' =>'weight' ,
|
||||
'name' =>'name',
|
||||
'picture' => 'picture',
|
||||
'id_mf_file_type' =>'type',
|
||||
'id_structure' =>'idStructure',
|
||||
'date_publication'=> 'datePublication',
|
||||
'zz_date_add' => 'addDate',
|
||||
'zz_date_edit' => 'editDate',
|
||||
'url' => 'url'
|
||||
);
|
||||
|
||||
protected $id;
|
||||
private $date;
|
||||
private $publication;
|
||||
private $weight;
|
||||
private $name;
|
||||
private $lang;
|
||||
private $fileDescriptionObj;
|
||||
private $picture;
|
||||
private $pictureMini;
|
||||
private $special = 0;
|
||||
private $type;
|
||||
private $idStructure;
|
||||
private $datePublication;
|
||||
private $addDate;
|
||||
private $editDate;
|
||||
private $url;
|
||||
public $isLinked;
|
||||
|
||||
|
||||
public function GetId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function SetId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function GetDate() {
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function SetDate($date) {
|
||||
$this->date = $date;
|
||||
}
|
||||
public function GetSpecial() {
|
||||
return $this->special;
|
||||
}
|
||||
|
||||
public function SetSpecial($special) {
|
||||
$this->special = $special;
|
||||
}
|
||||
|
||||
public function GetPublication() {
|
||||
return $this->publication;
|
||||
}
|
||||
|
||||
public function SetPublication($publication) {
|
||||
$this->publication = $publication;
|
||||
}
|
||||
|
||||
public function GetWeight() {
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
public function SetWeight($weight) {
|
||||
$this->weight = $weight;
|
||||
}
|
||||
|
||||
public function GetName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function SetName($name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function GetNameExt() {
|
||||
$array = explode('.',$this->name);
|
||||
return end($array);
|
||||
}
|
||||
public function GetFileIcon() {
|
||||
|
||||
$array = explode('.',$this->name);
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/image/fileIcon/' . end($array).'.gif';
|
||||
//return end($array);
|
||||
}
|
||||
|
||||
public function GetNameUrl() {
|
||||
if ($this->GetName()) {
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/upload/File/' . $this->GetName();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public function GetNamePath() {
|
||||
if ($this->GetName()) {
|
||||
return Config::Get('PATH_STATIC_CONTENT') . '/upload/File/' . $this->GetName();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetSize() {
|
||||
if ($this->GetName()) {
|
||||
return number_format(filesize(Config::Get('PATH_STATIC_CONTENT') . '/upload/File/' .$this->GetName()) / 1048576,2);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetLang() {
|
||||
if($this->lang=='') {
|
||||
|
||||
$this->SetLang(Router::$curLang);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
public function SetLang($lang) {
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
public function GetDescriptionObj() {
|
||||
if(!is_object($this->fileDescriptionObj)) {
|
||||
|
||||
$dalData = self::GetDalDataObj();
|
||||
$dalData->setCondition(array('publication' => 1, 'lang'=>$this->GetLang(), 'id_mf_file'=>$this->GetId()));
|
||||
|
||||
$fileDescriptionObj = MfFileDescriptionDAL::GetResult($dalData);
|
||||
if(isset($fileDescriptionObj[0]) && is_object($fileDescriptionObj[0])) {
|
||||
$this->SetFileDescriptionObj($fileDescriptionObj[0]);
|
||||
} else {
|
||||
throw new UserException('Brak wersji jezykowej dla tego rekordu! ('.$this->GetId().' '.$this->GetLang().')');
|
||||
}
|
||||
}
|
||||
return $this->fileDescriptionObj;
|
||||
}
|
||||
|
||||
public function SetFileDescriptionObj($fileDescriptionObj) {
|
||||
$this->fileDescriptionObj = $fileDescriptionObj;
|
||||
}
|
||||
public function SetMfFileDescription($fileDescriptionObj) {
|
||||
$this->fileDescriptionObj = $fileDescriptionObj;
|
||||
}
|
||||
|
||||
public function __call($name, $param) {
|
||||
|
||||
$obj = $this->GetDescriptionObj();
|
||||
|
||||
return $obj->$name($param);
|
||||
}
|
||||
|
||||
public function GetMfLinkDescription() {
|
||||
return $this->mfLinkDescription;
|
||||
}
|
||||
|
||||
public function SetMfLinkDescription($mfLinkDescription) {
|
||||
$this->mfLinkDescription = $mfLinkDescription;
|
||||
}
|
||||
|
||||
public function SetPicture($picture) {
|
||||
$this->picture = $picture;
|
||||
}
|
||||
|
||||
public function GetPicture() {
|
||||
return $this->picture;
|
||||
}
|
||||
|
||||
public function GetPictureUrl() {
|
||||
if ($this->GetPicture()) {
|
||||
return Config::Get('URL_STATIC_CONTENT') . '/upload/File/' . $this->GetPicture();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetDatePublication() {
|
||||
return $this->datePublication;
|
||||
}
|
||||
|
||||
public function GetDatePublicationWithoutTime() {
|
||||
return substr($this->datePublication, 0, -9);
|
||||
}
|
||||
|
||||
public function GetDatePublicationTime() {
|
||||
if (!$this->datePublication) {
|
||||
return '00';
|
||||
} else {
|
||||
return substr($this->datePublication, 11, -6);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function SetDatePublication($datePublication) {
|
||||
$this->datePublication = $datePublication;
|
||||
}
|
||||
|
||||
public function GetDateUpdate() {
|
||||
return $this->dateUpdate;
|
||||
}
|
||||
|
||||
public function GetDateUpdateWithoutTime() {
|
||||
return substr($this->dateUpdate, 0, -9);
|
||||
}
|
||||
|
||||
public function GetDateUpdateTime() {
|
||||
return substr($this->dateUpdate, 11, -6);
|
||||
}
|
||||
|
||||
public function SetDateUpdate($dateUpdate) {
|
||||
$this->dateUpdate = $dateUpdate;
|
||||
}
|
||||
public function GetType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function SetType($type) {
|
||||
|
||||
$this->type = $type;
|
||||
}
|
||||
public function GetIdStructure() {
|
||||
return $this->idStructure;
|
||||
}
|
||||
|
||||
public function SetIdStructure($idStructure) {
|
||||
$this->idStructure = $idStructure;
|
||||
}
|
||||
public function GetAddDate() {
|
||||
return $this->addDate;
|
||||
}
|
||||
|
||||
public function SetAddDate($add) {
|
||||
$this->addDate = $add;
|
||||
}
|
||||
|
||||
public function GetEditDate() {
|
||||
return $this->editDate;
|
||||
}
|
||||
|
||||
public function SetEditDate($edit) {
|
||||
$this->editDate = $edit;
|
||||
}
|
||||
public function GetUrl() {
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function SetUrl($url) {
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function getIsLinked(){
|
||||
return $this->isLinked;
|
||||
}
|
||||
|
||||
public function setIsLinked($isLinked){
|
||||
$this->isLinked = $isLinked;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor klasy
|
||||
*
|
||||
* @param integer $id
|
||||
*/
|
||||
|
||||
public function __construct($id = -1) {
|
||||
$this->SetId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera nazwę tabeli reprezentującej obiekt w SQL
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function GetTableName(){
|
||||
return self::$tableName;
|
||||
}
|
||||
/**
|
||||
* Pobiera taablice 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;
|
||||
}
|
||||
|
||||
|
||||
public function GetClassTablePK() {
|
||||
return self::$classTablePK;
|
||||
}
|
||||
|
||||
public function GetTypes(){
|
||||
return self::$types;
|
||||
}
|
||||
|
||||
public function GetTypeName($type){
|
||||
return self::$fields[$type];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user