64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Front;
|
|
|
|
use App\Models\SitepageModel;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class SitepageController extends FrontController
|
|
{
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
$this->_model = new SitepageModel($this->getFields());
|
|
parent::initController($request, $response, $logger);
|
|
$this->_viewPath .= strtolower($this->_model->getClassName());
|
|
}
|
|
public function getFields(string $action = ""): array
|
|
{
|
|
$fields = ["content"];
|
|
switch ($action) {
|
|
case "index":
|
|
case "excel":
|
|
return ['title', "created_at"];
|
|
break;
|
|
case "view":
|
|
return ['title', "created_at", "content"];
|
|
break;
|
|
default:
|
|
return $fields;
|
|
break;
|
|
}
|
|
}
|
|
public function getFieldFilters(): array
|
|
{
|
|
return [];
|
|
}
|
|
public function getFieldBatchFilters(): array
|
|
{
|
|
return parent::getFieldBatchFilters();
|
|
}
|
|
|
|
//권한체크
|
|
protected function isRole($action)
|
|
{
|
|
$this->_category = $this->request->getVar('category') ?: throw new \Exception("분류를 지정하지 않으셨습니다.");
|
|
parent::isRole($action);
|
|
}
|
|
//Index관련
|
|
protected function index_process()
|
|
{
|
|
//권한체크
|
|
$this->isRole('index');
|
|
return parent::index_process();
|
|
}
|
|
//Category 및 Status 조건추가
|
|
protected function index_setCondition()
|
|
{
|
|
$this->_model->where("category_uid", $this->_viewDatas['category']->getPrimaryKey());
|
|
$this->_model->where("status", DEFAULTS['STATUS']);
|
|
parent::index_setCondition();
|
|
}
|
|
}
|