mirror of
https://github.com/processwire/processwire.git
synced 2025-08-06 23:06:59 +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
|
||||
*
|
||||
|
@@ -1369,7 +1369,10 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
|
||||
$json = (int) $input->get('json'); // 1 or 0 (for json output mode on or off)
|
||||
$rotate = (int) $input->get('rotate');
|
||||
$flip = $input->get('flip');
|
||||
$crop = $input->get('crop');
|
||||
|
||||
if($flip != 'v' && $flip != 'h') $flip = '';
|
||||
if($crop !== null && (!ctype_alnum($crop) || strlen($crop) > 20)) $crop = '';
|
||||
|
||||
if(strpos($class, 'hidpi') !== false) {
|
||||
if(!$hidpi) $hidpi = true;
|
||||
@@ -1378,7 +1381,8 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
|
||||
}
|
||||
|
||||
$image = $this->getPageimage(true);
|
||||
if(strpos($image->basename, '-cropx') !== false) $image = $this->getLastCrop($image);
|
||||
|
||||
if(!$crop && strpos($image->basename, '-cropx') !== false) $image = $this->getLastCrop($image);
|
||||
|
||||
if( (!$hidpi && $width < $image->width) ||
|
||||
($hidpi && $width < $image->hidpiWidth()) ||
|
||||
@@ -1392,6 +1396,7 @@ class ProcessPageEditImageSelect extends Process implements ConfigurableModule {
|
||||
);
|
||||
if($rotate) $options['rotate'] = $rotate;
|
||||
if($flip) $options['flip'] = $flip;
|
||||
if($crop) $options['cropping'] = $crop;
|
||||
//$this->log(print_r($options, true));
|
||||
$resized = $image->width($width, $options);
|
||||
$height = $resized->height();
|
||||
|
@@ -284,7 +284,20 @@ abstract class ProcessPageListRender extends Wire {
|
||||
*
|
||||
*/
|
||||
public function ___getPageActions(Page $page) {
|
||||
return $this->actions->getActions($page);
|
||||
$actions = $this->actions->getActions($page);
|
||||
/*
|
||||
* @todo force 'extras' option to be last
|
||||
if(isset($actions['extras'])) {
|
||||
$keys = array_keys($actions);
|
||||
$lastKey = array_pop($keys);
|
||||
if($lastKey !== 'extras') {
|
||||
$extras = $actions['extras'];
|
||||
unset($actions['extras']);
|
||||
$actions['extras'] = $extras; // move to last
|
||||
}
|
||||
}
|
||||
*/
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -652,7 +652,7 @@ class ProcessTemplate extends Process implements ConfigurableModule {
|
||||
$template->roles = array($this->wire()->roles->getGuestRole()->id);
|
||||
$template->save();
|
||||
|
||||
$this->message(sprintf($this->_('Added template and fieldgroup: %s'), $basename));
|
||||
$this->message(sprintf($this->_('Added template and fieldgroup: %s'), $template->name));
|
||||
$addedTemplates[] = $template;
|
||||
|
||||
} catch(\Exception $e) {
|
||||
|
Reference in New Issue
Block a user