conectar(); // instanciar los 0bjetos $tabla_pregunta=new Tabla_Pregunta($dataBase->getEnlaceHost()); $pregunta=new Pregunta(); $tabla_empresa=new Tabla_Empresa($dataBase->getEnlaceHost()); $empresa=new Empresa(); $tabla_usuario=new Tabla_Usuario($dataBase->getEnlaceHost()); $usuario=new Usuario(); $tabla_tecnologia=new Tabla_Tecnologia($dataBase->getEnlaceHost()); $tecnologia=new Tecnologia(); $tabla_subtecnologia=new Tabla_Subtecnologia($dataBase->getEnlaceHost()); $subtecnologia=new Subtecnologia(); $tabla_pregunta_tecnologia=new Tabla_Pregunta_tecnologia($dataBase->getEnlaceHost()); $pregunta_tecnologia=new Pregunta_tecnologia(); $tabla_sector=new Tabla_Sector($dataBase->getEnlaceHost()); $sector=new Sector(); $tabla_subsector=new Tabla_Subsector($dataBase->getEnlaceHost()); $subsector=new Subsector(); $tabla_pregunta_sector=new Tabla_Pregunta_sector($dataBase->getEnlaceHost()); $pregunta_sector=new Pregunta_sector(); $tabla_seccion=new Tabla_Seccion($dataBase->getEnlaceHost()); $seccion=new Seccion(); $tabla_subseccion=new Tabla_Subseccion($dataBase->getEnlaceHost()); $subseccion=new Subseccion(); $lista_elementos=$tabla_pregunta->obtenerListaPreguntasWeb($desde); // leer las plantillas que forman la pagina $plantillas = array("plantillas/preguntas/index.htm","plantillas/cabecera.htm","plantillas/lateral.htm","plantillas/pie.htm"); $plantilla = plantillas($dataBase,$id,$plantillas,$se,$su); // aviso necesario estar registrado para escribir $Nusuario = obtenerCodigoUsuario(); if ($Nusuario != "") $plantilla = preg_replace("/([\S\s]*)/","", $plantilla); $indice=0; $color="normal"; $cuantos=$lista_elementos->getUltimo(); $plantillaFilaGenerica=leerFichero($id,RAIZ."/plantillas/preguntas/fila.htm"); while ($indice<$cuantos){ $pregunta=$lista_elementos->siguiente(); $plantillaFila=$plantillaFilaGenerica; $plantillaFila=str_replace(TAG_COLOR,$color,$plantillaFila); $plantillaFila=str_replace(TAG_Npregunt_VALUE,$pregunta->getNpregunt(),$plantillaFila); // empresa if ($tabla_empresa->existe($pregunta->getNempresa())) { $empresa = $tabla_empresa->obtener($pregunta->getNempresa()); $plantillaFila=str_replace(TAG_Nempresa_VALUE,$empresa->getTempresa(),$plantillaFila); } $plantillaFila=str_replace(TAG_Nempresa_VALUE,"",$plantillaFila); // usuario if ($tabla_usuario->existe($pregunta->getNusuario())) { $usuario = $tabla_usuario->obtener($pregunta->getNusuario()); $plantillaFila=str_replace(TAG_Nusuario_VALUE,$usuario->getTnombre(),$plantillaFila); } $plantillaFila=str_replace(TAG_Nusuario_VALUE,"",$plantillaFila); $plantillaFila=str_replace(TAG_Mpreg_es_VALUE,$pregunta->getMpreg_es(),$plantillaFila); // pregunta_tecnologias $lista_pregunta_tecnologias=$tabla_pregunta_tecnologia->obtenerListaPregunta($pregunta->getNpregunt()); $indice_tecnologias=0; $textoUsuario_tecnologia=""; $cuantos_tecnologias=$lista_pregunta_tecnologias->getUltimo(); while ($indice_tecnologias<$cuantos_tecnologias){ $pregunta_tecnologia=$lista_pregunta_tecnologias->siguiente(); // tecnologia if ($tabla_tecnologia->existe($pregunta_tecnologia->getNtecnolo())) { $tecnologia = $tabla_tecnologia->obtener($pregunta_tecnologia->getNtecnolo()); $textoUsuario_tecnologia .= $tecnologia->getTtecn_es(); } // subtecnologia if ($tabla_subtecnologia->existe($pregunta_tecnologia->getNsubtecn())) { $subtecnologia = $tabla_subtecnologia->obtener($pregunta_tecnologia->getNsubtecn()); $textoUsuario_tecnologia .= " - ".$subtecnologia->getTsubt_es(); } $textoUsuario_tecnologia .= "
"; $indice_tecnologias++; } $plantillaFila=str_replace(TAG_Ntecnolo_VALUE,$textoUsuario_tecnologia,$plantillaFila); // pregunta_sectores $lista_pregunta_sectores=$tabla_pregunta_sector->obtenerListaPregunta($pregunta->getNpregunt()); $indice_sectores=0; $textoUsuario_sector=""; $cuantos_sectores=$lista_pregunta_sectores->getUltimo(); while ($indice_sectores<$cuantos_sectores){ $pregunta_sector=$lista_pregunta_sectores->siguiente(); // sector if ($tabla_sector->existe($pregunta_sector->getNsector())) { $sector = $tabla_sector->obtener($pregunta_sector->getNsector()); $textoUsuario_sector .= $sector->getTsect_es(); } // subsector if ($tabla_subsector->existe($pregunta_sector->getNsubsect())) { $subsector = $tabla_subsector->obtener($pregunta_sector->getNsubsect()); $textoUsuario_sector .= " - ".$subsector->getTsubs_es(); } $textoUsuario_sector .= "
"; $indice_sectores++; } $plantillaFila=str_replace(TAG_Nsector_VALUE,$textoUsuario_sector,$plantillaFila); $plantillaFila=str_replace(TAG_Norden_VALUE,$pregunta->getNorden(),$plantillaFila); $plantillaFila=str_replace(TAG_Falta_VALUE,$pregunta->getFalta(),$plantillaFila); $plantillaFila=str_replace(TAG_Fmodific_VALUE,formatearFecha($pregunta->getFmodific()),$plantillaFila); $plantillaFilasCompleta.=$plantillaFila; $indice++; } $plantilla = preg_replace("/([\S\s]*)/",$plantillaFilasCompleta, $plantilla); // controlar que haya elementos if ($cuantos == 0) $plantilla = preg_replace("/([\S\s]*)/","",$plantilla); else $plantilla = preg_replace("/([\S\s]*)/","",$plantilla); $plantilla = str_replace("TAG_DESDE",$desde, $plantilla); $plantilla = str_replace("TAG_ORDEN",$orden, $plantilla); $plantilla = str_replace("TAG_SENTIDO",$sentido, $plantilla); $plantilla = str_replace("TAG_ELEMENTOS_POR_PAGINA",$lista_elementos->getUltimo(), $plantilla); // paginacion $num_pregunta=$tabla_pregunta->obtenerNumeroPreguntasWeb(); $num_paginas=ceil($num_pregunta/PREGUNTAS_WEB_POR_PAGINA); $pagina_actual=($desde/PREGUNTAS_WEB_POR_PAGINA)+1; $plantilla = str_replace("TAG_NUM_ELEMENTOS",$num_pregunta, $plantilla); $plantilla = str_replace("TAG_NUM_PAGINAS",$num_paginas, $plantilla); $plantilla = str_replace("TAG_PAGINA_ACTUAL",$pagina_actual, $plantilla); // anterior y siguiente $indice_anterior=$desde-PREGUNTAS_WEB_POR_PAGINA; $indice_siguiente=$desde+PREGUNTAS_WEB_POR_PAGINA; $plantilla = str_replace("TAG_ELEMENTO_ANTERIOR",$indice_anterior, $plantilla); $plantilla = str_replace("TAG_ELEMENTO_SIGUIENTE",$indice_siguiente, $plantilla); if ($desde <= 0) $plantilla = preg_replace("/([\S\s]*)/","", $plantilla); if ($indice_siguiente >= $num_pregunta) $plantilla = preg_replace("/([\S\s]*)/", "", $plantilla); // listado de paginas $lista_paginas = ""; $pagina_inicial = 1; $pagina_final = $num_paginas; // si hay mas de 20 paginas, mostrar 10 por delante y por detras de la actual if ($num_paginas > 20) { if ($pagina_actual > 10) $pagina_inicial = $pagina_actual - 10; if ($pagina_actual < ($num_paginas - 10)) $pagina_final = $pagina_actual + 10; } for ($i=$pagina_inicial; $i<=$pagina_final; $i++) { $j = ($i -1)*PREGUNTAS_WEB_POR_PAGINA; if ($i != $pagina_actual) { if ($id == "es") $lista_paginas.="
  • $i
  • "; if ($id == "eu") $lista_paginas.="
  • $i
  • "; if ($id == "en") $lista_paginas.="
  • $i
  • "; if ($id == "fr") $lista_paginas.="
  • $i
  • "; if ($id == "de") $lista_paginas.="
  • $i
  • "; if ($id == "ca") $lista_paginas.="
  • $i
  • "; if ($id == "gl") $lista_paginas.="
  • $i
  • "; } else $lista_paginas.="
  •  $i 
  • "; } $plantilla = str_replace("TAG_LISTA_PAGINAS",$lista_paginas, $plantilla); // quitar la paginacion si hay menos de 2 paginas if ($num_paginas < 2) $plantilla = preg_replace("/([\S\s]*)/", "", $plantilla); // seccion if ($tabla_seccion->existe($se)) { $seccion = $tabla_seccion->obtener($se); $plantilla=str_replace(TAG_Nseccion_VALUE,$seccion->getNseccion(),$plantilla); $plantilla=str_replace(TAG_Tsecc_es_VALUE,$seccion->getTsecc_es(),$plantilla); $plantilla=str_replace(TAG_Tsecc_eu_VALUE,$seccion->getTsecc_eu(),$plantilla); } $plantilla=str_replace(TAG_Nseccion_VALUE,"",$plantilla); $plantilla=str_replace(TAG_Tsecc_es_VALUE,"",$plantilla); $plantilla=str_replace(TAG_Tsecc_eu_VALUE,"",$plantilla); // subseccion if ($tabla_subseccion->existe($su)) { $subseccion = $tabla_subseccion->obtener($su); $plantilla=str_replace(TAG_Nsubsecc_VALUE,$subseccion->getNsubsecc(),$plantilla); $plantilla=str_replace(TAG_Tsubs_es_VALUE,$subseccion->getTsubs_es(),$plantilla); $plantilla=str_replace(TAG_Tsubs_eu_VALUE,$subseccion->getTsubs_eu(),$plantilla); } $plantilla=str_replace(TAG_Nsubsecc_VALUE,"",$plantilla); $plantilla=str_replace(TAG_Tsubs_es_VALUE,"",$plantilla); $plantilla=str_replace(TAG_Tsubs_eu_VALUE,"",$plantilla); $dataBase->desconectar(); echo(mostrarPlantilla($plantilla)); ?>