01_FHEMWEB.pm: editFiles is now configDB compatible (Forum #142235)
git-svn-id: https://svn.fhem.de/fhem/trunk@30203 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -2268,12 +2268,23 @@ FW_fileList($;$)
|
|||||||
$f eq "99_Utils.pm");
|
$f eq "99_Utils.pm");
|
||||||
|
|
||||||
push(@ret, $f);
|
push(@ret, $f);
|
||||||
$FW_editFileToPath{$f} = "$dir/$f";
|
$FW_editFileToPath{$f}{path} = "$dir/$f";
|
||||||
|
$FW_editFileToPath{$f}{forceType} = "file";
|
||||||
}
|
}
|
||||||
closedir(DH);
|
closedir(DH);
|
||||||
return sort { (CORE::stat("$dir/$a"))[9] <=> (CORE::stat("$dir/$b"))[9] }
|
return sort { (CORE::stat("$dir/$a"))[9] <=> (CORE::stat("$dir/$b"))[9] }
|
||||||
@ret if($mtime);
|
@ret if($mtime);
|
||||||
@ret = cfgDB_FW_fileList($dir,$re,@ret) if (configDBUsed());
|
if (configDBUsed()) {
|
||||||
|
@ret = cfgDB_FW_fileList($dir,$re,@ret);
|
||||||
|
map {
|
||||||
|
if (!defined($FW_editFileToPath{$_}{path})) {
|
||||||
|
my $f = $_;
|
||||||
|
$f =~ s/\.configDB//;
|
||||||
|
$FW_editFileToPath{$_}{path} = "$dir/$f";
|
||||||
|
$FW_editFileToPath{$_}{forceType} = "configDB";
|
||||||
|
}
|
||||||
|
} @ret;
|
||||||
|
}
|
||||||
return sort @ret;
|
return sort @ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2503,7 +2514,7 @@ FW_style($$)
|
|||||||
my $cfgFileName = $1;
|
my $cfgFileName = $1;
|
||||||
FW_displayFileList("config file", $cfgFileName)
|
FW_displayFileList("config file", $cfgFileName)
|
||||||
if(!configDBUsed());
|
if(!configDBUsed());
|
||||||
$FW_editFileToPath{$cfgFileName} = $attr{global}{configfile};
|
$FW_editFileToPath{$cfgFileName}{path} = $attr{global}{configfile};
|
||||||
|
|
||||||
my $efl = AttrVal($FW_wname, 'editFileList',
|
my $efl = AttrVal($FW_wname, 'editFileList',
|
||||||
"Own modules and helper files:\$MW_dir:^(.*sh|[0-9][0-9].*Util.*pm|".
|
"Own modules and helper files:\$MW_dir:^(.*sh|[0-9][0-9].*Util.*pm|".
|
||||||
@@ -2560,14 +2571,15 @@ FW_style($$)
|
|||||||
my $fileName = $a[2];
|
my $fileName = $a[2];
|
||||||
my $data = "";
|
my $data = "";
|
||||||
my $cfgDB = defined($a[3]) ? $a[3] : "";
|
my $cfgDB = defined($a[3]) ? $a[3] : "";
|
||||||
my $forceType = ($cfgDB eq 'configDB') ? $cfgDB : "file";
|
|
||||||
$fileName =~ s,.*/,,g; # Little bit of security
|
$fileName =~ s,.*/,,g; # Little bit of security
|
||||||
my $filePath = $FW_editFileToPath{$fileName};
|
$fileName .= ".configDB" if ($cfgDB eq 'configDB'); # add identifier if file has to be read from database
|
||||||
my($err, @content) = FileRead({FileName=>$filePath, ForceType=>$forceType});
|
my $filePath = $FW_editFileToPath{$fileName}{path};
|
||||||
|
my($err, @content) = FileRead({FileName=>$filePath, ForceType=>$FW_editFileToPath{$fileName}{forceType}});
|
||||||
if($err) {
|
if($err) {
|
||||||
FW_addContent(">$err</div");
|
FW_addContent(">$err</div");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$fileName =~ s,\.configDB,,; # remove identifier for pretty print in frontend
|
||||||
$data = join("\n", @content);
|
$data = join("\n", @content);
|
||||||
|
|
||||||
$data =~ s/&/&/g;
|
$data =~ s/&/&/g;
|
||||||
@@ -2602,9 +2614,11 @@ FW_style($$)
|
|||||||
$fileName = $FW_webArgs{saveName}
|
$fileName = $FW_webArgs{saveName}
|
||||||
if($FW_webArgs{saveAs} && $FW_webArgs{saveName});
|
if($FW_webArgs{saveAs} && $FW_webArgs{saveName});
|
||||||
$fileName =~ s,.*/,,g; # Little bit of security
|
$fileName =~ s,.*/,,g; # Little bit of security
|
||||||
my $filePath = $FW_editFileToPath{$fileName};
|
$fileName .= ".configDB" if ($cfgDB eq 'configDB'); # add identifier if file has to be read from database
|
||||||
|
my $filePath = $FW_editFileToPath{$fileName}{path};
|
||||||
|
$fileName =~ s,\.configDB,,; # remove identifier for pretty print in frontend
|
||||||
if(!$filePath) { # save as
|
if(!$filePath) { # save as
|
||||||
$FW_editFileToPath{$a[2]} =~ m,^(.*)/([^/]+)$,;
|
$FW_editFileToPath{$a[2]}{path} =~ m,^(.*)/([^/]+)$,;
|
||||||
return if(!$1); # No root experiments
|
return if(!$1); # No root experiments
|
||||||
$filePath = "$1/$fileName";
|
$filePath = "$1/$fileName";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user