config files in fhem editieren

Begonnen von justme1968, 05 Januar 2019, 20:39:56

Vorheriges Thema - Nächstes Thema

betateilchen

Zitat von: rudolfkoenig am 22 Januar 2019, 12:03:56
Nein, ich finde %data auch besser.

Ok, ich baue das heute Abend um und bereite einen patch vor.
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

betateilchen

#46
es ist zwar noch nicht Abend...

Die Registrierung einer Konfigurationsdatei erfolgt jetzt im zentralen hash %data in der Form:

$data{confFiles}{'demo.conf'} = '0';


Index: 01_FHEMWEB.pm
===================================================================
--- 01_FHEMWEB.pm       (revision 18379)
+++ 01_FHEMWEB.pm       (working copy)
@@ -15,6 +15,7 @@
sub FW_addContent(;$);
sub FW_addToWritebuffer($$@);
sub FW_answerCall($);
+sub FW_confFiles($);
sub FW_dev2image($;$);
sub FW_devState($$@);
sub FW_digestCgi($);
@@ -88,7 +89,6 @@
use vars qw(@FW_httpheader); # HTTP header, line by line
use vars qw(%FW_httpheader); # HTTP header, as hash
use vars qw($FW_userAgent); # user agent string
-use vars qw(%FW_customConfFiles);

$FW_formmethod = "post";

@@ -2244,7 +2244,7 @@
{
   my $name = shift;

-  my @f = sort keys %FW_customConfFiles;
+  my @f = FW_confFiles(2);
   return "$FW_confdir/$name" if ( map { $name =~ $_ } @f );

   $attr{global}{configfile} =~ m,([^/]*)$,;
@@ -2266,9 +2266,12 @@
   }
}

-sub FW_confFiles() {
+sub FW_confFiles($) {
+   my ($param) = @_;
    # create and return regexp for editFileList
-   return "(".join ( "|" , sort keys %FW_customConfFiles ).")";
+   return "(".join ( "|" , sort keys %{$data{confFiles}} ).")" if $param == 1;
+   # create and return array with filenames
+   return sort keys %{$data{confFiles}} if $param == 2;
}

##################
@@ -2296,7 +2299,7 @@
     my $efl = AttrVal($FW_wname, 'editFileList',
       "Own modules and helper files:\$MW_dir:^(.*sh|[0-9][0-9].*Util.*pm|".
                         ".*cfg|.*\.holiday|myUtilsTemplate.pm|.*layout)\$\n".
-      "Config files for external Programs:\$FW_confdir:^".FW_confFiles."\$\n".
+      "Config files for external programs:\$FW_confdir:^".FW_confFiles(1)."\$\n".
       "Gplot files:\$FW_gplotdir:^.*gplot\$\n".
       "Style files:\$FW_cssdir:^.*(css|svg)\$");
     foreach my $l (split(/[\r\n]/, $efl)) {

-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

rudolfkoenig