1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-10 16:54:44 +02:00
Co-authored-by: BernhardBaumrock <office@baumrock.com>
This commit is contained in:
Ryan Cramer
2022-11-10 11:44:29 -05:00
parent 78c2ca736d
commit 5aa0126b39

View File

@@ -1522,6 +1522,7 @@ class WireFileTools extends Wire {
) )
); );
// need to use different name than $options
$options = array_merge($defaults, $options); $options = array_merge($defaults, $options);
$filename = trim($filename); $filename = trim($filename);
@@ -1562,27 +1563,33 @@ class WireFileTools extends Wire {
if(!file_exists($filename)) $this->filesException(__FUNCTION__, "File does not exist: $filename"); if(!file_exists($filename)) $this->filesException(__FUNCTION__, "File does not exist: $filename");
// remember options[func] and $filename outside this method because of the extract() which can overwrite
$this->includeFunc = $options['func'];
$this->includeFile = $filename;
// extract all API vars // extract all API vars
$fuel = array_merge($this->wire()->fuel->getArray(), $vars); $fuel = array_merge($this->wire()->fuel->getArray(), $vars);
extract($fuel); extract($fuel);
// include the file // include the file
TemplateFile::pushRenderStack($filename); TemplateFile::pushRenderStack($this->includeFile);
$func = $options['func']; if($this->includeFunc === 'require') {
if($func === 'require') { require($this->includeFile);
require($filename); } else if($this->includeFunc === 'require_once') {
} else if($func === 'require_once') { require_once($this->includeFile);
require_once($filename); } else if($this->includeFunc === 'include_once') {
} else if($func === 'include_once') { include_once($this->includeFile);
include_once($filename);
} else { } else {
include($filename); include($this->includeFile);
} }
TemplateFile::popRenderStack(); TemplateFile::popRenderStack();
return true; return true;
} }
protected $includeFunc = '';
protected $includeFile = '';
/** /**
* Same as include() method except that file will not be executed if it as previously been included * Same as include() method except that file will not be executed if it as previously been included
* *