本文整理汇总了PHP中Wire::getAllFuel方法的典型用法代码示例。如果您正苦于以下问题:PHP Wire::getAllFuel方法的具体用法?PHP Wire::getAllFuel怎么用?PHP Wire::getAllFuel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wire
的用法示例。
在下文中一共展示了Wire::getAllFuel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fuel
/**
* Return all Fuel, or specified ProcessWire API variable, or NULL if it doesn't exist.
*
* Same as Wire::getFuel($name) and Wire::getAllFuel();
* When a $name is specified, this function is identical to the wire() function.
* Both functions exist more for consistent naming depending on usage.
*
* @param string $name If ommitted, returns a Fuel object with references to all the fuel.
* @return mixed Fuel value if available, NULL if not.
*
*/
function fuel($name = '')
{
if (!$name) {
return Wire::getAllFuel();
}
return Wire::getFuel($name);
}
示例2: wireIncludeFile
/**
* Include a PHP file passing it all API variables and optionally your own specified variables
*
* This is the same as PHP's include() function except for the following:
* - It receives all API variables and optionally your custom variables
* - If your filename is not absolute, it doesn't look in PHP's include path, only in the current dir.
* - It only allows including files that are part of the PW installation: templates, core modules or site modules
* - It will assume a ".php" extension if filename has no extension.
*
* Note this function produced direct output. To retrieve output as a return value, use the
* wireTemplateFile function instead.
*
* @param $filename
* @param array $vars Optional variables you want to hand to the include (associative array)
* @param array $options Array of options to modify behavior:
* - func: Function to use: include, include_once, require or require_once (default=include)
* - autoExtension: Extension to assume when no ext in filename, make blank for no auto assumption (default=php)
* - allowedPaths: Array of paths include files are allowed from. Note current dir is always allowed.
* @return bool Returns true
* @throws WireException if file doesn't exist or is not allowed
*
*/
function wireIncludeFile($filename, array $vars = array(), array $options = array())
{
$paths = wire('config')->paths;
$defaults = array('func' => 'include', 'autoExtension' => 'php', 'allowedPaths' => array($paths->templates, $paths->adminTemplates, $paths->modules, $paths->siteModules));
$options = array_merge($defaults, $options);
$filename = trim($filename);
if (DIRECTORY_SEPARATOR != '/') {
$filename = str_replace(DIRECTORY_SEPARATOR, '/', $filename);
}
// add .php extension if filename doesn't already have an extension
if ($options['autoExtension'] && !strrpos(basename($filename), '.')) {
$filename .= "." . $options['autoExtension'];
}
if (strpos($filename, '..') !== false) {
// if backtrack/relative components, convert to real path
$_filename = $filename;
$filename = realpath($filename);
if ($filename === false) {
throw new WireException("File does not exist: {$_filename}");
}
}
if (strpos($filename, '//') !== false) {
throw new WireException("File is not allowed (double-slash): {$filename}");
}
if (strpos($filename, './') !== 0) {
// file does not specify "current directory"
$slashPos = strpos($filename, '/');
// If no absolute path specified, ensure it only looks in current directory
if ($slashPos !== 0 && strpos($filename, ':/') === false) {
$filename = "./{$filename}";
}
}
if (strpos($filename, '/') === 0 || strpos($filename, ':/') !== false) {
// absolute path, make sure it's part of PW's installation
$allowed = false;
foreach ($options['allowedPaths'] as $path) {
if (strpos($filename, $path) === 0) {
$allowed = true;
}
}
if (!$allowed) {
throw new WireException("File is not in an allowed path: {$filename}");
}
}
if (!file_exists($filename)) {
throw new WireException("File does not exist: {$filename}");
}
// extract all API vars
$fuel = array_merge(Wire::getAllFuel()->getArray(), $vars);
extract($fuel);
// include the file
$func = $options['func'];
if ($func == 'require') {
require $filename;
} else {
if ($func == 'require_once') {
require_once $filename;
} else {
if ($func == 'include_once') {
include_once $filename;
} else {
include $filename;
}
}
}
return true;
}