diff --git a/wire/core/ProcessWire.php b/wire/core/ProcessWire.php index 0e7c1f6e..12d84895 100644 --- a/wire/core/ProcessWire.php +++ b/wire/core/ProcessWire.php @@ -17,7 +17,7 @@ require_once(__DIR__ . '/boot.php'); * ~~~~~ * #pw-body * - * ProcessWire 3.x, Copyright 2020 by Ryan Cramer + * ProcessWire 3.x, Copyright 2021 by Ryan Cramer * https://processwire.com * * Default API vars (A-Z) @@ -79,7 +79,7 @@ class ProcessWire extends Wire { * Reversion revision number * */ - const versionRevision = 169; + const versionRevision = 170; /** * Version suffix string (when applicable) diff --git a/wire/modules/Fieldtype/FieldtypeFile/FieldtypeFile.module b/wire/modules/Fieldtype/FieldtypeFile/FieldtypeFile.module index 1bcf30b0..633b1879 100644 --- a/wire/modules/Fieldtype/FieldtypeFile/FieldtypeFile.module +++ b/wire/modules/Fieldtype/FieldtypeFile/FieldtypeFile.module @@ -13,6 +13,7 @@ * https://processwire.com * * @property array $allowFieldtypes Allowed Fieldtype types for custom fields + * @property string $defaultFileExtensions * @method string formatValueString(Page $page, Field $field, $value) * */ @@ -145,6 +146,11 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule { if($this->className() === 'FieldtypeFile') $this->allowFieldtypes = $this->defaultAllowFieldtypes; parent::__construct(); } + + public function get($key) { + if($key === 'defaultFileExtensions') return $this->getDefaultFileExtensions(); + return parent::get($key); + } /** * Get the Inputfield module to handle input for this Fieldtype @@ -1253,7 +1259,9 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule { * Subclasses can override with their own string of file extensions * */ - public function getDefaultFileExtensions() { + protected function getDefaultFileExtensions() { + // note: this method is not public because other modules are implementing it + // access $fieldtype->defaultFileExtensions to get the value instead return "pdf doc docx xls xlsx gif jpg jpeg png"; } diff --git a/wire/modules/Fieldtype/FieldtypeFile/config.php b/wire/modules/Fieldtype/FieldtypeFile/config.php index 0e3be4cb..14fb3f93 100644 --- a/wire/modules/Fieldtype/FieldtypeFile/config.php +++ b/wire/modules/Fieldtype/FieldtypeFile/config.php @@ -57,7 +57,7 @@ class FieldtypeFileConfiguration extends Wire { $f = $modules->get('InputfieldTextarea'); $f->attr('name', 'extensions'); $value = $field->get('extensions'); - if(!$value) $value = $fieldtype->getDefaultFileExtensions(); + if(!$value) $value = $fieldtype->get('defaultFileExtensions'); $f->attr('value', $value); $f->attr('rows', 3); $f->label = $this->_('Allowed file extensions'); diff --git a/wire/modules/Fieldtype/FieldtypeImage/FieldtypeImage.module b/wire/modules/Fieldtype/FieldtypeImage/FieldtypeImage.module index d1009309..3c981109 100644 --- a/wire/modules/Fieldtype/FieldtypeImage/FieldtypeImage.module +++ b/wire/modules/Fieldtype/FieldtypeImage/FieldtypeImage.module @@ -68,7 +68,7 @@ class FieldtypeImage extends FieldtypeFile { * @return string * */ - public function getDefaultFileExtensions() { + protected function getDefaultFileExtensions() { return "gif jpg jpeg png"; }