function fetchlastUpdateEndpoint()
{
    return ARRAYfetchValue('DATESTAMP', 'ENDPOINT_CHANGE');
}
 function fetchVocabularyData($vocabulary_id)
 {
     $sql = SQLdatosVocabulario($vocabulary_id);
     $array = $sql->FetchRow();
     $arrayResponse["result"][vocabulary_id] = $array[vocabulario_id];
     $arrayResponse["result"][title] = $array[titulo];
     $arrayResponse["result"][author] = $array[autor];
     $arrayResponse["result"][lang] = $array[idioma];
     $arrayResponse["result"][scope] = $array[cobertura];
     $arrayResponse["result"][keywords] = $array[keywords];
     $arrayResponse["result"][uri] = $array[url_base];
     $arrayResponse["result"][createDate] = $array[cuando];
     $arrayResponse["result"][lastMod] = fetchlastMod();
     $ARRAYfetchValues = ARRAYfetchValues('METADATA');
     $ARRAYfetchContactMail = ARRAYfetchValue('CONTACT_MAIL');
     $arrayResponse["result"]["contributor"] = $ARRAYfetchValues["dc:contributor"]["value"];
     $arrayResponse["result"]["adminEmail"] = $ARRAYfetchContactMail["value"];
     $arrayResponse["result"]["publisher"] = $ARRAYfetchValues["dc:publisher"]["value"];
     $arrayResponse["result"]["rights"] = $ARRAYfetchValues["dc:rights"]["value"];
     $cant_term = ARRAYcantTerms4Thes("1");
     $arrayResponse["result"]["cant_terms"] = $cant_term["cant"];
     return $arrayResponse;
 }
															</select>
			                    </div>
			         </div>';
$rows .= '<div class="form-group">
							           <label for="cobertura" class="col-sm-3 control-label">' . ucfirst(LABEL_Cobertura) . '</label>
							                    <div class="col-sm-9">
																	<textarea class="form-control"
																	type="text"
																	rows="3"
																	name="' . FORM_LABEL_Cobertura . '"
																	id="cobertura">' . $array_vocabulario["cobertura"] . '</textarea>
							                    </div>
							         </div>';
