diff --git a/app/Config/Routes.php b/app/Config/Routes.php index a1a8275..aa379f8 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -12,6 +12,9 @@ $routes->addPlaceholder('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4} //1. app/Filters/AuthFilter.php //2. Config/Filters.php -> $aliases = ['authFilter' => AuthFilter::class] $routes->get('/', 'Home::index'); +$routes->group('/RSSFeed', function ($routes) { + $routes->get('getITWorld', 'RSSFeedController::getITWorld'); +}); $routes->group('/user', function ($routes) { $routes->get('login', 'UserController::login_form'); $routes->post('login', 'UserController::login'); diff --git a/app/Controllers/Admin/Home.php b/app/Controllers/Admin/Home.php index e1e1198..d592f34 100644 --- a/app/Controllers/Admin/Home.php +++ b/app/Controllers/Admin/Home.php @@ -2,12 +2,27 @@ namespace App\Controllers\Admin; -use App\Controllers\CommonController; +use Psr\Log\LoggerInterface; +use CodeIgniter\HTTP\ResponseInterface; +use CodeIgniter\HTTP\RequestInterface; +use App\Helpers\CommonHelper; +use App\Controllers\Admin\AdminController; -class Home extends CommonController +class Home extends AdminController { + public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) + { + parent::initController($request, $response, $logger); + $this->title = "Main"; + $this->helper = new CommonHelper(); + } + protected function getModel(): mixed + { + return null; + } public function index(): string { - return view('welcome_message'); + helper(['form']); + return view('admin/welcome_message', ['viewDatas' => $this->getViewDatas()]); } } diff --git a/app/Controllers/RSSFeedController.php b/app/Controllers/RSSFeedController.php new file mode 100644 index 0000000..d995642 --- /dev/null +++ b/app/Controllers/RSSFeedController.php @@ -0,0 +1,26 @@ +channel->item as $item) { + $items[] = [ + 'title' => (string) $item->title, + 'link' => (string) $item->link, + 'description' => (string) $item->description, + 'pubDate' => (string) $item->pubDate + ]; + } + + return $this->response->setJSON($items); + } +} diff --git a/app/Helpers/CommonHelper.php b/app/Helpers/CommonHelper.php index a079b4e..12c6b8d 100644 --- a/app/Helpers/CommonHelper.php +++ b/app/Helpers/CommonHelper.php @@ -2,9 +2,11 @@ namespace App\Helpers; -abstract class CommonHelper +class CommonHelper { - protected function __construct() {} + public function __construct() + { + } final public function getRandomString($length = 10, $characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") { return substr(str_shuffle($characters), 0, $length); diff --git a/app/Views/admin/welcome_message.php b/app/Views/admin/welcome_message.php index 3b71da9..ffcedaa 100644 --- a/app/Views/admin/welcome_message.php +++ b/app/Views/admin/welcome_message.php @@ -1,5 +1,134 @@ -= $this->extend('layouts/admin') ?> += $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?> = $this->section('content') ?> -= $this->include('templates/admin/header'); ?> -= $this->include('templates/admin/footer'); ?> +