summaryrefslogblamecommitdiff
path: root/lib/list/inc_process.php
blob: d4656b549f79255c0ec5ffeaa6b107fd70ac8f31 (plain) (tree)



























                                                                                                 
<?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);
}