Rebuilding with CodeIgniter 4
This commit is contained in:
parent
e6dcc92267
commit
3bce4ad0ac
92 changed files with 7304 additions and 380 deletions
46
app/Controllers/BaseController.php
Normal file
46
app/Controllers/BaseController.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
namespace App\Controllers;
|
||||
|
||||
/**
|
||||
* Class BaseController
|
||||
*
|
||||
* BaseController provides a convenient place for loading components
|
||||
* and performing functions that are needed by all your controllers.
|
||||
* Extend this class in any new controllers:
|
||||
* class Home extends BaseController
|
||||
*
|
||||
* For security be sure to declare any new methods as protected or private.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
*/
|
||||
|
||||
use CodeIgniter\Controller;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* An array of helpers to be loaded automatically upon
|
||||
* class instantiation. These helpers will be available
|
||||
* to all other controllers that extend BaseController.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $helpers = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
// Do Not Edit This Line
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Preload any models, libraries, etc, here.
|
||||
//--------------------------------------------------------------------
|
||||
// E.g.:
|
||||
// $this->session = \Config\Services::session();
|
||||
}
|
||||
|
||||
}
|
42
app/Controllers/Blog.php
Normal file
42
app/Controllers/Blog.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php namespace App\Controllers;
|
||||
|
||||
use App\Models\BlogModel;
|
||||
use CodeIgniter\Controller;
|
||||
|
||||
class Blog extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
helper('html');
|
||||
$model = new BlogModel();
|
||||
|
||||
$data = [
|
||||
'blog' => $model->getBlog(),
|
||||
'title' => 'Blog',
|
||||
];
|
||||
|
||||
echo view('common/header', $data);
|
||||
echo view('blog/overview', $data);
|
||||
echo view('common/footer', $data);
|
||||
|
||||
}
|
||||
|
||||
public function view($slug = null)
|
||||
{
|
||||
helper('html');
|
||||
$model = new BlogModel();
|
||||
|
||||
$data['blog'] = $model->getBlog($slug);
|
||||
|
||||
if (empty($data['blog']))
|
||||
{
|
||||
throw new \CodeIgniter\Exceptions\PageNotFoundException('Cannot find the blog post: '. $slug);
|
||||
}
|
||||
|
||||
$data['data'] = $data['blog']['title'];
|
||||
|
||||
echo view('common/header', $data);
|
||||
echo view('blog/view', $data);
|
||||
echo view('common/footer', $data);
|
||||
}
|
||||
}
|
28
app/Controllers/Pages.php
Normal file
28
app/Controllers/Pages.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php namespace App\Controllers;
|
||||
|
||||
class Pages extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
helper('html');
|
||||
echo view('common/header');
|
||||
echo view('home');
|
||||
echo view('common/footer');
|
||||
}
|
||||
|
||||
public function view($slug = null)
|
||||
{
|
||||
helper('html');
|
||||
|
||||
if (empty($slug)) {
|
||||
$page = "home";
|
||||
} else {
|
||||
$page = $slug;
|
||||
}
|
||||
|
||||
echo view('common/header');
|
||||
echo view('pages/'.$page);
|
||||
echo view('common/footer');
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue