86 lines
2.4 KiB
PHP
86 lines
2.4 KiB
PHP
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
|
|
|
abstract class Base_Front_Controller extends Controller
|
|
{
|
|
public $view = 'default_layout';
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
#$this->profiler = new Profiler();
|
|
/*
|
|
if(empty(Router::$segments))
|
|
{
|
|
$this->view = 'homepage_layout';
|
|
}
|
|
*/
|
|
$this->view = new View($this->view);
|
|
|
|
$this->session = Session::instance();
|
|
$this->view->title = Kohana::config('application.title');
|
|
$this->view->meta_description = Kohana::config('application.meta_description');
|
|
$this->view->meta_keywords = Kohana::config('application.meta_keywords');
|
|
$this->view->admin_menu = $this->session->get('admin');
|
|
|
|
$this->view->google_analytics = Kohana::config('application.google_analytics');
|
|
|
|
$this->view->menu_nav = Kohana::config('application.menu_nav');
|
|
|
|
$this->view->active_menu = $this->uri->string();
|
|
|
|
$this->view->szybki_kontakt = ORM::factory('page')->where('name', 'szybki-kontakt')->find();
|
|
|
|
$this->view->path = array();
|
|
$this->view->selected = '';
|
|
$this->view->content = '';
|
|
$this->path_arrow = ' » ';
|
|
$this->view->message = $this->session->get('message');
|
|
}
|
|
/*
|
|
public function __destruct()
|
|
{
|
|
$this->view->render(true);
|
|
}
|
|
*/
|
|
public function index()
|
|
{
|
|
url::redirect('');
|
|
}
|
|
|
|
public function error404()
|
|
{
|
|
header('HTTP/1.1 404 File Not Found');
|
|
|
|
$this->view->title .= " - Błąd 404";
|
|
$error404_view = new View('front/error404');
|
|
#$error404_view->page_name = Router::$current_uri.Router::$url_suffix. ' ('.Router::$routed_uri.')';
|
|
$error404_view->page_name = Router::$current_uri.Router::$url_suffix;
|
|
$this->view->content = $error404_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();
|
|
}
|
|
} |