summaryrefslogtreecommitdiff
path: root/lib/list/inc_process.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/list/inc_process.php')
-rw-r--r--lib/list/inc_process.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/list/inc_process.php b/lib/list/inc_process.php
new file mode 100644
index 0000000..d4656b5
--- /dev/null
+++ b/lib/list/inc_process.php
@@ -0,0 +1,28 @@
+<?php
+
+require("lib/JSON/inc_json.php");
+
+function mk_batch_json($models, $contents) {
+ $data = array("columns" => array(), "items" => array());
+
+ $columns = explode('|', $models);
+ foreach ($columns as $c) {
+ if ($c[0] == '!') {
+ $data['columns'][] = array("question" => false, "name" => substr($c, 1));
+ } else {
+ $data['columns'][] = array("question" => true, "name" => $c);
+ }
+ }
+
+ $items = explode("\n", $contents);
+ foreach($items as $i) {
+ $ii = explode('|', str_replace("\r", '', $i));
+ if (count($ii) == count($columns)) {
+ $data['items'][] = $ii;
+ }
+ }
+
+ return json_encode($data);
+}
+
+