c
This commit is contained in:
76
inc/Hura8/Components/Media/Model/ItemMediaModel.php
Normal file
76
inc/Hura8/Components/Media/Model/ItemMediaModel.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Hura8\Components\Media\Model;
|
||||
|
||||
use Hura8\Interfaces\AppResponse;
|
||||
use Hura8\System\Model\aEntityBaseModel;
|
||||
use Hura8\Interfaces\iEntityModel;
|
||||
use Hura8\System\Url;
|
||||
|
||||
|
||||
class ItemMediaModel extends aEntityBaseModel implements iEntityModel
|
||||
{
|
||||
|
||||
protected $item_type;
|
||||
protected $item_id;
|
||||
|
||||
public function __construct(string $item_type = '', $item_id = 0) {
|
||||
parent::__construct('item-media');
|
||||
|
||||
$this->item_type = $item_type;
|
||||
$this->item_id = $item_id;
|
||||
}
|
||||
|
||||
|
||||
protected function extendedFilterOptions() : array
|
||||
{
|
||||
return [
|
||||
// empty for now
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
protected function _buildQueryConditionExtend(array $filter_condition) : ?array
|
||||
{
|
||||
|
||||
$catCondition = [];
|
||||
$bind_types = [];
|
||||
$bind_values = [];
|
||||
|
||||
if($this->item_type) {
|
||||
$catCondition[] = " AND `item_type` = ? ";
|
||||
$bind_types[] = 's';
|
||||
$bind_values[] = $this->item_type;
|
||||
}
|
||||
|
||||
if($this->item_id) {
|
||||
$catCondition[] = " AND `item_id` = ? ";
|
||||
$bind_types[] = 'd';
|
||||
$bind_values[] = $this->item_id;
|
||||
}
|
||||
|
||||
if(isset($filter_condition["item_type"]) && $filter_condition["item_type"]){
|
||||
$catCondition[] = " AND `item_type` = ? ";
|
||||
$bind_types[] = 's';
|
||||
$bind_values[] = $filter_condition["item_type"];
|
||||
}
|
||||
|
||||
if(isset($filter_condition["item_id"]) && $filter_condition["item_id"]){
|
||||
$catCondition[] = " AND `item_id` = ? ";
|
||||
$bind_types[] = 's';
|
||||
$bind_values[] = $filter_condition["item_id"];
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
34
inc/Hura8/Components/Media/Model/ItemMediaSearchModel.php
Normal file
34
inc/Hura8/Components/Media/Model/ItemMediaSearchModel.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Hura8\Components\Media\Model;
|
||||
|
||||
use Hura8\Interfaces\iSearch;
|
||||
use Hura8\System\Model\aSearchBaseModel;
|
||||
|
||||
|
||||
class ItemMediaSearchModel extends aSearchBaseModel implements iSearch
|
||||
{
|
||||
|
||||
private $filter_fields = [
|
||||
'item_type' => "tb_item_media.item_type",
|
||||
'item_id' => "tb_item_media.item_id",
|
||||
'file_type' => "tb_item_media.file_type",
|
||||
];
|
||||
|
||||
private $fulltext_fields = [
|
||||
"keywords" => ["tb_item_media.title",],
|
||||
];
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
"tb_item_media",
|
||||
$this->fulltext_fields,
|
||||
$this->filter_fields
|
||||
);
|
||||
|
||||
//$this->createTableSearch();
|
||||
}
|
||||
|
||||
}
|
||||
20
inc/Hura8/Components/Media/Model/MediaCategoryModel.php
Normal file
20
inc/Hura8/Components/Media/Model/MediaCategoryModel.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Hura8\Components\Media\Model;
|
||||
|
||||
use Hura8\Interfaces\AppResponse;
|
||||
use Hura8\System\Model\aCategoryBaseModel;
|
||||
use Hura8\Interfaces\iEntityCategoryModel;
|
||||
|
||||
|
||||
class MediaCategoryModel extends aCategoryBaseModel implements iEntityCategoryModel
|
||||
{
|
||||
protected $tb_media_per_category = "tb_media_per_category";
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('media-category');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
61
inc/Hura8/Components/Media/Model/MediaModel.php
Normal file
61
inc/Hura8/Components/Media/Model/MediaModel.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
32
inc/Hura8/Components/Media/Model/MediaSearchModel.php
Normal file
32
inc/Hura8/Components/Media/Model/MediaSearchModel.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Hura8\Components\Media\Model;
|
||||
|
||||
use Hura8\Interfaces\iSearch;
|
||||
use Hura8\System\Model\aSearchBaseModel;
|
||||
|
||||
|
||||
class MediaSearchModel extends aSearchBaseModel implements iSearch
|
||||
{
|
||||
|
||||
private $filter_fields = [
|
||||
'file_type' => "tb_media.file_type",
|
||||
];
|
||||
|
||||
private $fulltext_fields = [
|
||||
"keywords" => ["tb_media.title",],
|
||||
];
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
"tb_media",
|
||||
$this->fulltext_fields,
|
||||
$this->filter_fields
|
||||
);
|
||||
|
||||
//$this->createTableSearch();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user