summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.php2
-rw-r--r--installer/helpers/installer.php88
-rw-r--r--installer/install.php7
-rw-r--r--installer/views/installer.html.php9
-rw-r--r--installer/views/installer.txt.php20
5 files changed, 67 insertions, 59 deletions
diff --git a/index.php b/index.php
index ac285645..e68d1926 100644
--- a/index.php
+++ b/index.php
@@ -47,7 +47,7 @@ define('SYSPATH', strtr(realpath('kohana') . '/', DIRECTORY_SEPARATOR, '/'));
if (!file_exists('var')) {
include DOCROOT . "installer/helpers/installer.php";
- if (installer::failed()) {
+ if (!installer::environment_check()) {
installer::display_requirements();
die;
}
diff --git a/installer/helpers/installer.php b/installer/helpers/installer.php
index 2c7e39ff..4ab1d94e 100644
--- a/installer/helpers/installer.php
+++ b/installer/helpers/installer.php
@@ -21,130 +21,139 @@ class installer {
private static $messages = array();
private static $config = array();
- public function failed() {
+ public function environment_check() {
$failed = false;
+ $section = array("header" => "Environment Test",
+ "description" => "The following tests have been run to determine if " .
+ "Gallery3 will work in your environment. If any of the tests have " .
+ "failed, consult the documention on http://gallery.menalto.com for " .
+ "more information on how to correct the problem.",
+ "msgs" => array());
+
if (version_compare(PHP_VERSION, "5.2", "<")) {
- self::$messages["PHP Version"] = array("error" => true,
+ $section["msgs"]["PHP Version"] = array("error" => true,
"text" => sprintf("Gallery3 requires PHP 5.2 or newer, current version: %s.", PHP_VERSION));
$failed = true;
} else {
- self::$messages["PHP Version"] = array("error" => false,
+ $section["msgs"]["PHP Version"] = array("error" => false,
"text" => PHP_VERSION);
}
if (!(is_dir(SYSPATH) AND is_file(SYSPATH.'core/Bootstrap'.EXT))) {
- self::$messages["Kohana Directory"] = array("error" => true,
+ $section["msgs"]["Kohana Directory"] = array("error" => true,
"text" => "The configured Kohana directory does not exist or does not contain the required files.");
} else {
- self::$messages["Kohana Directory"] = array("error" => false,
+ $section["msgs"]["Kohana Directory"] = array("error" => false,
"text" => SYSPATH);
}
if (!(is_dir(APPPATH) AND is_file(APPPATH.'config/config'.EXT))) {
- self::$messages["Application Directory"] = array("error" => true,
+ $section["msgs"]["Application Directory"] = array("error" => true,
"text" => "The configured Gallery3 application directory does not exist or does not contain the required files.");
$failed = true;
} else {
- self::$messages["Application Directory"] = array("error" => false,
+ $section["msgs"]["Application Directory"] = array("error" => false,
"text" => APPPATH);
}
if (!(is_dir(MODPATH))) {
- self::$messages["Modules Directory"] = array("error" => true,
+ $section["msgs"]["Modules Directory"] = array("error" => true,
"text" => "The configured Gallery3 modules directory does not exist or does not contain the required files.");
$failed = true;
} else {
- self::$messages["Modules Directory"] = array("error" => false,
+ $section["msgs"]["Modules Directory"] = array("error" => false,
"text" => MODPATH);
}
if (!(is_dir(THEMEPATH))) {
- self::$messages["Theme Directory"] = array("error" => true,
+ $section["msgs"]["Theme Directory"] = array("error" => true,
"text" => "The configured Gallery3 themes directory does not exist or does not contain the required files.");
$failed = true;
} else {
- self::$messages["Themes Directory"] = array("error" => false,
+ $section["msgs"]["Themes Directory"] = array("error" => false,
"text" => THEMEPATH);
}
if (!@preg_match("/^.$/u", utf8_encode("\xF1"))) {
- self::$messages["PCRE UTF-8"] = array("error" => true,
+ $section["msgs"]["PCRE UTF-8"] = array("error" => true,
"text" => "Perl-Compatible Regular Expressions has not been compiled with UTF-8 support.",
"html" => "<a href=\"http://php.net/pcre\">PCRE</a> has not been compiled with UTF-8 support.");
$failed = true;
} else if (!@preg_match("/^\pL$/u", utf8_encode("\xF1"))) {
- self::$messages["PCRE UTF-8"] = array("error" => true,
+ $section["msgs"]["PCRE UTF-8"] = array("error" => true,
"text" => "Perl-Compatible Regular Expressions has not been compiled with Unicode support.",
"html" => "<a href=\"http://php.net/pcre\">PCRE</a> has not been compiled with Unicode property support.");
$failed = true;
} else {
- self::$messages["PCRE UTF-8"] = array("error" => false,
+ $section["msgs"]["PCRE UTF-8"] = array("error" => false,
"text" => "Pass");
}
if (!(class_exists("ReflectionClass"))) {
- self::$messages["Reflection Enabled"] = array("error" => true,
+ $section["msgs"]["Reflection Enabled"] = array("error" => true,
"text" => "PHP relection is either not loaded or not compiled in.",
"html" => "PHP <a href=\"http://php.net/reflection\">relection<a> is either not loaded or not compiled in.");
$failed = true;
} else {
- self::$messages["Reflection Enabled"] = array("error" => false,
+ $section["msgs"]["Reflection Enabled"] = array("error" => false,
"text" => "Pass");
}
if (!(function_exists("filter_list"))) {
- self::$messages["Filters Enabled"] = array("error" => true,
+ $section["msgs"]["Filters Enabled"] = array("error" => true,
"text" => "The filter extension is either not loaded or not compiled in.",
"html" => "The <a href=\"http://php.net/filter\">filter</a> extension is either not loaded or not compiled in.");
$failed = true;
} else {
- self::$messages["Filters Enabled"] = array("error" => false,
+ $section["msgs"]["Filters Enabled"] = array("error" => false,
"text" => "Pass");
}
if (!(extension_loaded("iconv"))) {
- self::$messages["Iconv Loaded"] = array("error" => true,
+ $section["msgs"]["Iconv Loaded"] = array("error" => true,
"text" => "The iconv extension is not loaded.",
"html" => "The <a href=\"http://php.net/iconv\">iconv</a> extension is not loaded.");
$failed = true;
} else {
- self::$messages["Iconv Enabled"] = array("error" => false,
+ $section["msgs"]["Iconv Enabled"] = array("error" => false,
"text" => "Pass");
}
if (extension_loaded("mbstring") &&
(ini_get("mbstring.func_overload") & MB_OVERLOAD_STRING)) {
- self::$messages["Mbstring Overloaded"] = array("error" => true,
+ $section["msgs"]["Mbstring Overloaded"] = array("error" => true,
"text" => "The mbstring extension is overloading PHP's native string functions.",
"html" => "The <a href=\"http://php.net/mbstring\">mbstring</a> extension is overloading PHP's native string functions.");
$failed = true;
} else {
- self::$messages["MbString Overloaded"] = array("error" => false,
+ $section["msgs"]["MbString Overloaded"] = array("error" => false,
"text" => "Pass");
}
if (!(isset($_SERVER["REQUEST_URI"]) || isset($_SERVER["PHP_SELF"]))) {
- self::$messages["URI Determination"] = array("error" => true,
+ $section["msgs"]["URI Determination"] = array("error" => true,
"text" => "Neither \$_SERVER['REQUEST_URI'] or \$_SERVER['PHP_SELF'] is available.",
"html" => "Neither <code>\$_SERVER['REQUEST_URI']</code> or <code>\$_SERVER['PHP_SELF']<code> is available.");
$failed = true;
} else {
- self::$messages["URI Determination"] = array("error" => false,
+ $section["msgs"]["URI Determination"] = array("error" => false,
"text" => "Pass");
}
$short_tags = ini_get("short_open_tag");
if (empty($short_tags)) {
- self::$messages["Short Tags"] = array("error" => true,
+ $section["msgs"]["Short Tags"] = array("error" => true,
"text" => "Gallery3 requires that PHP short tags be enabled.",
"html" => "Gallery3 requires that PHP <a href=\"http://ca2.php.net/manual/en/ini.core.php\">short tags</a> be enabled");
$failed = true;
} else {
- self::$messages["Short Tags"] = array("error" => false,
+ $section["msgs"]["Short Tags"] = array("error" => false,
"text" => "Pass");
}
- return $failed;
+ self::$messages[] = $section;
+
+ return !$failed;
}
public static function display_requirements() {
@@ -155,18 +164,11 @@ class installer {
}
}
-/* -h Database host (default: localhost)
- * -u Database user (default: root)
- * -p Database user password (default: )
- * -d Database name (default: gallery3)
- * -t Table prefix (default: )
- * -f Response file (default: not used)
- * The response file is a php file that contains the following syntax;
- * $config[key] = value;
- * Where key is one of "host", "user", "password", "dbname", "prefix". Values specified
- * on the command line will override values contained in this file
- */
- public function parse_cli_parms($argv) {
+ public static function parse_cli_parms($argv) {
+ $section = array("header" => "Installation Parameters",
+ "description" => "The following parameters will be used to install and " .
+ "configure your Gallery3 installation.",
+ "msgs" => array());
for ($i=0; $i < count($argv); $i++) {
switch (strtolower($argv[$i])) {
case "-d":
@@ -200,8 +202,12 @@ class installer {
unset($arguments["file"]);
}
self::$config = array_merge($config, $arguments);
-
- var_dump(self::$config);
+
+ foreach (self::$config as $key => $value) {
+ $section["msgs"][$key] = array("text" => $value, "error" => false);
+ }
+ self::$messages[] = $section;
+
}
private static function _render($view) {
diff --git a/installer/install.php b/installer/install.php
index edb571a5..eaf73b6f 100644
--- a/installer/install.php
+++ b/installer/install.php
@@ -58,12 +58,13 @@ define('EXT', ".php");
include DOCROOT . "/installer/helpers/installer.php";
// @todo Log the results of failed call
-if (installer::failed()) {
+if (!installer::environment_check()) {
installer::display_requirements();
die;
}
-installer::display_requirements();
-$install_config = installer::parse_cli_parms($argv);
+installer::parse_cli_parms($argv);
+
+installer::display_requirements();
diff --git a/installer/views/installer.html.php b/installer/views/installer.html.php
index fef71834..34bcb56c 100644
--- a/installer/views/installer.html.php
+++ b/installer/views/installer.html.php
@@ -25,15 +25,15 @@
</head>
<body>
- <h1>Environment Tests</h1>
+ <? foreach (self::$messages as $section) : ?>
+ <h1><?php print $section["header"] ?></h1>
- <p>The following tests have been run to determine if Gallery3 will work in your environment. If any of the tests have failed, consult the
- <a href="http://gallery.menalto.com">documentation</a> for more information on how to correct the problem.</p>
+ <p><?php print $section["description"] ?></p>
<div id="tests">
<table cellspacing="0">
- <?php foreach (self::$messages as $header => $msg): ?>
+ <?php foreach ($section["msgs"] as $header => $msg): ?>
<tr>
<th><?php echo $header ?></th>
@@ -44,5 +44,6 @@
<?php endforeach ?>
</table>
</div>
+ <? endforeach ?>
</body>
</html> \ No newline at end of file
diff --git a/installer/views/installer.txt.php b/installer/views/installer.txt.php
index 5c98752f..3b6f0512 100644
--- a/installer/views/installer.txt.php
+++ b/installer/views/installer.txt.php
@@ -27,17 +27,17 @@ function print_msg($header, $msg, $error) {
}
}
-echo "+", str_repeat("-", 98), "+\n";
-printf("| %-96.96s |\n", "Environment Tests");
-printf("| %-96.96s |\n", "The following tests have been run to determine if Gallery3 will work " .
- "in your environment.");
-printf("| %-96.96s |\n", "If any of the tests have failed, consult the documention on " .
- "http://gallery.menalto.com");
-printf("| %-96.96s |\n", "for more information on how to correct the problem.");
-echo "+", str_repeat("-", 98), "+\n";
+foreach (self::$messages as $section) {
+ echo "+", str_repeat("-", 98), "+\n";
+ printf("| %-96.96s |\n", $section["header"]);
+ foreach (explode("\n", wordwrap($section["description"], 92)) as $text) {
+ printf("| %-96.96s |\n", $text);
+ }
+ echo "+", str_repeat("-", 98), "+\n";
-foreach (self::$messages as $header => $msg) {
- print_msg($header, $msg["text"], $msg["error"]);
+ foreach ($section["msgs"] as $header => $msg) {
+ print_msg($header, $msg["text"], $msg["error"]);
+ }
}
echo "+", str_repeat("-", 98), "+\n";