diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-11-02 19:56:57 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-11-02 19:56:57 +0000 |
commit | d742de4e1100df15153784fa0702a334cd388d73 (patch) | |
tree | 64b0a688f73dab4675564c71adbca3cf25593956 | |
parent | 3ec437029bc23fff6560871f67171c3990205477 (diff) |
Improve welcome scaffolding to walk you through getting the var
directory set up correctly and a database config file in place.
-rw-r--r-- | core/controllers/welcome.php | 50 | ||||
-rw-r--r-- | core/views/welcome.html.php | 29 | ||||
-rw-r--r-- | core/views/welcome_syscheck.html.php | 49 | ||||
-rw-r--r-- | index.php | 6 |
4 files changed, 129 insertions, 5 deletions
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. </p> - <h2>Useful Links</h2> + <h2>About your config</h2> + <iframe width="100%" src="<?= url::site("welcome/syscheck") ?>"/></iframe> + + <h2>Activities</h2> + <p> + </p> + + <h2>Documentation</h2> <ul> <li> <a href="http://docs.google.com/Doc?id=dfjxt593_184ff9jhmd8&hl=en">Gallery3: Prioritized Feature List</a> 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."); ?> +<html> + <head> + <title>Gallery3 Scaffold</title> + <style> + body { + font-family: Trebuchet MS; + } + + p { + margin: 0 0 0 0; + padding: 5px; + } + + pre { + margin: 0; + padding-left: 1em; + } + + .error { + color: red; + } + + div.block { + border: 1px solid black; + margin-bottom: 5px; + paddding: 1em; + } + </style> + </head> + <body> + <? foreach ($errors as $error): ?> + <div class="block"> + <p class="error"> + <?= $error->message ?> + </p> + <? foreach ($error->instructions as $line): ?> + <pre><?= $line ?></pre> + <? endforeach ?> + + <? if (!empty($error->message2)): ?> + <p class="error"> + <?= $error->message2 ?> + </p> + <? endif ?> + </div> + <? endforeach ?> + </body> +</html> @@ -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. |