Gave the controller some more smarts with the ability to detect requests for internal files and pass them through. Used to use the Javascript and CSS that is provided in PICKLES without the need of copying the files into the public scope, symlinking or Apache aliasing.

This commit is contained in:
Josh Sherman 2010-10-17 23:10:48 -04:00
parent 1980b8871a
commit 2d466d98e7

View file

@ -27,6 +27,18 @@
*/ */
class Controller extends Object class Controller extends Object
{ {
/**
* Pass Thru
*
* Whether or not the page being loaded is simple a pass thru for an
* internal PICKLES file. The point of this variable is to suppress the
* profiler report in the destructor.
*
* @access private
* @var boolean
*/
private $passthru = false;
/** /**
* Constructor * Constructor
* *
@ -37,6 +49,19 @@ class Controller extends Object
{ {
parent::__construct(); parent::__construct();
// Catches requests to PICKLES core files and passes them through
if (preg_match('/^__pickles\/(css|js)\/.+$/', $_REQUEST['request']))
{
// Checks that the file exists
$file = str_replace('__pickles', PICKLES_PATH, $_REQUEST['request']);
if (file_exists($file))
{
// Sets the pass thru flag and dumps the data
$this->passthru = true;
exit(file_get_contents($file));
}
}
// Generate a generic "site down" message if the site is set to be disabled // Generate a generic "site down" message if the site is set to be disabled
if (isset($this->config->pickles['disabled']) && $this->config->pickles['disabled'] == true) if (isset($this->config->pickles['disabled']) && $this->config->pickles['disabled'] == true)
{ {
@ -222,7 +247,8 @@ class Controller extends Object
{ {
parent::__destruct(); parent::__destruct();
if (isset($this->config->pickles['profiler']) && $this->config->pickles['profiler'] == true) // Display the Profiler's report is the stars are aligned
if (isset($this->config->pickles['profiler']) && $this->config->pickles['profiler'] == true && $this->passthru == false)
{ {
Profiler::report(); Profiler::report();
} }