Added support for custom maintenance templates.

This commit is contained in:
Joshua Sherman 2013-12-31 10:56:31 -05:00
parent 5a15c791c5
commit 9b1feda909
2 changed files with 26 additions and 15 deletions

View file

@ -42,16 +42,26 @@ class Controller extends Object
try
{
// @todo Clean this up to be just a single sanity check
if (isset($this->config->pickles['disabled']) && $this->config->pickles['disabled'] == true)
if (isset($this->config->pickles['disabled']) && $this->config->pickles['disabled'])
{
// @todo Add support for custom templates
throw new Exception('
<h1>Down for Maintenance</h1>
<p>' . $_SERVER['SERVER_NAME'] . ' is currently down for maintenance. Please check back in a few minutes.</p>
<p>Additionally, a custom maintenance template was not found.</p>
<hr>
<em>Powered by <a href="https://github.com/joshtronic/pickles">PICKLES</a></em>
');
$custom_template = SITE_TEMPLATE_PATH . '__shared/maintenance.phtml';
if (file_exists($custom_template))
{
require_once $custom_template;
}
else
{
echo '
<h1>Down for Maintenance</h1>
<p>' . $_SERVER['SERVER_NAME'] . ' is currently down for maintenance. Please check back in a few minutes.</p>
<p>Additionally, a custom maintenance template was not found.</p>
<hr>
<em>Powered by <a href="https://github.com/joshtronic/pickles">PICKLES</a></em>
';
}
throw new Exception();
}
// Checks for attributes passed in the URI
@ -310,9 +320,6 @@ class Controller extends Object
Profiler::timer('module ' . $default_method);
}
// @todo Set this in the module and use $module->return and rename module->return to module->data?
$module->display = ['template', 'json'];
// Checks if we have any templates
$parent_template = $module->template;
$template_exists = $this->validateTemplates($module, $parent_template);

View file

@ -27,12 +27,16 @@ class ControllerTest extends PHPUnit_Framework_TestCase
new Controller();
}
/*
public function testCustomSiteDown()
{
$this->fail();
$this->config->data['pickles']['disabled'] = true;
file_put_contents(SITE_TEMPLATE_PATH . '__shared/maintenance.phtml', '<h1>Custom Down for Maintenance</h1>');
new Controller();
$this->expectOutputRegex('/<h1>Custom Down for Maintenance<\/h1>/');
}
*/
public function testAttributesInURI()
{