public static function validateDataEditFilter($editor, $text, $section, &$error, $summary) { // I can't remember if jsondataobj needs to be a singleton/global, but // will chance calling a new instance here. $title = $editor->getTitle(); $ns = $title->getNamespace(); if (!JsonData::isJsonDataNeeded($ns)) { return true; } $jsondataobj = new JsonData($title); $json = JsonData::stripOuterTagsFromText($text); try { $schematext = $jsondataobj->getSchemaText(); } catch (JsonDataException $e) { $schematext = $jsondataobj->readJsonFromPredefined('openschema'); $error = "<b>" . wfMessage('jsondata-servervalidationerror') . "</b>: "; $error .= wfMessage('jsondata-invalidjson'); } $data = json_decode($json, true); if (is_null($data)) { $error = "<b>" . wfMessage('jsondata-servervalidationerror') . "</b>: "; $error .= wfMessage('jsondata-invalidjson'); return true; } $schema = json_decode($schematext, true); $rootjson = new JsonTreeRef($data); $rootjson->attachSchema($schema); try { $rootjson->validate(); } catch (JsonSchemaException $e) { $error = "<b>" . wfMessage('jsondata-servervalidationerror') . "</b>: "; $error .= htmlspecialchars($e->getMessage()); } return true; }
/** * 返回信息 */ public function sendResponse($status = 200, $body = '', $content_type = 'text/html') { // set the status $status_header = 'HTTP/1.1 ' . $status . ' ' . $this->getStatusCodeMessage($status); header($status_header); // and the content type header('Content-type: ' . $content_type); header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Credentials: true'); // send the body $ret = new JsonData(); $ret->autoFalse($body); echo CJSON::encode($ret); Yii::app()->end(); }
function getData($id) { $row = $this->database->getPageType($id); $json = new JsonData(); if ($id != 'viewcustomer') { $fields = $this->database->getData($id); $jsonA = $json->getData($fields); } else { $table = $this->database->getDataRecord($id); $fields = $this->database->getDataFields($table[0]); $jsonA = $json->getDataSelect($this->database, $table[0], $fields); } return $jsonA; }
function getData($id) { $json = new JsonData(); $table = $this->database->getDataRecord($id); $fields = $this->database->getFieldsPage($id); $ifcampos = false; if (is_array($fields)) { $ifcampos = true; } if ($table[0] == '') { $parametros = false; if ($ifcampos) { foreach ($fields as $field) { if (isset($_GET['accion'])) { if ($_GET['accion'] == 'b' or $_GET['accion'] == 's') { if (isset($_GET[$field[0]])) { $parametros = true; break; } } else { if (isset($_GET['_1_' . $field[0]])) { $parametros = true; break; } } } } } if ($parametros) { $fieldsData = array(); $where = "Where "; $i = 1; $tabla = ''; $j = 1; if (isset($_GET['accion'])) { if ($_GET['accion'] == 'b') { foreach ($fields as $field) { $key = $field[2]; $tabla = $field[1]; if ($tabla == '' or $tabla == $field[1]) { if ($key == 'Y') { if (isset($_GET[$field[0]])) { if ($_GET[$field[0]] != '') { $value = $this->database->getDataChange($field[0], $_GET[$field[0]]); if ($value[0] == '') { $value[0] = $_GET[$field[0]]; } $crypted = $this->database->ifCrypted($field[1], $field[0]); if ($crypted[0] == 'Y') { $value[0] = base64_decode($value[0]) / 444; } if ($i == 1) { $where = $where . $field[0] . "='" . $value[0] . "' "; } else { $where = $where . " AND " . $field[0] . "='" . $value[0] . "' "; } $fieldsData[$field[0]] = $value[0]; $fieldsData[$field[0] . 'X'] = $value[0]; } } $i++; } else { $value = $this->database->getDatavalueW($field[1], $field[0], $where); $type = $this->database->getTypes($field[1], $field[0]); $fieldsData[$field[0]] = $value[0]; } } else { $tabla = $field[1]; } } } else { if ($_GET['accion'] == 's') { if (isset($_GET[$field[0]])) { if ($_GET[$field[0]] != '') { $type = $this->database->getTypes($field[1], $field[0]); if ($type[0] == 'number') { if (!is_numeric($_GET[$field[0]])) { $_GET[$field[0]] = 0; } } $fieldsData[$field[0]] = $_GET[$field[0]]; $fieldxs = $this->database->getPromptSelect($id, $field[0], $_GET[$field[0]]); foreach ($fieldxs as $fieldx) { $value = $this->database->executeQueryOneRow($fieldx[1]); $fieldsData[$fieldx[0]] = $value[0]; } } } } } } if ($_GET['accion'] != 'bd') { $jsonA = $json->getData2($fieldsData); } } else { $fields = $this->database->getData($id); $jsonA = $json->getData($fields); } } else { if ($ifcampos) { $jsonA = $json->getDataSelect($this->database, $table[0], $fields); } else { $jsonA = ''; } } return $jsonA; }
public function getJsonRef() { if (is_null($this->jsonref)) { $json = JsonData::stripOuterTagsFromText($this->getEditorText()); $schematext = $this->getSchemaText(); $data = json_decode($json, true); $schema = json_decode($schematext, true); $this->jsonref = new JsonTreeRef($data); $this->jsonref->attachSchema($schema); } return $this->jsonref; }