1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-12 17:54:44 +02:00

Various minor unrelated updates

This commit is contained in:
Ryan Cramer
2023-10-19 10:26:23 -04:00
parent 88ad063af1
commit 463dd01e66
3 changed files with 23 additions and 13 deletions

View File

@@ -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]";
}

View File

@@ -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.');

View File

@@ -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 = "<i style='float: right;' class='fa fa-3x fa-fw fa-$icon ui-priority-secondary'></i> ";
$icon = wireIconMarkup("$icon 3x fw ui-priority-secondary style='float:right'");
}
}
@@ -113,4 +112,3 @@ class ProcessList extends Process {
return $out;
}
}