62 lines
1.5 KiB
PHP
62 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Hura8\Components\Media\Model;
|
||
|
|
|
||
|
|
use Hura8\Interfaces\AppResponse;
|
||
|
|
use Hura8\System\Model\aEntityBaseModel;
|
||
|
|
use Hura8\Interfaces\iEntityModel;
|
||
|
|
use Hura8\Interfaces\EntityType;
|
||
|
|
use Hura8\System\Url;
|
||
|
|
|
||
|
|
|
||
|
|
class MediaModel extends aEntityBaseModel implements iEntityModel
|
||
|
|
{
|
||
|
|
|
||
|
|
protected $tb_media_per_category = "tb_media_per_category";
|
||
|
|
|
||
|
|
public function __construct() {
|
||
|
|
parent::__construct(EntityType::MEDIA, '', new MediaSearchModel());
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
protected function extendedFilterOptions() : array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
// empty for now
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
protected function _buildQueryConditionExtend(array $filter_condition) : ?array
|
||
|
|
{
|
||
|
|
/*$condition = array(
|
||
|
|
"category" => getRequestInt("category"),
|
||
|
|
"file_type" => '',
|
||
|
|
);*/
|
||
|
|
|
||
|
|
$catCondition = [];
|
||
|
|
$bind_types = [];
|
||
|
|
$bind_values = [];
|
||
|
|
|
||
|
|
|
||
|
|
//Tim danh muc
|
||
|
|
if(isset($filter_condition["category"]) && $filter_condition["category"]){
|
||
|
|
$catCondition[] = " AND `id` IN (SELECT `item_id` FROM `".$this->tb_media_per_category."` WHERE `category_id` = ?) ";
|
||
|
|
$bind_types[] = 'd';
|
||
|
|
$bind_values[] = $filter_condition["category"];
|
||
|
|
}
|
||
|
|
|
||
|
|
if(isset($filter_condition["file_type"]) && $filter_condition["file_type"]){
|
||
|
|
$catCondition[] = " AND `file_type` = ? ";
|
||
|
|
$bind_types[] = 's';
|
||
|
|
$bind_values[] = $filter_condition["file_type"];
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
return array( join(" ", $catCondition), $bind_types, $bind_values);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
}
|