commit 8859a839942f8e3807a0dcbd59d93fa6bc83ee94
parent 3a8e8256ac1a3fc068e32ef2c1ef6a5335518584
Author: Felicitus <felicitus@felicitus.org>
Date: Sun, 25 Dec 2011 07:41:17 +0100
Added automatic config writing support and a default error catching mechanism
Diffstat:
8 files changed, 99 insertions(+), 9 deletions(-)
diff --git a/build.xml b/build.xml
@@ -138,11 +138,27 @@
<phingcall target="build-setup"/>
</target>
-
+
+ <!--
+ Creates a new PartKeepr release.
+
+ This task asks for the target version number, and then generates the zip and tbz2 archives out of it.
+ -->
<target name="release">
+ <propertyprompt propertyName="partkeepr.version" defaultValue=""
+ promptText="Please enter the version number of the build to generate (e.g. 0.1)" />
+ <phingcall target="prepare-archiving"/>
+ <phingcall target="set-version"/>
+
+ <zip destfile="partkeepr-${partkeepr.version}.zip" basedir="${packagepath}" prefix="partkeepr-${partkeepr.version}"/>
+ <tar destfile="partkeepr-${partkeepr.version}.tbz2" compression="bzip2" basedir="${packagepath}" prefix="partkeepr-${partkeepr.version}"/>
</target>
+ <!--
+ Runs the build process, then copies the current working tree to a temporary directory (specified by ${packagepath})
+ while excluding stuff the end-user doesn't need (like .git directories, and some 3rdparty stuff).
+ -->
<target name="prepare-archiving">
<phingcall target="build"/>
@@ -206,10 +222,14 @@
<delete dir="${packagepath}/frontend/resources/fugue-icons/icons-shadowless/"/>
</target>
+ <!--
+ Sets the version of the release inside PartKeeprVersion.php
+ -->
<target name="set-version">
<exec executable="sed">
- <arg value="s/{V_GIT}/${partkeepr.version}/g" />
- <arg value="${packagepath}/src/backend/de/RaumZeitLabor/PartKeepr/PartKeeprVersion.php" />
+ <arg value="-i" />
+ <arg value="s/{V_GIT}/${partkeepr.version}/g" />
+ <arg value="${packagepath}/src/backend/de/RaumZeitLabor/PartKeepr/PartKeeprVersion.php" />
</exec>
</target>
@@ -226,7 +246,7 @@
<zip destfile="${build.time}.zip" basedir="${packagepath}" prefix="partkeepr-nightly"/>
<tar destfile="${build.time}.tbz2" compression="bzip2" basedir="${packagepath}" prefix="partkeepr-nightly"/>
</target>
-
+
<!-- Builds the jsb3 file and build the minified JS files -->
<target name="jsbuilder">
<exec command="php util/gen-jsb3-file.php ./src/frontend/ ${extjs.path}"/>
diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Setup/ConfigFileSetup.php b/src/backend/de/RaumZeitLabor/PartKeepr/Setup/ConfigFileSetup.php
@@ -0,0 +1,26 @@
+<?php
+namespace de\RaumZeitLabor\PartKeepr\Setup;
+
+use de\RaumZeitLabor\PartKeepr\Util\Configuration,
+ de\RaumZeitLabor\PartKeepr\PartKeepr;
+
+/**
+ * Creates a new config file
+ */
+class ConfigFileSetup extends AbstractSetup {
+ public function run () {
+ $configFile = PartKeepr::getRootDirectory()."/config.php";
+ if (file_exists($configFile)) {
+ if (!is_writable($configFile)) {
+ echo json_encode(array("error" => true, "errormessage" => "The config.php file could not be written, because it already exists and the webserver has no write access to it."));
+ exit;
+ }
+ } else {
+ if (!is_writable(PartKeepr::getRootDirectory())) {
+ echo json_encode(array("error" => true, "errormessage" => "The config.php file could not be written, because the webserver has no write access to it."));
+ exit;
+ }
+ }
+ file_put_contents($configFile, Configuration::dumpConfig());
+ }
+}+
\ No newline at end of file
diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Setup/Setup.php b/src/backend/de/RaumZeitLabor/PartKeepr/Setup/Setup.php
@@ -52,7 +52,8 @@ class Setup {
"siprefix" => new SiPrefixSetup($entityManager),
"unit" => new UnitSetup($entityManager),
"manufacturer" => new ManufacturerSetup($entityManager),
- "schemamigration" => new SchemaMigrationSetup($entityManager)
+ "schemamigration" => new SchemaMigrationSetup($entityManager),
+ "configfile" => new ConfigFileSetup($entityManager)
);
if ($step == "all") {
diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Util/Configuration.php b/src/backend/de/RaumZeitLabor/PartKeepr/Util/Configuration.php
@@ -39,5 +39,26 @@ class Configuration {
}
return Configuration::$options[$option];
}
+
+ /**
+ * Returns a configuration file, based on all configurations.
+ *
+ * @param none
+ * @return string A complete configuration file including namespace and use directives
+ */
+ public static function dumpConfig () {
+ $config = <<<EOD
+<?php
+namespace de\RaumZeitLabor\PartKeepr;
+use de\RaumZeitLabor\PartKeepr\Util\Configuration;
+
+
+EOD;
+ foreach (Configuration::$options as $option => $value) {
+ $config .= 'Configuration::setOption("'.$option.'", "'.$value.'");'."\n";
+ }
+
+ return $config;
+ }
}
?>
\ No newline at end of file
diff --git a/src/setup/index.html b/src/setup/index.html
@@ -56,6 +56,7 @@
<script type="text/javascript" src="js/SetupSteps/UnitSetup.js"></script>
<script type="text/javascript" src="js/SetupSteps/FootprintSetup.js"></script>
<script type="text/javascript" src="js/SetupSteps/SchemaMigrationSetup.js"></script>
+ <script type="text/javascript" src="js/SetupSteps/ConfigFileSetup.js"></script>
<script type="text/javascript" src="js/PartKeeprSetup.js"></script>
</head>
diff --git a/src/setup/js/Cards/DatabaseSetupCard.js b/src/setup/js/Cards/DatabaseSetupCard.js
@@ -22,5 +22,6 @@ Ext.define('PartKeeprSetup.DatabaseSetupCard', {
this.tests.push(new PartKeeprSetup.UnitSetup());
this.tests.push(new PartKeeprSetup.ManufacturerSetup());
this.tests.push(new PartKeeprSetup.SchemaMigrationSetup());
+ this.tests.push(new PartKeeprSetup.ConfigFileSetup());
}
});
diff --git a/src/setup/js/SetupSteps/ConfigFileSetup.js b/src/setup/js/SetupSteps/ConfigFileSetup.js
@@ -0,0 +1,14 @@
+/**
+ * Sets up the default units
+ */
+Ext.define('PartKeeprSetup.ConfigFileSetup', {
+ extend: 'PartKeeprSetup.AbstractTest',
+ url: 'setup.php',
+ name: "Database",
+ message: "Creating the configuration file",
+
+ onBeforeRunTest: function () {
+ this.params = Ext.getCmp("database-parameters-card").dbparams;
+ this.params.step = "configfile";
+ }
+});+
\ No newline at end of file
diff --git a/src/setup/setup.php b/src/setup/setup.php
@@ -6,7 +6,12 @@ declare(encoding = 'UTF-8');
use de\RaumZeitLabor\PartKeepr\PartKeepr,
de\RaumZeitLabor\PartKeepr\Setup\Setup;
-declare(encoding = 'UTF-8');
+/*function exception_error_handler($errno, $errstr, $errfile, $errline ) {
+ throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
+}
+set_error_handler("errorHandler", E_ALL);*/
+set_error_handler(create_function('$a, $b, $c, $d', 'throw new ErrorException($b, 0, $a, $c, $d);'), E_ALL);
+
include("../src/backend/de/RaumZeitLabor/PartKeepr/PartKeepr.php");
PartKeepr::initializeClassLoaders();
@@ -26,6 +31,6 @@ try {
$setup->runStep($_REQUEST["step"]);
echo json_encode(array("error" => false));
} catch (\Exception $e) {
- echo json_encode(array("error" => true, "errormessage" => "An unexpected error occured during installation. The error message was:<br/><code>".$e->getMessage()."</code>"));
+ echo json_encode(array("error" => true, "errormessage" => "An unexpected error occured during installation. The error message was:<br/><code>".$e->getMessage()."</code> and happened in <code>".$e->getFile().":".$e->getLine() ));
exit;
-}-
\ No newline at end of file
+}