예제 #1
0
function HTMLformAssociateExistTerms($taskterm, $ARRAYtermino, $term_id = "0")
{
    switch ($taskterm) {
        case 'addRT':
            $nombre_pantalla = LABEL_AgregarTR . ' <a href="' . $PHP_SELF . '?tema=' . $ARRAYtermino[idTema] . '">' . $ARRAYtermino[titTema] . '</a>';
            break;
        case 'addBT':
            $nombre_pantalla = sprintf(LABEL_AgregarTG, '<a href="' . $PHP_SELF . '?tema=' . $ARRAYtermino[idTema] . '">' . $ARRAYtermino[titTema] . '</a>');
            break;
        case 'addFreeUF':
            $nombre_pantalla = sprintf(LABEL_existAgregarUP, '<a href="' . $PHP_SELF . '?tema=' . $ARRAYtermino[idTema] . '">' . $ARRAYtermino[titTema] . '</a>');
            break;
        case 'addFreeNT':
            $nombre_pantalla = sprintf(LABEL_existAgregarTE, '<a href="' . $PHP_SELF . '?tema=' . $ARRAYtermino[idTema] . '">' . $ARRAYtermino[titTema] . '</a>');
            break;
        default:
            '';
    }
    if (doValue($_POST, FORM_LABEL_buscarTermino)) {
        $expresBusca = doValue($_POST, FORM_LABEL_buscarTermino);
        //seleccionar SQL adecuado a la operacion
        if ($taskterm == 'addFreeNT' || $taskterm == 'addFreeUF') {
            $sql_busca = SQLsearchFreeTerms("{$expresBusca}");
        } else {
            $sql_busca = SQLbuscaTR("{$ARRAYtermino['idTema']}", "{$expresBusca}");
        }
        $search_leyenda = '<h3>' . $sql_busca[cant] . ' ' . MSG_ResultBusca . ' ' . $expresBusca . '".</h3>' . "\n\r";
        if ($sql_busca[cant] > 0) {
            $row_result = '<ol style="list-style-position:inside;">';
            while ($resulta_busca = mysqli_fetch_row($sql_busca[datos])) {
                $row_result .= '<li><a href="' . $PHP_SELF . '?tema=' . $resulta_busca[0] . '" class="link_secundario">' . LABEL_Detalle . '</a> |';
                $row_result .= ' <a href="' . $PHP_SELF . '?rema_id=' . $resulta_busca[0] . '&amp;tema=' . $ARRAYtermino[idTema] . '&amp;taskrelations=' . $taskterm . '">' . $resulta_busca[1] . '</a></li>';
            }
            $row_result .= '</ol>' . "\n\r";
        }
        // fin de if result
    }
    //fin de if buscar
    $rows .= '<div id="bodyText">
<a class="topOfPage" href="javascript: history.go(-1);">' . LABEL_Anterior . '</a>
<h1>' . LABEL_EditorTermino . '</h1>
  <fieldset>
    <legend>' . $nombre_pantalla . '</legend>
	 <form class="formdiv" name="busca_rel" action="' . $PHP_SELF . '" method="POST" onsubmit="return checkrequired(this)">' . LABEL_BuscaTermino . ':
		<input name="' . FORM_LABEL_buscarTermino . '" type="text" id="addExistTerm" size="15" maxlength="50"/>
  	  <input type="submit" name="boton" value="' . LABEL_Buscar . '"/>
	  <input type="button"  name="cancelar" type="button" onClick="location.href=\'index.php?tema=' . $ARRAYtermino[idTema] . '\'" value="' . ucfirst(LABEL_Cancelar) . '"/>
	  <input type="hidden" name="tema" value="' . $ARRAYtermino[idTema] . '"/>
	  <input type="hidden" name="' . $hidden . '" value="' . $ARRAYtermino[idTema] . '"/>
	  <input type="hidden" name="taskterm" value="' . $taskterm . '"/>	  
 </form>';
    $rows .= $search_leyenda;
    $rows .= $row_result;
    $rows .= '</fieldset>';
    $rows .= '   </div>';
    return $rows;
}
function HTMLformAssociateExistTerms($taskterm, $ARRAYtermino, $term_id = "0")
{
    global $new_relacion;
    switch ($taskterm) {
        case 'addRT':
            $nombre_pantalla = ucfirst(LABEL_AgregarRTexist) . ' <a title="' . $ARRAYtermino["titTema"] . '" href="index.php?tema=' . $ARRAYtermino["idTema"] . '">' . $ARRAYtermino["titTema"] . '</a>';
            break;
        case 'addBT':
            $nombre_pantalla = sprintf(LABEL_AgregarTG, '<a title="' . $ARRAYtermino["titTema"] . '" href="index.php?tema=' . $ARRAYtermino["idTema"] . '">' . $ARRAYtermino["titTema"] . '</a>');
            break;
        case 'addFreeUF':
            $nombre_pantalla = sprintf(LABEL_existAgregarUP, '<a  title="' . $ARRAYtermino["titTema"] . '" href="index.php?tema=' . $ARRAYtermino["idTema"] . '">' . $ARRAYtermino["titTema"] . '</a>');
            break;
        case 'addFreeNT':
            $nombre_pantalla = sprintf(LABEL_existAgregarTE, '<a href="index.php?tema=' . $ARRAYtermino["idTema"] . '">' . $ARRAYtermino["titTema"] . '</a>');
            break;
        default:
            '';
    }
    if (doValue($_POST, FORM_LABEL_buscarTermino) || $_GET["showFreeTerms"] == 1) {
        $expresBusca = doValue($_POST, FORM_LABEL_buscarTermino);
        if ($_GET["showFreeTerms"] == 1) {
            $sql_busca = SQLverTerminosLibres();
            $cant_result = SQLcount($sql_busca);
            $search_leyenda = '<h3>' . $cant_result . ' ' . LABEL_terminosLibres . '</h3>' . "\n\r";
        } elseif ($taskterm == 'addFreeNT' || $taskterm == 'addFreeUF') {
            $sql_busca = SQLsearchFreeTerms($expresBusca, $ARRAYtermino["idTema"]);
            $cant_result = SQLcount($sql_busca);
            $search_leyenda = '<h3>' . $cant_result . ' ' . MSG_ResultBusca . ' <i>' . $expresBusca . '</i>.</h3>' . "\n\r";
        } else {
            $sql_busca = SQLbuscaTR($ARRAYtermino["idTema"], "{$expresBusca}");
            $cant_result = SQLcount($sql_busca);
            $search_leyenda = '<h3>' . $cant_result . ' ' . MSG_ResultBusca . ' <i>' . $expresBusca . '</i>.</h3>' . "\n\r";
        }
        if ($cant_result > 0) {
            $rows_busca .= '<div><input id="filter" type="text" class="form-control" placeholder="' . ucfirst(LABEL_type2filter) . '"></div>';
            $rows_busca .= '<form role="form" class="form-inline" role="form" name="addRelations" id="addRelations" action="index.php" method="get" >';
            $rows_busca .= '<div class="table-responsive"> ';
            $rows_busca .= '<table class="table table-striped table-bordered table-condensed table-hover"">';
            $rows_busca .= '<thead>
			<tr><th>';
            //
            //$rows_busca.=($taskterm=='addBT') ? '':'<input name="checktodos" type="checkbox" title="'.LABEL_selectAll.'"/>';
            $rows_busca .= '</th><th>' . ucfirst(LABEL_Termino) . '</th>
			<th>' . ucfirst(LABEL_Fecha) . '</th>
			</tr>
			</thead>
			<tbody class="searchable">';
            while ($resulta_busca = $sql_busca->FetchRow()) {
                $css_class_MT = $resulta_busca["isMetaTerm"] == 1 ? ' class="metaTerm" ' : '';
                //prevenir que no seleccione el mismo término que esta mirando
                if ($resulta_busca["tema_id"] !== $ARRAYtermino["idTema"]) {
                    if ($taskterm == 'addBT') {
                        $rows_busca .= '<tr>';
                        $rows_busca .= '     <td align="center"><input type="radio" name="rema_id" id="rema_' . $resulta_busca["tema_id"] . '" title="' . $resulta_busca["tema"] . '" value="' . $resulta_busca["tema_id"] . '" /> </td>';
                        $rows_busca .= '     <td><label class="check_label" for="rema_' . $resulta_busca["tema_id"] . '" ' . $css_class_MT . '> ' . $resulta_busca["tema"] . '</label> </td>';
                        $rows_busca .= '      <td>' . $resulta_busca["cuando"] . '</td>';
                        $rows_busca .= '  </tr>';
                    } else {
                        $rows_busca .= '<tr>';
                        $rows_busca .= '     <td align="center"><input type="checkbox" name="rema_id[]" id="rema_' . $resulta_busca["tema_id"] . '" title="' . $resulta_busca["tema"] . '" value="' . $resulta_busca["tema_id"] . '" /> </td>';
                        $rows_busca .= '     <td><label class="check_label" for="rema_' . $resulta_busca["tema_id"] . '" ' . $css_class_MT . '> ' . $resulta_busca["tema"] . '</label> </td>';
                        $rows_busca .= '      <td>' . $resulta_busca["cuando"] . '</td>';
                        $rows_busca .= '  </tr>';
                    }
                }
            }
            $rows_busca .= '        </tbody>';
            $rows_busca .= '<tfoot>
			<tr>
			<td colspan=3>';
            $rows_busca .= ' <input type="hidden" name="tema" id="tema" value="' . $ARRAYtermino["idTema"] . '"/>';
            $rows_busca .= ' <input type="hidden" name="taskterm" id="taskterm" value="' . $taskterm . '"/>	  ';
            $rows_busca .= ' <input type="hidden" name="taskrelations" id="taskrelations" value="' . $taskterm . '"/>	  ';
            $rows_busca .= '		</td>
			</tr>
			</tfoot>

			</table>	</div>';
            //no es subordinar término y hay resultados
            if ($cant_result > 0) {
                $rows_busca .= '<div class="submit_form" align="center">';
                $rows_busca .= '  <button type="submit" class="btn btn-primary">' . LABEL_Agregar . '</button>';
                $rows_busca .= '</div>';
            }
            $rows_busca .= '</form>';
        }
        //if cant
        $rows_busca .= '</div>';
        $rows_busca .= '<script type="text/javascript">
		$(document).ready(function(){
			//Checkbox
			$("input[name=checktodos]").change(function(){
				$("input[type=checkbox]").each( function() {
					if($("input[name=checktodos]:checked").length == 1){
						this.checked = true;
					} else {
						this.checked = false;
					}
				});
			});

		});
		</script>';
    }
    //fin de if buscar
    $rows .= '<div class="container" id="bodyText">
	<a class="topOfPage" href="index.php?tema=' . $ARRAYtermino["idTema"] . '" title="' . LABEL_Anterior . ' (' . $ARRAYtermino["tema"] . ')">' . LABEL_Anterior . '</a>
	<h3>' . LABEL_EditorTermino . '</h3>';
    if ($new_relacion["log"] == true) {
        $rows .= '<p class="success">' . ucfirst(LABEL_saved) . '</p>';
    }
    $rows .= ' <form class="form-inline" role="form" name="busca_rel" action="index.php?taskterm=' . $taskterm . '&amp;tema=' . $ARRAYtermino["idTema"] . '" method="post">';
    $rows .= '  <fieldset>
	<legend>' . $nombre_pantalla . '</legend>
	<input class="form-inline input_ln form-control" name="' . FORM_LABEL_buscarTermino . '" type="search" id="addExistTerm" maxlength="50"/>
	<button type="submit" class="btn btn-primary">' . LABEL_Buscar . '</button>
	 <button type="button" class="btn btn-info" onClick="location.href=\'index.php?tema=' . $ARRAYtermino["idTema"] . '&amp;taskterm=' . $taskterm . '&amp;showFreeTerms=1\'"/>' . ucfirst(LABEL_showFreeTerms) . '</button>
	 <button type="button" class="btn btn-default" onClick="location.href=\'index.php?tema=' . $ARRAYtermino["idTema"] . '\'">' . ucfirst(LABEL_Cancelar) . '</button>
	<input type="hidden" name="tema" value="' . $ARRAYtermino["idTema"] . '"/>
	<input type="hidden" name="taskterm" value="' . $taskterm . '"/>
	</form>';
    if (in_array($taskterm, array("addFreeUF", "addFreeNT"))) {
        $rows .= '<p class="text-warning">' . LABEL_helpSearchFreeTerms . '</p>';
    }
    $rows .= '</fieldset>';
    $rows .= $search_leyenda;
    $rows .= $rows_busca;
    $rows .= '   </div>';
    return $rows;
}