From 2d466d98e7c2afdae50738bb2607952e35fec863 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sun, 17 Oct 2010 23:10:48 -0400 Subject: [PATCH] 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. --- classes/Controller.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/classes/Controller.php b/classes/Controller.php index 1a5c0cc..aa84fad 100644 --- a/classes/Controller.php +++ b/classes/Controller.php @@ -27,6 +27,18 @@ */ 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 * @@ -37,6 +49,19 @@ class Controller extends Object { 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 if (isset($this->config->pickles['disabled']) && $this->config->pickles['disabled'] == true) { @@ -222,7 +247,8 @@ class Controller extends Object { 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(); }