From 14c5871ea07b2582e83e826b372ff5a0e0bd46ed Mon Sep 17 00:00:00 2001 From: betateilchen <> Date: Wed, 28 Jan 2015 12:34:47 +0000 Subject: [PATCH] contrib/InfoPanel: updated added: include for layout files fixed: error in git-svn-id: https://svn.fhem.de/fhem/trunk@7755 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/InfoPanel/55_InfoPanel.pm | 34 ++++++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/fhem/contrib/InfoPanel/55_InfoPanel.pm b/fhem/contrib/InfoPanel/55_InfoPanel.pm index e68fd1491..b94edaeed 100644 --- a/fhem/contrib/InfoPanel/55_InfoPanel.pm +++ b/fhem/contrib/InfoPanel/55_InfoPanel.pm @@ -99,6 +99,7 @@ sub btIP_Define($$) { $hash->{NOTIFYDEV} = 'global'; $hash->{fhem}{hostname}= $hostname; $hash->{fhem}{filename}= $filename; + $hash->{fhem}{div} = ''; $hash->{LAYOUTFILE} = $filename; btIP_readLayout($hash); @@ -145,7 +146,22 @@ sub btIP_readLayout($) { Log 1, "InfoPanel $name: $err"; $hash->{fhem}{layout}= ("text 0.1 0.1 'Error: $err'"); } else { - $hash->{fhem}{layout}= join("\n", @layoutfile); + $hash->{fhem}{layout} = join("\n", @layoutfile); + while($hash->{fhem}{layout} =~ m/\@include/ ) { + my (@layout2,@include); + foreach my $ll (@layoutfile) { + if($ll !~ m/^\@include/) { + push(@layout2,$ll); + } else { + my ($cmd, $def)= split("[ \t]+", $ll, 2); + ($err,@include) = FileRead($def) if($def); + splice(@layout2,-1,0,@include) unless $err; + } + } + @layoutfile = @layout2; + @layout2 = undef; + $hash->{fhem}{layout} = join("\n",@layoutfile); + } $hash->{fhem}{layout} =~ s/\n\n/\n/g; } return; @@ -580,6 +596,7 @@ sub btIP_evalLayout($$@) { chomp $line; # kill comments and blank lines $line=~ s/\#.*$//; + $line=~ s/\@.*$//; $line=~ s/\s+$//; $line= $cont . $line; if($line=~ s/\\$//) { $cont= $line; undef $line; } @@ -650,7 +667,7 @@ sub btIP_evalLayout($$@) { when("group") { ($id,$text,$arg) = split("[ \t]+", $def, 3); - my $arg = AnalyzePerlCommand(undef, $arg); + my $arg = AnalyzePerlCommand(undef, $arg) if($arg); $svg .= btIP_itemGroup($id,$text,$arg); } @@ -748,6 +765,7 @@ sub btIP_evalLayout($$@) { ($id,$x,$y,$boxwidth,$boxheight,$text)= split("[ \t]+", $def, 6); ($x,$y)= btIP_xy($x,$y,%params); my $txt= AnalyzePerlCommand(undef, $text); + $txt =~ s/\n//g; my $name = $params{name}; $svg .= btIP_itemTextBox($id,$x,$y,$boxwidth,$boxheight,$txt,%params); $params{xx} = $x; @@ -761,7 +779,9 @@ sub btIP_evalLayout($$@) { $params{yy} = $y; $svg .= btIP_itemTime($id,$x,$y,%params); } - + + when('@include') {} + default { if($cmd ~~ @cmd_halign) { my $d = AnalyzePerlCommand(undef, $def); @@ -864,11 +884,9 @@ sub btIP_returnHTML($) { $code .= "\n". "
\n". - btIP_returnSVG($name). - "\n
\n". - $defs{$name}{fhem}{div}. - "\n". - btIP_HTMLTail(); + btIP_returnSVG($name)."\n\n"; + $code .= $defs{$name}{fhem}{div} if($defs{$name}{fhem}{div}); + $code .= "\n".btIP_HTMLTail(); return ("text/html; charset=utf-8", $code); }