diff --git a/backend/lib/Util/JSON.php b/backend/lib/Util/JSON.php index da287dd..38703ac 100644 --- a/backend/lib/Util/JSON.php +++ b/backend/lib/Util/JSON.php @@ -75,12 +75,12 @@ class JSON extends \ArrayObject { } /** - * Formats json with indents and new lines + * Formats JSON with indents and new lines * * @param string $json * @param string $indent * @param string $newLine - * @return string the formatted json + * @return string the formatted JSON */ protected static function format($json, $indent = "\t", $newLine = "\n") { $formatted = ''; diff --git a/backend/lib/View/JSON.php b/backend/lib/View/JSON.php index 47fc786..4d34745 100644 --- a/backend/lib/View/JSON.php +++ b/backend/lib/View/JSON.php @@ -34,24 +34,29 @@ use Volkszaehler\Model; * @author Steffen Vogel */ class JSON extends View { + /** + * @var array holds the JSON data in an array + */ protected $json; + /** + * @var string padding function name or NULL if disabled + */ protected $padding = FALSE; /** * constructor */ - public function __construct(HTTP\Request $request, HTTP\Response $response) { + public function __construct(HTTP\Request $request, HTTP\Response $response, $padding = FALSE) { parent::__construct($request, $response); $this->json = new Util\JSON(); - $this->json['source'] = 'volkszaehler.org'; $this->json['version'] = VZ_VERSION; - $this->response->setHeader('Content-type', 'application/json'); + $this->setPadding($padding); - $this->padding = $this->request->getParameter('padding'); + $this->response->setHeader('Content-type', 'application/json'); } public function addChannel(Model\Channel $channel, array $data = NULL) { diff --git a/share/properties.json b/share/properties.json index 3992ca2..8bdcb0c 100644 --- a/share/properties.json +++ b/share/properties.json @@ -283,5 +283,19 @@ "name" : "photo:url", "type" : "string", "pattern" : "" // TODO add pattern + }, + { + "name" : "cuuid", + "type" : "string", + "max" : 37 + }, + { + "name" : "port", + "type" : "string", + "max" : 6 + }, + { + "name" : "active", + "type" : "boolean" } ] diff --git a/share/tests/ajax.php b/share/tests/ajax.php index c077f12..884cad7 100644 --- a/share/tests/ajax.php +++ b/share/tests/ajax.php @@ -1,6 +1,6 @@