* @copyright Copyright (c) 2010, The volkszaehler.org project
@@ -23,84 +25,72 @@
* along with volkszaehler.org. If not, see .
*/
-{
- "properties" : [
- /*{
- "name" : "", // discriminator for database column
- "type" : "", // one of: string, numeric, multiple
- "pattern" : "", // regex pattern to match if type == string
- "min" : 0, // minimal value if type == numeric
- // required string length if type == string
- "max" : 100, // maximal value if type == numeric
- // allowed string length if type == string
- "choices" : ["", "", ""] // list of possible choices if type == multiple
- // (type as in javascript: 1.2 => numeric, "test" => string)
- },*/
- {
- "name" : "name",
- "type" : "string",
- "pattern" : "/[a-z0-9 ]/",
- "max" : 255,
- },
- {
- "name" : "description",
- "type" : "string",
- "pattern" : "/[a-z0-9 ]/", // TODO add whitespaces as \t \n \r
- "max" : 255, // TODO allowed column size in database?
- },
- {
- "name" : "cost",
- "type" : "numeric",
- "min" : 0,
- },
- {
- "name" : "resolution",
- "type" : "numeric",
- "min" : 1,
- },
- {
- "name" : "tolerance",
- "type" : "numeric",
- "min" : 0,
- "max" : 1
- },
- {
- "name" : "address:lat",
- "type" : "numeric",
- "min" : -90,
- "max" : 90
- },
- {
- "name" : "address:lon",
- "type" : "numeric",
- "min" : -90,
- "max" : 90
- },
- {
- "name" : "address:city",
- "type" : "string",
- "pattern" : "" // TODO add pattern
- },
- {
- "name" : "address:houseno",
- "type" : "string"
- },
- {
- "name" : "address:postal",
- "type" : "string"
- },
- {
- "name" : "address:state",
- "type" : "string"
- },
- {
- "name" : "address:country",
- "type" : "string"
- },
- {
- "name" : "photo:url",
- "type" : "string",
- "pattern" : "" // TODO add pattern
- },
- ]
-}
\ No newline at end of file
+[
+ {
+ "name" : "name",
+ "type" : "string",
+ "pattern" : "/[a-z0-9 ]/",
+ "min": 3,
+ "max" : 255
+ },
+ {
+ "name" : "description",
+ "type" : "string",
+ "pattern" : "/[a-z0-9 ]/", // TODO add whitespaces as \t \n \r
+ "max" : 255 // TODO allowed column size in database?
+ },
+ {
+ "name" : "cost",
+ "type" : "numeric",
+ "min" : 0
+ },
+ {
+ "name" : "resolution",
+ "type" : "numeric",
+ "min" : 1
+ },
+ {
+ "name" : "tolerance",
+ "type" : "numeric",
+ "min" : 0,
+ "max" : 1
+ },
+ {
+ "name" : "address:lat",
+ "type" : "numeric",
+ "min" : -90,
+ "max" : 90
+ },
+ {
+ "name" : "address:lon",
+ "type" : "numeric",
+ "min" : -90,
+ "max" : 90
+ },
+ {
+ "name" : "address:city",
+ "type" : "string",
+ "pattern" : "" // TODO add pattern
+ },
+ {
+ "name" : "address:houseno",
+ "type" : "string"
+ },
+ {
+ "name" : "address:postal",
+ "type" : "string"
+ },
+ {
+ "name" : "address:state",
+ "type" : "string"
+ },
+ {
+ "name" : "address:country",
+ "type" : "string"
+ },
+ {
+ "name" : "photo:url",
+ "type" : "string",
+ "pattern" : "" // TODO add pattern
+ }
+]
diff --git a/share/tests/json.php b/share/tests/json.php
new file mode 100644
index 0000000..47396bd
--- /dev/null
+++ b/share/tests/json.php
@@ -0,0 +1,62 @@
+
+ */
+/*
+ * This file is part of volkzaehler.org
+ *
+ * volkzaehler.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * volkzaehler.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with volkszaehler.org. If not, see .
+ */
+
+use Volkszaehler\Util;
+include '../../backend/lib/Util/JSON.php';
+echo '';
+
+$data = '{
+ "glossary": {
+ "title": "example glossary",
+ "GlossDiv": {
+ "title": "S",
+ "GlossList": {
+ "GlossEntry": {
+ "ID": "SGML",
+ "SortAs": "SGML",
+ "GlossTerm": "Standard Generalized Markup Language",
+ "Acronym": "SGML",
+ "Abbrev": "ISO 8879:1986",
+ "GlossDef": {
+ "para": "A meta-markup language, used to create markup languages such as DocBook.",
+ "GlossSeeAlso": ["GML", "XML"]
+ },
+ "GlossSee": "markup"
+ }
+ }
+ }
+ }
+}';
+
+$json = Util\JSON::decode($data);
+
+$json['test'] = 2;
+
+echo $json->encode(JSON_PRETTY);
+
+
+echo '
';
+?>
\ No newline at end of file
diff --git a/share/tests/properties.php b/share/tests/properties.php
new file mode 100644
index 0000000..5d0d7b1
--- /dev/null
+++ b/share/tests/properties.php
@@ -0,0 +1,41 @@
+
+ */
+/*
+ * This file is part of volkzaehler.org
+ *
+ * volkzaehler.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * volkzaehler.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with volkszaehler.org. If not, see .
+ */
+
+use Volkszaehler\Util;
+use Volkszaehler\Model;
+
+define('VZ_DIR', '/home/steffen/workspace/volkszaehler.org'); // TODO realpath(__DIR__)
+
+include '../../backend/lib/Util/JSONDefinition.php';
+include '../../backend/lib/Model/Property.php';
+include '../../backend/lib/Util/JSON.php';
+
+echo '';
+
+new Model\Property('name', '1as2');
+
+echo '
';
+?>
\ No newline at end of file