commit a728a39b73b48d79f2404d5054d53bd70c616b28
parent abfc2bbc0a68d84f32d8b99a25efe8bc5c9f472f
Author: Felicitus <felicitus@felicitus.org>
Date: Sun, 18 Dec 2011 04:43:12 +0100
Added the first setup checks, more to come
Diffstat:
14 files changed, 199 insertions(+), 31 deletions(-)
diff --git a/build.xml b/build.xml
@@ -54,7 +54,7 @@
</copy>
<copy overwrite="true" todir="setup/">
- <fileset dir="setup">
+ <fileset dir="src/setup">
<include name="**"/>
</fileset>
</copy>
diff --git a/src/setup/check-php-prequisites.php b/src/setup/check-php-prequisites.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * This file does various pre-flight checks in order to make sure the installer can run
+ * and do additional tests.
+ *
+ * The pre-flight check will immediately die if PHP is less than 5.3.0 or json_encode
+ * doesn't exist.
+ *
+ * Each pre-flight check consists of a json array returned in the following format:
+ *
+ * error: Either boolean true or false
+ * errormessage: An error message explaining what the error was
+ */
+
+/* We need at least PHP 5.3.0, bail out if the version is too low */
+if (version_compare(PHP_VERSION, '5.3.0', '<')) {
+ echo '{"error":true,"errormessage":"You need at least PHP 5.3.0"}';
+ exit;
+}
+
+/* json_decode is the most important function, as we communicate via JSON */
+if (!function_exists("json_encode")) {
+ echo '{"error":true,"errormessage":"Your PHP installation lacks the function json_decode, which is mandatory for PartKeepr."}';
+ exit;
+}
+
+$aChecks = array();
+
+echo json_encode(array("error" => false));
+exit;
+?>
diff --git a/src/setup/check-php.php b/src/setup/check-php.php
@@ -0,0 +1,2 @@
+/** <?php echo '*'.'/ {"error": false}'; exit; ?> */
+{"error":true,"errormessage":"You don't have PHP installed on your server, or the module is not activated."}+
\ No newline at end of file
diff --git a/src/setup/check.php b/src/setup/check.php
@@ -1,29 +0,0 @@
-<?php
-/**
- * This file does various pre-flight checks in order to make sure the installer can run
- * and do additional tests.
- *
- * The pre-flight check will immediately die if PHP is less than 5.3.0 or json_encode
- * doesn't exist.
- *
- * Each pre-flight check consists of a json array returned in the following format:
- *
- * error: Either boolean true or false
- * errormessage: An error message explaining what the error was
- * checks: An additional array containing the check names and their results
- */
-
-if (version_compare(PHP_VERSION, '5.3.0', '<')) {
- echo '{"error":true,"errormessage":"You need at least PHP 5.3.0"}';
- exit;
-}
-
-if (!function_exists("json_encode")) {
- echo '{"error":true,"errormessage":"Your PHP installation lacks the function json_decode, which is mandatory for PartKeepr."}';
- exit;
-}
-
-$aChecks = array();
-
-//echo json_encode(array("error" => true, "errormessage" => "You need at least PHP 5.3.0"));
-
diff --git a/src/setup/index.html b/src/setup/index.html
@@ -20,6 +20,17 @@
<script type="text/javascript" src="extjs/bootstrap.js"></script>
<script type="text/javascript" src="extjs/ext-all.js"></script>
+
+ <!-- Note that the files here are not minified to make debugging easier -->
+ <script type="text/javascript" src="js/PartKeeprSetup.js"></script>
+
+ <script type="text/javascript" src="js/TestResultPanel.js"></script>
+ <script type="text/javascript" src="js/TestRunner.js"></script>
+
+ <script type="text/javascript" src="js/SetupTests/BaseSetupTest.js"></script>
+ <script type="text/javascript" src="js/SetupTests/PHPTest.js"></script>
+ <script type="text/javascript" src="js/SetupTests/PHPPrequisitesTest.js"></script>
+ <script type="text/javascript" src="js/SetupTests/DoctrineTest.js"></script>
</head>
<body>
</body>
diff --git a/src/setup/js/PartKeeprSetup.js b/src/setup/js/PartKeeprSetup.js
@@ -2,8 +2,38 @@ Ext.application({
name: 'PartKeepr',
launch: function() {
+ this.createLayout();
+
+ var tests = new Array();
+
+
+ var j = Ext.create("PartKeeprSetup.PHPTest");
+ j.callback = this.testResultPanel;
+ tests.push(j);
+
+ var j = Ext.create("PartKeeprSetup.PHPPrequisitesTest");
+ j.callback = this.testResultPanel;
+ tests.push(j);
+
+ var j = Ext.create("PartKeeprSetup.DoctrineTest");
+ j.callback = this.testResultPanel;
+ tests.push(j);
+
+ var tr = Ext.create("PartKeeprSetup.TestRunner");
+ tr.run(tests);
+
+ //j.on("complete", function () { this.testResultPanel.appendTestResult(this); }, j);
},
- testInstaller: function () {
+ /**
+ * Creates the main viewport
+ */
+ createLayout: function () {
+ this.testResultPanel = Ext.create("PartKeeprSetup.TestResultPanel");
+ Ext.create('Ext.container.Viewport', {
+ layout: 'fit',
+ items: [this.testResultPanel]
+
+ });
}
});
\ No newline at end of file
diff --git a/src/setup/js/SetupTests/BaseSetupTest.js b/src/setup/js/SetupTests/BaseSetupTest.js
@@ -0,0 +1,47 @@
+Ext.define('PartKeeprSetup.BaseSetupTest', {
+ extend: 'Ext.util.Observable',
+
+ /**
+ * Defines the URL to call
+ */
+ url: 'check.php',
+
+ /**
+ * Defines if the call was successful or not.
+ */
+ success: false,
+ callback: null,
+ name: null,
+
+ constructor: function () {
+ this.addEvents({
+ "complete" : true
+ });
+ },
+ /**
+ * Runs a given test, and processes the response
+ */
+ run: function () {
+ Ext.Ajax.request({
+ url: this.url,
+ success: this.onSuccess,
+ scope: this
+ });
+ },
+
+ onSuccess: function (response) {
+ var obj = Ext.decode(response.responseText);
+
+ if (obj.error == false) {
+ this.success = true;
+ } else {
+ this.success = false;
+ this.errorMessage = obj.errormessage;
+ }
+
+ if (this.callback) {
+ this.callback.appendTestResult(this);
+ }
+ this.fireEvent("complete");
+ }
+});+
\ No newline at end of file
diff --git a/src/setup/js/SetupTests/DoctrineTest.js b/src/setup/js/SetupTests/DoctrineTest.js
@@ -0,0 +1,9 @@
+/**
+ * A minimalistic PHP check to make sure PHP is installed on the server and activated as PHP module.
+ */
+Ext.define('PartKeeprSetup.DoctrineTest', {
+ extend: 'PartKeeprSetup.BaseSetupTest',
+ url: 'tests/check-doctrine.php',
+ name: "PHP",
+ message: "Testing for Doctrine ORM"
+});+
\ No newline at end of file
diff --git a/src/setup/js/SetupTests/PHPPrequisitesTest.js b/src/setup/js/SetupTests/PHPPrequisitesTest.js
@@ -0,0 +1,9 @@
+/**
+ * A minimalistic PHP check to make sure PHP is installed on the server and activated as PHP module.
+ */
+Ext.define('PartKeeprSetup.PHPPrequisitesTest', {
+ extend: 'PartKeeprSetup.BaseSetupTest',
+ url: 'check-php-prequisites.php',
+ name: "PHP",
+ message: "Testing for PHP prequisites"
+});+
\ No newline at end of file
diff --git a/src/setup/js/SetupTests/PHPTest.js b/src/setup/js/SetupTests/PHPTest.js
@@ -0,0 +1,9 @@
+/**
+ * A minimalistic PHP check to make sure PHP is installed on the server and activated as PHP module.
+ */
+Ext.define('PartKeeprSetup.PHPTest', {
+ extend: 'PartKeeprSetup.BaseSetupTest',
+ url: 'check-php.php',
+ name: "PHP",
+ message: "Testing for PHP"
+});+
\ No newline at end of file
diff --git a/src/setup/js/TestResultPanel.js b/src/setup/js/TestResultPanel.js
@@ -0,0 +1,17 @@
+Ext.define('PartKeeprSetup.TestResultPanel', {
+ extend: 'Ext.panel.Panel',
+
+ appendTestResult: function (test) {
+ var response;
+
+ if (test.success) {
+ response = "OK";
+ } else {
+ response = "Error. "+test.errorMessage
+ }
+
+ this.add({
+ html: test.message +"..."+response
+ });
+ }
+});+
\ No newline at end of file
diff --git a/src/setup/js/TestRunner.js b/src/setup/js/TestRunner.js
@@ -0,0 +1,15 @@
+Ext.define('PartKeeprSetup.TestRunner', {
+ extend: 'Ext.util.Observable',
+
+ run: function (tests) {
+ test = tests.shift();
+
+ if (!test) {
+ return;
+ }
+
+ test.on("complete", function () { this.run(tests); }, this);
+ test.run();
+
+ }
+});+
\ No newline at end of file
diff --git a/src/setup/tests/check-database-connectivity.php b/src/setup/tests/check-database-connectivity.php
diff --git a/src/setup/tests/check-doctrine.php b/src/setup/tests/check-doctrine.php
@@ -0,0 +1,10 @@
+<?php
+@include_once 'Doctrine/Common/ClassLoader.php';
+
+if (!class_exists("\\Doctrine\\Common\ClassLoader")) {
+ echo json_encode(array("error" => true, "errormessage" => "Doctrine needs to be installed and in the PHP include_path. You can install doctrine on most unix systems using 'pear channel-discover pear.doctrine-project.org && pear install pear.doctrine-project.org/DoctrineORM'"));
+ exit;
+}
+
+echo json_encode(array("error" => false));
+exit;