Ejemplo/parte 1
Código PHP:
<?PHP
session_start();
//require_once("../Funciones/FnPHP/FnPHP_Otros.php");
if (!isset($_SESSION['VStemas'])){
$_SESSION['VStemas'] = array(array());
$_SESSION['VStemas'] = array(array());
$_SESSION['VSposT'] = -1;
$_SESSION['VSmodo'] = 0;
$_SESSION['VStemasE'] = array(array());
}else{
}
//PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php
//PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php
//PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php
//PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php
//PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php //PHPTemas.php
//----- FnPHP_Temas_CrearFisico1
//----- FnPHP_Temas_CSS
//----- FnPHP_Temas_Eliminar1
//----- FnPHP_Temas_EliminarP
//----- FnPHP_Temas_EliminarR
//----- FnPHP_Temas_EliminarV
//----- FnPHP_Temas_esOK
//----- FnPHP_Temas_Guardar
//----- FnPHP_Temas_Intercambiar2
//----- FnPHP_Temas_Margen
//----- FnPHP_Temas_Nuevo1
//----- FnPHP_Temas_SumarLista
//----- FnPHP_Temas_ULLI
function FnPHP_Temas_CrearFisico1($margen, $Id_tema, $nombre, $pagina, $indice, $i, $check){
$cadena ='
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="20">
<input id="opt_'.$i.'" name="opt_'.$i.'" type="checkbox" value="'.$i.'" onclick="xajax_FnXAJAX_VSposT_Cambiar('.$i.');" ';
if ($check==1){
$cadena .='checked="checked" />';
}else{
$cadena .='/>';
}
$cadena .='
</td>
<td width="80"><input id="txt_Indice_'.$i.'" name="txt_Indice_'.$i.'" type="text" value="'.$indice.'" size="15" /></td>
<td nowrap="nowrap"><span id="span_Margen_'.$i.'" class="Margen_01">'.FnPHP_Temas_Margen($margen).'</span></td>
<td width="800"><div id="div_Titulo_'.$i.'" align="justify" class="'.FnPHP_Temas_CSS($margen).'">'.$nombre.'</div></td>
</tr>
</table>';
return $cadena;
}
function FnPHP_Temas_CSS($N){
$cadena = "Titulo_0";
if ($N < 7){
$cadena .= $N;
}else{
$cadena = "Titulo_06";
}
return $cadena;
}
function FnPHP_Temas_Eliminar1($lista, $POS){
$N = FnPHP_Lista_Tam($lista);
$TAM = FnPHP_Lista_Tam($_SESSION['VStemasE']);
$result = array(array());
$result = FnPHP_Temas_SumarLista($result, 0, $lista, 0, $POS-1);
if($lista[$POS]["Id_tema"] <> ""){
$_SESSION['VStemasE'][$TAM]["Id_tema"] = $lista[$POS]["Id_tema"];
}
$result = FnPHP_Temas_SumarLista($result, $POS, $lista, $POS+1, $N-1);
return $result;
}
function FnPHP_Temas_Intercambiar2($result, $POSa, $POSb){
$N = $TAM;
$temp = array(array());
$temp[0] = $result[$POSa];
$result[$POSa] = $result[$POSb];
$result[$POSb] = $temp[0];
$result[$POSa]["numero"] = $POSb;
$result[$POSb]["numero"] = $POSa;
return $result;
}
function FnPHP_Temas_Margen($N){
$cadena = "";
for($i=1; $i<$N; $i++){
$cadena .="---+";
}
return $cadena;
}
function FnPHP_Temas_Nuevo1($lista, $POS){
$N = FnPHP_Lista_Tam($lista);
$result = array(array());
$result = FnPHP_Temas_SumarLista($result, 0, $lista, 0, $POS);
$result[$POS+1]["margen"] = "1";
$result[$POS+1]["Id_tema"] = "";
$result[$POS+1]["Id_curso"] = $_SESSION['VScurso'];
$result[$POS+1]["nombre"] = "";
$result[$POS+1]["pagina"] = "";
$result[$POS+1]["indice"] = "";
$result[$POS+1]["numero"] = $POS+1;
$result = FnPHP_Temas_SumarLista($result, $POS+2, $lista, $POS+1, $N-1);
return $result;
}
function FnPHP_Temas_SumarLista($result, $TAM, $lista, $ini, $fin){
$N = $TAM;
if ($ini>$fin){
}else{
for($i=0; $i <= $fin-$ini; $i++){
$result[$i+$N]["margen"] = $lista[$i+$ini]["margen"];
$result[$i+$N]["Id_tema"] = $lista[$i+$ini]["Id_tema"];
$result[$i+$N]["Id_curso"] = $_SESSION['VScurso'];
$result[$i+$N]["nombre"] = $lista[$i+$ini]["nombre"];
$result[$i+$N]["pagina"] = $lista[$i+$ini]["pagina"];
$result[$i+$N]["indice"] = $lista[$i+$ini]["indice"];
$result[$i+$N]["numero"] = $i+$N;
}
}
return $result;
}
//echo FnPHP_Numeracion_Tam("1.1")."<br>";
//echo FnPHP_Numeracion_Siguiente("1.1.1", FnPHP_Numeracion_CrearL(3));
//PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP
//PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP
//PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP
//PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP
//PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP //PHPOtros.PHP
//----- FnPHP_Numeracion_Cortar
//----- FnPHP_Numeracion_CrearL
//----- FnPHP_Numeracion_CrearN
//----- FnPHP_File_Ext
//----- FnPHP_File_Name
//----- FnPHP_Numeracion_MayMen
//----- FnPHP_Numeracion_POS
//----- FnPHP_Numeracion_Siguiente
//----- FnPHP_Numeracion_Tam
//----- FnPHP_Numeracion_Ultimo
//----- FnPHP_Lista_InsertSort
//----- FnPHP_Union_TemasEvaluaciones
//----- esValido
function FnPHP_Numeracion_Cortar($indice, $TAM){
$result = explode('.', $indice);
if ( $TAM <= count($result) ){
$result = array_slice($result, 0, $TAM);
}
$result = FnPHP_Numeracion_CrearN($result);
return $result;
}
function FnPHP_Numeracion_CrearL($N){
$result = "";
for($i=0; $i<$N; $i++){
if($i==0){ $result = "1"; }else{ $result = $result."."."1"; }
}
return $result;
}
function FnPHP_Numeracion_CrearN($lista){
$N = count($lista);
$result = "";
for($i=0; $i<$N; $i++){
if($i==0){ $result = $lista[$i]; }else{ $result = $result.".".$lista[$i];}
}
return $result;
}
function FnPHP_File_Name($filename){
$path_parts = pathinfo($filename);
$result = $path_parts['basename'];
$ext = FnPHP_File_Ext($filename);
$result = str_replace('.'.$ext, '', $result);
return $result;
}
function FnPHP_File_Ext($filename){
$path_parts = pathinfo($filename);
$result = $path_parts['extension'];
return $result;
}
function FnPHP_Numeracion_MayMen($cadenaA, $cadenaB, $i){
if ($cadenaA=="" and $cadenaB==""){
$result = 0;
}elseif ($cadenaA=="" and $cadenaB<>""){
$result = -1;
}elseif ($cadenaB=="" and $cadenaA<>""){
$result = 1;
}else{
$A = explode('.', $cadenaA);
$B = explode('.', $cadenaB);
$a = $A[$i];
$b = $B[$i];
if($cadenaA."X" == $cadenaB."X"){
$result = 0;
}else{
if ($a == $b){
if (( count($A) == $i+1 ) and ( count($B) > count($A) )){
$result = -1;
}elseif (( count($B) == $i+1 ) and ( count($A) > count($B) )){
$result = 1;
}elseif((count($A)-1 > $i) and (count($B)-1 > $i) ){
$result = FnPHP_Numeracion_MayMen($cadenaA, $cadenaB, $i+1);
}else{
$result = 0;
}
}else if ($a > $b){
$result = 1;
}else if ($a < $b){
$result = -1;
}
}
}
return $result;
}
function FnPHP_Numeracion_POS($lista, $indice){
$result = -1;
$N = FnPHP_Lista_Tam ($lista);
for($i=0; $i<$N; $i++){
if ($lista[$i]["indice"]."X" == $indice."X"){
$result = $i;
}
}
return $result;
}
function FnPHP_Numeracion_Siguiente($indiceA, $indiceB){
$listaA = explode(".", $indiceA);
$listaB = explode(".", $indiceB);
$M = count($listaA);
$N = count($listaB);
$cadena = "";
if ($indiceA==""){
$cadena = "1";
}elseif (($M >= $N)){
for($i=0; $i<$N-1; $i++){
$listaB[$i] = $listaA[$i];
}
$listaB[$i] = $listaA[$i]+1;
$cadena = FnPHP_Numeracion_CrearN($listaB);
}elseif ($M+1 == $N){
$cadena = FnPHP_Numeracion_CrearN($listaA);
$cadena = $cadena.".1";
}
return $cadena;
}
function FnPHP_Numeracion_Tam($indice){
$lista = explode(".", $indice);
return (count($lista));
}
function FnPHP_Numeracion_Ultimo($lista, $indice){
$may = $indice;
foreach($lista as $row){;
$indiceB = FnPHP_Numeracion_Cortar( $row["indice"], FnPHP_Numeracion_Tam( $indice ) );
if(FnPHP_Numeracion_MayMen($indice, $indiceB, 0) == 0){
if(FnPHP_Numeracion_MayMen($may, $row["indice"], 0)== -1){
$may = $row["indice"];
}
}
}
return $may;
}
function FnPHP_Lista_InsertSort($lista){
$TAM = FnPHP_Lista_Tam($lista);
$temp = array(array());
for($i=1; $i<$TAM; $i++){
$temp[0] = $lista[$i];
for ($j = $i-1; $j >= 0 and ( FnPHP_Numeracion_MayMen( $lista[$j]["indice"], $temp[0]["indice"], 0) == 1 ); $j--) {
$lista[$j+1] = $lista[$j];
$lista[$j] = $temp[0];
}
}
return $lista;
}
function FnPHP_Lista_Tam($lista){
if(count($lista[0]) == 0){
$result = 0;
}else{
$result = count($lista);
}
return $result;
}
function FnPHP_Union_TemasEvaluaciones($listaA, $listaB){
$tamA = FnPHP_Lista_Tam($listaA);
$tamB = FnPHP_Lista_Tam($listaB);
$result = array(array());
for ($i=0; $i<$tamA; $i++){
$result[$i] = $listaA[$i];
$result[$i]["Id_prueba"] = "";
$result[$i]["Id_tipoPrueba"]= "";
}
for ($i=0; $i<$tamB; $i++){
$result[$i + $tamA] = $listaB[$i];
}
return FnPHP_Lista_InsertSort($result);
}
function esValido($cadena, $opc){
$result = 0;
if($cadena <> ""){
$result = 1;
}
return $result;
}