function HTMLtargetTerms($tema_id) { $sql = SQLtargetTerms($tema_id); if ($sql[cant]) { $rows = '<ul>'; while ($array = mysqli_fetch_array($sql[datos])) { $del = $_SESSION[$_SESSION["CFGURL"]][ssuser_id] ? '[<a id="elimina_' . $array[tterm_id] . '" title="' . LABEL_borraRelacion . '" class="eliminar" href="' . $PHP_SELF . '?tterm_id=' . $array[tterm_id] . '&tema=' . $tema_id . '&tvocab_id=' . $array[tvocab_id] . '&taskrelations=delTgetTerm" onclick="return askData();"><acronym title="' . LABEL_borraRelacion . '" lang="' . LANG . '">x</acronym></a>]' : ''; $rows .= '<li>' . $del . ' ' . FixEncoding(ucfirst($array[tvocab_label])) . ' <a href="' . $array[tterm_url] . '" title="' . FixEncoding($array[tterm_string]) . '">' . FixEncoding($array[tterm_string]) . '</a></li>'; } $rows .= '</ul>'; } return $rows; }
function fetchTargetTermsById($tema_id) { $sql = SQLtargetTerms($tema_id); while ($array = $sql->FetchRow()) { $result["result"][$array[tterm_id]] = array("string" => $array[tterm_string], "url" => $array[tterm_url], "uri" => $array[tterm_uri], "term_id" => $array[tema_id], "target_vocabulary_label" => $array[tvocab_label], "target_vocabulary_tag" => $array[tvocab_tag], "target_vocabulary_title" => $array[tvocab_title]); } return $result; }
function ARRAYtargetTerm($tema_id, $tterm_id) { global $DBCFG; $sql = SQLtargetTerms($tema_id, $tterm_id); return mysqli_fetch_array($sql[datos]); }
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 ARRAYtargetTerm($tema_id, $tterm_id) { global $DBCFG; $sql = SQLtargetTerms($tema_id, $tterm_id); return $sql->FetchRow(); }
function txt4term($tema_id, $params = array()) { $arrayTema = ARRAYverTerminoBasico($tema_id); $txt .= "\n" . $arrayTema[tema] . "\r\n"; $label_target_vocabulary = ''; $txt .= $params["includeCreatedDate"] == 1 ? LABEL_fecha_creacion . ': ' . $arrayTema[cuando] . "\r\n" : ''; if ($arrayTema[cuando_final] > $arrayTema[cuando] && $params["includeModDate"] == 1) { $txt .= LABEL_fecha_modificacion . ': ' . $arrayTema[cuando_final] . "\r\n"; } //Notas $sqlNotas = SQLdatosTerminoNotas($arrayTema[tema_id]); while ($arrayNotas = $sqlNotas->FetchRow()) { $arrayNotas[label_tipo_nota] = in_array($arrayNotas[ntype_id], array(8, 9, 10, 11, 15)) ? arrayReplace(array(8, 9, 10, 11, 15), array(LABEL_NA, LABEL_NH, LABEL_NB, LABEL_NP, LABEL_NC), $arrayNotas[ntype_id]) : $arrayNotas[ntype_code]; if ($arrayNotas[tipo_nota] !== 'NP' && in_array($arrayNotas[tipo_nota], $params["includeNote"])) { $txt .= ' ' . $arrayNotas[label_tipo_nota] . ': ' . html2txt($arrayNotas[nota]) . "\r\n"; } } //Relaciones $sqlRelaciones = SQLverTerminoRelaciones($arrayTema[tema_id]); $arrayRelacionesVisibles = array(2, 3, 4, 5, 6, 7); // TG/TE/UP/TR while ($arrayRelaciones = $sqlRelaciones->FetchRow()) { if (in_array($arrayRelaciones[t_relacion], $arrayRelacionesVisibles)) { $acronimo = arrayReplace($arrayRelacionesVisibles, array(TR_acronimo, TG_acronimo, UP_acronimo, EQP_acronimo, EQ_acronimo, NEQ_acronimo), $arrayRelaciones[t_relacion]); if (in_array($arrayRelaciones[t_relacion], array(5, 6, 7))) { //términos equivalentes .. se concatenan después de los TE/NT $label_target_vocabulary .= ' ' . $acronimo . ': ' . $arrayRelaciones[tema] . ' (' . $arrayRelaciones[titulo] . ')' . "\r\n"; } else { $txt .= ' ' . $acronimo . $arrayRelaciones[rr_code] . ': ' . $arrayRelaciones[tema] . "\r\n"; } } } //Terminos especificos $SQLTerminosE = SQLverTerminosE($arrayTema[tema_id]); while ($arrayTE = $SQLTerminosE->FetchRow()) { $txt .= ' ' . TE_acronimo . $arrayTE[rr_code] . ': ' . $arrayTE[tema] . "\r\n"; } $txt .= $label_target_vocabulary; //Terminos equivalentes web services $SQLtargetTerms = SQLtargetTerms($arrayTema[tema_id]); while ($arrayTT = $SQLtargetTerms->FetchRow()) { $txt .= ' ' . FixEncoding(ucfirst($arrayTT[tvocab_label])) . ': ' . FixEncoding($arrayTT[tterm_string]) . "\r\n"; } return $txt; }
function HTMLtargetTerms($tema_id) { $sql = SQLtargetTerms($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["tterm_id"] . '" title="' . LABEL_borraRelacion . '" href="index.php?tterm_id=' . $array["tterm_id"] . '&tema=' . $tema_id . '&tvocab_id=' . $array[tvocab_id] . '&taskrelations=delTgetTerm" onclick="return askData();"><span class="glyphicon glyphicon-remove"></span></a> '; $checkLink = '<a id="actua_' . $array["tterm_id"] . '" title="' . LABEL_ShowTargetTermforUpdate . '" class="btn btn-warning btn-xs" href="index.php?tterm_id=' . $array["tterm_id"] . '&tema=' . $tema_id . '&tvocab_id=' . $array[tvocab_id] . '&tterm_id=' . $array["tterm_id"] . '&taskEdit=checkDateTermsTargetVocabulary">' . LABEL_ShowTargetTermforUpdate . '</a>'; $ttermManageLink = ' ' . $delLink . ' ' . $checkLink . ' '; } $rows .= '<li>' . $ttermManageLink . ' ' . FixEncoding(ucfirst($array[tvocab_label])) . ' <a href="' . $array["tterm_url"] . '" target="_blank" title="' . FixEncoding($array[tterm_string]) . '">' . FixEncoding($array["tterm_string"]) . '</a>'; $rows .= $_GET["taskEdit"] == 'checkDateTermsTargetVocabulary' && $_GET["tterm_id"] == $array["tterm_id"] && $_SESSION[$_SESSION["CFGURL"]]["ssuser_nivel"] ? HTMLcheckTargetTerm($array) : ''; $rows .= '</li>'; } $rows .= '</ul>'; } return $rows; }