function do_jsonld($tema_id) { global $CFG; $ARRAYjson_relations = array("skos:narrower" => array(), "skos:broader" => array(), "skos:altLabel" => array(), "skos:hiddenLabel" => array(), "skos:related" => array()); $_URI_BASE_ID = $CFG["_URI_BASE_ID"] ? $CFG["_URI_BASE_ID"] : $_SESSION["CFGURL"]; /* Tomar URL por default * Para que utilice URLs navegables: * $_URI_SEPARATOR_ID = ($CFG["_URI_SEPARATOR_ID"]) ? $CFG["_URI_SEPARATOR_ID"] : '?tema='; * Para que utilice URLs Skos core */ $_URI_SEPARATOR_ID = $CFG["_URI_SEPARATOR_ID"] ? $CFG["_URI_SEPARATOR_ID"] : 'xml.php?skosTema='; $datosTermino = ARRAYverDatosTermino($tema_id); if (!is_numeric($datosTermino["tema_id"])) { return null; } $SQLTerminosE = SQLverTerminosE($tema_id); while ($datosTerminosE = $SQLTerminosE->FetchRow()) { array_push($ARRAYjson_relations["skos:narrower"], $_URI_BASE_ID . $_URI_SEPARATOR_ID . $datosTerminosE[id_tema]); } $SQLterminosRelacionados = SQLverTerminoRelaciones($tema_id); while ($datosTerminosRelacionados = $SQLterminosRelacionados->FetchRow()) { if ($datosTerminosRelacionados[t_relacion] == '2') { // TR array_push($ARRAYjson_relations["skos:related"], $_URI_BASE_ID . $_URI_SEPARATOR_ID . $datosTerminosRelacionados[tema_id]); } if ($datosTerminosRelacionados[t_relacion] == '3') { // TG array_push($ARRAYjson_relations["skos:broader"], $_URI_BASE_ID . $_URI_SEPARATOR_ID . $datosTerminosRelacionados[tema_id]); } if ($datosTerminosRelacionados[t_relacion] == '4') { // UF //HiddenLabel if (in_array($datosTerminosRelacionados[rr_code], $CFG["HIDDEN_EQ"])) { array_push($ARRAYjson_relations["skos:hiddenLabel"], array("language" => $_SESSION["CFGIdioma"], "value" => $datosTerminosRelacionados[tema])); } else { array_push($ARRAYjson_relations["skos:altLabel"], array("language" => $_SESSION["CFGIdioma"], "value" => $datosTerminosRelacionados[tema])); } } } $SQLtargetTerms = SQLtargetTerms($tema_id); $ARRAYjson_map = array(); while ($datosTargetTerms = $SQLtargetTerms->FetchRow()) { $map_label = in_array(strtolower($datosTargetTerms[tvocab_tag]), array('exact', 'close', 'related', 'partial', 'broad', 'narrow')) ? strtolower($datosTargetTerms[tvocab_tag]) : 'exact'; $skos_tag = 'skos:' . $map_label . 'Match'; $ARRAYjson_map["{$skos_tag}"][] = array("@id" => $datosTargetTerms[tterm_url], "@type" => "skos:Concept", "skos:prefLabel" => array("@language" => $datosTargetTerms[tvocab_lang], "@value=" => $datosTargetTerms[tterm_string])); } $SQLURI2term = SQLURIxterm($tema_id); $ARRAYjson_URI = array(); while ($datosURI2term = $SQLURI2term->FetchRow()) { if (in_array(strtolower($datosURI2term[uri_code]), array('exactmatch', 'closematch', 'relatedmatch', 'partialmatch', 'broadmatch', 'narrowmatch'))) { $ARRAYjson_URI["{$datosURI2term['uri_code']}"][] = array("@id" => $datosURI2term[uri], "@type" => "skos:Concept"); } } $ARRAYjson_notes = array(); for ($iNota = 0; $iNota < count($datosTermino[notas]); ++$iNota) { if ($datosTermino[notas][$iNota][id]) { switch ($datosTermino[notas][$iNota][tipoNota]) { case 'NH': $ARRAYjson_notes["skos:historyNote"][] = array("@lang" => $datosTermino[notas][$iNota][lang_nota], "@value" => html2txt($datosTermino[notas][$iNota][nota])); break; case 'NA': $ARRAYjson_notes["skos:scopeNote"][] = array("@lang" => $datosTermino[notas][$iNota][lang_nota], "@value" => html2txt($datosTermino[notas][$iNota][nota])); break; case 'DF': $ARRAYjson_notes["skos:definition"][] = array("@lang" => $datosTermino[notas][$iNota][lang_nota], "@value" => html2txt($datosTermino[notas][$iNota][nota])); break; case 'ED': $ARRAYjson_notes["skos:editorialNote"][] = array("@lang" => $datosTermino[notas][$iNota][lang_nota], "@value" => html2txt($datosTermino[notas][$iNota][nota])); break; case 'EX': $ARRAYjson_notes["skos:example"][] = array("@lang" => $datosTermino[notas][$iNota][lang_nota], "@value" => html2txt($datosTermino[notas][$iNota][nota])); break; case 'CH': $ARRAYjson_notes["skos:changeNote"][] = array("@lang" => $datosTermino[notas][$iNota][lang_nota], "@value" => html2txt($datosTermino[notas][$iNota][nota])); break; case 'NB': $ARRAYjson_notes["skos:note"][] = array("@lang" => $datosTermino[notas][$iNota][lang_nota], "@value" => html2txt($datosTermino[notas][$iNota][nota])); break; } } } $ARRAY_json = array("@context" => array("dc" => "http://purl.org/dc/elements/1.1/", "skos" => "http://www.w3.org/2004/02/skos/core#", "skos:broader" => array("@type" => "@id"), "skos:inScheme" => array("@type" => "@id"), "skos:related" => array("@type" => "@id"), "skos:narrower" => array("@type" => "@id"), "skos:hasTopConcept" => array("@type" => "@id"), "skos:topConceptOf" => array("@type" => "@id")), "@id" => $_URI_BASE_ID . $_URI_SEPARATOR_ID . $datosTermino[idTema], "@type" => "skos:Concept", "skos:prefLabel" => array("@language" => $_SESSION["CFGIdioma"], "@value=" => xmlentities($datosTermino[titTema])), "skos:inScheme" => $_URI_BASE_ID, "dct:created" => $datosTermino[cuando]); if ($datosTermino[cuando_final]) { $ARRAY_json = array_merge($ARRAY_json, array("dct:modified" => $datosTermino[cuando_final])); } //Use or not term code / notation tag in Skos if ($CFG["_USE_CODE"] == '1' && strlen($datosTermino[code]) > 0) { $ARRAY_json = array_merge($ARRAY_json, array("skos:notation" => $datosTermino[code])); } //Unset empty array if (count($ARRAYjson_relations["skos:related"]) == 0) { unset($ARRAYjson_relations["skos:related"]); } if (count($ARRAYjson_relations["skos:broader"]) == 0) { unset($ARRAYjson_relations["skos:broader"]); } if (count($ARRAYjson_relations["skos:narrower"]) == 0) { unset($ARRAYjson_relations["skos:narrower"]); } if (count($ARRAYjson_relations["skos:altLabel"]) == 0) { unset($ARRAYjson_relations["skos:altLabel"]); } if (count($ARRAYjson_relations["skos:hiddenLabel"]) == 0) { unset($ARRAYjson_relations["skos:hiddenLabel"]); } return json_encode(array_merge($ARRAY_json, $ARRAYjson_notes, $ARRAYjson_relations, $ARRAYjson_map, $ARRAYjson_URI)); }
function fetchURI($tema_id) { $sql = SQLURIxterm($tema_id); while ($array = $sql->FetchRow()) { $result["result"][$array["tema_id"]] = array("link_type" => $array["uri_value"], "link" => $array["uri"]); } return $result; }
function HTMLURI4term($tema_id) { $sql = SQLURIxterm($tema_id); if (SQLcount($sql) > 0) { $rows = '<ul class="list-unstyled">'; while ($array = $sql->FetchRow()) { if ($_SESSION[$_SESSION["CFGURL"]]["ssuser_id"]) { $delLink = '<a type="button" class="btn btn-danger btn-xs" id="elimina_' . $array["uri_id"] . '" title="' . LABEL_borraRelacion . '" href="index.php?uri_id=' . $array[uri_id] . '&tema=' . $tema_id . '&taskrelations=delURIterm" onclick="return askData();"><span class="glyphicon glyphicon-remove"></span></a> '; } $rows .= '<li>' . $delLink . ' ' . ucfirst($array["uri_value"]) . ' <a href="' . $array["uri"] . '" target="_blank" title="' . ucfirst($array[uri_value]) . '">' . $array["uri"] . '</a>'; $rows .= '</li>'; } $rows .= '</ul>'; } return $rows; }