mirror of
https://github.com/processwire/processwire.git
synced 2025-08-13 02:04:35 +02:00
Various minor updates
This commit is contained in:
@@ -512,7 +512,12 @@ class Fieldgroup extends WireArray implements Saveable, Exportable, HasLookupIte
|
||||
* @param Page $page Page that the Inputfields will be for.
|
||||
* @param string|array $contextStr Optional context string to append to all the Inputfield names, OR array of options.
|
||||
* - Optional context string is helpful for things like repeaters.
|
||||
* - You may instead specify associative array of any method arguments if preferred.
|
||||
* - Or associative array with any of these options:
|
||||
* - `contextStr` (string): Context string to append to all Inputfield names.
|
||||
* - `fieldName` (string|array): Limit to particular fieldName(s) or field ID(s). See $fieldName argument for details.
|
||||
* - `namespace` (string): Additional namespace for Inputfield context.
|
||||
* - `flat` (bool): Return all Inputfields in a flattened InputfieldWrapper?
|
||||
* - `populate` (bool): Populate page values to Inputfields? (default=true) since 3.0.208
|
||||
* @param string|array $fieldName Limit to a particular fieldName(s) or field IDs (optional).
|
||||
* - If specifying a single field (name or ID) and it refers to a fieldset, then all fields in that fieldset will be included.
|
||||
* - If specifying an array of field names/IDs the returned InputfieldWrapper will maintain the requested order.
|
||||
@@ -530,13 +535,17 @@ class Fieldgroup extends WireArray implements Saveable, Exportable, HasLookupIte
|
||||
'fieldName' => $fieldName,
|
||||
'namespace' => $namespace,
|
||||
'flat' => $flat,
|
||||
'populate' => true, // populate page values?
|
||||
);
|
||||
$options = $contextStr;
|
||||
$options = array_merge($defaults, $options);
|
||||
$contextStr = $options['contextStr'];
|
||||
$fieldName = $options['fieldName'];
|
||||
$namespace = $options['namespace'];
|
||||
$populate = (bool) $options['populate'];
|
||||
$flat = $options['flat'];
|
||||
} else {
|
||||
$populate = true;
|
||||
}
|
||||
|
||||
$container = $this->wire(new InputfieldWrapper());
|
||||
@@ -649,7 +658,7 @@ class Fieldgroup extends WireArray implements Saveable, Exportable, HasLookupIte
|
||||
if(!$inputfield) continue;
|
||||
if($inputfield->collapsed == Inputfield::collapsedHidden) continue;
|
||||
|
||||
if(!$page instanceof NullPage) {
|
||||
if($populate && !$page instanceof NullPage) {
|
||||
$value = $page->get($field->name);
|
||||
$inputfield->setAttribute('value', $value);
|
||||
}
|
||||
|
@@ -600,6 +600,76 @@ class PagefilesManager extends Wire {
|
||||
return $filesPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all potential disk paths for given Page files (not yet in use)
|
||||
*
|
||||
* @todo FOR FUTURE USE
|
||||
* @param Page $page
|
||||
* @return string[]
|
||||
*
|
||||
static public function _paths(Page $page) {
|
||||
$config = $page->wire()->config;
|
||||
$path = $config->paths->files;
|
||||
$securePrefix = $config->pagefileSecurePathPrefix;
|
||||
$useSecure = $page->secureFiles();
|
||||
$useExtended = $config->pagefileExtendedPaths;
|
||||
$useUnique = $config->pagefileUnique && $page->hasStatus(Page::statusUnique);
|
||||
|
||||
if(!strlen($securePrefix)) $securePrefix = self::defaultSecurePathPrefix;
|
||||
|
||||
$paths = array(
|
||||
'current' => '',
|
||||
'normal' => $path . "$page->id/",
|
||||
'unique' => $path . "0/$page->name/",
|
||||
'extended' => $path . self::_dirExtended($page->id),
|
||||
'secure' => $path . $securePrefix . "$page->id/",
|
||||
'secureUnique' => $path . "0/$securePrefix$page->name/",
|
||||
'secureExtended' => $path . self::_dirExtended($page->id, $securePrefix),
|
||||
);
|
||||
|
||||
if($useUnique) {
|
||||
// use unique page name paths
|
||||
$paths['current'] = ($useSecure ? $paths['secureUnique'] : $paths['unique']);
|
||||
|
||||
} else if($useSecure) {
|
||||
// use secure files
|
||||
$paths['current'] = ($useExtended ? $paths['secureExtended'] : $paths['secure']);
|
||||
|
||||
} else {
|
||||
// use normal path
|
||||
$paths['current'] = ($useExtended ? $paths['extended'] : $paths['normal']);
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Scan all paths for page and make sure only the correct one exists (not yet in use)
|
||||
*
|
||||
* Also crates and moves files when necessary.
|
||||
*
|
||||
* @todo FOR FUTURE USE
|
||||
* @param Page $page
|
||||
*
|
||||
private function verifyPaths(Page $page) {
|
||||
$paths = self::_paths($page);
|
||||
$current = $paths['current'];
|
||||
$currentExists = is_dir($current);
|
||||
unset($paths['current']);
|
||||
foreach($paths as $path) {
|
||||
if(!is_dir($path)) continue;
|
||||
if(!$currentExists) {
|
||||
$this->_createPath($current);
|
||||
$currentExists = true;
|
||||
}
|
||||
$this->_copyFiles($path, $current);
|
||||
$this->wire()->files->rmdir($path, true);
|
||||
self::$numRenamedPaths++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get quantity of renamed paths to to pagefileSecure changes
|
||||
*
|
||||
|
Reference in New Issue
Block a user