Created
August 5, 2010 04:13
-
-
Save ryross/509221 to your computer and use it in GitHub Desktop.
classes/controller/base.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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