<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>Ajax Script4All - www.bei123.de - Alles aus baseportal herausholen</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript"><script type="text/javascript" language="JavaScript">function _display(x){eval(x);}</script>
</head>
<body>
<perl>
################################################################################### siehe 1.) bis 5.)
&DEFINITIONEN();# !!!! die Subroutine hier als Erstes stehen lassen !!!!
#################
#........................................................... 1.) Name des baseportal Accounts anpassen
$my_Baseportal_ = "/bei123/" ; # Name des EIGENEN baseportal Miet- oder Kostenlos-Accounts !!!!!!!!!!
#........................................................... 2.) $IntroMessage ggf. ändern/löschen
$IntroMessage ="Wählen Sie aus dem Menü aus ! <h2>...Demo</h2> <center><p>Frohe Weihnachten wünscht Euch allen <i>Harald Fehde</i></p></center>";
#........................................................... 3.) Name Datei-Pseudonyme anpassen
#- Über Pseudonyme werden entsprechende Links zum Auruf generiert !!!
#- Datenbank-Verzeichnisse im Menü (siehe 5.) mit $show{BaseLink}->('Pseudonym') abrufbar.
%Datei =
(
"Autos" => $my_Baseportal_."AUTO/Autos",
"Hersteller" => $my_Baseportal_."AUTO/Autohersteller",
"Werkstatt" => $my_Baseportal_."AUTO/Ersatzteile",
);
#............................................................ 4.) diverse eigene Relationen festlegen
# ACHTUNG: die Datei 'Werkstatt' hat eine baseportal-Relation,
# deshalb "AutoTyp==*" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# baseportal hier seine "Schwäche"
##############################################################
%Relationen =
(
"Hersteller" => {
"HerstellerAutos" => [$Datei{'Autos'},"Hersteller==Hersteller"],
},
"Autos" => {
"Typen_ErsatzTeile" => [$Datei{'Werkstatt'},"AutoTyp==Id"],
"HerstellerAdresse" => [$Datei{'Hersteller'},"Hersteller==Hersteller"],
"Alle_HerstellerAutos" => [$Datei{'Autos'},"Hersteller==Hersteller"],
},
"Werkstatt" => {
"Gleichartige_Ersatzteile" => [$Datei{'Werkstatt'},"Ersatzteil==Ersatzteil"],
},
);
#.......................................................... 5.) Das Menü mit $show{BaseLink}->('Pseudonym')
# definieren
out "<b>Menü</b> ".$show{BaseLink}->('Autos')." ".$show{BaseLink}->('Hersteller')." ".$show{BaseLink}->('Werkstatt');
out ' ..................... (siehe <a href=" http://baseportal.de/cgi-bin/baseportal.pl?show=/bei123/_script4all" target="_BLANK"><b><Code></b></a> - Programm von H.Fehde & Dank an <i>Sander</i>)'; #........................................................... 6.) dies obige out LÖSCHEN !!!!!!!!!!!!!!!!
out "<div id='_BASE' style='border:1px solid silver'>$IntroMessage</div>"; ## siehe 2.)
#-------------------------------------------------------------------------------------------------------
############################## man darf auch selber weitermachen - DEMO !!!!!!!
$SO_WEIT_SO_GUT="<font size=4 color=red>So weit, so gut.... DEMO !</font><br>Folgende <b>Variablen</b> liegen bis hier vor:<br>";
$SO_WEIT_SO_GUT.="(<b>\$div</b>=[$div], <b>\$pseu</b>=[$pseu], <b>\$db</b>=[$db], <b>\$id</b>=[$id], <b>\$sort</b>=[$sort], <b>\$get</b>=[$get], <b>\$display</b>=[$display], <b>\$sel</b>=[$sel], <b>\$more</b>=[$more] )<br>";
$SO_WEIT_SO_GUT.="<font size=4 font color=blue>... selbst ist der Mann / die Frau ....... ;-) </font><br><center>Mit freundlichen ".convert_html('Grüßen')."<br><i>Harald Fehde</i></center>";
#################################################################################### Variablen und Subs
# ACHTUNG: AB HIER NU ÄNDERN, wenn SIE das Programm
# verstanden haben !!!!!!!!!!!!!!!!!!!!!!!
########################################################################################################
%MY_PSEUDONYME=reverse(%Datei); # ??? >-------> von $db auf eindeutiges Pseudonym rückschließen
sub DEFINITIONEN
{################################# --------------------------------------- MENÜLINKS generieren
%show =
(
BaseLink => sub{my $BL=convert_html($_[0]);return qq{<a name="$BL" onclick='display("div=_BASE&pseu="+this.name+"&db=$Datei{$BL}&id=&sort=&get=&display=")' style="padding:1px;border:2px solid silver;border-bottom:1px solid #ffffff;background-color:#f0f0f0;color:blue;font-weight:normal;cursor:pointer" onMouseOver=(this.style.backgroundColor="#ffffff",this.style.color="#000000",this.style.fontWeight="normal") onMouseOut=(this.style.backgroundColor="#f0f0f0",this.style.color="blue",this.style.fontWeight="normal")> $BL </a>}},
);
}#################################
sub MY_BASE_INNER_HTML
{#################################
($pseu,$db,$id,$sort,$get,$display,$sel,$more)=@_;
#---------------------------------------------
$MY__BASE="";
$my_display=($div eq "_BASE" ? "_MORE":$div);
#-------------------------------------------------------------------------------------------- AnwendungLink
$_Anwendung="<a onclick=(display('div=".$my_display."&pseu=".$pseu."&db=".$db."&id=".$id."&sort=".$sort."&get=Anwendung&display=".$div."')) style='color:blue;font-weight:bold;cursor:pointer'>Anwendung</a>";
$_Relationen="<a onclick=(display('div=".$my_display."&pseu=".$pseu."&db=".$db."&id=".$id."&sort=".$sort."&get=Relationen&display=".$div."')) style='color:blue;font-weight:bold;cursor:pointer'>Relationen</a> ";
#------------------------------------------------- ggf. weitere Links je nach Pseudonym, falls id nicht LEER
#--------------------------------------------------------------------------------------------------------
my $more_aktion=($id ne "" ? "Datensatz" : "Datenbank");
my $m_aktion="<a onclick=(display('div=".$my_display."&pseu=".$pseu."&db=".$db."&id=".$id."&sort=".$sort."&get=".$more_aktion."&display=".$div."')) style='color:blue;font-weight:bold;cursor:pointer'>$more_aktion</a>";
#--------------------------------------------------------------------------------------------------------
$_Auswahl_Darstellung="";
#########################
if($id ne "")
{#--------------------------------------- also EIN Datensatz angezeigt
if(keys(%{$Relationen{$pseu}})>0)
{#--------------------------------------- falls stimmige Relationen festgelegt
foreach(keys(%{$Relationen{$pseu}}))
{#*************************************** wie in Hash %MY_MORE "MyRelationen" => sub aufrufen
$_Auswahl_Darstellung.="<a onclick=(display('div=_MORE&pseu=".convert_html($pseu)."&db=".$db."&id=".$id."&sort=".$sort."&get=Relation&display=_BASE&more=".convert_html($_)."')) style='color:blue;font-weight:bold;cursor:pointer'>".convert_html($_)."</a> | ";
}#***************************************
}
}
#------------------------------------------------------------------------------------------------------
$my__ID="Id(<span style='font-weight:bold;background-color:aliceblue'>$id</span>) " if($id ne "");
$my__SORT="Sort(<span style='font-weight:bold;background-color:aliceblue'>$sort</span>) " if($sort ne "");
#------------------------------------------------------------------------------------------------------
$MY__BASE.="<div style='width:100%;border-top:1px solid silver;border-bottom:1px solid silver'>";
$MY__BASE.="<div style='width:50%;float:left'>$m_aktion <b>".$pseu." ".$MY_PESUDONYME{$db}."</b> $my__ID $my__SORT</div>";
$MY__BASE.="<div style='width:49.99%;float:left;text-align:right;color:silver'>$_Anwendung | $_Relationen</div>";
$MY__BASE.="<div style='width:0.01%;clear:left'></div>";
$MY__BASE.="</div>";
#-------------------------------------------------------------------------------------------------------
$MY__BASE.=&MY_INNER_BASE($pseu,$db,$id,$sort,$get,$display,$sel);
$MY__BASE.="<div style='border-top:1px solid silver;background-color:#ffffff;color:silver'>$_Auswahl_Darstellung</div>";
$MY__BASE.="<div id='_MORE' style='border-bottom:0px solid silver;border-top:1px solid silver;'></div>";
#--------------------------------------------------------------------------------------------------------
return($MY__BASE);
}#################################
sub MY_MORE_INNER_HTML
{#####################
($pseu,$db,$id,$sort,$get,$display,$sel,$more)=@_;
#----------------------------------------------------- nachfolgend ein close-"Button"
$MY_RETURN_MORE="<div style='background-color:#d0d0d0;border-bottom:1px solid #808080;border-right:1px solid #808080;border-top:1px solid #ffffff;border-left:1px solid #ffffff;text-align:center;color:#d80000;font-weight:bold;cursor:pointer;font-size:0.8em' onclick=(display('div=".$display."&pseu=".$pseu."&db=".$db."&id=".$id."&sort=".$sort."&get=".$get."&display=".$display."&more=".$more."')) style=''> « ---------- close -------- » </div>";
#................................................... verschiedene Erweiterungs-Möglichkeiten offen lassen
# %MY_MORE also als sub ergänzen/definieren
%MY_MORE =
(
Anwendung => &MY_ANWENDUNG_AKTION($pseu,$db,$id,$sort,$get,$display,$sel,$more),
Relationen => &MY_RELATIONEN_AKTION($pseu,$db,$id,$sort,$get,$display,$sel,$more),
Datensatz => &MY_DATENSATZ($pseu,$db,$id,$sort,$get,$display,$sel,$more),
Datenbank => &MY_DATENBANK($pseu,$db,$id,$sort,$get,$display,$sel,$more),
Sonstiges => " ",
Weiteres => " ",
E_N_D_E => " !!! MY_DATENBANK_RELATIONEN muss der letzte key im Hash sein !!! ",
Relation => &MY_DATENBANK_RELATION($pseu,$db,$id,$sort,$get,$display,$sel,$more),
);
#--------------------------------------------------------------------------------------------------------
$MY_MORE{$get}=$MY_MORE{$get}||"<font color='red'><b>Achtung</b></font> : HashWert <b>\$MY_MORE{$get}</b> in <b>sub MY_MORE_INNER_HTML</b> (bisher) nicht deniert";
$MY_RETURN_MORE.=$MY_MORE{$get};
return($MY_RETURN_MORE);
}#####################
sub MY_DATENBANK_RELATION
{########################
($pseu,$db,$id,$sort,$get,$display,$sel,$more)=@_;
#------------------------------------
$SQL=${$Relationen{$pseu}{$more}}[1];
$DB=${$Relationen{$pseu}{$more}}[0];
@SQL=split(/==/,$SQL);
#------------------------------------
get "Id==$id","$db";
#%DETAIL=%_raw; #------------------------------------------- DA KANN MAN DO NOCH MEHR DRAUS MACHEN ?!
my $Value=$_raw{$SQL[1]};
my $Field=$SQL[0];
$Value=~ s/ /\\ /gi;
$sel="$Field==!$Value";
#------------------------------------
$FILTER{Wert}=$Value;
$FILTER{Feld}=$Field;
$FILTER{DB}=$DB;
#------------------------------------
$pseu=$MY_PSEUDONYME{$DB} if($sel ne "");
&MY_INNER_BASE($pseu,$DB,"",$sort,$get,"_BASE",$sel,$more);
}##############################################################################
sub MY_INNER_BASE_OLD
{#############################################
($pseu,$db,$id,$sort,$get,$display,$sel,$more)=@_;
#------------------------------------------------------------- Datei $db einlesen/auswerten
&MY_DB_INFO($pseu,$db,$id,$sort,$get,$display,$more);
#------------------------------------------------------------- Daten der $db ausgeben
my $height=($id ne "" ? "4em" : "16em");
$ausgabe.="<div style='height:$height;overflow:auto;background-color:#f0f0f0'><table cellpadding=3 cellspacing=2 style='border:0px solid #ffffff;width:90%'><tr>";
#---------------------------------------------------------------------- Sortierung ?
if($id ne "" or $sel ne "")
{
map{$ausgabe.="<td><b>".convert_html($_)."<b></td>"}(@{$DBF{Field}});
}
else
{
map{$ausgabe.=&MY_SORTIERUNG($_,$pseu,$db,$id,$sort,$get)}(@{$DBF{Field}});
}
$ausgabe.="</tr>";
#----------------------------------------------------------------------------------
get "Id==$id sort=$sort $sel","$db","DB";
#------------------------------
while(get_next("DB"))
{#***************************************** falls Relationsfeld vorhanden, dann Link
my $satz="";
map{$satz.=($RW{$_} ne "" ? "<td>".&MY_SATZ_LINK(" ® ".convert_html($RW{$_}{$_raw{$_}}),$MY_PSEUDONYME{$my_Baseportal_.$R{$_}[2]},"$my_Baseportal_".$R{$_}[2],$_raw{$_},$sort,$get,$display)."</td>" : (($_ eq "Id" ? ($id ne "" ? "<td bgcolor='#ffffff'>".convert_html($_raw{$_})."</td>" : "<td bgcolor='#ffffff'>".&MY_SATZ_LINK("<b>$_id</b>",$pseu,$db,$_raw{$_},$sort,$get,$display)."</td>") : "<td>".convert_html($_raw{$_})."</td>")) )}(@{$DBF{Field}});
$ausgabe.="<tr>$satz</tr>";
}#**********************************************************************************
$ausgabe.="</table></div>";
#----------------------------------------------
@{$DBF{Field}}="";
return($ausgabe);
}#############################################
sub MY_INNER_BASE
{#############################################
($pseu,$db,$id,$sort,$get,$cmd,$sel,$more)=@_;
#------------------------------------------------------------- Datei $db einlesen/auswerten
&MY_DB_INFO($pseu,$db,$id,$sort,$get,$cmd,$more);
#------------------------------------------------------------- Daten der $db ausgeben
my $key=$FILTER{Feld};
my $val=$FILTER{Wert};
my $fdb=$FILTER{DB};
my $Frage_relaton="";
#------------------------------------------------------------------------------- baseportal-Relation ?
#
#
map{$Frage_Relation.=($RW{$_} ne "" ? "<div style='font-size:0.8em;text-align:left'>AuswahlListe, da <b> ® <a href='http://doku.baseportal.de/35.html' target='_BLANK'>baseportal-Relation</a><sup>1.)</sup></b> </div>" : "")}(@{$DBF{Field}})if($id eq "" and $sel ne "");
#
#
#----------------------------------------------------------------- Höhe anpassen, wenn nur 1 Datensatz
my $height=($id ne "" ? "5em" : "16em");
$ausgabe.="<div style='height:$height;overflow:auto;background-color:#f0f0f0'>";
$ausgabe.=$Frage_Relation."<table cellpadding=3 cellspacing=2 style='border:0px solid #ffffff;width:90%'><tr>";
#---------------------------------------------------------------------------------------- Sortierung ?
if($id ne "" or $sel ne "")
{
map{$ausgabe.="<td><b>".convert_html($_)."<b></td>"}(@{$DBF{Field}});
}
else
{
map{$ausgabe.=&MY_SORTIERUNG($_,$pseu,$db,$id,$sort,$get,$cmd,$more)}(@{$DBF{Field}});
}
$ausgabe.="</tr>";
#----------------------------------------------------------------------------------
if($Frage_Relation eq "")
{######################################## keine bp-Relation
get "Id==$id sort=$sort $sel","$db","DB";
while(get_next("DB"))
{#***************************************** falls Relationsfeld vorhanden, dann Link
my $satz="";
map{$satz.=($RW{$_} ne "" ? "<td>".&MY_SATZ_LINK(" ® ".convert_html($RW{$_}{$_raw{$_}}),$MY_PSEUDONYME{$my_Baseportal_.$R{$_}[2]},"$my_Baseportal_".$R{$_}[2],$_raw{$_},$sort,$get,$cmd)."</td>" : (($_ eq "Id" ? ($id ne "" ? "<td bgcolor='#ffffff'>".convert_html($_raw{$_})."</td>" : "<td bgcolor='#ffffff'>".&MY_SATZ_LINK("<b>$_id</b>",$pseu,$db,$_raw{$_},$sort,$get,$cmd)."</td>") : "<td>".convert_html($_raw{$_})."</td>")) )}(@{$DBF{Field}});
$ausgabe.="<tr>$satz</tr>";
}#**********************************************************************************
$ausgabe.="</table>".($_amount<1 ? "<center><font color=red size=4>Noch kein Datensatz eingegeben !!</font></center>":"");
}#Ende if
else
{####################################### bp-Relation
get "Id==$id sort=$sort","$db","DB";
my $treffer=0;
while(get_next("DB"))
{#***************************************** falls Relationsfeld vorhanden, dann Link
if($$key eq "$val")
{##################
$treffer++;
my $satz="";
map{$satz.=($RW{$_} ne "" ? "<td> ® ".convert_html($RW{$_}{$_raw{$_}})."</td>" :(($_ eq "Id" ?($id ne "" ? "<td bgcolor='#ffffff'>".convert_html($_raw{$_})."</td>":"<td bgcolor='#ffffff'>".&MY_SATZ_LINK("<b>$_id</b>",$pseu,$db,$_raw{$_},$sort,$get,$cmd)."</td>"):"<td>".convert_html($_raw{$_})."</td>")))}(@{$DBF{Field}});
$ausgabe.="<tr>$satz</tr>";
}##################
}#**********************************************************************************
$ausgabe.="</table>".($treffer<1 ? "<center><font color=red size=4>Noch kein Datensatz eingegeben !!</font></center>":"");
}#ende else
$ausgabe.="</div>";
@{$DBF{Field}}="";
return($ausgabe);
}#############################################
sub MY_SATZ_LINK
{###############################################################
my ($LABEL,$__pseu,$__db,$__id,$__sort,$__get,$__display,$__sel)=@_;
#--------------------------------------------------------
my $___L="";
$___L="<a onclick=display('div=_BASE&pseu=".$__pseu."&db=".$__db."&id=".$__id."&sort=&get=".$__get."&display=".$__display."&sel=".$__sel."') style='cursor:pointer;color:blue'>$LABEL</a>";
return($___L);
}###############################################################
sub MY_DB_INFO
{#############
($pseu,$db,$id,$sort,$get,$display)=@_;
#----------------------------------
get "Id==*","$db.fields","DBF"; #................ $db-Struktur
@FP{@{$DBF{Field}}}=@{$DBF{Params}};#................ FeldParameter der $db
@FI{@{$DBF{Field}}}=@{$DBF{Index}}; #................ FeldIndex der $db
#.................................................... relevante IndexFelder von $db
%I=map{$_ => $FI{$_}}keys(%FI);
#.................................................... levante RelationsFelder von $db herausfiltern
%R=map{$_ => [(split(/#/,$FP{$_}))]}(grep{index($FP{$_},"#Relation#")>=0}keys(%FP));
#---------------
if(keys(%R)>0)
{#............ falls mindestens 1 Relationsfeld vorhanden
foreach(keys(%R))
{#************
$NN="$_"; #.................. RelationsFeld
$NF="$R{$_}[3]"; #.................. RelationsFeld-DateiFeld
$NDB="$R{$_}[2]"; #.................. RelationsDatei
get "$NF==*","$NDB","$_";
@NN{@{$$NN{Id}}}=@{$$NN{$NF}}; #.................. RelationsDatei-Werte
$RW{$NN}=\%NN; #.................. RelationsFeld-Hash{Datei-Werte} erstellen
}#************
}#
}#############
sub MY_SORTIERUNG
{################
($FIELD,$__pseu,$__db,$__id,$__sort,$__get,$__display)=@_;
#-----------------------------------------------------
my $___L="";
$LABEL=convert_html($FIELD);
#----------------
if($RW{$_} ne "")
{#.................................................... Hash Relation ?
$___L="<td><a style='color:black;'><b><i>$LABEL</i></b> <sup>1.) 2.)</sup></a></td>";
}
else
{#..................................................... Prüfen, was IndexFelder sind
if($I{$_}ne "")
{#..................................................... falls Indexfeld = Sorter (+)(-) ausgeben
my $bg=($_ eq "Id" ? "bgcolor='#ffffff'":"");
$___L="<td $bg><b>$LABEL<b> <a onclick=display('div=_BASE&pseu=".$__pseu."&db=".$__db."&id=&sort=".$FIELD."&get=".$__get."&display=".$__display."') style='cursor:pointer;color:green;'><b>[+]</b></a> <label onclick=display('div=_BASE&pseu=".$__pseu."&db=".$__db."&id=&sort=-".$FIELD."&get=".$__get."&display=".$__display."') style='cursor:pointer;color:red;'><b>[-]</b></label></td>";
}
else
{#...................................................... KEIN Indexfeld = kein Sorter
$___L="<td><a style='color:black;'><b><i>$LABEL</i></b> <sup>2.)</sup></a></td>";
}#
}
return($___L);
}########################################
sub MY_DATENBANK
{###############
($pseu,$db,$id,$sort,$get,$display,$sel,$more)=@_;
#----------------------------------------------
$test="$SO_WEIT_SO_GUT";
}###############
sub MY_DATENSATZ
{###############
($pseu,$db,$id,$sort,$get,$display,$sel,$more)=@_;
#----------------------------------------------
$test="$SO_WEIT_SO_GUT";
}###############
sub MY_ANWENDUNG_AKTION
{########################################
($pseu,$db,$id,$sort,$get,$display,$sel,$more)=@_;
#--------------------------------------------------
&MY_DB_INFO($pseu,$db,$id,$sort,$get,$display,$sel,$more);
#---------------------------------------------
$zu_Index="<b>Anwendung</b> <font color='blue'><i>$pseu</i></font> - die <i>Datenbank</i> <b><a href='baseportal.pl?htx=$db' target='_BLANK'>$db</a></b> hat folgende <b>Felder</b>: <ul>";
foreach(@{$DBF{Field}})
{#*********************
my $rf=($RW{$_} ne "" ? " Hinweis <b>1.)</b> <font color='blue'>Relationsfeld</font>" : "");
my $ix=($I{$_} eq "" ? " Hinweis <b>2.)</b> <font color='red'>kein Index</font>" : " IndexTyp: <b>$I{$_}</b>");
$zu_Index.="<li><b>$_</b> $rf $ix</li>";
}#*********************
$zu_Index.="</ul>";
@{$DBF{Field}}="";
#---------------------------------------------
my $info="";
$info.="$zu_Index";
}##############################################################################
sub MY_RELATIONEN_AKTION
{########################
($pseu,$db,$id,$sort,$get,$display,$sel,$more)=@_;
#-----------------------------------------------------
my $my_info="<b>Relationen</b> zur <i>Anwendung</i> <font color='blue'><i>$pseu</i></font> mit der <i>Datenbank</i> <b>$db</b> :<ul>";
#------------------------------------------
my @Relationen=keys(%{$Relationen{$pseu}});
foreach(@Relationen)
{#*********************
$my_info.="<li><b>$_</b></li>";
}#*********************
$my_info.="</ul>";
$my_info="<center><h3>.....kein Wert <b>\$Relationen{$pseu}</b> in %Relationen definiert !</h3></center>" if(@Relationen<1);
my $info="";
$info.="$my_info";
}###
sub _BASE
{########
($pseu,$db,$id,$sort,$get,$display,$more,$sel)=@_;
$MY_BASE_INNER_HTML=&MY_BASE_INNER_HTML($pseu,$db,$id,$sort,$get,$display,$more,$sel);
return(qq|document.getElementById("_BASE").innerHTML="$MY_BASE_INNER_HTML";|);
}########
sub _MORE
{########
($pseu,$db,$id,$sort,$get,$display,$more,$sel)=@_;
$MY_MORE_INNER_HTML=&MY_MORE_INNER_HTML($pseu,$db,$id,$sort,$get,$display,$more,$sel) if($get ne "");
return(qq|document.getElementById("_MORE").innerHTML="$MY_MORE_INNER_HTML";|);
}########
sub script
{#########
out &$div($pseu,$db,$id,$sort,$get,$display,$more,$sel);
}#########
</perl></body></html><perl script=display>&script();</perl>
<div style="display:block"><center><banner type="banner"></center></div>