Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactoring home page, removing commented code.

  • Loading branch information...
commit 8fda39172eb17039508c9d33f4eca08842c48516 1 parent 7e9ed5c
@davidpersson davidpersson authored nateabele committed
Showing with 46 additions and 87 deletions.
  1. +46 −87 app/views/pages/home.html.php
View
133 app/views/pages/home.html.php
@@ -11,30 +11,21 @@
$this->title('Home');
-$checkName = null;
-$checkStatus = array();
$self = $this;
-$notify = function($status, $message, $solution = null) use (&$checkName, &$checkStatus) {
- $checkStatus[$checkName] = $status === true;
-
- if (!is_string($status)) {
- $status = $status ? 'success' : 'fail';
- }
- $message = is_array($message) ? join("\n<br />", $message) : $message;
- $solution = is_array($solution) ? join("\n<br />", $solution) : $solution;
-
- return <<<HTML
-<div class="test-result test-result-{$status}">{$message}</div>
-<div class="test-result solution">{$solution}</div>
-HTML;
+$notify = function($status, $message, $solution = null) {
+ $html = "<div class=\"test-result test-result-{$status}\">{$message}</div>";
+ $html .= "<div class=\"test-result solution\">{$solution}</div>";
+ return $html;
};
-$sanityChecks = array(
+$checks = array(
'home' => function() use ($notify) {
$file = realpath(LITHIUM_APP_PATH . '/views/pages/home.html.php');
- return $notify('notice', "You're using the application's default home page.",
+ return $notify(
+ 'notice',
+ "You're using the application's default home page.",
"To change this template, edit the file
<code>{$file}</code>."
);
@@ -43,7 +34,9 @@
$file = realpath(LITHIUM_APP_PATH . '/views/layouts/default.html.php');
$link = $self->html->link('layout', 'http://lithify.me/docs/lithium/template');
- return $notify('notice', 'Change the default layout.',
+ return $notify(
+ 'notice',
+ 'Change the default layout.',
"To change the {$link},
this is the file wrapping your content as well as containing header and footer,
edit the file <code>{$file}</code>."
@@ -53,15 +46,19 @@
$file = realpath(LITHIUM_APP_PATH . '/config/routes.php');
$link = $self->html->link('routing', 'http://lithify.me/docs/lithium/net/http/Router');
- return $notify('notice', 'Use custom routing.',
+ return $notify(
+ 'notice',
+ 'Use custom routing.',
"To change the {$link} edit the file <code>{$file}</code>."
);
},
'resourcesWritable' => function() use ($notify) {
if (is_writable($path = realpath(Libraries::get(true, 'resources')))) {
- return $notify(true, 'Resources directory is writable.');
+ return $notify('success', 'Resources directory is writable.');
}
- return $notify(false, 'Your resource path is not writeable.',
+ return $notify(
+ 'fail',
+ 'Your resource path is not writeable.',
"To fix this on *nix and Mac OSX, run the following from the command line:
<code>$ chmod -R 0777 {$path}</code>"
);
@@ -71,89 +68,51 @@
$boot = realpath(LITHIUM_APP_PATH . '/config/bootstrap.php');
$connections = realpath(LITHIUM_APP_PATH . '/config/bootstrap/connections.php');
- if (empty($config)) {
- return $notify('notice', 'No database connection defined.',
- "To create a database connection:
- <ol>
- <li>Edit the file <code>{$boot}</code>.</li>
- <li>
- Uncomment the line having
- <code>require __DIR__ . '/bootstrap/connections.php';</code>.
- </li>
- <li>Edit the file <code>{$connections}</code>.</li>
- </ol>"
- );
+ if (!empty($config)) {
+ return $notify('success', 'Database connection/s configured.');
}
- return $notify(true, 'Database connection/s configured.');
+ return $notify(
+ 'notice',
+ 'No database connection defined.',
+ "To create a database connection:
+ <ol>
+ <li>Edit the file <code>{$boot}</code>.</li>
+ <li>
+ Uncomment the line having
+ <code>require __DIR__ . '/bootstrap/connections.php';</code>.
+ </li>
+ <li>Edit the file <code>{$connections}</code>.</li>
+ </ol>"
+ );
},
- // 'databaseEnabled' => function() use ($notify, &$checkStatus) {
- // if (!$checkStatus['database']) {
- // return;
- // }
- // $results = array();
- // $config = Connections::config();
- // foreach ($config as $name => $options) {
- // $enabled = Connections::enabled($name);
- // if (!$enabled) {
- // $results[] = $notify('exception', "Database for <code>{$options}</code> is not enabled.");
- // }
- // }
- // if (empty($results)) {
- // $results[] = $notify(true, "Database(s) enabled.");
- // }
- // return implode("\n", $results);
- // },
- // 'databaseConnected' => function() use ($notify, &$checkStatus) {
- // if (!$checkStatus['database']) {
- // return;
- // }
- // $results = array();
- // $config = Connections::config();
- // foreach ($config as $name => $options) {
- // $enabled = Connections::enabled($name);
- // if ($enabled) {
- // $connection = Connections::get($name)->connect();
- // if ($connection) {
- // $results[] = $notify(
- // true, "Connection to <code>{$name}</code> database verified."
- // );
- // } else {
- // $results[] = $notify(
- // false, "Could not connect to <code>{$name}</code> database."
- // );
- // }
- // }
- // }
- // return implode("\n", $results);
- // },
'magicQuotes' => function() use ($notify) {
if (get_magic_quotes_gpc() === 0) {
return;
}
- return $notify(false, array(
- "Magic quotes are enabled in your PHP configuration. Please set <code>" .
- "magic_quotes_gpc = Off</code> in your <code>php.ini</code> settings."
- ));
+ return $notify(
+ 'fail',
+ 'Magic quotes are enabled in your PHP configuration.',
+ 'Please set <code>magic_quotes_gpc = Off</code> in your <code>php.ini</code> settings.'
+ );
},
'registerGlobals' => function() use ($notify) {
if (!ini_get('register_globals')) {
return;
}
- return $notify(false, array(
- 'Register globals is enabled in your PHP configuration. Please set <code>' .
- 'register_globals = Off</code> in your <code>php.ini</code> settings.'
- ));
+ return $notify(
+ 'fail',
+ 'Register globals is enabled in your PHP configuration.',
+ 'Please set <code>register_globals = Off</code> in your <code>php.ini</code> settings.'
+ );
},
);
?>
<h3>Getting Started</h3>
-<div class="sanity-checks">
- <?php foreach ($sanityChecks as $checkName => $check): ?>
- <?php echo $check(); ?>
- <?php endforeach; ?>
-</div>
+<?php foreach ($checks as $check): ?>
+ <?php echo $check(); ?>
+<?php endforeach; ?>
<h3>Additional Resources</h3>
<ul>
Please sign in to comment.
Something went wrong with that request. Please try again.