diff --git a/wire/core/Pages.php b/wire/core/Pages.php
index e147c999..a3ef7084 100644
--- a/wire/core/Pages.php
+++ b/wire/core/Pages.php
@@ -52,6 +52,7 @@
* @method string setupPageName(Page $page, array $options = array()) Determine and populate a name for the given page. #pw-internal
* @method void insertBefore(Page $page, Page $beforePage) Insert one page as a sibling before another. #pw-advanced
* @method void insertAfter(Page $page, Page $afterPage) Insert one page as a sibling after another. #pw-advanced
+ * @method bool touch($pages, $options = null, $type = 'modified') Update page modification time to now (or the given modification time). #pw-group-manipulation
*
* METHODS PURELY FOR HOOKS
* ========================
diff --git a/wire/modules/Fieldtype/FieldtypePageTitle.module b/wire/modules/Fieldtype/FieldtypePageTitle.module
index 19e6197f..7d24adda 100644
--- a/wire/modules/Fieldtype/FieldtypePageTitle.module
+++ b/wire/modules/Fieldtype/FieldtypePageTitle.module
@@ -8,7 +8,7 @@
* For documentation about the fields used in this class, please see:
* /wire/core/Fieldtype.php
*
- * ProcessWire 3.x, Copyright 2016 by Ryan Cramer
+ * ProcessWire 3.x, Copyright 2022 by Ryan Cramer
* https://processwire.com
*
*
@@ -22,11 +22,9 @@ class FieldtypePageTitle extends FieldtypeText implements FieldtypePageTitleComp
'version' => 100,
'summary' => 'Field that stores a page title',
'permanent' => true,
- );
+ );
}
- public static $languageSupport = false;
-
/**
* This field is only used for new fields in advanced mode
*
@@ -49,9 +47,16 @@ class FieldtypePageTitle extends FieldtypeText implements FieldtypePageTitleComp
return $value;
}
+ /**
+ * Get compatible Fieldtypes
+ *
+ * @param Field $field
+ * @return Fieldtypes
+ *
+ */
public function ___getCompatibleFieldtypes(Field $field) {
$fieldtypes = $this->wire(new Fieldtypes());
- foreach($this->wire('fieldtypes') as $fieldtype) {
+ foreach($this->wire()->fieldtypes as $fieldtype) {
if($fieldtype instanceof FieldtypePageTitleCompatible) {
$fieldtypes->add($fieldtype);
}
@@ -59,10 +64,30 @@ class FieldtypePageTitle extends FieldtypeText implements FieldtypePageTitleComp
return $fieldtypes;
}
+ /**
+ * Get Inputfield
+ *
+ * @param Page $page
+ * @param Field $field
+ * @return Inputfield|InputfieldPageTitle
+ *
+ */
public function getInputfield(Page $page, Field $field) {
+ /** @var InputfieldPageTitle $inputField */
$inputField = $this->modules->get('InputfieldPageTitle');
return $inputField;
}
+ /**
+ * True when language support is active, false if not
+ *
+ * Set by LanguageSupport.module to true during LanguageSupport::init()
+ *
+ * @var bool
+ * @deprecated No longer in use
+ *
+ */
+ public static $languageSupport = false;
+
}
diff --git a/wire/modules/Fieldtype/FieldtypeText.module b/wire/modules/Fieldtype/FieldtypeText.module
index 9668d272..9cc2c555 100644
--- a/wire/modules/Fieldtype/FieldtypeText.module
+++ b/wire/modules/Fieldtype/FieldtypeText.module
@@ -8,7 +8,7 @@
* For documentation about the fields used in this class, please see:
* /wire/core/Fieldtype.php
*
- * ProcessWire 3.x, Copyright 2021 by Ryan Cramer
+ * ProcessWire 3.x, Copyright 2022 by Ryan Cramer
* https://processwire.com
*
*
@@ -54,7 +54,7 @@ class FieldtypeText extends Fieldtype {
*/
public function ___getCompatibleFieldtypes(Field $field) {
$fieldtypes = $this->wire(new Fieldtypes());
- foreach($this->wire('fieldtypes') as $fieldtype) {
+ foreach($this->wire()->fieldtypes as $fieldtype) {
if($fieldtype instanceof FieldtypeText) {
$fieldtypes->add($fieldtype);
} else {
@@ -117,7 +117,7 @@ class FieldtypeText extends Fieldtype {
*
*/
public function isEmptyValue(Field $field, $value) {
- return !strlen($value);
+ return !strlen("$value");
}
/**
@@ -162,7 +162,7 @@ class FieldtypeText extends Fieldtype {
*/
public function getDatabaseSchema(Field $field) {
$schema = parent::getDatabaseSchema($field);
- $len = $this->wire('database')->getMaxIndexLength();
+ $len = $this->wire()->database->getMaxIndexLength();
$schema['data'] = 'text NOT NULL';
$schema['keys']['data_exact'] = "KEY `data_exact` (`data`($len))";
$schema['keys']['data'] = 'FULLTEXT KEY `data` (`data`)';
@@ -193,7 +193,7 @@ class FieldtypeText extends Fieldtype {
$inputfields->add($fieldset);
/** @var InputfieldAsmSelect $f */
- $f = $this->modules->get('InputfieldAsmSelect');
+ $f = $modules->get('InputfieldAsmSelect');
$f->attr('name', 'textformatters');
$f->label = $this->_('Text formatters');
@@ -216,7 +216,7 @@ class FieldtypeText extends Fieldtype {
if($field->type->className() === 'FieldtypeText') {
/** @var InputfieldSelect $field */
$defaultLabel = $this->_('Default');
- $f = $this->modules->get('InputfieldRadios');
+ $f = $modules->get('InputfieldRadios');
$f->attr('name', 'inputfieldClass');
$f->label = $this->_('Input module');
$f->description = $this->_('Save after changing this as it may affect what settings are available on the “Input” tab.');
@@ -231,7 +231,6 @@ class FieldtypeText extends Fieldtype {
$f->collapsed = Inputfield::collapsedBlank;
$fieldset->add($f);
}
-
return $inputfields;
}
@@ -249,7 +248,7 @@ class FieldtypeText extends Fieldtype {
if(isset($data['textformatters']) && is_array($data['textformatters'])) {
$errors = array();
foreach($data['textformatters'] as $className) {
- if(!$this->wire('modules')->isInstalled($className)) {
+ if(!$this->wire()->modules->isInstalled($className)) {
$errors[] = "Requires module '$className' to be installed";
}
}
@@ -269,7 +268,7 @@ class FieldtypeText extends Fieldtype {
*
*/
public function ___importValue(Page $page, Field $field, $value, array $options = array()) {
- if(is_array($value) && isset($value['default']) && !$this->wire('languages')) {
+ if(is_array($value) && isset($value['default']) && !$this->wire()->languages) {
// multi-language value to non-multi-language site, use only default language
$value = $value['default'];
}
diff --git a/wire/modules/Fieldtype/FieldtypeTextarea.module b/wire/modules/Fieldtype/FieldtypeTextarea.module
index 874f99f5..430e87d1 100644
--- a/wire/modules/Fieldtype/FieldtypeTextarea.module
+++ b/wire/modules/Fieldtype/FieldtypeTextarea.module
@@ -8,7 +8,7 @@
* For documentation about the fields used in this class, please see:
* /wire/core/Fieldtype.php
*
- * ProcessWire 3.x, Copyright 2018 by Ryan Cramer
+ * ProcessWire 3.x, Copyright 2022 by Ryan Cramer
* https://processwire.com
*
* Properties set to $field that is using this type, acceessed by $field->get('property'):
@@ -190,7 +190,7 @@ class FieldtypeTextarea extends FieldtypeText {
*/
protected function htmlReplacements(Page $page, Field $field, &$value, $sleep = true) {
- $languages = $this->wire('languages');
+ $languages = $this->wire()->languages;
if(is_array($value)) {
// array of values, most likely multi-language data123 columns from loadPageField
@@ -265,7 +265,7 @@ class FieldtypeTextarea extends FieldtypeText {
}
static $lsep = null;
- if($lsep === null) $lsep = $this->wire('sanitizer')->unentities('
');
+ if($lsep === null) $lsep = $this->wire()->sanitizer->unentities('
');
if(strpos($value, $lsep) !== false) $value = str_replace($lsep, '', $value);
}
@@ -279,16 +279,17 @@ class FieldtypeTextarea extends FieldtypeText {
*/
public function getInputfield(Page $page, Field $field) {
+ $modules = $this->wire()->modules;
$inputfieldClass = $field->get('inputfieldClass');
if($inputfieldClass) {
- $inputfield = $this->modules->getModule($inputfieldClass, array('noSubstitute' => true));
+ $inputfield = $modules->getModule($inputfieldClass, array('noSubstitute' => true));
} else {
- $inputfield = $this->modules->get(self::defaultInputfieldClass);
+ $inputfield = $modules->get(self::defaultInputfieldClass);
}
if(!$inputfield) {
- $inputfield = $this->modules->get(self::defaultInputfieldClass);
+ $inputfield = $modules->get(self::defaultInputfieldClass);
$this->configHelper()->getInputfieldError($field);
}
@@ -319,7 +320,7 @@ class FieldtypeTextarea extends FieldtypeText {
*/
public function configHelper() {
if(is_null($this->configHelper)) {
- require_once($this->wire('config')->paths->FieldtypeTextarea . 'FieldtypeTextareaHelper.php');
+ require_once($this->wire()->config->paths('FieldtypeTextarea') . 'FieldtypeTextareaHelper.php');
$this->configHelper = new FieldtypeTextareaHelper();
}
return $this->configHelper;
@@ -400,7 +401,7 @@ class FieldtypeTextarea extends FieldtypeText {
*/
protected function importValueHTML($value, array $options) {
// update changed root URLs in href or src attributes
- $config = $this->wire('config');
+ $config = $this->wire()->config;
$url = $config->urls->root;
$host = $config->httpHost;
$_url = isset($options['originalRootUrl']) ? $options['originalRootUrl'] : $url; // original URL
@@ -453,7 +454,7 @@ class FieldtypeTextarea extends FieldtypeText {
$searchFields = array();
if($selector === true) $selector = "include=all";
- foreach($this->wire('fields') as $f) {
+ foreach($this->wire()->fields as $f) {
if($field) {
if("$f" != "$field") continue;
} else {
@@ -467,7 +468,7 @@ class FieldtypeTextarea extends FieldtypeText {
$searchFields[$f->name] = $f->name;
}
- if(!count($searchFields)) return $this->wire('pages')->newPageArray();
+ if(!count($searchFields)) return $this->wire()->pages->newPageArray();
return $this->markupQA()->findLinks($page, $searchFields, $selector, $options);
}
diff --git a/wire/modules/Fieldtype/FieldtypeTextareaHelper.php b/wire/modules/Fieldtype/FieldtypeTextareaHelper.php
index bd86e635..888926d9 100644
--- a/wire/modules/Fieldtype/FieldtypeTextareaHelper.php
+++ b/wire/modules/Fieldtype/FieldtypeTextareaHelper.php
@@ -3,7 +3,7 @@
/**
* Helper class for FieldtypeTextarea configuration
*
- * ProcessWire 3.x, Copyright 2016 by Ryan Cramer
+ * ProcessWire 3.x, Copyright 2022 by Ryan Cramer
* https://processwire.com
*
*/
@@ -27,9 +27,11 @@ class FieldtypeTextareaHelper extends Wire {
*
*/
function getConfigInputfields(Field $field, InputfieldWrapper $inputfields) {
+ $modules = $this->wire()->modules;
+
$value = $field->get('inputfieldClass');
/** @var InputfieldSelect $f */
- $f = $this->modules->get('InputfieldSelect');
+ $f = $modules->get('InputfieldSelect');
$f->attr('name', 'inputfieldClass');
$f->attr('value', $value ? $value : FieldtypeTextarea::defaultInputfieldClass);
$f->label = $this->_('Inputfield Type');
@@ -48,7 +50,8 @@ class FieldtypeTextareaHelper extends Wire {
$htmlLabel = $this->_('Markup/HTML');
$typeLabel = $this->_('Content Type');
- $f = $this->modules->get('InputfieldRadios');
+ /** @var InputfieldRadios $f */
+ $f = $modules->get('InputfieldRadios');
$f->attr('name', 'contentType');
$f->label = $typeLabel;
$f->addOption(FieldtypeTextarea::contentTypeUnknown, $this->_('Unknown/Text'));
@@ -62,13 +65,15 @@ class FieldtypeTextareaHelper extends Wire {
$f->notes = sprintf($this->_('For more information about the options above see [description of content type options](%s).'), 'https://processwire.com/api/fieldtypes/textarea-fieldtype/#content-type');
$inputfields->append($f);
- $fieldset = $this->wire('modules')->get('InputfieldFieldset');
+ /** @var InputfieldFieldset $fieldset */
+ $fieldset = $modules->get('InputfieldFieldset');
$fieldset->label = "$htmlLabel ($typeLabel)";
$fieldset->icon = 'html5';
$fieldset->showIf = 'contentType=' . FieldtypeTextarea::contentTypeHTML;
$inputfields->add($fieldset);
- $f = $this->modules->get('InputfieldCheckboxes');
+ /** @var InputfieldCheckboxes $f */
+ $f = $modules->get('InputfieldCheckboxes');
$f->attr('name', 'htmlOptions');
$f->label = $this->_('HTML Options');
$f->description = $this->_('The following options provide additional quality assurance for HTML at runtime.');
@@ -112,7 +117,7 @@ class FieldtypeTextareaHelper extends Wire {
$fieldset->add($f);
/** @var InputfieldCheckbox $f */
- $f = $this->wire('modules')->get('InputfieldCheckbox');
+ $f = $modules->get('InputfieldCheckbox');
$f->attr('name', '_applyHTML');
$f->label = $this->_('Apply HTML Options Now');
$f->description = $this->_('To apply the above options to all existing pages right now, check this box. This primarily focuses on the link abstraction option.');
@@ -123,9 +128,9 @@ class FieldtypeTextareaHelper extends Wire {
$f->showIf = 'htmlOptions=' . FieldtypeTextarea::htmlLinkAbstract;
$fieldset->add($f);
- if($this->wire('input')->post('_applyHTML') && $this->wire('process') == 'ProcessField') {
+ if($this->wire()->input->post('_applyHTML') && $this->wire('process') == 'ProcessField') {
$this->applyFieldHTML = $field;
- $this->wire('session')->addHookBefore('redirect', $this, 'applyFieldHTML');
+ $this->wire()->session->addHookBefore('redirect', $this, 'applyFieldHTML');
}
return $inputfields;
@@ -139,6 +144,10 @@ class FieldtypeTextareaHelper extends Wire {
*
*/
public function applyFieldHTML(HookEvent $event) {
+ if($event) {} // ignore
+
+ $pages = $this->wire()->pages;
+ $config = $this->wire()->config;
set_time_limit(3600);
@@ -146,9 +155,9 @@ class FieldtypeTextareaHelper extends Wire {
if(!$field || !$field instanceof Field || !$field->type instanceof FieldtypeTextarea) return;
$selector = "$field->name%=href|src, include=all";
- $total = $this->wire('pages')->count($selector);
+ $total = $pages->count($selector);
- $applyMax = (int) $this->wire('config')->applyHTMLMaxItems;
+ $applyMax = (int) $config->applyHTMLMaxItems;
if(!$applyMax) $applyMax = 300;
if($total > $applyMax) {
@@ -157,7 +166,7 @@ class FieldtypeTextareaHelper extends Wire {
$selector .= ", limit=$applyMax, modified<=$modified";
}
- $items = $this->wire('pages')->find($selector);
+ $items = $pages->find($selector);
$totals = array();
foreach($items as $item) {
@@ -174,7 +183,7 @@ class FieldtypeTextareaHelper extends Wire {
}
}
- $this->wire('pages')->touch($items, time());
+ $pages->touch($items, time());
if(!count($items) || count($items) == $total) {
$statusNote = ' ' .
@@ -187,10 +196,10 @@ class FieldtypeTextareaHelper extends Wire {
$statusNote = sprintf($statusNote, '$config->applyHTMLMaxItems = ' . ($applyMax * 2) . ';
');
}
- $logFile = $this->wire('config')->paths->logs . 'markup-qa-errors.txt';
+ $logFile = $config->paths->logs . 'markup-qa-errors.txt';
$logInfo = '';
if(is_file($logFile)) {
- $logURL = $this->wire('config')->urls->admin . 'setup/logs/view/markup-qa-errors/';
+ $logURL = $config->urls->admin . 'setup/logs/view/markup-qa-errors/';
$logInfo = ' ' . sprintf($this->_('(see %s log)'), "markup-qa-errors");
}
@@ -229,7 +238,7 @@ class FieldtypeTextareaHelper extends Wire {
}
}
- $this->wire('session')->message('' .
+ $this->wire()->session->message('' .
sprintf($this->_('Updated %1$d out of %2$d pages for HTML options.'), count($items), $total) . '
' .
"$statusNote
" .
"$html5 " . $this->_('Markup/HTML quality assurance summary:') . '
' .
@@ -246,9 +255,10 @@ class FieldtypeTextareaHelper extends Wire {
*
*/
public function getInputfieldError(Field $field) {
+ $config = $this->wire()->config;
- $editURL = $this->wire('config')->urls->admin . "setup/field/edit?id=$field->id";
- $modulesURL = $this->wire('config')->urls->admin . "module/";
+ $editURL = $config->urls->admin . "setup/field/edit?id=$field->id";
+ $modulesURL = $config->urls->admin . "module/";
$inputfieldClass = $field->get('inputfieldClass');
$findURL = "https://processwire.com/search/?q=$inputfieldClass&t=Modules";
$tab = '
';
@@ -260,7 +270,7 @@ class FieldtypeTextareaHelper extends Wire {
"$tab 3. Select the \"Inputfield Type\". $tab 4. Click \"Save\".";
if($inputfieldClass == 'InputfieldTinyMCE') {
- $this->wire('modules')->getInstall('InputfieldCKEditor'); // install it so it's ready for them
+ $this->wire()->modules->getInstall('InputfieldCKEditor'); // install it so it's ready for them
$this->error(
"Field '$field->name' uses TinyMCE, which is no longer part of the core. " .
"Please install TinyMCE " .
diff --git a/wire/modules/Fieldtype/FieldtypeURL.module b/wire/modules/Fieldtype/FieldtypeURL.module
index 194aa1cf..c151da9f 100644
--- a/wire/modules/Fieldtype/FieldtypeURL.module
+++ b/wire/modules/Fieldtype/FieldtypeURL.module
@@ -8,7 +8,7 @@
* For documentation about the fields used in this class, please see:
* /wire/core/Fieldtype.php
*
- * ProcessWire 3.x, Copyright 2016 by Ryan Cramer
+ * ProcessWire 3.x, Copyright 2022 by Ryan Cramer
* https://processwire.com
*
*
@@ -22,7 +22,7 @@ class FieldtypeURL extends FieldtypeText {
'version' => 101,
'summary' => __('Field that stores a URL', __FILE__),
'permanent' => true,
- );
+ );
}
public function init() {
@@ -39,22 +39,38 @@ class FieldtypeURL extends FieldtypeText {
*
*/
public function sanitizeValue(Page $page, Field $field, $value) {
- return $this->sanitizer->url($value, array(
+ return $this->wire()->sanitizer->url($value, array(
'allowRelative' => $field->get('noRelative') ? false : true,
'allowIDN' => $field->get('allowIDN') ? true : false,
'stripQuotes' => $field->get('allowQuotes') ? false : true
));
}
-
+ /**
+ * Get Inputfield
+ *
+ * @param Page $page
+ * @param Field $field
+ * @return Inputfield|InputfieldURL
+ *
+ */
public function getInputfield(Page $page, Field $field) {
/** @var InputfieldURL $inputfield */
- $inputfield = $this->modules->get('InputfieldURL');
+ $inputfield = $this->wire()->modules->get('InputfieldURL');
$inputfield->set('noRelative', $field->get('noRelative'));
$inputfield->set('addRoot', $field->get('addRoot'));
return $inputfield;
}
+ /**
+ * Format value
+ *
+ * @param Page $page
+ * @param Field $field
+ * @param string $value
+ * @return string
+ *
+ */
public function ___formatValue(Page $page, Field $field, $value) {
if($field->get('addRoot') && !$field->get('noRelative') && substr($value, 0, 1) == '/') {
$root = rtrim($this->config->urls->root, '/');
@@ -64,7 +80,16 @@ class FieldtypeURL extends FieldtypeText {
return $value;
}
+ /**
+ * Get field configuration Inputfields
+ *
+ * @param Field $field
+ * @return InputfieldWrapper
+ *
+ */
public function ___getConfigInputfields(Field $field) {
+ $modules = $this->wire()->modules;
+
$inputfields = parent::___getConfigInputfields($field);
$labelYes = $this->_('Yes');
$labelNo = $this->_('No');
@@ -79,7 +104,7 @@ class FieldtypeURL extends FieldtypeText {
}
/** @var InputfieldRadios $f */
- $f = $this->modules->get('InputfieldRadios');
+ $f = $modules->get('InputfieldRadios');
$f->attr('name', 'noRelative');
$f->label = $this->_('Allow relative/local URLs without "http://" at the beginning?');
$f->addOption(0, $labelYes);
@@ -90,7 +115,8 @@ class FieldtypeURL extends FieldtypeText {
$f->optionColumns = 1;
$inputfields->add($f);
- $f = $this->modules->get('InputfieldRadios');
+ /** @var InputfieldRadios $f */
+ $f = $modules->get('InputfieldRadios');
$f->attr('name', 'allowIDN');
$f->label = $this->_('Allow internationalized domain names (IDNs)?');
$f->addOption(1, $labelYes);
@@ -101,7 +127,8 @@ class FieldtypeURL extends FieldtypeText {
$f->optionColumns = 1;
$inputfields->add($f);
- $f = $this->modules->get('InputfieldRadios');
+ /** @var InputfieldRadios $f */
+ $f = $modules->get('InputfieldRadios');
$f->attr('name', 'allowQuotes');
$f->label = $this->_('Allow single/double quote characters in URLs?');
$f->addOption(1, $labelYes);
@@ -112,7 +139,8 @@ class FieldtypeURL extends FieldtypeText {
$f->optionColumns = 1;
$inputfields->add($f);
- $f = $this->modules->get('InputfieldRadios');
+ /** @var InputfieldRadios $f */
+ $f = $modules->get('InputfieldRadios');
$f->attr('name', 'addRoot');
$f->label = $this->_("Prepend site's root path to local/relative URLs?");
$f->addOption(1, $labelYes);
diff --git a/wire/modules/Inputfield/InputfieldSelect.module b/wire/modules/Inputfield/InputfieldSelect.module
index 8c7ea26a..367e8b23 100644
--- a/wire/modules/Inputfield/InputfieldSelect.module
+++ b/wire/modules/Inputfield/InputfieldSelect.module
@@ -49,7 +49,7 @@ class InputfieldSelect extends Inputfield implements InputfieldHasSelectableOpti
'summary' => __('Selection of a single value from a select pulldown', __FILE__), // Module Summary
'version' => 102,
'permanent' => true,
- );
+ );
}
/**
diff --git a/wire/modules/Inputfield/InputfieldText/InputfieldText.module b/wire/modules/Inputfield/InputfieldText/InputfieldText.module
index 401200c9..da90e990 100644
--- a/wire/modules/Inputfield/InputfieldText/InputfieldText.module
+++ b/wire/modules/Inputfield/InputfieldText/InputfieldText.module
@@ -3,6 +3,9 @@
/**
* An Inputfield for handling single line "text" form inputs
*
+ * ProcessWire 3.x, Copyright 2022 by Ryan Cramer
+ * https://processwire.com
+ *
* @property string $type Input type (typically "text")
* @property int $size Size of input or 0 for full width
* @property int $minlength Minimum allowed length of value (usually combined with 'required' option)
@@ -32,7 +35,7 @@ class InputfieldText extends Inputfield {
'summary' => __('Single line of text', __FILE__), // Module Summary
'version' => 106,
'permanent' => true,
- );
+ );
}
/**
@@ -53,14 +56,19 @@ class InputfieldText extends Inputfield {
$this->set('noTrim', false);
$this->set('showCount', self::showCountNone);
}
-
+
+ /**
+ * Wired to API
+ *
+ */
public function wired() {
// if multi-language, support placeholders for each language
- /** @var Languages $languages */
- $languages = $this->wire('languages');
- if($languages) foreach($languages as $language) {
- // set to blank value so that Field::getInputfield() will recogize this setting is for InputfieldText
- if(!$language->isDefault()) $this->set("placeholder$language", '');
+ $languages = $this->wire()->languages;
+ if($languages) {
+ foreach($languages as $language) {
+ // set to blank value so that Field::getInputfield() will recogize this setting is for InputfieldText
+ if(!$language->isDefault()) $this->set("placeholder$language", '');
+ }
}
parent::wired();
}
@@ -149,8 +157,8 @@ class InputfieldText extends Inputfield {
if(isset($attrs['maxlength']) && (int) $attrs['maxlength'] < 1) unset($attrs['maxlength']);
// placeholder attribute, languages support
- if(!empty($attrs['placeholder']) && $this->wire('languages')) {
- $language = $this->wire('user')->language;
+ if(!empty($attrs['placeholder']) && $this->wire()->languages) {
+ $language = $this->wire()->user->language;
if($language && $language->id && !$language->isDefault()) {
$placeholder = parent::get("placeholder$language->id");
if(strlen($placeholder)) $attrs['placeholder'] = $placeholder;
@@ -193,12 +201,12 @@ class InputfieldText extends Inputfield {
protected function setAttributeValue($value) {
if($this->maxlength > 0) {
- $value = $this->wire('sanitizer')->text($value, array(
+ $value = $this->wire()->sanitizer->text($value, array(
'maxLength' => $this->maxlength,
'maxBytes' => $this->maxlength*4,
'stripTags' => false,
'trim' => $this->noTrim ? false : true,
- ));
+ ));
}
if($this->stripTags) $value = strip_tags($value);
@@ -243,7 +251,9 @@ class InputfieldText extends Inputfield {
if($this->pattern) {
$regex = '#' . str_replace('#', '\#', $this->pattern) . '#'; // add delimeters
- if(!preg_match($regex, $value)) $this->error($this->_('Does not match required pattern'));
+ if(!preg_match($regex, $value)) {
+ $this->error($this->_('Does not match required pattern'));
+ }
}
if($minlength > 0 && $length < $minlength) {
@@ -276,10 +286,13 @@ class InputfieldText extends Inputfield {
*/
public function ___getConfigInputfields() {
+ $modules = $this->wire()->modules;
+ $languages = $this->wire()->languages;
+
$inputfields = parent::___getConfigInputfields();
/** @var InputfieldInteger $field */
- $field = $this->modules->get('InputfieldInteger');
+ $field = $modules->get('InputfieldInteger');
$field->setAttribute('name', 'minlength');
$field->label = $this->_('Minimum length');
$field->setAttribute('value', (int) $this->minlength);
@@ -290,7 +303,7 @@ class InputfieldText extends Inputfield {
$inputfields->append($field);
/** @var InputfieldInteger $field */
- $field = $this->modules->get('InputfieldInteger');
+ $field = $modules->get('InputfieldInteger');
$field->setAttribute('name', 'maxlength');
$field->label = $this->_('Maximum length');
$field->setAttribute('value', $this->attr('maxlength'));
@@ -301,7 +314,7 @@ class InputfieldText extends Inputfield {
$inputfields->append($field);
/** @var InputfieldRadios $field */
- $field = $this->modules->get('InputfieldRadios');
+ $field = $modules->get('InputfieldRadios');
$field->attr('name', 'showCount');
$field->label = $this->_('Counter');
$field->addOption(0, $this->_('No counter'));
@@ -314,7 +327,7 @@ class InputfieldText extends Inputfield {
$inputfields->add($field);
/** @var InputfieldInteger $field */
- $field = $this->modules->get('InputfieldInteger');
+ $field = $modules->get('InputfieldInteger');
$field->setAttribute('name', 'size');
$field->label = $this->_('Size');
$field->setAttribute('value', $this->attr('size') > 0 ? $this->attr('size') : 0);
@@ -324,7 +337,7 @@ class InputfieldText extends Inputfield {
$inputfields->append($field);
/** @var InputfieldCheckbox $field */
- $field = $this->modules->get('InputfieldCheckbox');
+ $field = $modules->get('InputfieldCheckbox');
$field->attr('name', 'stripTags');
$field->label = $this->_('Strip Tags');
$field->description = $this->_('When checked, any HTML tags will be stripped from the input when the form is processed.');
@@ -338,15 +351,15 @@ class InputfieldText extends Inputfield {
$inputfields->append($field);
/** @var InputfieldText $field */
- $field = $this->modules->get('InputfieldText');
+ $field = $modules->get('InputfieldText');
$field->setAttribute('name', 'placeholder');
$field->label = $this->_('Placeholder Text');
$field->setAttribute('value', $this->attr('placeholder'));
$field->description = $this->_('Optional placeholder phrase of text that appears in the field when blank.');
$field->collapsed = Inputfield::collapsedBlank;
- if($this->wire('languages')) {
+ if($languages) {
$field->useLanguages = true;
- foreach($this->wire('languages') as $language) {
+ foreach($languages as $language) {
if($language->isDefault()) continue;
$value = $this->getSetting("placeholder$language");
if(!is_null($value)) $field->set("value$language", $value);
@@ -355,7 +368,7 @@ class InputfieldText extends Inputfield {
$inputfields->append($field);
/** @var InputfieldText $field */
- $field = $this->modules->get('InputfieldText');
+ $field = $modules->get('InputfieldText');
$field->setAttribute('name', 'pattern');
$field->label = $this->_('Pattern');
$field->setAttribute('value', $this->attr('pattern'));
@@ -366,7 +379,7 @@ class InputfieldText extends Inputfield {
if($this->hasFieldtype === false) {
/** @var InputfieldText $field */
- $field = $this->modules->get('InputfieldText');
+ $field = $modules->get('InputfieldText');
$field->setAttribute('name', 'initValue');
$field->label = $this->_('Initial Value');
$field->description = $this->_('Optional initial/default value pre-populated for the user.');
@@ -389,8 +402,4 @@ class InputfieldText extends Inputfield {
$a = array('initValue', 'pattern', 'placeholder', 'maxlength', 'minlength', 'required', 'requiredAttr');
return array_merge(parent::___getConfigAllowContext($field), $a);
}
-
-
-
-
}
diff --git a/wire/modules/Inputfield/InputfieldTextarea.module b/wire/modules/Inputfield/InputfieldTextarea.module
index bff42c15..23c246f2 100644
--- a/wire/modules/Inputfield/InputfieldTextarea.module
+++ b/wire/modules/Inputfield/InputfieldTextarea.module
@@ -30,7 +30,7 @@ class InputfieldTextarea extends InputfieldText {
'summary' => __('Multiple lines of text', __FILE__), // Module Summary
'version' => 103,
'permanent' => true,
- );
+ );
}
/**
diff --git a/wire/modules/Markup/MarkupHTMLPurifier/MarkupHTMLPurifier.module b/wire/modules/Markup/MarkupHTMLPurifier/MarkupHTMLPurifier.module
index 34e1b1c2..407aa249 100644
--- a/wire/modules/Markup/MarkupHTMLPurifier/MarkupHTMLPurifier.module
+++ b/wire/modules/Markup/MarkupHTMLPurifier/MarkupHTMLPurifier.module
@@ -182,7 +182,7 @@ class MarkupHTMLPurifier extends WireData implements Module {
* See configuration options at: http://htmlpurifier.org/live/configdoc/plain.html
*
* @param string $key
- * @param string $value
+ * @param string|array|mixed $value
* @return WireData|MarkupHTMLPurifier
*
*/
diff --git a/wire/modules/Process/ProcessHome.module b/wire/modules/Process/ProcessHome.module
index cb75520a..e703f446 100644
--- a/wire/modules/Process/ProcessHome.module
+++ b/wire/modules/Process/ProcessHome.module
@@ -9,8 +9,11 @@
* For more details about how Process modules work, please see:
* /wire/core/Process.php
*
- * ProcessWire 3.x, Copyright 2016 by Ryan Cramer
+ * ProcessWire 3.x, Copyright 2022 by Ryan Cramer
* https://processwire.com
+ *
+ * @method string execute()
+ * @method string ajax()
*
*
*/
@@ -24,24 +27,28 @@ class ProcessHome extends Process {
'version' => 101,
'permission' => 'page-view',
'permanent' => true,
- );
+ );
}
public function ___execute() {
- $input = $this->wire('input');
+
+ if($this->wire()->config->ajax) return '';
+
+ $input = $this->wire()->input;
+ $sanitizer = $this->wire()->sanitizer;
$vars = array();
- if($input->get('login')) $vars['login'] = (int) $input->get('login');
- if($input->get('layout')) $vars['layout'] = $this->wire('sanitizer')->name($input->get('layout'));
- $url = "page/";
- if(count($vars)) {
- $url .= '?';
- foreach($vars as $key => $value) {
- $url .= "$key=" . $this->wire('sanitizer')->entities($value) . "&";
- }
- $url = rtrim($url, '&');
- }
- $this->session->redirect($url);
- }
+
+ $login = $input->get('login');
+ $layout = $input->get('layout');
+ if($login) $vars['login'] = (int) $login;
+ if($layout) $vars['layout'] = $sanitizer->name($layout);
+ unset($login, $layout);
+
+ $url = 'page/';
+ if(count($vars)) $url .= '?' . http_build_query($vars);
+
+ $this->wire()->session->location($url);
+ }
}