Updates from lnApp

This commit is contained in:
Deon George
2011-07-14 08:59:32 +10:00
parent 5c9750e957
commit 46c3b9a075
31 changed files with 991 additions and 434 deletions

View File

@@ -144,6 +144,9 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
}
public function after() {
if (! is_string($this->template) AND empty($this->template->content))
$this->template->content = Block::factory();
if ($this->auto_render) {
// Application Title
$this->meta->title = 'Application Title';
@@ -189,10 +192,10 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
$this->response->bodyadd(sprintf('<table class="content"><tr><td>%s</td></tr></table>',$this->template->content));
}
if (isset($this->template->content) AND ! $this->template->content)
$this->template->content = Block::factory();
parent::after();
// Generate and check the ETag for this file
$this->response->check_cache(NULL,$this->request);
}
/**
@@ -240,9 +243,6 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
* @return void
*/
final public function action_media() {
// Generate and check the ETag for this file
$this->response->check_cache(NULL,$this->request);
// Get the file path from the request
$file = $this->request->param('file');
@@ -251,9 +251,14 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
// Remove the extension from the filename
$file = substr($file, 0, -(strlen($ext) + 1));
$f = '';
// If our file is pathed with session, our file is in our session.
if ($fd = Session::instance()->get_once($this->request->param('file'))) {
$this->response->body($fd);
// First try and find media files for the site_id
if ($f = Kohana::find_file(sprintf('media/%s',Config::siteid()), $file, $ext)) {
} elseif ($f = Kohana::find_file(sprintf('media/%s',Config::siteid()), $file, $ext)) {
// Send the file content as the response
$this->response->body(file_get_contents($f));
@@ -267,10 +272,13 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
$this->response->status(404);
}
// Generate and check the ETag for this file
$this->response->check_cache(NULL,$this->request);
// Set the proper headers to allow caching
$this->response->headers('Content-Type',File::mime_by_ext($ext));
$this->response->headers('Content-Length',(string)filesize($f));
$this->response->headers('Last-Modified',date('r', filemtime($f)));
$this->response->headers('Content-Length',(string)$this->response->content_length());
$this->response->headers('Last-Modified',date('r', $f ? filemtime($f) : time()));
}
}
?>