first commit
This commit is contained in:
87
application/controllers/base_admin.php
Normal file
87
application/controllers/base_admin.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
|
||||
abstract class Base_Admin_Controller extends Controller
|
||||
{
|
||||
public $view = 'admin_layout';
|
||||
protected $email;
|
||||
protected $message;
|
||||
protected $redirect;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
#$this->profiler = new Profiler();
|
||||
$this->view = new View($this->view);
|
||||
$this->session = Session::instance();
|
||||
$this->view->title = Kohana::config('application.title') ." - Administracja ";
|
||||
$this->view->content = '';
|
||||
#$this->view->main = '';
|
||||
#$this->view->message = '';
|
||||
$this->path_arrow = ' » ';
|
||||
$this->email = array(Kohana::config('application.email'), Kohana::config('application.email_name'));
|
||||
|
||||
$this->session->set('tiny_mce_public_html_dir', Kohana::config('tiny_mce.public_html_dir'));
|
||||
$this->session->set('tiny_mce_upload_dirs', Kohana::config('tiny_mce.upload_dirs'));
|
||||
|
||||
$this->view->message = $this->session->get('message');
|
||||
|
||||
#ustawienie przekierowania dla logowania
|
||||
if(empty($_POST) && Router::$method != 'login' && Router::$method != 'logout')
|
||||
{
|
||||
#cookie::set('admin_redirect', url::current());
|
||||
$this->session->set('admin_redirect', url::current());
|
||||
}
|
||||
#zabezpieczenie panelu admina
|
||||
if(!$this->session->get('admin') && Router::$method != 'login' && Router::$method != 'logout')
|
||||
{
|
||||
# TODO ? zastosowac parametr GET '?url='.url::current() do przekazywania adresu strony o dodawac do redirect
|
||||
url::redirect('admin/login');
|
||||
}
|
||||
else{
|
||||
$this->admin = $this->session->get('admin');
|
||||
$this->view->admin = $this->admin;
|
||||
}
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
url::redirect('');
|
||||
}
|
||||
|
||||
public function error404()
|
||||
{
|
||||
header('HTTP/1.1 404 File Not Found');
|
||||
|
||||
$this->template->title .= ":: Error 404";
|
||||
$error_view = new View('admin/error404');
|
||||
#$content->page_name = Router::$current_uri.Router::$url_suffix. ' ('.Router::$routed_uri.')';
|
||||
$error_view->page_name = Router::$current_uri.Router::$url_suffix;
|
||||
$this->view->content = $error_view;
|
||||
$this->view->render(true);
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
return $this->error404();
|
||||
}
|
||||
|
||||
protected function forward($controller, $method = 'index')
|
||||
{
|
||||
#Event::clear('system.post_controller',array($this,'_render'));
|
||||
if(strpos($controller, '/') === false)
|
||||
{
|
||||
$controller = '/'. $controller;
|
||||
}
|
||||
list($directory, $controller) = explode('/', $controller);
|
||||
Router::$controller = $controller;
|
||||
Router::$method = $method;
|
||||
$class = ucfirst($controller). '_Controller';
|
||||
if ($filename = Kohana::find_file('controllers/'.$directory, $controller))
|
||||
{
|
||||
// Load the class extension
|
||||
require_once $filename;
|
||||
}
|
||||
$object = new $class;
|
||||
return $object->$method();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user