Code /
Part5
| sub SplitUrlPunct {
my ($url)=@_;
my ($punct);
if($url =~ s/\"\"$//) {
return ($url,"");
}
$punct = "";
if($url =~ /^news:/) {
($punct) = ($url =~ /([^\+a-zA-Z0-9\/\xc0-\xff]+)$/);
$url =~ s/([^\+a-zA-Z0-9\/\xc0-\xff]+)$//;
} else {
($punct) = ($url =~ /([^a-zA-Z0-9\/\xc0-\xff]+)$/);
$url =~ s/([^a-zA-Z0-9\/\xc0-\xff]+)$//;
}
return ($url, $punct);
}
sub StripUrlPunct {
my ($url)=@_;
my ($junk);
($url, $junk) = SplitUrlPunct($url);
return $url;
}
sub GetBracketUrlIndex {
my ($id)=@_;
if($SaveUrlNum{$id}>0) {
return $SaveUrlNum{$id};
}
$SaveUrlNumIndex++; # Start with 1
$SaveUrlNum{$id} = $SaveUrlNumIndex;
return $SaveUrlNumIndex;
}
sub StoreBracketInterWikiPage {
my ($iwp)=@_;
my ($url,$index,$link);
$url=InterWikiPageRetUrl($iwp);
$index=GetBracketUrlIndex($iwp);
$link=UrlLabelClassTitleTargetRetLink($url,"[$index]",'body');
return StoreRaw($link);
}
sub PageRetLogoDec {
my ($id)=@_;
my ($LogoImage,$header,$action);
if($LogoUrl ne "") {
$LogoImage = "img src='$LogoUrl' alt='[Home]' border='0'";
if(UserHasStatus($NeedStatusAdmin)) {
$action="edit=" . $id;
} else {
$action="action=HomePage";
}
$header = ActionLabelClassIdTargetTitleRetLink($action,"<$LogoImage>","");
}
return $header;
}
sub WikiRetFormSearchMini {
my $ret=FormStart("form_search",'');
$ret.=Lu("Search|Suchbegriff|Cherche|Buscar") . ": " . FormText('search','',20);
$ret.=" " . Lu("in|gesucht wird|dans|en") . " " . FormCheck('title',1,Lu('title|im Titel|title|título'));
$ret.=" " . FormCheck("text",1,Lu('text|im Text|text|texto'));
$ret.=FormEnd();
return $ret;
}
sub FormCheckHelper {
my ($p_opt,$p_hid,$ident,$label,$val,$defval)=@_;
my ($numval);
if($val eq 'on' || $val eq 'off') {
$$p_hid .= FormNameValueHidden($ident,$val) . "\n";
} else {
if($val eq '') {
$val=$defval;
}
$numval = ($val>0) ? 1 : 0;
$$p_opt .= ' ' . FormCheck($ident,$numval,$label);
}
}
sub ParsRetVal {
my $object=shift;
my $ret;
foreach (@_) {
$ret=RetParam($_);
if($ret ne '') {
goto do_ret;
}
}
if($ret eq '') {
$ret= $object;
}
do_ret:
return $ret;
}
sub HvnRetVal {
my($h_pars,$object,$var1,$var2,$var3,$var4)=@_;
my $ret=$$h_pars{$var1};
if($ret eq '') {
$ret=$$h_pars{$var2};
if(($ret eq '') && ($var3 ne '')) {
$ret=$$h_pars{$var3};
if(($ret eq '') && ($var4 ne '')) {
$ret=$$h_pars{$var4};
}
}
}
if($ret eq '') {
$ret= $object;
}
return $ret;
}
sub HvnRetColor { # hash, default, ...
my $ret=HvnRetVal(@_);
if(substr($ret,0,1) ne '#') {
$ret=ColorDefaultRetCode($ret,$_[1]);
}
return $ret;
}
sub HvnHeight { return HvnRetVal(@_,"Höhe",Unicode("Höhe"),'height'); }
sub HvnWidth { return HvnRetVal(@_,'Breite','width'); }
sub HvnSize { return HvnRetVal(@_,"Größe",Unicode("Größe"),'size'); }
sub HvnSelect { return HvnRetVal(@_,'','select'); }
sub HvnFilter { return HvnRetVal(@_,'','filter'); }
sub WikiRetFormSearch {
my ($h_pars)=@_;
my $prompt=HvnRetVal($h_pars,LuNbsp('Search for:|Suchen nach:|Chercher :|Buscar:'),'Prompt','prompt');
my $bcol= HvnRetColor($h_pars,'#eeeeee','Hintergrund','background');
my $tlen=HvnRetVal($h_pars,20,'Feldlänge',Unicode('Feldlänge'),'inputwidth');
my $title=HvnRetVal($h_pars,'','Titel','title');
my $text=HvnRetVal($h_pars,'','Text','text');
my $word=HvnRetVal($h_pars,'','Wort','word');
my $case=HvnRetVal($h_pars,'','Case','case');
my $regex=HvnRetVal($h_pars,'','Regex','regex');
my $button=HvnRetVal($h_pars,'1','Button','button');
my $val;
my ($opt,$hid);
if($tlen<20) {
$tlen=20;
}
FormCheckHelper(\$opt,\$hid,'title',Lu('titles|Titel|titres|títulos'),$title,1);
FormCheckHelper(\$opt,\$hid,'text' ,Lu('texts|Texte|textes|textos'),$text,1);
FormCheckHelper(\$opt,\$hid,'word' ,Lu("words-only|Worte|mots-seulement|Palabras"),$word,0);
FormCheckHelper(\$opt,\$hid,'case' ,Lu('match-case|Groß/klein|respecter-la-casse|considerar-la-caja'),$case,0);
FormCheckHelper(\$opt,\$hid,'regex',Lu('regex|Regex|expressions-régulières'),$regex,0);
$button = ($button) ? FormButton('do',Lu('Search|Suchen|Chercher|Buscar')) : $n1;
my $ret = FormStart("form_search",'');
$ret .= FormTableStart();
$ret .= LineRsLsLmCol($prompt,FormText('search','',$tlen),$button,$bcol);
if($opt) {
$ret .= LineRsLsLmCol(LuNbsp('Options:|Optionen:|Options :|Opciones:'),$opt,$n1,$bcol);
}
$ret .= $hid;
$ret .= FormTableEnd();
$ret .= FormEnd();
return $ret;
}
sub HtmlLuft {
my ($width,$height)=@_;
return "<img src='/image/p.gif' border='0' width='$width' height='$height'>";
}
sub ImageRetHtmlBar {
my ($imnam,$width,$height)=@_;
return ImageUrlRetHtmlPlus($imnam,'0',$width,$height);
}
sub FormNameValueHidden {
my ($name,$value)=@_;
$value =~ s/&/&/g;
return "<input type='hidden' name='$name' value='$value' />";
}
sub ColorRetCode {
my ($cnam)=@_;
my $ret= $ColorTabDe{$cnam};
if($ret eq '') {
$ret= $ColorTabEn{$cnam};
}
if($ret eq '') {
$ret= $ColorTabFr{$cnam};
}
return $ret;
}
sub ColorDefaultRetCode {
my ($cnam,$object)=@_;
my $ret=ColorRetCode($cnam);
if($ret eq '') {
$ret=$object;
}
return $ret;
}
$CdmlHash{ASIN}=\&CdmlAsin;
$CdmlHash{asin}=\&CdmlAsin;
sub CdmlAsin {
my($body,$h_pars)=@_;
HashAddContextDefaultsMissing($h_pars,'cdml.asin.defaults');
my $image=HvnRetVal($h_pars,"http://images.amazon.com/images/P/\{code\}.01.THUMBZZZ.jpg",'image');
my $url=HvnRetVal($h_pars,"http://www.amazon.com/exec/obidos/ASIN/\{code\}/\{aid\}",'url');
my $aid=HvnRetVal($h_pars,'','aid');
my $title=HvnRetVal($h_pars,'','title');
my $asin=HvnRetVal($h_pars,$body,'code');
StrStripBoth($asin);
$asin=First($asin,'020171499X'); # default "The Wiki Way"
$url=~ s/\{aid\}/$aid/;
$url=~ s/\{code\}/$asin/;
$image=~ s/\{aid\}/$aid/;
$image=~ s/\{code\}/$asin/;
$$h_pars{url}=$url;
$$h_pars{image}=$image;
return CdmlLink($title,$h_pars);
}
$CdmlHash{Bild}=\&CdmlImage;
$CdmlHash{image}=\&CdmlImage;
sub CdmlImage {
my($body, $h_pars)=@_;
HashAddContextDefaultsMissing($h_pars,'cdml.image.defaults');
my ($ret,$width,$link,$punkt,$imw,$imh,$tablestyle,$scol,$tbcol,$ipad,$istyle);
my $left_flag=1;
my $url=HvnRetVal($h_pars,'','URL','url');
my $text=HvnRetVal($h_pars,'','Text','text');
my $pos=HvnRetVal($h_pars,'links','Position','align');
my $pad=HvnRetVal($h_pars,'4','Luft','padding');
my $art=HvnRetVal($h_pars,'','Art','type');
my $bcol=HvnRetColor($h_pars,'','Hintergrund','background');
my $border=HvnRetVal($h_pars,'0','Linienbreite','linewidth');
my $breite=HvnRetVal($h_pars,'','Breite','width');
my $abstand=HvnRetVal($h_pars,'','Abstand','distance');
my $style=HvnRetVal($h_pars,'','Stil','style');
my $imsize=HvnRetVal($h_pars,'','Bildformat','imagesize');
my $framecolor=HvnRetColor($h_pars,'','Rahmenfarbe','framecolor');
my $framewidth=HvnRetVal($h_pars,'','Rahmenbreite','framewidth');
my $linecolor=HvnRetColor($h_pars,'','Linienfarbe','linecolor');
my $linewidth=$border; # FIXME ugly
my $ititle=HvnRetVal($h_pars,'','Bildtitel','imagetitle');
my $ifont=HvnRetVal($h_pars,'','Bildfont','imagefont');
if($url ne '' && $text eq '') {
$text=$body; StrStripBoth($text);
$body=$url;
}
StrStripBoth($body);
if($body =~ m/$InterWebPattern/) {
$body=InterWikiPageRetUrl($body);
}
if($text eq '') {
$pos=HvnRetVal($h_pars,'','Ausrichtung','Position','align');
if($pos =~ m/^r/) {
$style.=" float: right; "
} elsif ($pos =~ m/^l/) {
$style.=" float: left; "
}
if($border>0) {
$style.=" border: solid ${border}px $bcol; background-color:$bcol; "
}
($link,$punkt)=UrlpRetLinkPunct($body,1,$style);
return $link;
}
$text=TextCdmlRetText($text);
TextMarkupImagesLinksParasLists($text,0,1,1,1);
if($breite eq "") {
$width="width='100%'";
} else {
$width="width='$breite'";
}
if($bcol ne "") {
$tbcol=" bgcolor='$bcol'";
}
if($imsize =~ m/(\d+)x(\d+)/) {
$imw=$1; $imh=$2;
}
my $al="left";
if($pos =~ /^r/ ) {
$al="right";
$left_flag=0;
}
if($framecolor ne '') {
if($framewidth==0) {
$framewidth=3;
}
$style.=" border: solid ${framewidth}px $framecolor; ";
}
if($linecolor ne '') {
if($linewidth==0) {
$linewidth=1;
}
$tablestyle=" border: solid ${linewidth}px $linecolor; ";
$tablestyle="style='$tablestyle'";
}
$ipad=$pad;
if($ititle ne '') {
$ipad=''
}
my $im=ImageUrlRetHtmlPlus($body,'0',$imw,$imh,$al,$ipad,$style);
if($ititle ne '') {
if($ifont ne '') {
$ititle=TextFontRetHtml($ititle,$ifont);
}
$scol=First($framecolor,$bcol);
if($left_flag) {
$istyle.=" margin: 0 ${pad}px 0 0; "; #right
} else {
$istyle.=" margin: 0 0 0 ${pad}px; "; #left
}
$istyle.=" padding: 0 0 ${framewidth}px 0; ";
$im="<table cellspacing='0' border='0' cellpadding='0' bgcolor='$scol' width='1%' align='$al' style='$istyle' ><tr><td width='1%'>$im</td></tr><tr><td width='1%'><center>$ititle</center></td></tr></table>";
}
if(StrEquList($art,'Spalte','column')) {
if($left_flag) {
$ret="<table $width cellspacing='0' border='0' $tbcol cellpadding='$pad' $tablestyle><tr><td valign='top'>$im</td><td>$text</td></tr></table>";
} else {
$ret="<table $width cellspacing='0' border='0' valign='top' $tbcol cellpadding='$pad' $tablestyle><tr><td>$text</td><td valign='top'>$im</td></tr></table>";
}
} else {
$ret="<table $width border='0' $tbcol cellspacing='0' cellpadding='$pad' $tablestyle><tr><td>$im$text</td></tr></table>";
}
if(StrEmpty($abstand)) {
$ret="<center>$ret</center>";
} else {
$ret="<table cellspacing='0' cellpadding='0' border='0'><tr><td>" . HtmlLuft($abstand,1) . "</td><td>$ret</td></tr></table>"
}
return $ret;
}
sub WikiRetFormBlog {
my ($id,$form)=@_;
my $editRows = RetParam("editrows", $Def_editrows);
my $editCols = RetParam("editcols", $Def_editcols);
my ($ret,$h);
$ret .= FormStart("form_blog",$id);
$ret .= FormTableStart();
$ret .= FormNameValueHidden("title",$id) . "\n";
$ret .= FormNameValueHidden("form",$form) . "\n";
$h = Lu('Contribution input form|Eingabeformular für Beiträge|Formulaire de Publication|Formulario de publicación');
$ret .= HeaderColSpan($h,$FormTitlebackground,1);
$h = Lu('Heading|Überschrift|En-tête|Título') . ': ' . FormText('summary','',30);
$ret .= LineLm($h,$n1);
$FontDecSuppress=1;
$h = FormTextArea('text','',$editRows,$editCols,1,1);
$ret .= LineLm($h,$n1);
$FontDecSuppress=0;
$h = FormButton('Save',LiSave()) . "$n3(" . LiUser() . ": $UserName)";
$ret .= LineLm($h,$n1);
$ret .= FormTableEnd();
$ret .= FormEnd();
return $ret;
}
sub WordForm {
my ($text,@words)=@_;
$text =~ s/(\%(\d+))/{$words[$2];}/ge;
return $text;
}
sub TextProcess {
my ($text,$process)=@_;
PageContextInit();
my $rule=$PageContext{rule};
my (@arr,@arw);
@arr = split(/[,;]/,$rule);
$arw[0]=$PageCur;
$arw[1]=$PageContext{plural};
$text =~ s/(\$(\d+))/{&WordForm($arr[$2-1],@arw);}/ge;
# $text =~ s/\$/xxx/g;
return $text;
}
sub HashAddPageReRange {
my ($h_pages,$page,$minlevel,$maxlevel)=@_;
my $pagelevel=StrFindStrRetCount($page,'/');
my ($key,$keylevel,$push,$re);
$re=($page ne '') ? "$page/" : $page;
PageIndexInit();
foreach $key (keys %PageIndex) {
if($key =~ m#^$re#) {
$keylevel=StrFindStrRetCount($key,'/');
$push=1;
if($keylevel<$pagelevel+$minlevel) {
$push=0;
} elsif($keylevel>$pagelevel+$maxlevel) {
$push=0;
}
if($push) {
$$h_pages{$key}++;
}
}
}
}
sub ArrayRandomize {
my ($a_arr)=@_;
my ($i,$ind,$h);
for($i=$#$a_arr; $i>0; $i--) {
$ind=int(rand($i + 1));
$h=$$a_arr[$i];
$$a_arr[$i]=$$a_arr[$ind];
$$a_arr[$ind]=$h;
}
}
sub HashAddPageTypes {
my($h_pages,$page,$types)=@_;
my ($type,$serr);
PageIndexInit();
my ($grand,$parent)=PageRetGrandParent($page);
foreach $type (ListSplit($types)) {
if(StrEquList($type,'Selbst','self')) {
$$h_pages{$page}++;
} elsif(StrEquList($type,'Kinder','children')) {
HashAddPageReRange($h_pages,$page,1,1);
} elsif(StrEquList($type,'Enkel','grandchildren')) {
HashAddPageReRange($h_pages,$page,2,2);
} elsif(StrEquList($type,'Nachkommen','descendants')) {
HashAddPageReRange($h_pages,$page,1,1000);
} elsif(StrEquList($type,'Kleinfamilie','sfamily')) {
HashAddPageReRange($h_pages,$page,0,1);
} elsif(StrEquList($type,'Zweig','branch')) {
do_branch:
HashAddPageReRange($h_pages,$page,0,1000);
} elsif(StrEquList($type,'Familie','family')) {
HashAddPageReRange($h_pages,First($parent,$page),0,1000);
} elsif(StrEquList($type,"Großfamilie",Unicode("Großfamilie"),'xfamily')) {
HashAddPageReRange($h_pages,First($grand,$parent,$page),0,1000);
} elsif(StrEquList($type,'*','@')) {
HashAddHash($h_pages,\%PageIndex);
} else {
goto do_branch;
}
}
return $serr;
}
$CdmlHash{Liste}=\&CdmlList;
$CdmlHash{list}=\&CdmlList;
sub CdmlList {
my($body, $h_pars)=@_;
HashAddContextDefaultsMissing($h_pars,'cdml.list.defaults');
my $type=HvnRetVal($h_pars,'children','Typ','type');
my $vida=HvnRetVal($h_pars,'','Vida','vida');
my $title=HvnRetVal($h_pars,'','Titel','title');
my $layout=HvnRetVal($h_pars,'','Layout','layout');
my $anzahl=HvnRetVal($h_pars,0,'Anzahl','count');
my $showdate=HvnRetVal($h_pars,'','Datum','date');
my $publish=HvnRetVal($h_pars,'','Veröffentlichen',Unicode('Veröffentlichen'),'publish');
my $edit=HvnRetVal($h_pars,'','Bearbeiten',"Ändern",Unicode('Ändern'),'edit');
my $filter=HvnRetVal($h_pars,'','Filter','filter');
my $select=HvnRetVal($h_pars,'','Selektion','select');
my $opt= HvnRetVal($h_pars,'','Optionen','options');
my $page=HvnRetVal($h_pars,$PageCur,'Seite','page');
my $varlist=HvnRetVal($h_pars,'','Variablen','Variable','variables','variable');
my $off=0;
my ($re,@pageinfo,$self,@vars);
my (@pages,$ret,%hinfo,%horder,$pagename,$fnam,$ftim,$ftim2,$info,$pp,%phash);
$body=~s/\s+/ /g;
StrStripBoth($body);
if($body ne '') {
if($varlist eq '') {
$varlist=$body;
$vida=1;
$type=HvnRetVal($h_pars,'*','Typ','type');
}
}
@vars=ListSplit($varlist);
HashAddPageTypes(\%phash,$page,$type);
@pages=sort keys %phash;
if($filter ne '') {
@pages=ArrayStrFilterRegex(\@pages,$filter,1);
if($publish ne '') {
@pages=ArrayStrFilterRegex(\@pages,"/Context",1);
}
}
if($select ne '') {
@pages=ArrayStrFilterRegex(\@pages,$select,0);
}
if($vida) {
my $sep=" /// ";
if($VidaCaching) {
@pageinfo=VidaCacheVarsSepRetArrFilterPages(\@vars,$sep,\@pages);
} else {
VidaInitPageArray(\@pages);
@pageinfo=VidaVarsSepRetArr(\@Vida,\@vars,$sep);
}
my %pars=%$h_pars;
HashAddArray(\%pars,'separator',$sep);
my $header=join($sep,LiPages(),@vars);
unshift(@pageinfo,$header);
return CdmlTable(join("\n",@pageinfo),\%pars);
}
if($opt =~ m#r#) {
ArrayRandomize(\@pages);
}
if($publish ne '') {
$showdate=1;
}
if($edit ne '') {
$showdate=1;
$hinfo{"column.edit"}=1;
}
if($showdate ne '') {
foreach $pagename (@pages) {
$horder{$pagename}=$ftim=PageRetTime($pagename);
$info=TimeRetText($ftim);
if($edit ne '') {
$hinfo{"edit.$pagename"}=" ";
}
if($publish ne '') {
$pp=PageRetPublishPage($pagename);
$ftim2=PageRetTime($pp);
if($ftim2<$ftim) {
$info.=" ".NameStyleRetImageGif('newer');
} else {
$info.=" up-to-date";
}
}
$hinfo{$pagename}=$info;
}
$ret=PageListRetHtml('',$ScriptName,\@pages,\%hinfo,'',1,1,$layout,$anzahl,\%horder,1,0,undef,undef,0);
} else {
$ret=PageListRetHtml('',$ScriptName,\@pages,undef,'',1,1,$layout,$anzahl,undef,0,0,undef,undef,0);
}
do_err:
return $ret;
}
sub HashRetSize {
my ($h_hash)=@_;
return int(keys %$h_hash);
}
sub HashRetMax {
my ($h_hash)=@_;
my ($max,$val);
foreach (keys %$h_hash) {
$val=$$h_hash{$_};
if($val>$max) {
$max=$val;
}
}
return $max;
}
sub ArrayElementRetInd {
my ($a_ar,$el)=@_;
my $ind=0;
foreach (@$a_ar) {
if($_ eq $el) {
return $ind;
}
$ind++;
}
return -1;
}
sub TablePageFieldRetSum {
my ($id,$field)=@_;
my $text=PageRetTextFast($id);
my @lines=split("\n",$text);
my $fieldline=shift(@lines);
my @fields=LineRetFields($fieldline);
my $ind=ArrayElementRetInd(\@fields,$field);
my $sum;
# MsgPrint("TPFRS id=$id field=$field fieldline=$fieldline ind=$ind");
if($ind<0) {
return " error ";
}
foreach (@lines) {
$sum += LineIndRetField($_,$ind);
}
return $sum;
}
sub DataRetVal {
my ($var)=@_;
my $ret=$var;
if($var =~ m/vida\.(.*)/) {
$var=$1;
$ret=PageVarRetValDefault($PageCur,$var,$n1);
} elsif($var =~ m#tablesum\.([^.]+)\.([^.]+)# ) {
$ret=TablePageFieldRetSum($1,$2);
}
$ret;
}
$CdmlHash{"Einfügen"}=\&CdmlInsert;
$CdmlHash{Unicode("Einfügen")}=\&CdmlInsert;
$CdmlHash{insert}=\&CdmlInsert;
sub CdmlInsert {
my($body, $h_pars)=@_;
my $typ=HvnRetVal($h_pars,'','Typ','type');
my $id=HvnRetVal($h_pars,'','Seite','page');
my $process=HvnRetVal($h_pars,'','Prozess','process');
my $form=HvnRetVal($h_pars,'','Formular','form');
my $silent=HvnRetVal($h_pars,'','Tolerant','silent');
my $bcol=HvnRetColor($h_pars,'','Hintergrund','background');
my $days=HvnRetVal($h_pars,7200,'days');
my $detail=HvnRetVal($h_pars,0,'detail');
my $months=($days>90)?1:0;
my $ret;
my $es=Lu("Error in insert|Fehler in Einfügung|Erreur en insertion|Error de inserción");
my $var;
if($typ eq 'Datum') {
$ret=TimeRetDay($^T);
} elsif(StrEquList($typ,'Seitenzahl','pagecount')) {
PageIndexInit();
$ret=HashRetSize(\%PageIndex);
} elsif(StrEquList($typ,'Daten','data')) {
$var=$body;
$ret=DataRetVal($var);
} elsif(StrEquList($typ,'Mediendaten','mediadata')) {
$ret=StatCreatePlus(0,1,$months,$days,$detail);
} elsif(StrEquList($typ,"Seitengröße",Unicode("Seitengröße"),"Seitenlänge",Unicode("Seitenlänge"),'pagesize')) {
$ret=PageRetSize(ValDefault($id,$PageCur));
} elsif(StrEquList($typ,'Wortanzahl','wordcount')) {
$ret=PageRetWordCount(ValDefault($id,$PageCur));
} elsif(StrEquList($typ,'Zeichenanzahl','charactercount')) {
$ret=PageRetCharCount(ValDefault($id,$PageCur));
} elsif($typ eq 'ProtId') {
$ProtId=RandomRetStamp();
$ProtId=substr($ProtId,0,6);
$ret=$ProtId;
} elsif(StrEquList($typ,'WebLog','weblog','Blog','blog')) {
$ret=WikiRetFormBlog($PageCur,$form);
} elsif($id ne '') {
if($id =~ m/\$/) {
PageContextInit();
$id =~ s/\$(.*)$/$PageContext{$1}/;
}
if(PageExist($id)) {
$ret=PageRetText($id);
if($process ne '') {
$ret=TextProcess($ret,$process);
}
$ret=TextWikiRetHtmlBasic($ret);
if($bcol ne '') {
$ret="<div style='background:url(/image/bg_pergament1.jpg); padding: 10 10 10 10; margin: 10 10 10 10; border: dotted 3px gray;'>$ret</div>";
# $ret="<div style='background:$bcol; padding: 10 10 10 10; margin: 10 10 10 10; border: dotted 3px gray;'>$ret</div>";
# $ret="<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr bgcolor='$bcol'><td>$ret</td></tr></table>";
# TableCvtLineColorWidth($ret,'#000000','90%');
# TableCvtAbstandWidth($ret,'','90%');
}
} elsif($silent eq '') {
$lb1=Lu("Page %PAGENAME% doesn't exist.|Seite %PAGENAME% existiert nicht.|page %PAGENAME% n'existe pas.|página %PAGENAME% no existe.");
MessRepPagename($lb1,$id);
$ret=$es.LiColon().$lb1;
}
} else {
$lb1=Lu("Type %TYPENAME% unknown.|Typ %TYPENAME% unbekannt.|type %TYPENAME% inconnu.|tipo %TYPENAME% desconocido.");
MessRepVar($lb1,"%TYPENAME%",$typ);
$ret=$es.LiColon().$lb1;
}
return $ret;
}
$CdmlHash{Schrift}=\&CdmlFont;
$CdmlHash{font}=\&CdmlFont;
sub FontRetFaceSizeColorBoldItalUdl {
my ($font)=@_;
my ($face,$size,$col,$bold,$ital,$udl,$fmtcol);
($face) = ($font =~ m/^([^@#]*)/ );
($col) = ($font =~ m/#([^@#]*)/ );
($size) = ($font=~ m/@([^@#]*)/ );
if($col ne '') {
$fmtcol=ColorRetCode($col);
if($fmtcol ne '') {
$col=$fmtcol;
} else {
$col="#$col";
}
}
if($size ne '') {
$bold = ($size =~ m/[bBfF]/) ? 1 : 0;
$ital = ($size =~ m/[iIkK]/) ? 1 : 0;
$udl = ($size =~ m/[uU]/) ? 1 : 0;
$size = int($size);
if($size == 0) {
$size='';
}
}
return ($face,$size,$col,$bold,$ital,$udl);
}
sub TextFaceSizeColorBoldItalUdlRetHtml {
my ($text,$face,$size,$color,$bold,$ital,$udl)=@_;
my ($h1,$h2);
if($face ne '') {
$face=" face='$face'";
}
if($size ne '') {
$size=" size='$size'";
}
if($color ne '') {
$color=" color='$color'";
}
if($bold) {
$h1.="<b>"; $h2.="</b>";
}
if($ital) {
$h1.="<i>"; $h2="</i>".$h2;
}
if($udl) {
$h1.="<u>"; $h2="</u>".$h2;
}
return "<font$face$size$color>" . $h1 . $text . $h2 . '</font>';
}
sub TextFontRetHtml {
my ($text,$font)=@_;
my ($face,$size,$col,$bold,$ital,$udl)=FontRetFaceSizeColorBoldItalUdl($font);
return TextFaceSizeColorBoldItalUdlRetHtml($text,$face,$size,$col,$bold,$ital,$udl);
}
sub CdmlFont {
my($body, $h_pars)=@_;
HashAddContextDefaultsMissing($h_pars,'cdml.font.defaults');
my $face=HvnRetVal($h_pars,'','Art','face');
my ($size,$col,$bold,$ital,$udl);
if($face ne '') {
($face,$size,$col,$bold,$ital,$udl)=FontRetFaceSizeColorBoldItalUdl($face);
}
$size=HvnSize($h_pars,$size);
$col=HvnRetColor($h_pars,$col,'Farbe','color');
TextMarkupImagesLinksParasLists($body,0,1,1,1);
return TextFaceSizeColorBoldItalUdlRetHtml($body,$face,$size,$col,$bold,$ital,$udl);
}
sub PixelRetTwips {
return 15*$_[0];
}
sub RtfRowsRetTable {
my ($rows)=@_;
return "{\\intbl\n" . $rows . "}\n";
}
sub RtfCellsRetRow {
my ($cells,$abstand,$luft)=@_;
my $rabstand=PixelRetTwips($abstand);
my $rluft=PixelRetTwips($luft);
return "\\trowd\\trleft$rabstand\\li$rluft\\ri$rluft\\sb$rluft\\sa$rluft\n" . $cells . "\\row\n";
}
sub RtfCell {
my ($body,$fcol,$width,$bcol,$lwidth,$lcol)=@_;
my $find=RtfColorTabRetInd($fcol);
my $bind=RtfColorTabRetInd($bcol);
my $lind=RtfColorTabRetInd($lcol);
my $lw=PixelRetTwips($lwidth);
my $cwidth=PixelRetTwips($width);
my $ret=
"\\tcelld\n"
."\\clbrdrb\\brdrs\\brdrw$lw\\brdrcf$lind\\clbrdrt\\brdrs\\brdrw$lw\\brdrcf$lind\\clbrdrl\\brdrs\\brdrw$lw\\brdrcf$lind\\clbrdrr\\brdrs\\brdrw$lw\\brdrcf$lind\n"
."\\clcbpat$bind\\cellx$cwidth\\ql {\\f0\\cf$find $body}\\cell\n";
return $ret;
}
sub RtfTextColorTableAbstandWidthColorLinewidthColorLuft {
my ($body,$fcol,$abstand,$width,$bcol,$lwidth,$lcol,$luft)=@_;
my $cells=RtfCell($body,$fcol,$width,$bcol,$lwidth,$lcol);
my $rows=RtfCellsRetRow($cells,$abstand,$luft);
return RtfRowsRetTable($rows);
}
$CdmlHash{Posting}=\&CdmlCode;
$CdmlHash{Code}=\&CdmlCode;
$CdmlHash{posting}=\&CdmlCode;
$CdmlHash{code}=\&CdmlCode;
sub CdmlCode {
my($body, $h_pars)=@_;
HashAddContextDefaultsMissing($h_pars,'cdml.code.defaults');
my $abstand=HvnRetVal($h_pars,50,'Abstand','distance');
my $w=HvnWidth($h_pars,400);
my $fcol=HvnRetColor($h_pars,'#000066','Farbe','color');
my $bcol=HvnRetColor($h_pars,'#e7e7e7','Hintergrund','background');
my $lcol=HvnRetColor($h_pars,'#cccccc','Linienfarbe','linecolor');
my $luft=HvnRetVal($h_pars,'8','Luft','padding');
my $lwidth=HvnRetVal($h_pars,'2','Linienbreite','linewidth');
my $face=HvnRetVal($h_pars,'mono','Schriftart','face');
my $lnr=HvnRetVal($h_pars,'','Zeilennummer','linenumber');
my $lfmt=HvnRetVal($h_pars,'','Zeilennummernformat','linenumberformat');
my ($b2,$line,$ret);
$body =~ tr/\r//d;
StrStripChrBoth($body,"\n");
$body=TextCdmlRetText($body);
if($lnr ne '' || $lfmt ne '') {
$lnr=int($lnr);
if($lnr==0) {
$lnr=1;
}
if($lfmt eq '') {
$lfmt='%3d: ';
} else {
StrStripBrackets($lfmt,'"','"');
}
foreach $line (split(/\n/,$body)) {
$b2 .= sprintf($lfmt,$lnr++) . $line . "\n";
}
$body=$b2;
}
if($face ne '') {
$face=StrDecorate($face," face='\@'");
}
if($RtfMode) {
$body =~ s#\n*<p>\n*#\\line\n#g;
$body =~ s#\\line\n$##;
$ret="{\\f2\\fs20 $body}";
$ret=RtfTextColorTableAbstandWidthColorLinewidthColorLuft($ret,$fcol,$abstand,$w,$bcol,$lwidth,$lcol,$luft);
return $ret;
}
my $text="<td width=$w><pre style='margin:0 0 0 0;'><font color=$fcol$face>".$body."</font></pre></td>";
my $tb;
$tb .= "<table border='0' cellspacing=0 cellpadding='0' bgcolor='$lcol'><tr><td>";
$tb .= "<table border='0' cellspacing=$lwidth cellpadding='$luft'><tr bgcolor=$bcol>";
$tb .= $text;
$tb .= "</tr></table>";
$tb .= "</td></tr></table>";
$ret="<table cellspacing='0' cellpadding='0' border='0'><tr><td>";
$ret .= HtmlLuft($abstand,1) . "</td><td>$tb</td></tr></table>";
return $ret;
}
sub TextMarkWord {
my($word)=@_;
my($mean,$word2);
$mean=$AltWordSet{$word};
if($mean eq '') {
my $word2=WordTogCase($word);
$mean=$AltWordSet{$word2};
if($mean eq '') {
return $word;
}
}
return "<a href='$ScriptName?$AltWordSource' title='$mean' onmouseover=\"status='$mean'; return true;\" onmouseout=\"status=''; return true;\"><span style='background-color: $AltWordColor'>$word</span></a>";
}
sub PageRetWordHash {
my($id)=@_;
my(@lines,$line,$word,$mean,%hash);
my $fnam = $PageDir . "/" . PageRetDirectory($id) . "/$id.db";
if(!(-f $fnam)) {
return;
}
my $text=PageRetText($id);
if($text =~ m#\[\[Tabelle\](.*)\n\]#s ) {
@lines=split("\n",$1);
foreach $line (@lines) {
($word,$mean)=split(';',$line);
$hash{$word}=$mean;
}
}
return %hash;
}
sub Cover {
my($s,$head,$tail)=@_;
if($s ne '') {
return $head.$s.$tail;
}
return '';
}
sub TableCvtAbstandWidth {
# my($table,$abstand,$width)=@_;
my $abstand=$_[1];
my $width=$_[2];
my $twid=Cover($width," width=");
if($abstand eq '') {
$_[0]="<center>$_[0]</center>";
} else {
$_[0]="<table cellspacing=0 cellpadding='0' border='0' width=100%><tr><td width=1%>" . HtmlLuft($abstand,1) . "</td><td align=left $twid>$_[0]</td></tr></table>";
}
}
sub AltWordInit {
my($lang)=@_;
if($AltWordColor eq '') {
$AltWordColor="#ffddbb";
%BaseWordSet= PageRetWordHash("GrundWortschatz".$lang);
$AltWordSource="ErweiterungsWortschatz".$lang;
%AltWordSet= PageRetWordHash($AltWordSource);
}
}
sub ParsRetHash {
my($pars)=@_;
my (%hash,@ar,$key,$val);
($pars) = ($pars =~ m/^\s*\[(.*)\]\s*$/);
@ar=split(/\ |
|
| \s*\[/,$pars);
foreach (@ar) {
($key,$val) = ($_ =~ m/^([^=]*)=(.*)/);
$hash{$key}=$val;
}
return %hash;
}
sub ContextVarRetHashDefault {
my($var,$def)=@_;
my $val=ContextVarRetDefault($var,$def);
my %hash=ParsRetHash($val);
return %hash;
}
sub HashAddHashMissing {
my($h pars,$h defaults)=@_;
my $key;
foreach $key (keys %$h defaults) {
if($$h pars{$key} eq '') {
$$h pars{$key}=$$h defaults{$key};
}
}
}
sub HashAddContextDefaultsMissing {
my($h pars,$defname,$defstring)=@_;
my %defaults=ContextVarRetHashDefault($defname,$defstring);
HashAddHashMissing($h pars,\%defaults);
}
$CdmlHash{quote}=\&CdmlQuote;
$CdmlHash{Zitat}=\&CdmlQuote;
sub CdmlQuote {
my($body, $h pars)=@_;
HashAddContextDefaultsMissing($h pars,'cdml.quote.defaults',$CdmlQuoteDefaults);
return CdmlText($body,$h pars);
}
sub TrailInit {
$TrailPage=$_[0];
$TrailName=$_[1];
$TrailSection=$_[2];
}
sub TrailExit {
$TrailPage='';
$TrailSection='';
$TrailName='';
}
$CdmlHash{document}=\&CdmlDocument;
$CdmlHash{Dokument}=\&CdmlDocument;
sub CdmlDocument {
my($body, $h pars)=@_;
my $name= HvnRetVal($h pars,'',"Name",'name');
my $type= HvnRetVal($h pars,'',"Typ",'type');
if($type eq '') {
$$h pars{type}='Tour';
}
HashAddContextDefaultsMissing($h pars,'cdml.document.defaults',$CdmlDocumentDefaults);
return CdmlText($body,$h pars);
}
$CdmlHash{Text}=\&CdmlText;
$CdmlHash{text}=\&CdmlText;
sub CdmlText {
my($body, $h pars)=@_;
HashAddContextDefaultsMissing($h pars,'cdml.text.defaults');
my $abstand= HvnRetVal($h pars,20,'Abstand','distance');
my $bcol= HvnRetColor($h pars,'#f7f7ee','Hintergrund','background');
my $lcol= HvnRetColor($h pars,'#cccccc','Linienfarbe','linecolor');
my $luft= HvnRetVal($h pars,'3','Luft','padding');
my $lwidth= HvnRetVal($h pars,'1','Linienbreite','linewidth');
my $width = HvnWidth($h pars,'');
my $lang= HvnRetVal($h pars,'Englisch','Sprache','language');
my $ar= HvnRetVal($h pars,'l','Ausrichtung','alignment','align');
my $zu= HvnRetVal($h pars,'ja','Zeilenumbruch','wordwrapping');
my $opt= HvnRetVal($h pars,'','Optionen','options');
my $titel= HvnRetVal($h pars,'','Titel','title');
my $ttibg=$TableTitlebackground;
my $tcol=HvnRetColor($h pars,$ttibg,'Titelhintergrund','titlebackground');
my $foot= HvnRetVal($h pars,'',"Fuß",Unicode("Fuß"),'footer');
my $ftcol=HvnRetColor($h pars,$ttibg,"Fußhintergrund",Unicode("Fußhintergrund"),'footerbackground');
my $document= HvnRetVal($h pars,'',"Typ",'type');
my $docflag=($document ne '') ? 1 : 0;
my $name= HvnRetVal($h pars,'',"Name",'name');
my $section=HvnRetVal($h pars,'',"Auswahl",'selection');
my $tfont= HvnRetVal($h pars,'#000066','Schriftart','font');
my $hfont= HvnRetVal($h pars,'','Titelschriftart','titlefont');
my $ffont= HvnRetVal($h pars,'',"Fußschriftart",Unicode("Fußschriftart"),'footerfont');
my $center=($ar =~ m/[cz]/) ? 1 : 0;
my $pre=($zu =~ m/n/)? 1 : 0;
$body =~ tr/\r//d;
StrStripChrBoth($body,"\n");
TextMarkupImagesLinksParasLists($titel,0,1,1,0);
TextMarkupImagesLinksParasLists($foot,0,1,1,0);
$body=TextCdmlRetText($body);
if($docflag) {
if($titel eq '') {
$titel="Inhaltsverzeichnis $document";
}
TrailInit($PageCur,$name,$section);
}
TextMarkupImagesLinksParasLists($body,0,1,1,1);
TrailExit();
if($abstand eq '-') {
if($RtfMode) {
if($width<1) {
$width=0.8*$RtfBodyWidth;
}
$abstand=($RtfBodyWidth-PixelRetTwips($width))/2;
} else {
$abstand='';
}
}
if($RtfMode) {
if($pre) {
$body =~ s#\n*<p>\n*#\\line\n#g;
} else {
$body =~ s#\n*<p>\n*#\n#g;
}
$body =~ s#\\line\n$##;
my $cells=RtfCell($body,'#000066',$width,$bcol,$lwidth,$lcol);
my $rows=RtfCellsRetRow($cells,$abstand,$luft);
return RtfRowsRetTable($rows);
}
AltWordInit($lang);
$body =~ s/([A-ZÄÖÜ]?[a-zäöüß]+)/&TextMarkWord($1)/ge;
my $text=$body;
if($center) {
$text="<center>$text</center>";
}
if($pre) {
$text=" $text ";
}
my $twid=Cover($width," width=");
if($tfont ne '') {
$text=TextFontRetHtml($text,$tfont);
}
$text="<td width=$width>" . $text . "</td>";
my $tb;
$tb .= "<table border='0' cellspacing=0 cellpadding='0' bgcolor=$lcol $twid><tr><td>";
$tb .= "<table border='0' cellspacing=$lwidth cellpadding=$luft width=100%>";
if($titel ne '') {
if($hfont ne '') {
$titel=TextFontRetHtml($titel,$hfont);
}
$tb .= "<tr bgcolor=$tcol><td>$titel</td></tr>";
}
$tb .= "<tr bgcolor=$bcol>$text</tr>";
if($foot ne '') {
if($ffont ne '') {
$foot=TextFontRetHtml($foot,$ffont);
}
$tb .= "<tr bgcolor=$ftcol><td>$foot</td></tr>";
}
$tb .= "</table>";
$tb .= "</td></tr></table>";
my $ret=$tb;
TableCvtAbstandWidth($ret,$abstand,"100%");
return $ret;
}
sub ScriptCodeFrage {
my $ret =<<'#END_OF_SCRIPT_FRAGE';
function SetColorStyleText(qi,color,style,t)
{
document.all['ac_'+qi].style.backgroundColor=color;
document.getElementById('ab_'+qi).style.display=style;
document.all['at_'+qi].innerText=t;
}
function QuestionCheck(frm,qi)
{
els=frm.elements("frage_"+qi);
nok=0;
for(i=0; i<els.length; i++) {
e=els[i];
if((e.value&1)!=((e.checked)?1:0)) {
nok++;
}
}
if(nok) {
SetColorStyleText(qi,"#ff0000",'none',"{NOK}");
} else {
SetColorStyleText(qi,"#00ff00",'none',"{OK}");
}
}
function QuestionCheckVal(frm,qi,val)
{
sbox=document.getElementById("frage_"+qi);
nok=0;
if(sbox.value!=val) {
nok++;
}
if(nok) {
SetColorStyleText(qi,"#ff0000",'none',"{NOK}");
} else {
SetColorStyleText(qi,"#00ff00",'none',"{OK}");
}
}
function AnswerDel(frm,qi)
{
SetColorStyleText(qi,"#ffffff",,);
}
- END_OF_SCRIPT_FRAGE
$ret =~ s/{OK}/&Lu("That's correct!|Richtig!|Exact. Bravo !|¡Exacto!")/ge;
$ret =~ s/{NOK}/&Lu("Sorry, not correct!|Falsch!|Mauvaise Réponse !|¡Falso!")/ge;
return $ret;
}
$CdmlHash{Frage}=\&CdmlQuestion;
$CdmlHash{question}=\&CdmlQuestion;
$CdmlHash{apprendre}=\&CdmlQuestion;
sub CdmlQuestion {
my($body, $h pars)=@_;
HashAddContextDefaultsMissing($h pars,'cdml.question.defaults');
my $text=HvnRetVal($h pars,'','texte','Text','text');
my $pos=HvnRetVal($h pars,'','Position','position');
my $art=HvnRetVal($h pars,'','Art','type');
my $info=HvnRetVal($h pars,'','Info','info');
my $code=HvnRetVal($h pars,'','Code','code');
my $bild=HvnRetVal($h pars,'','Bild','image');
my $ant=HvnRetVal($h pars,'','reponse','Antwort','answer');
my $border=HvnRetVal($h pars,'','lignelargeur','Linienbreite','linewidth');
my $color=HvnRetColor($h pars,$QuizColor,'couleur','Farbe','color');
my ($ret,$bgcol,$fb,$val,$cs,$td but,$pagetext,$qfunc,$qval);
my $ind=0;
if($FrageCount==0) {
$pagetext=PageRetTextFast($PageCur);
$FrageBogenFlag=($pagetext =~ m/\[\[(Auswertung|evaluation)\]/ )? 0 : 1;
}
$fb=$FrageBogenFlag;
if($border eq '') {
if($fb) {
$border=1;
} else {
$border=0;
}
}
if($fb) {
if($ScriptCodeInit==0) {
$ScriptCode.=ScriptCodeFrage();
$ScriptCodeInit++;
}
}
if($FrageCount==0) {
$ret .= FormStart("form evaluation",'');
$ret .= FormNameValueHidden("cur page",$PageCur) . "\n";
}
my $h="" . ($FrageCount+1) . ". ";
$ret .= "<table width='100%' cellpadding='2' border='0' bgcolor='$color'><tr><td><font size=+1>$h$text</font></td></tr></table>";
my $al="'left'";
my $im= HtmlLuft(50,1);
if($info ne "") {
TextMarkupImagesLinksParasLists($info,0,1,1,0);
$im= "<table cellpadding='10' cellspacing='0' bgcolor='#dddddd' border='0'><tr><td><font color='#000066'>$info</font></td></tr></table>";
$im= "<table cellpadding='1' cellspacing='0' bgcolor='#000066' border='0'><tr><td>$im</td></tr></table>";
} elsif($code ne "") {
$code =~ tr/\r//d;
StrStripChrBoth($code,"\n");
TextMarkupImagesLinksParasLists($code,0,0,1,0);
$im= "<table cellpadding=10 cellspacing=0 bgcolor='#dddddd' border='0'><tr><td> <font color='#000066'>$code</font></td> </tr></table>";
$im= "<table cellpadding=1 cellspacing=0 bgcolor='#000066' border='0'><tr><td>$im</td></tr></table>";
} elsif($bild ne "") {
$im= "<table cellpadding=10><tr><td><img src='$bild' border='0'></td></tr></table>";
}
$body =~ s/\r//sg;
StrStripChrBoth($body,"\n");
TextMarkupImagesLinksParasLists($body,0,1,1,0);
my @lines=split("\n",$body);
my ($line,$fragen,$elem,@ar,$count,$size,$maxlen);
$qfunc="QuestionCheck(this.form,'$FrageCount')";
$qval=1;
foreach $line (@lines) {
$val=$ind;
$cs='';
if($fb) {
$val*=10;
}
if($line =~ s/\[([ x]?)\]//) {
if(StrExist($1)) {
$val++;
}
if($fb) {
$fragen .= "<input type='checkbox' name='frage_$FrageCount' value='$val' onclick=\"AnswerDel(this.form,'$FrageCount')\"> $line";
} else {
- $fragen .= $cgi->checkbox(-name=>"frage_${FrageCount}_$ind", -label=>$line, -checked=>0);
$fragen .= FormCheck("frage_${FrageCount}_$ind",0,$line);
}
} elsif($line =~ s/\(([ .]?)\)//) {
if(StrExist($1)) {
$val++;
}
if($fb) {
$fragen .= "<input type='radio' name='frage_$FrageCount' value='$val' onclick=\"AnswerDel(this.form,'$FrageCount')\"> $line";
} else {
$fragen .= "<input type='radio' name='frage_$FrageCount' value='$ind'> $line";
}
} elsif($line =~ m#\.\.\(([^()]+)\)\.\.# ) {
@ar=split(/\|/,$1);
if($#ar == 0) {
if($fb) {
$elem="<input type='text' id='frage_${FrageCount}' value='' onchange=\"AnswerDel(this.form,'$FrageCount')\" size='20' maxlength='80'>";
} else {
$elem="<input type='text' name='frage_${FrageCount}' value='' size='20' maxlength='80'>";
}
$qval=$ar[0];
} else {
$qval=1;
if($fb) {
$elem="<select id='frage_${FrageCount}' onchange=\"AnswerDel(this.form,'$FrageCount')\" ><option selected value='0'>";
} else {
$elem="<select name='frage_${FrageCount}'><option selected value=''>";
}
$count=1;
foreach (@ar) {
if($_ =~ m/^=/) {
$qval=$count;
$_ =~ s/^=//;
}
if($fb) {
$elem .= "<option value='$count'>$_";
} else {
$elem .= "<option value='$_'>$_";
}
$count++;
}
$elem.="</select>";
}
$elem="<span style='position:relative; left:0px; top:+3px;'>$elem</span>";
$fragen .= "$br0$`$n2$elem$n2$'$br0";
$qfunc="QuestionCheckVal(this.form,'$FrageCount','$qval')";
}
$fragen.=$br;
$ind++;
do next:
}
if($fb) {
my $s check=Lu("Check answer|Kontrollieren|Vérifiez la réponse|Controlar");
$td but="<td ID='ac_$FrageCount' width='30%' align='center'>\n" .
"<span ID='ab_$FrageCount' ><input type='button' onclick=\"$qfunc\" value='$s check'></span>\n" .
"<span ID='at_$FrageCount'></span>\n" .
"</td>\n";
}
$ret .= "<table width='100%' cellpadding='5' border=$border><tr><td width='20%' align='center'>$im</td><td width='50%'>\n$fragen\n</td>$td but</tr></table>";
$FrageCount++;
return $ret;
}
$CdmlHash{'Auswertung'} = \&CdmlEvaluation;
$CdmlHash{'evaluation'} = \&CdmlEvaluation;
sub CdmlEvaluation {
my($body, $h pars)=@_;
my $ret;
my $color=HvnRetColor($h pars,$QuizColor,'colour','Farbe','color');
my $cb=FontDec(&FormButton('eval',Lu("Evaluate...|Auswertung durchführen...|Evaluation...|Evaluación...")));
my $l1=Lu("Evaluation|Auswertung|Evaluation|Evaluatión");
$ret.="<table width='100%' cellpadding='2' border='0' bgcolor='$color'><tr><td><font size='5'>$l1 $cb</font></td></tr></table>";
$ret.=FormEnd();
return $ret;
}
sub LabelNameHrefRetLink {
my ($text,$name,$href)=@_;
return "<a name='$name'></a><a href='$href'>$text</a>";
}
$CdmlHash{Flash}=\&CdmlFlash;
$CdmlHash{flash}=\&CdmlFlash;
sub CdmlFlash {
my($body,$h pars,$jdir)=@_;
HashAddContextDefaultsMissing($h pars,'cdml.flash.defaults');
my $url=HvnRetVal($h pars,'','Url','url');
my $width=HvnWidth($h pars,600);
my $height=HvnHeight($h pars,400);
my $clsid="D27CDB6E-AE6D-11cf-96B8-444553540000";
my $codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0";
my $type="application/x-shockwave-flash";
my $pi=" http://www.macromedia.com/go/getflashplayer";
my $ret;
- ../img/examples/swf/soccer.swf
$ret = "<OBJECT classid=\"clsid:$clsid\" codebase=\"$codebase\" WIDTH=\"$width\" HEIGHT=\"$height\">\n";
$ret.= "<PARAM NAME=movie VALUE=\"$url\"><PARAM NAME=quality VALUE=high>\n";
$ret.= "<EMBED src=\"$url\" quality=high WIDTH=\"$width\" HEIGHT=\"$height\" TYPE=\"$type\" PLUGINSPAGE=\"$pi\"></EMBED>\n";
$ret.= "</OBJECT>\n";
return $ret;
}
$CdmlHash{"Fußnote"}=\&CdmlFootnote;
$CdmlHash{Unicode("Fußnote")}=\&CdmlFootnote;
$CdmlHash{footnote}=\&CdmlFootnote;
sub CdmlFootnote {
my($body, $h pars)=@_;
HashAddContextDefaultsMissing($h pars,'cdml.footnote.defaults');
my $ret;
$FootnoteCount++;
push(@FootnoteTab,$body);
$ret = "".LabelNameHrefRetLink("[$FootnoteCount]","fa_$FootnoteCount","#fn_$FootnoteCount")."";
return $ret;
}
sub CdmlJavaDir {
my($body,$h pars,$jdir)=@_;
my $code=HvnRetVal($h pars,'code','Code','code');
my $code2=HvnRetVal($h pars,'','CODE');
my $width=HvnWidth($h pars,100);
my $height=HvnHeight($h pars,100);
my $path=HvnRetVal($h pars,'com.hls','Pfad','path');
my ($key,$val,$CODE);
my $ret;
$body =~ s/\r//sg; # damn shit...
$body =~ s/\"//sg;
StrStripChrBoth($body,"\n");
$body =~ s/\n/|/sg;
if(!StrEmpty($body)) {
$$h pars{"Body"}=$body; # for transfer
}
$CODE="$path.$code.$code.class";
if($code2 ne '') {
$CODE=$code2;
}
$ret = "<APPLET CODE=\"$CODE\" ARCHIVE=\"/$jdir/$code.jar\" WIDTH='$width' HEIGHT='$height'>\n";
foreach $key (keys(%$h pars)) {
if($key ne "Code") {
$val = $$h pars{$key};
$ret .= " <PARAM NAME=$key VALUE=\"$val\">\n";
}
}
$ret .= Lu("Java is not activated in this browser!|Dieser Browser hat Java nicht aktiviert!|Java n'est pas activé dans ce navigateur !|¡Java no está activado!");
$ret .= "</APPLET>";
return $ret;
}
$CdmlHash{JavaTest} = \&CdmlJavaTest;
$CdmlHash{javatest} = \&CdmlJavaTest;
sub CdmlJavaTest {
my($body,$h pars)=@_;
return CdmlJavaDir($body,$h pars,'java2');
}
$CdmlHash{Java}=\&CdmlJava;
$CdmlHash{java}=\&CdmlJava;
sub CdmlJava {
my($body,$h pars)=@_;
HashAddContextDefaultsMissing($h pars,'cdml.java.defaults');
return CdmlJavaDir($body,$h pars,'java');
}
sub TimeRetDayMonthYearWeekday {
my ($ts)=@_;
my (undef,undef,undef,$day,$month,$year,$wday) = TimeRetTimeClient($ts);
$month++;
$year+=1900;
return ($day,$month,$year,$wday)
}
sub YearMonthAdd { # $_[0]=year $_[1]=month $_[2]=inc
$_[1]+=$_[2];
while($_[1]>12) {
$_[0]++; $_[1]-=12;
}
while($_[1]<1) {
$_[0]--; $_[1]+=12;
}
}
sub YearMonthRetWeekday {
my ($year,$month)=@_;
my $ts=TimeAllRetTimeSec($year,$month,1,12,0);
my (undef,undef,undef,$wday)=TimeRetDayMonthYearWeekday($ts);
return $wday;
}
sub RunRetImageBar {
my ($r,$height)=@_;
my ($c,$col);
$c=substr($r,0,1);
if($c eq '1') {
$col="cc3333";
} elsif($c eq '9') {
$col="666666";
} else {
$col="999999";
}
return ImageRetHtmlBar("/pixel/p_$col.gif",length($r),$height);
}
sub StrRetImageBar {
my ($s,$height)=@_;
my ($ret,$i,$c,$c1,$run,$rlen);
my $slen=length($s);
for($i=0; $i<$slen; $i++) {
$c=substr($s,$i,1);
if($c ne $c1) {
if($run ne '') {
$ret.=RunRetImageBar($run,$height);
$run='';
}
}
$run.=$c;
$c1=$c;
}
if($run ne '') {
$ret.=RunRetImageBar($run,$height);
}
return $ret;
}
sub HourMinRetInd {
my ($hour,$min)=@_;
my $ind;
if($hour>24) {
$hour=24;
}
if($hour==24) {
$min=0;
}
if($min>60) {
$min=60;
}
$hour+=$min/60;
$ind=int(2*$hour);
return $ind;
}
sub PageRetDates {
my ($page,$day,$nday)=@_;
my (@ar,$line,$i,$i1,$i2);
my $s=PageRetTextFast($page);
my $cday=$day;
my $h='999999999999000000000000000000000000000000009999';
if($day) {
$ar[0]=$h;
$cday=0;
} else {
for($i=0; $i<=$nday; $i++) {
$ar[$i]=$h;
}
}
foreach $line (split("\n",$s)) {
if($day==0) {
if($line =~ m/^=+\s*(\d+)/) {
if($1<=$nday) {
$cday=$1;
}
}
}
if($line =~ m/\*+\s*(\d+)\d+)\s*-\s*(\d+)\d+)/) {
$i1=HourMinRetInd($1,$2);
$i2=HourMinRetInd($3,$4);
for($i=$i1; $i<=$i2; $i++) {
substr($ar[$cday],$i,1)='1';
}
}
}
return @ar;
}
sub PageYearMonthParsRetCalendar {
my ($page,$year,$month,$h pars)=@_;
my ($ret,$title,$body,$i,$ind,$day,$wday,$nday,$off,$mname,$lines,$cols,$wind,$ccol);
my ($dday,$dpat,$dpage,@dar,$dlen,$tr1,$tr2,$trn,$page2);
my ($cday,$cmonth,$cyear,$cwday) = TimeRetDayMonthYearWeekday($^T);
my $scol=HvnRetVal($h pars,'lightorange','Untertitelhintergrund','subtitlebackground');
my $tcol=HvnRetVal($h pars,'lightblue','Heutehintergrund','todaybackground');
my $wcol=HvnRetVal($h pars,'lightgray','Wochenendehintergrund','weekendbackground');
my $pat=HvnRetVal($h pars,'{page}/{year}{month}#{day}','Linkmuster','linkpattern');
my $opt=HvnRetVal($h pars,'','Optionen','options');
my $trange=HvnRetVal($h pars,'8:00-18:00','Zeitbereich','timerange');
my $sflag= ($opt=~m/s/) ? 1 : 0;
my $bardist=HvnRetVal($h pars,'2','Balkenabstand','bardistance');
my $barheight=HvnRetVal($h pars,4,"Balkenhöhe",Unicode("Balkenhöhe"),'barheight');
if($trange =~ m/\s*(\d+)\d+)\s*-\s*(\d+)\d+)/) {
$tr1=HourMinRetInd($1,$2);
$tr2=HourMinRetInd($3,$4);
} else {
$tr1=HourMinRetInd(8,0);
$tr2=HourMinRetInd(18,0);
}
$trn=$tr2-$tr1+1;
$pat=~ s/\{page\}/$page/;
$pat=~ s/\{year\}/$year/;
$month=sprintf("%02d",$month);
$pat=~ s/\{month\}/$month/;
$nday=YearMonthRetLen($year,$month);
$wday=YearMonthRetWeekday($year,$month);
$off=($wday+6)%7;
if($sflag) {
$dpat=$pat;
$dpat=~ s/#.*//;
if($dpat =~ m/\{day\}/) {
for($day=1; $day<$nday; $day++) {
$dpage=$dpat;
$dpage=~ s/\{day\}/$day/;
($dar[$day])=PageRetDates($dpage,$day,$nday);
}
} else {
@dar=PageRetDates($dpat,0,$nday);
}
}
$mname=MonthName($month-1);
$title="$mname $year\@7c";
for($i=1; $i<=7; $i++) {
if($i>1) {
$body.=",";
}
$body.=DayNameShort($i)."\@c#$scol";
}
$body.="\n"; $lines=0; $cols=0;
for($ind=1; $ind<=42; $ind++) {
$day=$ind-$off;
$wind=$ind%7;
$ccol='';
if($wind==6 || $wind==0) {
$ccol=$wcol;
}
if($year==$cyear && $month==$cmonth && $day==$cday) {
$ccol=$tcol;
}
if($day>0 && $day<=$nday) {
$page2=$pat;
$page2=~ s/\{day\}/$day/;
$body.=ScriptPageRefLabelClassCompleteRetLink($ScriptName,$page2,'',$day,'body',1);
if($sflag) {
$dday=substr($dar[$day],$tr1,$trn);
$dlen=length($dday);
if($dlen) {
$body.=$br0.ImageRetHtmlBar("/pixel/p.gif",$dlen,$bardist);
$body.=$br0.StrRetImageBar($dday,$barheight);
}
}
} else {
$body.=$n1;
if($sflag) {
$body.=$br0.ImageRetHtmlBar("/pixel/p.gif",1,$bardist);
$body.=$br0.ImageRetHtmlBar("/pixel/p.gif",1,$barheight);
}
}
$body.="\@c";
if($ccol ne '') {
$body.="#$ccol";
}
if($wind==0) {
$body.="\n"; $lines++; $cols=0;
} else {
$body.=","; $cols++;
}
}
if($cols) {
$body.="\n"; $lines++;
}
if($lines<6) {
$body.=",\n";
}
$ret=CdmlTable("$title\n$body",$h pars);
return $ret;
}
$CdmlHash{Kalender}=\&CdmlCalendar;
$CdmlHash{calendar}=\&CdmlCalendar;
sub CdmlCalendar {
my($body, $h pars)=@_;
HashAddContextDefaultsMissing($h pars,'cdml.calendar.defaults');
my ($ret,$title,%pars,$key,$inc,$i,@ar,$qflag);
my $page=HvnRetVal($h pars,$PageCur,'Seite','page');
my $count=HvnRetVal($h pars,1,'Anzahl','count');
my $ncol=HvnRetVal($h pars,3,'Spalten','columns');
my ($cday,$cmonth,$cyear,$cwday) = TimeRetDayMonthYearWeekday($^T);
my $year= HvnRetVal($h pars,$cyear,'Jahr','year');
my $abstand=HvnRetVal($h pars,'','Abstand','distance');
my $cpadding=HvnRetVal($h pars,'2','Kalenderluft','calendarpadding');
if($year<100) {
$year+=2000;
}
my $month= HvnRetVal($h pars,$cmonth,'Monat','month');
if(($month eq '0') || ($month =~ m/^[\+\-]/)) {
if($month=~m/q/) {
$qflag++;
}
$inc=int($month); $month=$cmonth;
YearMonthAdd($year,$month,$inc);
if($qflag) {
while($month%3!=1) {
YearMonthAdd($year,$month,-1);
}
}
}
%pars=('separator'=>',','formatseparator'=>'@','titlebackground'=>'orange','titlefont'=>'@4#black','markup'=>0,'textbackground'=>'hellgelb');
foreach $key (%$h pars) {
$pars{$key}=$$h pars{$key};
}
undef $pars{Abstand};
undef $pars{distance};
for($i=0; $i<$count; $i++) {
$ar[$i]=PageYearMonthParsRetCalendar($page,$year,$month,\%pars);
YearMonthAdd($year,$month,1);
}
if($count>1) {
$ret="<table border='0' cellpadding='0' cellspacing=$cpadding width=1%><tr>";
$i=0;
foreach (@ar) {
$ret.="<td>$_</td>";
$i++;
if($count>$ncol) {
if($i>=$ncol) {
$i=0;
$ret.="</tr><tr>";
}
}
}
$ret.="</tr></table>";
} else {
$ret=$ar[0];
}
if($abstand ne '') {
TableCvtAbstandWidth($ret,$abstand,"100%");
}
return $ret;
}
sub TaskTabAddPage {
my ($a ar,$page)=@_;
my $s=PageRetTextFast($page);
my ($line,$task);
foreach $line (split("\n",$s)) {
if($line =~ m/[:*]+\s*(\(.?\))(.*)/) {
$task=join("|","0000",$2,$page,$line);
push(@$a ar,$task);
}
}
}
$CdmlHash{Aufgaben}=\&CdmlTasks;
$CdmlHash{tasks}=\&CdmlTasks;
sub CdmlTasks {
my($body,$h pars)=@_;
my ($ret,%pars,$key,$title,$tbody,@tar,@pages,$page,$i,$gain,$cost,$task,$pri,$proj,$skey);
my $count=HvnRetVal($h pars,50,'Anzahl','count');
my ($cday,$cmonth,$cyear,$cwday) = TimeRetDayMonthYearWeekday($^T);
my $sep="//";
@pages=WikiRetPageList();
foreach $page (@pages) {
if($page =~ m#^$PageCur/#) {
TaskTabAddPage(\@tar,$page);
}
}
$title=Lu("Tasks|Aufgaben").$sep.LiProject().$sep."Pri".$sep.Lu("Gain|Nutzen").$sep.Lu("Costs|Kosten");
LOOP TASK:
foreach $task (sort @tar) {
($skey,$task,$proj,$pri,$gain,$cost)=split(/\|/,$task);
$tbody.=join("//",$task,$proj,$pri,$gain,$cost)."\n";
if(++$i >= $count) {
last LOOP TASK;
}
}
%pars=('formatseparator'=>'@','separator'=>$sep,'titlebackground'=>'lightblue',
'linewidth'=>1,'linecolor'=>'white','padding'=>5,
'markup'=>0,'textbackground'=>'lightgray','distance'=>20
);
foreach $key (%$h pars) {
$pars{$key}=$$h pars{$key};
}
$ret=CdmlTable("$title\n$tbody",\%pars);
return $ret;
}
$CdmlHash{Link}=\&CdmlLink;
$CdmlHash{link}=\&CdmlLink;
sub CdmlLink {
my($body, $h pars)=@_;
HashAddContextDefaultsMissing($h pars,'cdml.link.defaults');
my $url= HvnRetVal($h pars,'','Url','url');
my $target= HvnRetVal($h pars,'','Fenster','window');
my $title= HvnRetVal($h pars,'','Titel','title');
my $par=HvnRetVal($h pars,'','Parameter','parameter');
my ($ret,$hidden);
my $image=HvnRetVal($h pars,'','Bild','image');
my $icon=HvnRetVal($h pars,'','Icon','icon');
if($url eq '') {
return Lu('[link lacks url-parameter]|[Link mit fehlendem Url-Parameter]|[le lien manque un paramètre-url]|[enlace sin URL-parámetro]');
}
if($target ne '') {
if(($target eq 'new') || ($target eq 'neu')) {
$target='_blank';
}
}
if($par ne '') {
my $val = RetParam($par);
$url =~ s/@/$val/g;
}
if($url =~ m/^$UrlPattern$/) {
# url ok
if($ShowHiddenLinks) {
$hidden=" ($url)";
}
} elsif($url =~ m/^ Upload:(.*)$/) {
$url="$UploadUrl/$1";
} elsif($url =~ m/^DiesesWiki:(.*)$/) {
$url="$ScriptUrl?$1";
} elsif($url =~ m/^ThisWiki:(.*)$/) {
$url="$ScriptUrl?$1";
} elsif($url =~ m/^$InterWebPattern$/) {
$url=InterWikiPageRetUrl($url);
} else {
return Lu('[link has an invalid url-parameter]|[Link mit ungültigem Url-Parameter-Wert]|[le lien a un paramètre-url invalide]|[enlace con un parámetro inválido]');
}
if($image ne '') {
$image =~ s/\.(DECLARE)?IMAGE$//;
$body=ImageUrlRetHtml($image);
} elsif ($icon ne '') {
$body=Icon($icon);
}
return UrlLabelClassTitleTargetRetLink($url,$body,'body',$title,$target);
}
sub ValDefault {
my($val,$object)=@_;
if($val eq '') {
return $object;
}
return $val;
}
sub WikiGetPagesAll {
my($a pages)=@_;
my $page;
PageIndexInit();
foreach $page (keys %PageIndex) {
push(@$a pages,$page);
}
}
sub VidaInitPageArray {
my ($a pages)=@_;
if($VidaInit==0) { #FIXME: secure against context switch
VidaAppPageListPlus(\@Vida,$a pages,0,0);
$VidaInit=1;
}
}
sub VidaInitIndex {
my @pages;
WikiGetPagesAll(\@pages);
VidaInitPageArray(\@pages);
}
sub VidaInitPage {
my($id)=@_;
my @pages=($id);
VidaInitPageArray(\@pages);
}
sub VidaHashHashInitVar {
my ($var)=@_;
my ($val,%vida,$fnam,$h cache);
$h cache=$VidaHashHash{$var};
if(!defined($h cache)) {
%vida=();
$h cache=\%vida;
$fnam="$DataDir/vida/$var.lvd";
LogFileGetHash Type($fnam,$h cache);
$VidaHashHash{$var}=$h cache;
}
}
sub VidaCacheVarRetPages {
my ($var)=@_;
VidaHashHashInitVar($var);
my $h cache=$VidaHashHash{$var};
return sort keys %$h cache;
}
sub VidaCachePageVarRetVal {
my ($id,$var)=@_;
my ($val,%vida,$fnam,$h cache);
VidaHashHashInitVar($var);
$h cache=$VidaHashHash{$var};
$val=$$h cache{$id};
return $val;
}
sub PageVarRetVal {
my($id,$var)=@_;
my($val,$fnam,%vida);
if($VidaCaching) {
$val=VidaCachePageVarRetVal($id,$var);
} else {
VidaInitPage($id);
$val=VidaVarRetVal(\@Vida,$var);
}
return $val;
}
sub PageVarRetValDefault {
my($id,$var,$object)=@_;
my $val=PageVarRetVal($id,$var);
return ValDefault($val,$object);
}
$CdmlHash{Anzeige}=\&CdmlDisplay;
$CdmlHash{display}=\&CdmlDisplay;
sub CdmlDisplay {
my($body,$h pars)=@_;
HashAddContextDefaultsMissing($h pars,'cdml.display.defaults');
my $var0=HvnRetVal($h pars,'','Variable','variable');
my $type=HvnRetVal($h pars,'',"Typ",'type');
my $var=substr($var0,1,100);
my $select=HvnSelect($h pars);
my $filter=HvnFilter($h pars);
my ($title,$tbody,$key,$i,@ar,%pars,$val);
InterWebInit();
$title="Variable $var0:";
if($var0 =~ m/%/ ) {
foreach $key (sort keys %$var) {
push(@ar,"$key => $$var{$key}");
}
} elsif($var0 =~ m/@/ ) {
for($i=0; $i<= $#$var; $i++) {
push(@ar,"[$i] = $$var[$i]");
}
} else {
if(!($var0 =~ m/\$/)) {
$var=$var0;
}
if($var =~ m/vida\.(.*)/) {
$var=$1;
$val=PageVarRetValDefault($PageCur,$var,$n1);
} elsif($var =~ m/\./) {
$val=ContextVarRetDefault($var,$n1);
} else {
$val=$$var;
}
push(@ar,$val);
}
if($filter ne '') {
@ar=ArrayStrFilterRegex(\@ar,$filter,1,1);
}
if($select ne '') {
@ar=ArrayStrFilterRegex(\@ar,$select,0,1);
}
if(StrEquList($type,'Text','inline')) {
return join(" ",@ar);
}
$tbody=" ".join("\n ",@ar);
%pars=( 'separator'=>'//@#0815#', 'distance'=>0, 'titlebackground'=>'gelb', 'titlefont'=>'@#black',
'markup'=>0, 'textbackground'=>'hellgelb', 'width'=>300, 'formatseparator'=>'@#7751#');
foreach $key (%$h pars) {
$pars{$key}=$$h pars{$key};
}
return CdmlTable($title."\n".$tbody,\%pars);
}
$CdmlHash{Hotspots}=\&CdmlHotspots;
$CdmlHash{hotspots}=\&CdmlHotspots;
sub CdmlHotspots {
my($body,$h pars)=@_;
HashAddContextDefaultsMissing($h pars,'cdml.hotspots.defaults');
my $anzahl=HvnRetVal($h pars,10,'Anzahl','count');
my $amp=HvnRetVal($h pars,200,'Amplitude','amplitude');
my ($i,@tab,$line,$page,$count,%pars,$scale,$hcount,$im,$wcount);
my ($loop,$text,$age,$key);
my $fnam="$DataDir/hotspots";
if(!(-f $fnam)) {
goto do build;
}
do restart:
@tab=FileSepRetArray($fnam,"\n");
$age=$^T - $tab[0];
my $refage=$HotspotDelta*0.9 + rand($HotspotDelta*0.2);
if($age > $refage) {
do build:
WikiBuildHotspotFile(0);
if($loop<1) {
$loop++;
goto do restart;
}
}
my $deft=Lu("main focus (age: {age} seconds)\@2|Brennpunkte des Interesses (Alter: {age} Sekunden)\@2|principal focus (age : {age} secondes\@2");
my $titel=HvnRetVal($h pars,$deft,"Titel",'title');
$titel =~ s/\{age\}/$age/;
if($anzahl>20) {
$anzahl=20;
}
for($i=1; $i<=$anzahl; $i++) {
$line=$tab[$i];
($page,$count,$wcount)=split(",",$line);
if($i==1) {
$hcount=$count;
}
if($page ne '') {
$im = ImageRetHtmlBar('/pixel/p1rot.gif',int(1+$amp*$wcount/$hcount),12)
. ImageRetHtmlBar('/pixel/p1blau.gif',int(1+$amp*$count/$hcount),12);
if($page =~ m/>$/) {
$anzahl++;
} else {
$text.= "{{$page}},$im\n";
}
}
}
%pars=('Texthintergrund'=>'weiß', 'Abstand' =>'-', 'Formatzeichen'=>'@', 'separator'=>',' );
HashAddHash(\%pars,$h pars);
foreach $key (%$h pars) {
$pars{$key}=$$h pars{$key};
}
$titel =~ s/ / /g ;
return CdmlTable("$titel\n".$text,\%pars);
}
$CdmlHash{Luft} = \&CdmlPadding;
$CdmlHash{padding} = \&CdmlPadding;
sub CdmlPadding {
my($body, $h pars)=@_;
my $width=HvnWidth($h pars,1);
my $height=HvnHeight($h pars,1);
return HtmlLuft($width,$height);
}
]
|
|