47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Entities;
|
|
|
|
use CodeIgniter\Entity\Entity;
|
|
|
|
abstract class BaseEntity extends Entity
|
|
{
|
|
abstract public function getTitle(): string;
|
|
final public function getPrimaryKey()
|
|
{
|
|
return $this->attributes['uid'];
|
|
}
|
|
//조화수관련 Field전용
|
|
final public function getViews($field = 'view_cnt')
|
|
{
|
|
return $this->attributes[$field];
|
|
}
|
|
//파일관련 Field전용
|
|
final public function getFileDownload($field = "upload_file")
|
|
{
|
|
if (is_null($this->attributes[$field])) {
|
|
return "";
|
|
}
|
|
$files = explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field]);
|
|
return anchor(
|
|
current_url() . "download/{$field}/{$this->getPrimaryKey()}",
|
|
ICONS['IMAGE_FILE'] . $files[0],
|
|
["target" => "_self"]
|
|
);
|
|
}
|
|
//이미지관련 Field전용
|
|
final public function getFileImage($field = "photo", $size = false)
|
|
{
|
|
if (is_null($this->attributes[$field])) {
|
|
return "";
|
|
}
|
|
$files = explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field]);
|
|
return sprintf(
|
|
"<img src=\"/upload_images/%s%s\" alt=\"%s\">",
|
|
$size ? $size . '_' : '',
|
|
$files[1],
|
|
$files[0]
|
|
);
|
|
}
|
|
}
|