#!/usr/bin/perl
use strict;
$ENV{DOCUMENT_ROOT}.='/' if $ENV{DOCUMENT_ROOT};
require $ENV{DOCUMENT_ROOT}.'_adm/incs/Generales.pm';
my $ref=Generales::Entrada();
my %para=%$ref;
my $html;
my $linea;
my $check;
my $hoy = time;
my $fotoTapa;
my $epigrafeTapa;
my $idRevista;
my $nombreRevista;
my @Eventos;
require $ENV{DOCUMENT_ROOT}.'_adm/incs/clNota.pm';
require $ENV{DOCUMENT_ROOT}.'_adm/incs/clSeccion.pm';
my $oEvento = clNota->new();
$oEvento->buscar($para{evento});
my $oSeccion = clSeccion->new();
$oSeccion->buscar($oEvento->{idSeccion});
$oSeccion->{cNombreSeccion}="\L$oSeccion->{cNombreSeccion}";
open (ARCHI, $ENV{DOCUMENT_ROOT}.'evento/tpl/'.$oSeccion->{cNombreSeccion}.'.htm')||print $!."- tapa.pl
\n";
while ($linea = ){
$html .= $linea;
}
close ARCHI;
$html =Generales::sacaLineas($html);
my $referencia=$oEvento->{staff};
my @staff=@$referencia;
$html =~ s //$oEvento->{cNombreSeccion}/i;
$html=~ s/()(.*)()/$1$2$3/;
my $staff_html;
my $staff_html2=$2;
my $contador_staff;
foreach (@staff){
if (($oEvento->{idSeccion}==1) && ($$_{idFuncion}==3)){
$contador_staff++;
}
}
if ($contador_staff>5) {
$staff_html.=$staff_html2;
$staff_html=~ s //Artistas varios/gi;
$staff_html=~ s /.?://;
$staff_html=~ s//\/artistas\/varios.pl?evento=$oEvento->{idNota}/gi;
foreach (@staff){
if ($$_{idFuncion}!=3) {
$staff_html.=$staff_html2;
$staff_html=~ s //$$_{Nombre}/;
$staff_html=~ s //$$_{Cargo}/;
$staff_html=~ s//\/personas\/persona.pl?persona=$$_{idPersona}/;
}
}
}else{
foreach (@staff){
$staff_html.=$staff_html2;
$staff_html=~ s //$$_{Nombre}/;
$staff_html=~ s //$$_{Cargo}/;
$staff_html=~ s//\/personas\/persona.pl?persona=$$_{idPersona}/;
};
}
$html=~ s/.*/$staff_html/;
$html =~ s //$oEvento->{idNota}/gi;
$html =~ s //$oEvento->{cVolanta}/i;
$html =~ s //$oEvento->{cTitulo}/i;
$html =~ s //$oEvento->{cCopete}/i;
$html =~ s //$oEvento->{cFechaTxt}/i;
#$oEvento->{cCuerpo} =~ s /\n/
\n/g;
$html =~ s //$oEvento->{cCuerpo}/i;
$html=~ s//$oEvento->{urlFoto}/;
$html=~ s//$oEvento->{epigrafeFoto}/;
$html =~ s //$oEvento->{urlMedia}/gi if $oEvento->{urlMedia};
$html =~ s //\/muestras\/muestras.pl?id=$oEvento->{idNota}&cont=-1/gi if $oEvento->{idCatalogo};
$html =~ s //$oEvento->{cAncho}/gi;
$html =~ s //$oEvento->{cAlto}/gi;
$html=~ s/.*//gi if !$oEvento->{urlMedia}&&!$oEvento->{idCatalogo};
$referencia=$oEvento->{fotos};
my @fotos=@$referencia;
my $contador=0;
my $loop;
foreach (@fotos){
$html=~ s/()(.*)()/$1$2$3/;
my $html2 =$2;
$loop++;
if ($html2 =~ //) {
$contador++;
$html2 =~ s //$$_{Url}/i;
$html2 =~ s //$$_{Epigrafe}/i;
$html=~ s/()(.*)()/$html2/;
}
}
$html=~ s/()(.*)()//gi;
my $contadortotal=$contador;
$contador=0;
my $anterior;
my $align;
foreach (@fotos){
$contador++;
$anterior++;
if ($anterior==1){
$align='left';
}elsif($anterior==2){
$align='right';
#}elsif($anterior==3){
# $align='center' ;
$anterior=0;
}
if ($html =~ /IMAGEN/) {
$html =~ s //
/i;
$contadortotal++;
}
}
$contador=0;
foreach (@fotos){
$html=~ s/()(.*)()/$1$2$3/;
$contador++;
if ($contador>$contadortotal) {
my $html2 =$2.$1.$2.$3;
$html2 =~ s //$$_{Url}/i;
$html2 =~ s //$$_{Epigrafe}/i;
$html=~ s/()(.*)()/$html2/;
}
}
$html=~ s/()(.*)()//gi;
$referencia=$oEvento->{audios};
my @audio=@$referencia;
$html =~ s //$oEvento->{cNombreSeccion}/i;
$html=~ s/()(.*)(.*)()/$1$2$3$4/;
my $audio_html;
my $audio_html2=$3;
$check=0;
foreach (@audio){
$audio_html.=$audio_html2."
";
if($$_{Audio}){$check=1}
$audio_html=~ s//$$_{Audio}/;
$audio_html=~ s//$$_{Epigrafe}/;
};
$html=~ s/()(.*)()/$2/;
if ($check){
$audio_html = $2.$audio_html;
}
$html=~ s/.*/$audio_html/;
$html =~ s //$oEvento->{cNombreSeccion}/i;
$html=~ s/()(.*)(.*)()/$1$2$3$4/;
$referencia=$oEvento->{videos};
my @video=@$referencia;
my $video_html;
my $video_html2=$3;
$check=0;
foreach (@video){
$video_html.=$video_html2."
";
if($$_{Video}){$check=1}
$video_html=~ s//$$_{Video}/;
$video_html=~ s//$$_{Epigrafe}/;
$video_html=~ s//$$_{Enco}/;
};
$html=~ s/()(.*)()/$2/;
if ($check){
$video_html = $2.$video_html;
}
$html=~ s/.*/$video_html/;
$html=~ s/()(.*)(.*)()/$1$2$3$4/;
$referencia=$oEvento->{urls};
my @url=@$referencia;
my $url_html;
my $url_html2=$3;
$check=0;
foreach (@url){
$url_html.=$url_html2."
";
if($$_{Url}){$check=1}
$url_html=~ s//$$_{Url}/;
$url_html=~ s//$$_{Epigrafe}/;
}
$html=~ s/()(.*)()/$2/;
if ($check){
$url_html = $2.$url_html;
}
$html=~ s/.*/$url_html/;
$html=~ s/()(.*)(.*)()/$1$2$3$4/;
$referencia=$oEvento->{notas};
my @nota=@$referencia;
my $nota_html;
my $nota_html2=$3;
$check=0;
foreach (@nota){
$nota_html.=$nota_html2."
";
if($$_{Nota}){$check=1}
$nota_html=~ s//$$_{Nota}/;
$nota_html=~ s//$$_{Titulo}/;
}
$html=~ s/()(.*)()/$2/;
if ($check){
$nota_html = $2.$nota_html;
}
$html=~ s/.*/$nota_html/;
$html=~ s/()(.*)(.*)()/$1$2$3$4/;
$referencia=$oEvento->{horarios};
my @horario=@$referencia;
my $horario_html;
my $horario_html2=$3;
$check=0;
foreach (@horario){
$horario_html.=$horario_html2;
if($$_{HorarioIn}){$check=1}
if ($oEvento->{idSeccion}==1||$oEvento->{idSeccion}==3) {
$$_{HorarioIn}=&FechaMuestras($$_{HorarioIn});
$$_{HorarioOut}=&FechaMuestras2($$_{HorarioOut});
}else{
$$_{HorarioIn}=&FechaCiclos($$_{HorarioIn});
$$_{HorarioOut}="";#&FechaCiclos($$_{HorarioOut});
}
$horario_html=~ s//$$_{HorarioIn}/;
$horario_html=~ s//$$_{HorarioOut}/;
$horario_html=~ s//$$_{Descripcion}/;
}
$html=~ s/()(.*)()/$2/;
if ($check){
$horario_html = $2.$horario_html;
}
$html=~ s/.*/$horario_html/;
$html=~ s/()(.*)(.*)()/$1$2$3$4/;
$referencia=$oEvento->{salas};
my @sala=@$referencia;
my $sala_html;
my $sala_html2=$3;
$check=0;
foreach (@sala){
$sala_html.=$sala_html2;
if($$_{Sala}){$check=1}
$sala_html=~ s//$$_{idSala}/;
$sala_html=~ s//$$_{urlFoto}/;
$sala_html=~ s//$$_{Epigrafe}/;
$sala_html=~ s//$$_{Nombre}/;
$sala_html=~ s//$$_{Descripcion}/;
$sala_html=~ s//$$_{Direccion}/;
$sala_html=~ s//$$_{Localidad}/;
$sala_html=~ s//$$_{Provincia}/;
$sala_html=~ s//$$_{Pais}/;
}
$html=~ s/()(.*)()/$2/;
if ($check){
$sala_html = $2.$sala_html;
}
# $sala_html = substr $sala_html, 0,((length $sala_html)-3);
$html=~ s/.*/$sala_html/;
$html=~ s/()(.*)(.*)()/$1$2$3$4/;
my $criticas_html2=$3;
$referencia=$oEvento->{criticas};
my @criticas=@$referencia;
my $criticas_html;
$check=0;
foreach (@criticas){
$criticas_html.=$criticas_html2;
if($$_{Critica}){$check=1}
#$html.=$criticas_html2;
$criticas_html=~ s//$$_{Critica}/;
$criticas_html=~ s//$$_{Titulo}/;
$$_{Cuerpo} = substr $$_{Cuerpo}, 0,80;
$$_{Cuerpo} =~ s /\n/
\n/g;
$criticas_html=~ s//$$_{Cuerpo}/;
$criticas_html=~ s//$$_{Autor}/;
$criticas_html=~ s//$$_{idPersona}/;
#$html.=%$_;
}
$html=~ s/()(.*)()/$2/;
if ($check){
$criticas_html = $2.$criticas_html;
}
$html=~ s/.*/$criticas_html/;
$html=~ s/()(.*)(.*)()/$1$2$3$4/;
$referencia=$oEvento->{auspiciantes};
my @auspiciante=@$referencia;
my $auspiciante_html;
my $auspiciante_html2=$3;
$check=0;
foreach (@auspiciante){
if (!$check) {
$auspiciante_html.=$auspiciante_html2;
if($$_{Auspiciante}){$check=1}
$auspiciante_html=~ s//$$_{idAuspiciante}/;
$auspiciante_html=~ s//$$_{urlFoto}/;
$auspiciante_html=~ s//$$_{Epigrafe}/;
$auspiciante_html=~ s//$$_{Nombre}/;
my $linkabre;
my $linkcierre;
if (!$$_{Link}) {
$$_{Link}="#";#\" onmousedown='alert(\"El auspiciante no posee un sitio relacionado\")'";
}else{
$linkabre = qq~~;
$linkcierre = qq~~;
}
$auspiciante_html=~ s//$linkabre/;
$auspiciante_html=~ s//$linkcierre/;
$auspiciante_html=~ s//$$_{Link}/;
}
}
$html=~ s/()(.*)()/$2/;
if ($check){
$auspiciante_html = $2.$auspiciante_html;
}
$html=~ s/.*/$auspiciante_html/;
$html=~ s/()(.*)(.*)()/$1$2$3$4/;
$referencia=$oEvento->{obras};
my @obra=@$referencia;
my $obra_html;
my $obra_html2=$3;
$check=0;
foreach (@obra){
$obra_html.=$obra_html2."
";
if($$_{Obra}){$check=1}
$obra_html=~ s//$$_{Obra}/;
$obra_html=~ s//$$_{Titulo}/;
}
$html=~ s/()(.*)()/$2/;
if ($check){
$obra_html = $2.$obra_html;
}
$html=~ s/.*/$obra_html/;
if (!$oEvento->{urlPrensa}) {
$html=~ s/()(.*)()/\ \;/gi;
}
my $HayMedia;
$HayMedia = 0;
$_ = $oEvento->{fotos};
if ($$_[0]) {
$HayMedia = 1;
}
$_ = $oEvento->{audios};
if ($$_[0]) {
$HayMedia = 1;
}
$_ = $oEvento->{videos};
if ($$_[0]) {
$HayMedia = 1;
}
$_ = $oEvento->{urls};
if ($$_[0]) {
$HayMedia = 1;
}
$_ = $oEvento->{urls};
if ($$_[0]) {
# $HayMedia = 1;
}
$_ = $oEvento->{notas};
if ($$_[0]) {
# $HayMedia = 1;
}
if($contador_staff>1&&$HayMedia){
my $LinkMedia="/mmedia/frm.pl?e=$oEvento->{idNota}&p=virtual.htm";
$html=~ s//$LinkMedia/gi;
}elsif (-e 'media\m'.$oEvento->{idNota}.'\m'.$oEvento->{idNota}.'.htm') {
#my $t = 'media\m'.$oEvento->{idEvento}.'.htm';
my $LinkMedia="/media/m$oEvento->{idNota}/m$oEvento->{idNota}.htm";
$html=~ s//$LinkMedia/gi;
}else{
$html=~ s/()(.*)()/\ \;/gi;
}
$html =Generales::procesarDinamico($html);
$html =Generales::poneLineas($html);
Generales::imprimir($html);
############################################################################################################
sub Fecha{
#Variables para la fecha
my $fecha;
my $ahora = shift;
if ($ahora){
my $semdia = ('Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado')[(localtime($ahora))[6]];
my $mes = ('Enero','Febrero','Marzo','Abril','Mayo', 'Junio','Julio','Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre')[(localtime($ahora))[4]];
my $mesdia = (localtime($ahora))[3];
my $anio = (localtime($ahora))[5] + 1900;
$fecha = "$semdia $mesdia de $mes de $anio";
}
return $fecha;
}
sub FechaCiclos{
#Variables para la fecha
my $fecha;
my $ahora = shift;
if ($ahora){
my $semdia = ('Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado')[(localtime($ahora))[6]];
my $mes = ('Enero','Febrero','Marzo','Abril','Mayo', 'Junio','Julio','Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre')[(localtime($ahora))[4]];
my $mesdia = (localtime($ahora))[3];
my $anio = (localtime($ahora))[5] + 1900;
$fecha = "$semdia $mesdia de $mes de $anio";
my $min = (localtime($ahora))[1];
if (length $min<2) { $min='0'.$min;}
if ($min>0) {
$min=":$min";
}else{
$min="";
}
my $hora = (localtime($ahora))[2];
my $nMes;
if ((localtime($ahora))[4]!=(localtime(time))[4]) {
$nMes=" de ".$mes;
}
$fecha = "$semdia $mesdia$nMes, $hora$min Hs.";
}
return $fecha;
}
sub FechaMuestras{
#Variables para la fecha
my $fecha;
my $ahora = shift;
if ($ahora){
my $semdia = ('Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado')[(localtime($ahora))[6]];
my $mes = ('Enero','Febrero','Marzo','Abril','Mayo', 'Junio','Julio','Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre')[(localtime($ahora))[4]];
my $mesdia = (localtime($ahora))[3];
my $anio = (localtime($ahora))[5] + 1900;
$fecha = "$semdia $mesdia de $mes de $anio";
my $min = (localtime($ahora))[1];
if (length $min<2) { $min='0'.$min;}
if ($min>0) {
$min=":$min";
}else{
$min="";
}
my $hora = (localtime($ahora))[2];
$fecha = "$mesdia de $mes";
}
return $fecha;
}
sub FechaMuestras2{
#Variables para la fecha
my $fecha;
my $ahora = shift;
if ($ahora){
my $semdia = ('Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado')[(localtime($ahora))[6]];
my $mes = ('Enero','Febrero','Marzo','Abril','Mayo', 'Junio','Julio','Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre')[(localtime($ahora))[4]];
my $mesdia = (localtime($ahora))[3];
my $anio = (localtime($ahora))[5] + 1900;
$fecha = "$semdia $mesdia de $mes de $anio";
my $min = (localtime($ahora))[1];
if (length $min<2) { $min='0'.$min;}
if ($min>0) {
$min=":$min";
}else{
$min="";
}
my $hora = (localtime($ahora))[2];
$fecha = "$mesdia de $mes de $anio";
}
return $fecha;
}