<?php include "config.tematres.php"; //user login true if ($_SESSION[$_SESSION["CFGURL"]][ssuser_id]) { //gestión de codigo de tema if ($_POST["code_tema_id"]) { $tema_id = str_replace("code_tema", "", $_POST["code_tema_id"]); if (is_numeric($tema_id)) { $task = edit_single_code($tema_id, $_POST[code_tema]); switch ($task["log"]) { case '0': //no pasó nada = nothing echo $task[code]; break; case '1': // OK echo $task[code]; break; case '-1': // ERROR header("HTTP/1.1 406 Not Acceptable"); echo ' ' . $_POST[code_tema] . ': ' . MSG_ERROR_CODE . ' (' . LABEL_Termino . ' ' . $task[tema] . ')'; break; } } } //gestión de codigo de tema if ($_POST["edit_tema_id"]) { $tema_id = str_replace("edit_tema", "", $_POST["edit_tema_id"]); //additional secure check
//es un término if (strlen($term) > 0 && !$objectTerm) { $term_id = resolveTerm_id($term); $i = ++$i; } //es una nota if (in_array($rwTerms[0], $arrayTiposNotas)) { //re-redactar nota para prevenir signo de separación en notas $note = implode($separador, array_slice($rwTerms, 1)); abmNota("A", $term_id, $rwTerms[0], "{$thes_lang}", trim($note)); } elseif (in_array($rwTerms[0], $arrayTiposTermino)) { //Retomar tag $label = $rwTerms[0] == $tabulador ? $past_label : trim($rwTerms[0]); switch ($label) { case 'CODE': edit_single_code($term_id, $objectTerm); break; case 'BT': $BTterm_id = resolveTerm_id($objectTerm, "1"); ALTArelacionXId($BTterm_id, $term_id, "3"); break; case 'RT': $RTterm_id = resolveTerm_id($objectTerm, "1"); ALTArelacionXId($term_id, $RTterm_id, "2"); ALTArelacionXId($RTterm_id, $term_id, "2"); break; case 'NT': $NTterm_id = resolveTerm_id($objectTerm, "1"); ALTArelacionXId($term_id, $NTterm_id, "3"); break; case 'UF':
function addTerm($skos, $node) { /* fectch hidden label ID */ $ARRAYhiddenLabelCode = ARRAYfetchValue("4", "H"); // Preferred label $prefLabels = $skos->xpath->query('./skos:prefLabel', $node); foreach ($prefLabels as $prefLabel) { $value = setI18nValue($skos, $prefLabel); if (isset($value)) { // find URI $uri = $node->getAttributeNodeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'about'); if ($uri instanceof DOMAttr) { $source_uri = $uri->nodeValue; } $node_stringPreferedTerm = $value["value"]; $node_stringPreferedTermLang = $value["lang"]; //add term if ($node_stringPreferedTermLang == $_SESSION["CFGIdioma"]) { $ARRAYterm = ARRAYCode($source_uri); if ($ARRAYterm[tema_id]) { $term_id = $ARRAYterm[tema_id]; } else { $term_id = ALTAtema($node_stringPreferedTerm, "1", "13"); } } elseif (!$node_stringPreferedTermLang) { /* * What to do if the term is not in the same language of the controlled vocabulary ??? */ $ARRAYterm = ARRAYCode($source_uri); if ($ARRAYterm[tema_id]) { $term_id = $ARRAYterm[tema_id]; } else { $term_id = ALTAtema($node_stringPreferedTerm, "1", "13"); } } } } //This is a new term if (!$ARRAYterm[tema_id]) { edit_single_code($term_id, $source_uri); // Alternate labels foreach ($skos->xpath->query('./skos:altLabel', $node) as $altLabel) { $value = setI18nValue($skos, $altLabel); //the same language if (isset($value) && $_SESSION["CFGIdioma"] == $value["lang"]) { $node_alt_term[] = $value; $alt_term_id = ALTAtema($value["value"], "1", "13"); ALTArelacionXId($alt_term_id, $term_id, "4"); } } // Alternate hidden labels foreach ($skos->xpath->query('./skos:hiddenLabel', $node) as $altLabel) { $value = setI18nValue($skos, $altLabel); //the same language if (isset($value) && $_SESSION["CFGIdioma"] == $value["lang"]) { $node_alt_term[] = $value; $alt_term_id = ALTAtema($value["value"], "1", "13"); ALTArelacionXId($alt_term_id, $term_id, "4", $ARRAYhiddenLabelCode[value_id]); } } // Scope notes foreach ($skos->xpath->query('./skos:scopeNote', $node) as $scopeNote) { $value = setI18nValue($skos, $scopeNote); if (isset($value["value"]) && is_string($value["value"])) { $node_notes[] = $value; $lang_nota = $value["lang"] ? $value["lang"] : $node_stringPreferedTermLang; ALTAnota($term_id, "NA", $lang_nota, $value["value"]); } } // Definition notes foreach ($skos->xpath->query('./skos:definition', $node) as $defNote) { $value = setI18nValue($skos, $defNote); if (isset($value["value"])) { $node_defnotes[] = $value; $lang_nota = $value["lang"] ? $value["lang"] : $node_stringPreferedTermLang; ALTAnota($term_id, "NA", $lang_nota, $value["value"]); } } // changeNote foreach ($skos->xpath->query('./skos:changeNote', $node) as $defNote) { $value = setI18nValue($skos, $defNote); if (isset($value["value"])) { $node_defnotes[] = $value; $lang_nota = $value["lang"] ? $value["lang"] : $node_stringPreferedTermLang; ALTAnota($term_id, "NH", $lang_nota, $value["value"]); } } //~ // exactMatch $sqlMatchTypes = SQLfetchValue('URI_TYPE'); while ($arrayMatchTypes = $sqlMatchTypes->FetchRow()) { foreach ($skos->xpath->query("./skos:{$arrayMatchTypes['value']}", $node) as $matchNode) { // find URI $uri_match = $matchNode->getAttributeNodeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource'); if ($uri_match instanceof DOMAttr) { abmURI("A", $term_id, array("uri" => $uri_match->nodeValue, "uri_type_id" => $arrayMatchTypes[value_id])); } } } // Find and add narrow terms // TODO: Merge broader/narrower relations for this term, as defining // inverse of relationship is not required by SKOS // http://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#sechierarchy if ($uri instanceof DOMAttr) { foreach ($skos->xpath->query('./skos:Concept[skos:broader[@rdf:resource="' . $uri->nodeValue . '"]]') as $narrower) { if (!$narrower instanceof DOMElement) { continue; } $NT_term_id = addTerm($skos, $narrower); if ($NT_term_id) { ALTArelacionXId($term_id, $NT_term_id, "3"); } } } //end if new term } return $term_id; }