From d742de4e1100df15153784fa0702a334cd388d73 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sun, 2 Nov 2008 19:56:57 +0000
Subject: Improve welcome scaffolding to walk you through getting the var
directory set up correctly and a database config file in place.
---
core/controllers/welcome.php | 50 ++++++++++++++++++++++++++++++++++--
core/views/welcome.html.php | 29 +++++++++++++++++++--
core/views/welcome_syscheck.html.php | 49 +++++++++++++++++++++++++++++++++++
index.php | 6 ++++-
4 files changed, 129 insertions(+), 5 deletions(-)
create mode 100644 core/views/welcome_syscheck.html.php
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php
index 3329a402..1e77ad4a 100644
--- a/core/controllers/welcome.php
+++ b/core/controllers/welcome.php
@@ -17,8 +17,54 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Welcome_Controller extends Controller {
+class Welcome_Controller extends Template_Controller {
+ public $template = 'welcome.html';
+
function Index() {
- print new View('welcome.html');
+ }
+
+ function Syscheck() {
+ $errors = array();
+ if (!file_exists(VARPATH)) {
+ $error = new stdClass();
+ $error->message = "Missing: " . VARPATH;
+ $error->instructions[] = "mkdir " . VARPATH;
+ $error->instructions[] = "chmod 777 " . VARPATH;
+ $errors[] = $error;
+ } else if (!is_writable(VARPATH)) {
+ $error = new stdClass();
+ $error->message = "Not writable: " . VARPATH;
+ $error->instructions[] = "chmod 777 " . VARPATH;
+ $errors[] = $error;
+ }
+
+ $db_php = VARPATH . "database.php";
+ if (!file_exists($db_php)) {
+ $error = new stdClass();
+ $error->message = "Missing: $db_php";
+ $error->instructions[] = "cp kohana/config/database.php $db_php";
+ $error->instructions[] = "chmod 644 $db_php";
+ $error->message2 = "Then edit this file and enter your database configuration settings.";
+ $errors[] = $error;
+ } else if (!is_readable($db_php)) {
+ $error->message = "Not readable: $db_php";
+ $error->instructions[] = "chmod 644 $db_php";
+ $error->message2 = "Then edit this file and enter your database configuration settings.";
+ $errors[] = $error;
+ }
+
+ if (empty($errors)) {
+ Database::instance()->connect();
+ }
+
+ $this->_create_directories();
+ $this->template = new View('welcome_syscheck.html');
+ $this->template->errors = $errors;
+ }
+
+ function _create_directories() {
+ foreach (array("logs") as $dir) {
+ @mkdir(VARPATH . "$dir");
+ }
}
}
diff --git a/core/views/welcome.html.php b/core/views/welcome.html.php
index da75ebcc..a22bb324 100644
--- a/core/views/welcome.html.php
+++ b/core/views/welcome.html.php
@@ -13,16 +13,34 @@
background: white;
border: 1px solid black;
margin: 0 auto;
+ padding: -10px;
}
div.inner {
- padding: 1em;
+ padding: 0 1em 0 1em;
+ margin: 0px;
}
p {
+ margin: 0 0 0 0;
padding-left: 1em;
}
+ pre {
+ margin: 0;
+ padding-left: 2em;
+ }
+
+ .error {
+ color: red;
+ }
+
+ div.block {
+ padding: 0px;
+ margin: 0px;
+ padding-bottom: 1em;
+ }
+
ul {
margin-top: -1em;
}
@@ -51,7 +69,14 @@
links to get you started.
- Useful Links
+ About your config
+
+
+ Activities
+
+
+
+ Documentation
-
Gallery3: Prioritized Feature List
diff --git a/core/views/welcome_syscheck.html.php b/core/views/welcome_syscheck.html.php
new file mode 100644
index 00000000..c87c4763
--- /dev/null
+++ b/core/views/welcome_syscheck.html.php
@@ -0,0 +1,49 @@
+ defined("SYSPATH") or die("No direct script access."); ?>
+
+
+ Gallery3 Scaffold
+
+
+
+ foreach ($errors as $error): ?>
+
+
+ = $error->message ?>
+
+ foreach ($error->instructions as $line): ?>
+
= $line ?>
+ endforeach ?>
+
+ if (!empty($error->message2)): ?>
+
+ = $error->message2 ?>
+
+ endif ?>
+
+ endforeach ?>
+
+
diff --git a/index.php b/index.php
index a9310500..9d278e62 100644
--- a/index.php
+++ b/index.php
@@ -49,7 +49,11 @@ if (PHP_SAPI == 'cli') {
@system('mkdir -p test/var/logs');
define('VARPATH', realpath('test/var') . '/');
} else {
- define('VARPATH', realpath('var') . '/');
+ if (file_exists('var')) {
+ define('VARPATH', realpath('var') . '/');
+ } else {
+ define('VARPATH', getcwd() . "/var/");
+ }
}
// Initialize.
--
cgit v1.2.3