Skip to content

Instantly share code, notes, and snippets.

@ryross
Created August 5, 2010 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryross/509221 to your computer and use it in GitHub Desktop.
Save ryross/509221 to your computer and use it in GitHub Desktop.
classes/controller/base.php
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Base extends Controller_Template
{
public $auto_render = TRUE;
public $template = 'template/template';
protected $session;
public function __construct(Request $request)
{
if (Request::$is_ajax)
{
$this->profiler = NULL;
$this->auto_render = FALSE;
}
$this->session = Session::instance();
parent::__construct($request);
}
public function before()
{
parent::before();
$this->session= Session::instance();
if ($this->auto_render)
{
$this->template->content = '';
$this->template->styles = array();
$this->template->scripts = array();
}
}
public function after()
{
if ($this->auto_render)
{
$styles = array(
'base.css',
'master.css',
);
$scripts = array(
'jquery-1.4.2.min.js',
);
$this->template->styles = array_merge($styles, $this->template->styles);
$this->template->scripts = array_merge($scripts, $this->template->scripts);
}
parent::after();
if($this->auto_render)
{
$this->template->styles = Minify::factory('css')->minify($this->template->styles);
$this->template->scripts = Minify::factory('js')->minify($this->template->scripts);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment