From 463dd01e660a8b7645db5bd98b5ddaedf23ee457 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 19 Oct 2023 10:26:23 -0400 Subject: [PATCH] Various minor unrelated updates --- wire/core/Sanitizer.php | 19 +++++++++++++++---- .../modules/Inputfield/InputfieldFloat.module | 13 +++++++------ wire/modules/Process/ProcessList.module | 4 +--- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/wire/core/Sanitizer.php b/wire/core/Sanitizer.php index 6c553c7c..c8a5f9cb 100644 --- a/wire/core/Sanitizer.php +++ b/wire/core/Sanitizer.php @@ -90,7 +90,7 @@ * * #pw-body * - * ProcessWire 3.x, Copyright 2022 by Ryan Cramer + * ProcessWire 3.x, Copyright 2023 by Ryan Cramer * https://processwire.com * * @link https://processwire.com/api/variables/sanitizer/ Offical $sanitizer API variable Documentation @@ -1082,7 +1082,17 @@ class Sanitizer extends Wire { * Name filter for ProcessWire filenames (basenames only, not paths) * * This sanitizes a filename to be consistent with the name format in ProcessWire, - * ASCII-alphanumeric, hyphens, underscores and periods. + * ASCII-alphanumeric (a-z A-Z 0-9), hyphens, underscores and periods. Note that + * filenames may contain mixed case (a-z A-Z) so if you require lowercase then + * run the return value through a `strtolower()` function. + * + * ~~~~~ + * // outputs: FileName.jpg + * echo $sanitizer->filename('©®™FileName.jpg'); + * + * // outputs: c_r_tmfilename.jpg + * echo strtolower($sanitizer->filename('©®™filename.jpg', Sanitizer::translate)); + * ~~~~~ * * #pw-group-strings * #pw-group-files @@ -1102,9 +1112,10 @@ class Sanitizer extends Wire { if(strlen($value) > $maxLength) { // truncate, while keeping extension in tact + $tt = $this->getTextTools(); $pathinfo = pathinfo($value); - $extLen = strlen($pathinfo['extension']) + 1; // +1 includes period - $basename = substr($pathinfo['filename'], 0, $maxLength - $extLen); + $extLen = $tt->strlen($pathinfo['extension']) + 1; // +1 includes period + $basename = $tt->substr($pathinfo['filename'], 0, $maxLength - $extLen); $value = "$basename.$pathinfo[extension]"; } diff --git a/wire/modules/Inputfield/InputfieldFloat.module b/wire/modules/Inputfield/InputfieldFloat.module index 2dbb8f1a..cb40aeeb 100644 --- a/wire/modules/Inputfield/InputfieldFloat.module +++ b/wire/modules/Inputfield/InputfieldFloat.module @@ -3,10 +3,10 @@ /** * Inputfield for floating point numbers * - * ProcessWire 3.x, Copyright 2022 by Ryan Cramer + * ProcessWire 3.x, Copyright 2023 by Ryan Cramer * https://processwire.com * - * @property int $precision Decimals precision (or -1 to disable rounding in 3.0.193+) + * @property int|null|string $precision Decimals precision (or -1 to disable rounding in 3.0.193+) * @property int $digits Total digits, for when used in decimal mode (default=0) * @property string $inputType Input type to use, one of "text" or "number" * @property int|float $min @@ -98,7 +98,7 @@ class InputfieldFloat extends InputfieldInteger { * Typecast value to float, override from InputfieldInteger * * @param string|int|float $value - * @return int + * @return float * */ protected function typeValue($value) { @@ -140,7 +140,9 @@ class InputfieldFloat extends InputfieldInteger { } if(empty($attributes['step']) || $attributes['step'] === 'any') { $precision = (int) $this->precision; - if($precision < 1 && $value !== null) $precision = $this->getPrecision($value); + if($precision === 0 && $value !== null) { + $precision = $this->getPrecision($value); + } if($precision > 0) { $attributes['step'] = '.' . ($precision > 1 ? str_repeat('0', $precision - 1) : '') . '1'; } @@ -188,8 +190,7 @@ class InputfieldFloat extends InputfieldInteger { $inputfields = parent::getConfigInputfields(); if($this->hasFieldtype === false) { // when used without FieldtypeFloat - /** @var InputfieldInteger $f */ - $f = $this->wire()->modules->get('InputfieldInteger'); + $f = $inputfields->InputfieldInteger; $f->attr('name', 'precision'); $f->label = $this->_('Number of decimal digits to round to'); $f->description = $this->_('Or use a negative number like `-1` to disable rounding.'); diff --git a/wire/modules/Process/ProcessList.module b/wire/modules/Process/ProcessList.module index 1a32fa89..884f7858 100644 --- a/wire/modules/Process/ProcessList.module +++ b/wire/modules/Process/ProcessList.module @@ -66,8 +66,7 @@ class ProcessList extends Process { $icon = $child->get('page_icon'); if(!$icon) $icon = $info['icon']; if($icon) { - if(strpos($icon, 'fa-') === 0) list(,$icon) = explode('-', 2); - $icon = " "; + $icon = wireIconMarkup("$icon 3x fw ui-priority-secondary style='float:right'"); } } @@ -113,4 +112,3 @@ class ProcessList extends Process { return $out; } } -