From 855cfd7370ff18965311330eed3e318c6faa457a Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 5 Jun 2020 08:15:14 -0400 Subject: [PATCH] Various minor adjustments, typo and text fixes --- wire/core/Functions.php | 4 +++- wire/core/Page.php | 2 +- wire/core/WireFileTools.php | 15 ++++++++++----- wire/core/WireLog.php | 1 + wire/index.config.php | 2 +- .../types/InputfieldDatetimeSelect.php | 2 +- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/wire/core/Functions.php b/wire/core/Functions.php index 4d59d6f7..cd731a7c 100644 --- a/wire/core/Functions.php +++ b/wire/core/Functions.php @@ -723,8 +723,10 @@ function wireBytesStr($bytes, $small = false, $options = array()) { $val = $bytes; if($small) { $label = $val > 0 ? __('B', __FILE__) : ''; // bytes + } else if($val == 1) { + $label = __('byte', __FILE__); // singular 1-byte } else { - $label = __('bytes', __FILE__); + $label = __('bytes', __FILE__); // plural 2+ bytes (or 0 bytes) } } else if($bytes < 1000000 || $type === 'k') { $val = $bytes / 1024; diff --git a/wire/core/Page.php b/wire/core/Page.php index a20c7b1e..c69c41f3 100644 --- a/wire/core/Page.php +++ b/wire/core/Page.php @@ -3239,7 +3239,7 @@ class Page extends WireData implements \Countable, WireMatchable { */ public function url($options = null) { if($options !== null) return $this->traversal()->urlOptions($this, $options); - $url = rtrim($this->wire('config')->urls->root, "/") . $this->path(); + $url = rtrim($this->wire('config')->urls->root, '/') . $this->path(); if($this->template->slashUrls === 0 && $this->settings['id'] > 1) $url = rtrim($url, '/'); return $url; } diff --git a/wire/core/WireFileTools.php b/wire/core/WireFileTools.php index 744ce267..56195aa2 100644 --- a/wire/core/WireFileTools.php +++ b/wire/core/WireFileTools.php @@ -993,7 +993,7 @@ class WireFileTools extends Wire { // add .php extension if filename doesn't already have an extension if($options['autoExtension'] && !strrpos(basename($filename), '.')) { - $filename .= "." . $options['autoExtension']; + $filename .= '.' . $options['autoExtension']; } if(strpos($filename, '..') !== false) { @@ -1034,10 +1034,15 @@ class WireFileTools extends Wire { // include the file TemplateFile::pushRenderStack($filename); $func = $options['func']; - if($func == 'require') require($filename); - else if($func == 'require_once') require_once($filename); - else if($func == 'include_once') include_once($filename); - else include($filename); + if($func === 'require') { + require($filename); + } else if($func === 'require_once') { + require_once($filename); + } else if($func === 'include_once') { + include_once($filename); + } else { + include($filename); + } TemplateFile::popRenderStack(); return true; diff --git a/wire/core/WireLog.php b/wire/core/WireLog.php index 70b33085..59acd5fe 100644 --- a/wire/core/WireLog.php +++ b/wire/core/WireLog.php @@ -259,6 +259,7 @@ class WireLog extends Wire { * */ public function getFilename($name) { + $name = strtolower($name); if($name !== $this->wire('sanitizer')->pageName($name)) { throw new WireException("Log name must contain only [-_.a-z0-9] with no extension"); } diff --git a/wire/index.config.php b/wire/index.config.php index 96de674c..d1b89d23 100644 --- a/wire/index.config.php +++ b/wire/index.config.php @@ -25,7 +25,7 @@ if(!defined("PROCESSWIRE")) die(); * Note that if your site may be accessed at either domain.com OR www.domain.com, then you'll * want to include entries for both, pointing to the same /site-domain/ directory. * - * Each /site/ dir has it's own /site/config.php file that should be pointing to a separate + * Each /site/ dir has its own /site/config.php file that should be pointing to a separate * database. You shouldn't have two different /site/ dirs sharing the same database. * */ diff --git a/wire/modules/Inputfield/InputfieldDatetime/types/InputfieldDatetimeSelect.php b/wire/modules/Inputfield/InputfieldDatetime/types/InputfieldDatetimeSelect.php index 8c738e8d..85f50a20 100644 --- a/wire/modules/Inputfield/InputfieldDatetime/types/InputfieldDatetimeSelect.php +++ b/wire/modules/Inputfield/InputfieldDatetime/types/InputfieldDatetimeSelect.php @@ -138,7 +138,7 @@ class InputfieldDatetimeSelect extends InputfieldDatetimeType { $attrs = $this->inputfield->getAttributes(); $attrs['type'] = 'hidden'; - $attrs['value'] = date(InputfieldDatetime::defaultDateInputFormat . ' ' . InputfieldDatetime::defaultTimeInputFormat, $value); + if($value) $attrs['value'] = date(InputfieldDatetime::defaultDateInputFormat . ' ' . InputfieldDatetime::defaultTimeInputFormat, $value); unset($attrs['size'], $attrs['placeholder'], $attrs['class'], $attrs['required']); $attrs['class'] = 'InputfieldDatetimeValue'; $attrStr = $this->inputfield->getAttributesString($attrs);