//is main vocab
if ($array_vocabulario[vocabulario_id] == 1) {
    $ARRAYcontactMail = ARRAYfetchValue('CONTACT_MAIL');
    $rows .= '<div class="form-group">
			           <label for="dia" class="col-sm-3 control-label">' . ucfirst(LABEL_Fecha) . '</label>
			                    <div class="col-sm-9">
													<select id="' . FORM_LABEL_FechaDia . '" name="' . FORM_LABEL_FechaDia . '">
														<optgroup label="' . LABEL_dia . '">
													' . doSelectForm($array_dia, $fecha_crea["dia"]) . '
															</optgroup>
															</select>
													<select id="' . FORM_LABEL_FechaMes . '" name="' . FORM_LABEL_FechaMes . '">
														<optgroup label="' . LABEL_mes . '">
													' . doSelectForm($array_mes, $fecha_crea["mes"]) . '
															</optgroup>
															</select>
													<select id="' . FORM_LABEL_FechaAno . '" name="' . FORM_LABEL_FechaAno . '">
														<optgroup label="' . LABEL_ano . '">
 function abm_vocabulario($do, $vocabulario_id = "")
 {
     global $DBCFG;
     global $DB;
     $arrayTesa = doArrayDatosTesauro($_POST);
     $POSTarrayUser[orga] = trim($POSTarrayUser[orga]);
     $arrayTesa[titulo] = trim($arrayTesa[titulo]);
     $arrayTesa[autor] = trim($arrayTesa[autor]);
     $arrayTesa[idioma] = trim($arrayTesa[idioma]);
     $arrayTesa[cobertura] = trim($arrayTesa[cobertura]);
     $arrayTesa[keywords] = trim($arrayTesa[keywords]);
     $arrayTesa[tipo] = trim($arrayTesa[tipo]);
     $arrayTesa[polijerarquia] = trim($arrayTesa[polijerarquia]);
     $arrayTesa[url_base] = trim($arrayTesa[url_base]);
     $arrayTesa[cuando] = trim($arrayTesa[cuando]);
     $POSTarrayUser[orga] = $DB->qstr($POSTarrayUser[orga], get_magic_quotes_gpc());
     $arrayTesa[titulo] = $DB->qstr($arrayTesa[titulo], get_magic_quotes_gpc());
     $arrayTesa[autor] = $DB->qstr($arrayTesa[autor], get_magic_quotes_gpc());
     $arrayTesa[idioma] = $DB->qstr($arrayTesa[idioma], get_magic_quotes_gpc());
     $arrayTesa[cobertura] = $DB->qstr($arrayTesa[cobertura], get_magic_quotes_gpc());
     $arrayTesa[keywords] = $DB->qstr($arrayTesa[keywords], get_magic_quotes_gpc());
     $arrayTesa[tipo] = $DB->qstr($arrayTesa[tipo], get_magic_quotes_gpc());
     $arrayTesa[polijerarquia] = $DB->qstr($arrayTesa[polijerarquia], get_magic_quotes_gpc());
     $arrayTesa[url_base] = $DB->qstr($arrayTesa[url_base], get_magic_quotes_gpc());
     $arrayTesa[cuando] = $DB->qstr($arrayTesa[cuando], get_magic_quotes_gpc());
     $arrayTesa["contact_mail"] = $_POST["contact_mail"];
     $vocabulario_id = secure_data($vocabulario_id, "int");
     switch ($do) {
         case 'A':
             //Alta de vocabulario de referencia
             $sql = SQL("insert", "into {$DBCFG['DBprefix']}config (titulo,autor,idioma,cobertura,keywords,tipo,polijerarquia,url_base,cuando)\r\n\tvalues\r\n\t({$arrayTesa['titulo']},{$arrayTesa['autor']},{$arrayTesa['idioma']},{$arrayTesa['cobertura']},{$arrayTesa['keywords']},{$arrayTesa['tipo']}, {$arrayTesa['polijerarquia']}, {$arrayTesa['url_base']},{$arrayTesa['cuando']})");
             break;
         case 'M':
             //Modificacion de vocabulario de referencia y principal
             $sql = SQL("update", "{$DBCFG['DBprefix']}config SET titulo={$arrayTesa['titulo']},\r\n\t\t\t\tautor={$arrayTesa['autor']},\r\n\t\t\t\tidioma={$arrayTesa['idioma']},\r\n\t\t\t\tcobertura={$arrayTesa['cobertura']},\r\n\t\t\t\tkeywords= {$arrayTesa['keywords']},\r\n\t\t\t\ttipo= {$arrayTesa['tipo']},\r\n\t\t\t\tpolijerarquia=  {$arrayTesa['polijerarquia']},\r\n\t\t\t\turl_base= {$arrayTesa['url_base']},\r\n\t\t\t\tcuando={$arrayTesa['cuando']}\r\n\t\t\t\twhere id= '{$vocabulario_id}'");
             //It is the main vocabulary => change config values
             if ($vocabulario_id == '1') {
                 $sql = SQL("select", "v.value_id,v.value_type,v.value,v.value_code,v.value_order\r\n\t\t\t\t\t\tfrom {$DBCFG['DBprefix']}values v\r\n\t\t\t\t\t\twhere v.value_type='config'");
                 while ($array = $sql->FetchRow()) {
                     $value_code = $_POST[$array["value"]] == '00' ? '0' : secure_data($_POST[$array[value]], "int");
                     $sql_update = SQL("update", "{$DBCFG['DBprefix']}values set value_code='{$value_code}' where value_type='config' and value='{$array['value']}'");
                 }
                 //Update to 1.72=> check if CFG_SUGGESTxWORD is defined
                 $ctrl = ARRAYfetchValueXValue('config', 'CFG_SUGGESTxWORD');
                 if (!$ctrl[value_id]) {
                     $value_code = $_POST["CFG_SUGGESTxWORD"] == '00' ? '0' : secure_data($_POST["CFG_SUGGESTxWORD"], "int");
                     $sql1_6x1_7b = SQL("insert", "into `" . $DBCFG[DBprefix] . "values` (`value_type`, `value`, `value_order`, `value_code`) VALUES\r\n\t\t\t\t\t('config', 'CFG_SUGGESTxWORD', NULL, '{$value_code}')");
                 }
                 //Update to 1.73=> check if CONTACT_MAIL is defined
                 if (ARRAYfetchValue('CONTACT_MAIL')) {
                     $ADDcontactMail = ABM_value("MOD_SINGLE_VALUE", array("value_type" => 'CONTACT_MAIL', "value_code" => 'NULL', "value" => $arrayTesa["contact_mail"]));
                 } else {
                     $ADDcontactMail = ABM_value("ADD_VALUE", array("value_type" => 'CONTACT_MAIL', "value_code" => 'NULL', "value" => $arrayTesa["contact_mail"]));
                 }
                 $MODdccontributor = ABM_value("MOD_VALUE", array("value_type" => 'METADATA', "value_code" => 'dc:contributor', "value" => $_POST["dccontributor"]));
                 $MODdcpublisher = ABM_value("MOD_VALUE", array("value_type" => 'METADATA', "value_code" => 'dc:publisher', "value" => $_POST["dcpublisher"]));
                 $MODdcrights = ABM_value("MOD_VALUE", array("value_type" => 'METADATA', "value_code" => 'dc:rights', "value" => $_POST["dcrights"]));
             }
             break;
         case 'B':
             //Eliminacion de un vocabulario de REFERENCIA
             //no es el vocabulario por defecto
             if ($vocabulario_id > 1) {
                 $sql = SQLo("delete", "from {$DBCFG['DBprefix']}tema where tesauro_id=?", array($vocabulario_id));
                 $sql = SQLo("delete", "from {$DBCFG['DBprefix']}config where id=?", array($vocabulario_id));
             }
             break;
     }
     return array("vocabulario_id" => $vocabulario_id);
 }
function HTMLformTargetVocabularySuggested($arrayTterm, $t_relation, $string_search, $arrayVocab, $tema_id)
{
    //SEND_KEY to prevent duplicated
    session_start();
    $_SESSION['SEND_KEY'] = md5(uniqid(rand(), true));
    $label_relation = ucfirst(arrayReplace(array('0', '2', '3', '4'), array(LABEL_Termino, TR_termino, TE_termino, UP_termino), $t_relation));
    $rows .= '<h3 id="suggestResult">' . FixEncoding($arrayVocab["tvocab_title"]) . '</h3>';
    if (count($arrayTterm) > 0) {
        $rows .= '<form role="form" name="select_multi_term" action="index.php" method="post">';
        $rows .= '	<div class="row">
		    <div class="col-lg-10">
		        <legend class="alert alert-info"> ' . $label_relation . ': ' . count($arrayTterm) . ' ' . MSG_ResultBusca . ' <i>' . $string_search . '</i></legend>
		    </div>
		    <!-- panel  -->

		    <div class="col-lg-10">
		        <div class="panel panel-default">
		            <div class="panel-body form-horizontal">';
        $rows .= '<div><input id="filter" type="text" class="form-control" placeholder="' . ucfirst(LABEL_type2filter) . '"></div>';
        $rows .= '<div class="table-responsive"> ';
        $rows .= '<table class="table table-striped table-bordered table-condensed table-hover">
		<thead>
		<tr>
			<th align="center"></th>
			<th>' . ucfirst(LABEL_Termino) . '</th>
		</tr>
		</thead>
		<tbody class="searchable">';
        foreach ($arrayTterm as $value) {
            $rows .= '<tr>';
            $rows .= '     	<td align="center"><input type="checkbox" name="selectedTerms[]" id="tterm_' . $value["term_id"] . '" title="' . $value["source_string"] . ' (' . $label_relation . ')" value="' . $value["string"] . '|tterm_|' . $value["term_id"] . '" /> </td>';
            $rows .= '      <td><label class="check_label" title="' . $value["source_string"] . ' (' . $label_relation . ')" for="tterm_' . $value["term_id"] . '">' . $value["string"] . ' <span style="font-weight:normal;">[<a href="' . $arrayVocab["tvocab_url"] . '?tema=' . $value["source_term_id"] . '" title="' . $value["source_string"] . ' (' . $label_relation . ')" target="_blank">' . LABEL_Detalle . '</a>]</span></label></td>';
            $rows .= '</tr>';
        }
        $rows .= '        </tbody>		</table>';
        $rows .= '        </div>';
        if ($t_relation !== "4") {
            $ARRAYuriReference = ARRAYfetchValue("URI_TYPE", "exactMatch");
            $rows .= '<div class="form-group">
			<input type="checkbox" name="addLinkReference" id="addLinkReference" value="' . $ARRAYuriReference["value_id"] . '" alt="' . ucfirst(LABEL_addExactLink) . '" />
			<div class="col-sm-4">
			<label for="addLinkReference">' . ucfirst(LABEL_addExactLink) . '</label>
				</div>
			</div>';
            $rows .= '<div class="form-group">
			<input type="checkbox" name="addMappReference" id="addMappReference" value="1" alt="' . ucfirst(LABEL_addMapLink) . ' (' . ucfirst($arrayVocab["tvocab_label"]) . '" checked />
			<div class="col-sm-4">
			<label for="addMappReference">' . ucfirst(LABEL_addMapLink) . '</label>
				</div>
			</div>';
            $rows .= '<div class="form-group">
			<input type="checkbox" name="addNoteReference" id="addNoteReference" value="1" alt="' . ucfirst(LABEL_addSourceNote) . '" checked  />
			<div class="col-sm-4">
			<label for="addNoteReference">' . ucfirst(LABEL_addSourceNote) . '</label>
				</div>
			</div>';
        }
        $rows .= '	<div class="form-group">
				<div class="col-sm-12 text-center">
				<button type="submit" class="btn btn-primary" value="' . LABEL_Enviar . '"/>' . ucfirst(LABEL_Enviar) . '</button>
				 <button type="button" class="btn btn" name="cancelar" type="button" onClick="location.href=\'index.php?tema=' . $ARRAYtermino["idTema"] . '\'" value="' . ucfirst(LABEL_Cancelar) . '"/>' . ucfirst(LABEL_Cancelar) . '</button>
				</div>
		</div>
	</div>
	</div>
	</div> <!-- / panel  -->';
        $rows .= '<input type="hidden"  name="ks" id="ks" value="' . $_SESSION["SEND_KEY"] . '"/>';
        $rows .= '<input type="hidden"  name="tema" value="' . $tema_id . '" />';
        $rows .= '<input type="hidden" id="t_relation" name="t_relation" value="' . $t_relation . '"/>';
        $rows .= '<input type="hidden" id="taskterm" name="taskterm" value="addSuggestedTerms"/>';
        $rows .= '<input type="hidden" name="tvocab_id" name="tvocab_id" value="' . $arrayVocab["tvocab_id"] . '"/>';
        $rows .= '</form>';
    } else {
        $rows .= '<p class="alert alert-danger"> ' . $label_relation . ': ' . count($arrayTterm) . ' ' . MSG_ResultBusca . ' <i>' . $string_search . '</i></p>';
    }
    return $rows;
}
 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;
 }
?>
" />
             </div>
           </div>
         </form>

       </div>

     </div>
   </nav>
   <div class="container">
    <?php 
$resumen = ARRAYresumen($_SESSION["id_tesa"], "G", "");
$fecha_crea = do_fecha($_SESSION["CFGCreacion"]);
$fecha_mod = do_fecha($_SESSION["CFGlastMod"]);
$ARRAYmailContact = ARRAYfetchValue('CONTACT_MAIL');
?>
<div class="container" id="bodyText">

     <h1><?php 
echo $_SESSION[CFGTitulo];
?>
 / <?php 
echo $_SESSION[CFGAutor];
?>
</h1>
        <dl class="dl-horizontal" id="sumario">
        <dt><?php 
echo ucfirst(LABEL_URI);
?>
</dt><dd><?php