From 906640ecb787ce53c081ccb162ac3144d72a16f5 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 1 Mar 2019 15:38:48 -0500 Subject: [PATCH] Bump version to 3.0.127 plus some other minor updates --- wire/core/PagesLoader.php | 4 ++++ wire/core/ProcessWire.php | 2 +- .../InputfieldPassword.module | 4 ++-- wire/modules/LanguageSupport/Languages.php | 20 ++++++++++++++++++- wire/modules/Process/ProcessPageView.module | 14 +++++++++++++ 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/wire/core/PagesLoader.php b/wire/core/PagesLoader.php index a2af896f..65b8ad6d 100644 --- a/wire/core/PagesLoader.php +++ b/wire/core/PagesLoader.php @@ -147,6 +147,10 @@ class PagesLoader extends Wire { foreach($a as $k => $v) $a[$k] = (int) $v; $value = $this->getById($a, $loadOptions); } + } else if(!Selectors::stringHasOperator($selector)) { + if($this->wire('sanitizer')->pageNameUTF8($selector) === $selector) { + $selector = "name=$selector"; + } } } } diff --git a/wire/core/ProcessWire.php b/wire/core/ProcessWire.php index ca335887..ef36a2be 100644 --- a/wire/core/ProcessWire.php +++ b/wire/core/ProcessWire.php @@ -44,7 +44,7 @@ class ProcessWire extends Wire { * Reversion revision number * */ - const versionRevision = 126; + const versionRevision = 127; /** * Version suffix string (when applicable) diff --git a/wire/modules/Inputfield/InputfieldPassword/InputfieldPassword.module b/wire/modules/Inputfield/InputfieldPassword/InputfieldPassword.module index 18b70969..fb6ac3e2 100644 --- a/wire/modules/Inputfield/InputfieldPassword/InputfieldPassword.module +++ b/wire/modules/Inputfield/InputfieldPassword/InputfieldPassword.module @@ -8,8 +8,8 @@ * * @property array $requirements Array of requirements (See require* constants) * @property array $requirementsLabels Text labels used for requirements - * @property string $complexifyBanMode Complexify ban mode (default='loose') - * @property float $complexifyFactor Complexify factor + * @property string $complexifyBanMode Complexify ban mode, 'loose' or 'strict' (default='loose') + * @property float $complexifyFactor Complexify factor, lower numbers enable simpler passwords (default=0.7) * @property int $requireOld Require previous password? 0=Auto, 1=Yes, -1=No, Default=0 (Auto) * @property bool $showPass Allow password to be rendered in renderValue and/or re-populated in form? * @property string $defaultLabel Default label for field (default='Set Password'). Used when no 'label' has been set. diff --git a/wire/modules/LanguageSupport/Languages.php b/wire/modules/LanguageSupport/Languages.php index f5bc2ae8..a28a8049 100644 --- a/wire/modules/LanguageSupport/Languages.php +++ b/wire/modules/LanguageSupport/Languages.php @@ -358,6 +358,24 @@ class Languages extends PagesType { return true; } + /** + * Get the current language or optionally a specific named language + * + * - This method is not entirely necessary but is here to accompany the setLanguage() method for syntax convenience. + * - If you specify a `$name` argument, this method works the same as the `$languages->get($name)` method. + * - If you call with no arguments, it returns the current user language, same as `$user->language`, but using this + * method may be preferable in some contexts, depending on how your IDE understands API calls. + * + * @param string $name Specify language name (or ID) to get a specific language, or omit to get current language + * @return Language|NullPage|null + * @since 3.0.127 + * + */ + public function getLanguage($name = '') { + if($name !== '') return is_object($name) && $name instanceof Language ? $name : $this->get($name); + return $this->wire('user')->language; + } + /** * Undo a previous setLanguage() call, restoring the previous user language * @@ -754,7 +772,7 @@ class Languages extends PagesType { } $table = $matches[1]; - $col = $matches[2]; + // $col = $matches[2]; $languageID = (int) $matches[3]; foreach($this->wire('languages') as $language) { diff --git a/wire/modules/Process/ProcessPageView.module b/wire/modules/Process/ProcessPageView.module index ce4b383b..02839acb 100644 --- a/wire/modules/Process/ProcessPageView.module +++ b/wire/modules/Process/ProcessPageView.module @@ -386,6 +386,20 @@ class ProcessPageView extends Process { } } return $page; + } else { + // check for globally unique page which can redirect + $trit = trim($it, '/'); + $spit = $this->wire('sanitizer')->pageNameUTF8($trit); + if($trit === $spit) { + // one segment off root + $spit = $this->wire('sanitizer')->selectorValue($spit); + $page = $this->wire('pages')->get("name=$spit, status=" . Page::statusUnique); + if($page->id && $page->viewable()) { + $this->redirectURL = $page->url; + } else { + $page = null; + } + } } $this->requestURL = $it;