1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-07 15:26:54 +02:00

Various minor code and phpdoc updates in several classes

This commit is contained in:
Ryan Cramer
2023-09-11 12:12:56 -04:00
parent 4bb5dbf4a6
commit 41adc02373
22 changed files with 205 additions and 196 deletions

View File

@@ -5,7 +5,7 @@
*
* Supportings finding and manipulating of markup regions in an HTML document.
*
* ProcessWire 3.x, Copyright 2017 by Ryan Cramer
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
* https://processwire.com
*
*/
@@ -277,7 +277,7 @@ class WireMarkupRegions extends Wire {
if(!empty($options['leftover'])) {
if(!empty($leftover)) {
foreach($regions as $key => $region) {
foreach($regions as $region) {
if(strpos($leftover, $region['html']) !== false) {
$leftover = str_replace($region['html'], '', $leftover);
}
@@ -340,7 +340,7 @@ class WireMarkupRegions extends Wire {
if(strpos($find, '.') > 0) {
// i.e. "div.myclass"
list($findTag, $_find) = explode('.', $find, 2);
if($this->wire('sanitizer')->alphanumeric($findTag) === $findTag) {
if($this->wire()->sanitizer->alphanumeric($findTag) === $findTag) {
$find = ".$_find";
} else {
$findTag = '';
@@ -997,14 +997,15 @@ class WireMarkupRegions extends Wire {
*
*/
public function renderAttributes(array $attrs, $encode = true, $quote = '"') {
$sanitizer = $this->wire()->sanitizer;
$str = '';
foreach($attrs as $name => $value) {
if(!ctype_alnum($name)) {
// only allow [-_a-zA-Z] attribute names
$name = $this->wire('sanitizer')->name($name);
$name = $sanitizer->name($name);
}
// convert arrays to space separated string
@@ -1023,7 +1024,7 @@ class WireMarkupRegions extends Wire {
if($encode) {
// entity encode value
$value = $this->wire('sanitizer')->entities($value);
$value = $sanitizer->entities($value);
} else if(strpos($value, '"') !== false && strpos($value, "'") === false) {
// if value has a quote in it, use single quotes rather than double quotes
@@ -1358,7 +1359,7 @@ class WireMarkupRegions extends Wire {
$options = array_merge($defaults, $options);
$leftoverMarkup = '';
$hasDebugLandmark = strpos($htmlDocument, self::debugLandmark) !== false;
$debug = $hasDebugLandmark && $this->wire('config')->debug;
$debug = $hasDebugLandmark && $this->wire()->config->debug;
$debugTimer = $debug ? Debug::timer() : 0;
if(is_array($htmlRegions)) {
@@ -1398,7 +1399,7 @@ class WireMarkupRegions extends Wire {
$updates = array();
$numUpdates = 0;
foreach($regions as $regionKey => $region) {
foreach($regions as /* $regionKey => */ $region) {
if(empty($region['action'])) $region['action'] = 'auto'; // replace
if(empty($region['actionTarget'])) $region['actionTarget'] = $region['pwid']; // replace
@@ -1506,7 +1507,7 @@ class WireMarkupRegions extends Wire {
if(count($this->debugNotes)) {
$this->debugNotes = array_unique($this->debugNotes);
$debugNotes[] = "---------------";
foreach($this->debugNotes as $n => $s) {
foreach($this->debugNotes as $s) {
$debugNotes[] = $this->debugNoteStr($s);
}
}
@@ -1630,7 +1631,7 @@ class WireMarkupRegions extends Wire {
if(!count($debugNotes)) $debugNotes[] = "Nothing found";
if($debugTimer !== null) $debugNotes[] = '[sm]' . Debug::timer($debugTimer) . ' seconds[/sm]';
$out = "" . implode("\n", $debugNotes);
$out = $this->wire('sanitizer')->entities($out);
$out = $this->wire()->sanitizer->entities($out);
$out = str_replace(array('[sm]', '[/sm]'), array('<small style="opacity:0.7">', '</small>'), $out);
$out = str_replace(array('[b]', '[/b]'), array('<strong>', '</strong>'), $out);
$out = "<pre class='pw-debug pw-region-debug'>$out</pre>" . self::debugLandmark;
@@ -1643,4 +1644,4 @@ class WireMarkupRegions extends Wire {
$markup = str_replace(self::debugLandmark, $out, $markup);
}
}
}

View File

@@ -5,7 +5,7 @@
*
* Includes methods for random strings, numbers, arrays and passwords.
*
* ProcessWire 3.x, Copyright 2018 by Ryan Cramer
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
* https://processwire.com
*
* @since 3.0.111
@@ -640,7 +640,7 @@ class WireRandom extends Wire {
$numUpper = $this->integer($options['minUpper'], $options['maxUpper']);
if($numUpper) {
$value = strtolower($value);
$test = $this->wire('sanitizer')->alpha($value);
$test = $this->wire()->sanitizer->alpha($value);
if(strlen($test) < $numUpper) {
// there aren't enough characters present to meet requirements, so add some
$value .= $this->alpha($numUpper - strlen($test), array('disallow' => $disallow));
@@ -672,7 +672,7 @@ class WireRandom extends Wire {
// manage quantity of required digits
if($options['minDigits'] > 0) {
$test = $this->wire('sanitizer')->digits($value);
$test = $this->wire()->sanitizer->digits($value);
$test = str_replace($options['disallow'], '', $test);
$numDigits = $options['minDigits'] - strlen($test);
if($numDigits > 0) {

View File

@@ -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 2023 by Ryan Cramer
* https://processwire.com
*
*/
@@ -21,7 +21,7 @@ class FieldtypePassword extends Fieldtype {
'version' => 101,
'summary' => 'Field that stores a hashed and salted password',
'permanent' => true,
);
);
}
/**
@@ -29,7 +29,7 @@ class FieldtypePassword extends Fieldtype {
*
*/
public function init() {
return parent::init();
parent::init();
}
/**
@@ -120,7 +120,7 @@ class FieldtypePassword extends Fieldtype {
* @param Page $page
* @param Field $field
* @param string|int|array|object $value
* @return string|int
* @return array|string|int
*
*/
public function ___sleepValue(Page $page, Field $field, $value) {
@@ -130,7 +130,7 @@ class FieldtypePassword extends Fieldtype {
$sleepValue = array(
'salt' => $value->salt,
'data' => $value->hash,
);
);
// salt not needed for blowfish since it is prepended to the hash already
// if($value->isBlowfish()) $sleepValue['salt'] = '';
@@ -150,7 +150,7 @@ class FieldtypePassword extends Fieldtype {
$schema = parent::getDatabaseSchema($field);
$schema['data'] = 'char(40) NOT NULL';
$schema['salt'] = 'char(32) NOT NULL';
$engine = $this->wire('config')->dbEngine;
$engine = $this->wire()->config->dbEngine;
$schema['xtra']['append'] = "ENGINE=$engine DEFAULT CHARSET=ascii";
return $schema;
}
@@ -168,4 +168,3 @@ class FieldtypePassword extends Fieldtype {
return $inputfields;
}
}

View File

@@ -69,7 +69,7 @@
* For documentation about the fields used in this class, please see:
* /wire/core/Fieldtype.php
*
* ProcessWire 3.x, Copyright 2019 by Ryan Cramer
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
* https://processwire.com
*
*
@@ -117,7 +117,7 @@ class FieldtypeToggle extends Fieldtype {
*
* @param Page $page
* @param Field $field
* @return mixed
* @return string
*
*/
public function getDefaultValue(Page $page, Field $field) {
@@ -142,7 +142,6 @@ class FieldtypeToggle extends Fieldtype {
*
*/
public function isEmptyValue(Field $field, $value) {
if($field) {}
// 0 is allowed because it represents "no/off" selection
if($value === 0 || $value === "0") return false;
if($value === 'unknown' || "$value" === "-1") return true;
@@ -180,7 +179,7 @@ class FieldtypeToggle extends Fieldtype {
* @param Page $page
* @param Field $field
* @param int|object|WireArray|string $value
* @return int|object|WireArray|string
* @return string
*
*/
public function sanitizeValue(Page $page, Field $field, $value) {
@@ -202,8 +201,7 @@ class FieldtypeToggle extends Fieldtype {
* @param Field $field
* @param int|string|null $value
* @param string $property
*
* @return MarkupFieldtype|string
* @return string
*
*/
public function ___markupValue(Page $page, Field $field, $value = null, $property = '') {
@@ -224,7 +222,7 @@ class FieldtypeToggle extends Fieldtype {
*/
public function getInputfield(Page $page, Field $field) {
/** @var InputfieldToggle $f */
$f = $this->wire('modules')->get('InputfieldToggle');
$f = $this->wire()->modules->get('InputfieldToggle');
return $f;
}
@@ -243,13 +241,12 @@ class FieldtypeToggle extends Fieldtype {
}
/**
* @param DatabaseQuerySelect $query
* @param DatabaseQuerySelect|PageFinderDatabaseQuerySelect $query
* @param string $table
* @param string $subfield
* @param string $operator
* @param mixed $value
*
* @return DatabaseQuery|DatabaseQuerySelect
* @return DatabaseQuerySelect|PageFinderDatabaseQuerySelect
* @throws WireException
*
*/
@@ -323,9 +320,8 @@ class FieldtypeToggle extends Fieldtype {
*
*/
public function ___getCompatibleFieldtypes(Field $field) {
if($field) {}
$fieldtypes = $this->wire(new Fieldtypes());
foreach($this->wire('fieldtypes') as $fieldtype) {
foreach($this->wire()->fieldtypes as $fieldtype) {
if($fieldtype instanceof FieldtypeToggle || $fieldtype instanceof FieldtypeCheckbox) {
$fieldtypes->add($fieldtype);
}
@@ -339,12 +335,11 @@ class FieldtypeToggle extends Fieldtype {
* @param Page $page
* @param Field $field
* @param string|int|float|array|object $value
* @return string|int|float|array
* @return string
* @see Fieldtype::wakeupValue()
*
*/
public function ___sleepValue(Page $page, Field $field, $value) {
if($page && $field) {}
return $this->_sanitizeValue($value);
}
@@ -371,11 +366,11 @@ class FieldtypeToggle extends Fieldtype {
} else if($formatType === self::formatString || $formatType === self::formatEntities) {
/** @var InputfieldToggle $f */
$f = $field->getInputfield($page, $field);
if($f && $f instanceof InputfieldToggle) {
if($f instanceof InputfieldToggle) {
$value = $f->getValueLabel($value);
if($formatType == self::formatEntities) $value = $f->formatLabel($value, false);
} else if($formatType == self::formatEntities) {
$value = $this->wire('sanitizer')->entities1($value);
$value = $this->wire()->sanitizer->entities1($value);
}
}
@@ -393,7 +388,7 @@ class FieldtypeToggle extends Fieldtype {
$inputfields = parent::___getConfigInputfields($field);
/** @var InputfieldRadios $f */
$f = $this->modules->get('InputfieldRadios');
$f = $this->wire()->modules->get('InputfieldRadios');
$f->attr('name', 'formatType');
$f->attr('value', (int) $field->get('formatType'));
$f->label = $this->_('What do you want the formatted value of your toggle field to be?');
@@ -418,4 +413,3 @@ class FieldtypeToggle extends Fieldtype {
}
}

View File

@@ -25,10 +25,6 @@ class FieldtypeURL extends FieldtypeText {
);
}
public function init() {
parent::init();
}
/**
* Sanitize value for storage
*
@@ -73,7 +69,7 @@ class FieldtypeURL extends FieldtypeText {
*/
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, '/');
$root = rtrim($this->wire()->config->urls->root, '/');
$value = $root . $value;
}
$value = parent::___formatValue($page, $field, $value);
@@ -159,4 +155,3 @@ class FieldtypeURL extends FieldtypeText {
// @todo add markupValue()
}

View File

@@ -3,7 +3,7 @@
/**
* An Inputfield for handling a single checkbox
*
* ProcessWire 3.x, Copyright 2020 by Ryan Cramer
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
* https://processwire.com
*
* Note: if you want a checkbox already checked, you need to add a setAttribute('checked', 'checked');
@@ -324,6 +324,7 @@ class InputfieldCheckbox extends Inputfield {
// if working with fieldtype, no additional settings are applicable
if($this->hasFieldtype) return $inputfields;
/** @var InputfieldText $f */
$f = $this->wire()->modules->get('InputfieldText');
$f->attr('name', 'checkedValue');
$f->attr('value', $this->checkedValue);
@@ -333,6 +334,7 @@ class InputfieldCheckbox extends Inputfield {
$f->required = true;
$inputfields->add($f);
/** @var InputfieldText $f */
$f = $this->wire()->modules->get('InputfieldText');
$f->attr('name', 'uncheckedValue');
$f->attr('value', "$this->uncheckedValue");

View File

@@ -8,7 +8,7 @@
* For documentation about the fields used in this class, please see:
* /wire/core/Fieldtype.php
*
* ProcessWire 3.x, Copyright 2020 by Ryan Cramer
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
* https://processwire.com
*
* ~~~~~~
@@ -147,7 +147,7 @@ class InputfieldDatetime extends Inputfield {
$this->set('subMinute', 0);
$this->set('requiredAttr', 0);
foreach($this->getInputTypes() as $name => $type) {
foreach($this->getInputTypes() as $type) {
$this->setArray($type->getDefaultSettings());
}
@@ -297,7 +297,7 @@ class InputfieldDatetime extends Inputfield {
$format .= self::defaultTimeInputFormat;
}
return $this->wire('datetime')->formatDate($value, trim($format));
return $this->wire()->datetime->formatDate($value, trim($format));
}
/**
@@ -364,7 +364,7 @@ class InputfieldDatetime extends Inputfield {
$inputfields = parent::___getConfigInputfields();
$inputTypes = $this->getInputTypes();
$modules = $this->wire('modules'); /** @var Modules $modules */
$modules = $this->wire()->modules;
/** @var InputfieldRadios $f */
$f = $modules->get('InputfieldRadios');
@@ -383,7 +383,7 @@ class InputfieldDatetime extends Inputfield {
$inputfields->add($f);
foreach($inputTypes as $inputTypeName => $inputType) {
/** @var InputfieldFieldset $inputfields */
/** @var InputfieldFieldset $fieldset */
$fieldset = $modules->get('InputfieldFieldset');
$fieldset->attr('name', '_' . $inputTypeName . 'Options');
$fieldset->label = $inputType->getTypeLabel();
@@ -393,7 +393,7 @@ class InputfieldDatetime extends Inputfield {
}
/** @var InputfieldCheckbox $f */
$f = $this->modules->get('InputfieldCheckbox');
$f = $modules->get('InputfieldCheckbox');
$f->setAttribute('name', 'defaultToday');
$f->attr('value', 1);
if($this->defaultToday) $f->attr('checked', 'checked');

View File

@@ -36,6 +36,8 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
*/
public function getDefaultSettings() {
$languages = $this->wire()->languages;
$a = array(
'datepicker' => self::datepickerNo,
'dateInputFormat' => InputfieldDatetime::defaultDateInputFormat,
@@ -43,9 +45,9 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
'timeInputSelect' => 0,
'yearRange' => '',
);
if($this->languages) {
foreach($this->languages as $language) {
if($languages) {
foreach($languages as $language) {
/** @var Language $language */
// account for alternate formats in other languages
if($language->isDefault()) continue;
@@ -67,8 +69,8 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
*/
public function renderReady() {
/** @var Config $config */
$config = $this->wire('config');
$config = $this->wire()->config;
$modules = $this->wire()->modules;
// this method only needs to run if datepicker is in use
$datepicker = (int) $this->getSetting('datepicker');
@@ -78,10 +80,10 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
if($dateFormat) {} // not used here
$useTime = false;
$language = $this->wire('languages') ? $this->wire('user')->language : null;
$language = $this->wire()->languages ? $this->wire()->user->language : null;
$this->wire('modules')->get('JqueryCore'); // Jquery Core required before Jquery UI
$this->wire('modules')->get('JqueryUI');
$modules->get('JqueryCore'); // Jquery Core required before Jquery UI
$modules->get('JqueryUI');
$this->inputfield->addClass("InputfieldDatetimeDatepicker InputfieldDatetimeDatepicker{$datepicker}");
if(strlen($timeFormat) && $datepicker != self::datepickerInline) {
@@ -128,11 +130,8 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
*/
public function render() {
/** @var Sanitizer $sanitizer */
$sanitizer = $this->wire('sanitizer');
/** @var WireDateTime $datetime */
$datetime = $this->wire('datetime');
$sanitizer = $this->wire()->sanitizer;
$datetime = $this->wire()->datetime;
$datepicker = (int) $this->getSetting('datepicker');
@@ -169,6 +168,7 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
if(strlen($timeFormatJS)) $timeFormatJS = $sanitizer->entities($timeFormatJS);
if(empty($value)) $value = '';
$yearRange = $sanitizer->entities($this->getSetting('yearRange'));
$timeInputSelect = $this->getSetting('timeInputSelect');
@@ -196,7 +196,7 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
public function renderValue() {
$value = $this->getAttribute('value');
$format = $this->getSetting('dateInputFormat') . ' ' . $this->getSetting('timeInputFormat');
return $format && $value ? $this->wire('datetime')->formatDate($value, trim($format)) : '';
return $format && $value ? $this->wire()->datetime->formatDate($value, trim($format)) : '';
}
/**
@@ -218,8 +218,8 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
protected function getInputFormat($getArray = false) {
$inputFormats = array();
$language = $this->wire('user')->language;
$useLanguages = $this->wire('languages') && $language && !$language->isDefault();
$language = $this->wire()->user->language;
$useLanguages = $this->wire()->languages && $language && !$language->isDefault();
foreach(array('date', 'time') as $type) {
$inputFormat = '';
@@ -248,7 +248,7 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
public function sanitizeValue($value) {
// convert date string to unix timestamp
$format = $this->getInputFormat();
$value = $this->wire('datetime')->stringToTimestamp($value, $format);
$value = $this->wire()->datetime->stringToTimestamp($value, $format);
return $value;
}
@@ -258,14 +258,16 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
*/
public function getConfigInputfields(InputfieldWrapper $inputfields) {
$languages = $this->wire('languages');
$datetime = $this->wire('datetime');
$languages = $this->wire()->languages;
$datetime = $this->wire()->datetime;
$modules = $this->wire()->modules;
$dateInputFormat = $this->getSetting('dateInputFormat');
$timeInputFormat = $this->getSetting('timeInputFormat');
$timeInputSelect = (int) $this->getSetting('timeInputSelect');
/** @var InputfieldRadios $f */
$f = $this->modules->get('InputfieldRadios');
$f = $modules->get('InputfieldRadios');
$f->label = $this->_('Date Picker');
$f->setAttribute('name', 'datepicker');
$f->addOption(self::datepickerNo, $this->_('No date/time picker'));
@@ -278,12 +280,12 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
$inputfields->append($f);
/** @var InputfieldFieldset $fieldset */
$fieldset = $this->modules->get('InputfieldFieldset');
$fieldset = $modules->get('InputfieldFieldset');
$fieldset->attr('name', '_dateTimeInputFormats');
$fieldset->label = $this->_('Date/Time Input Formats');
/** @var InputfieldSelect $f */
$f = $this->modules->get('InputfieldSelect');
$f = $modules->get('InputfieldSelect');
$f->attr('name', '_dateInputFormat');
$f->label = $this->_('Date Input Format');
$f->description = $this->_('Select the format to be used for user input to this field. Your selection will populate the field below this, which you may customize further if needed.');
@@ -299,7 +301,7 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
$fieldset->add($f);
/** @var InputfieldSelect $f */
$f = $this->modules->get('InputfieldSelect');
$f = $modules->get('InputfieldSelect');
$f->attr('name', '_timeInputFormat');
$f->label = $this->_('Time Input Format');
$f->addOption('', $this->_('None'));
@@ -317,7 +319,7 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
$fieldset->add($f);
/** @var InputfieldRadios $f */
$f = $this->modules->get("InputfieldRadios");
$f = $modules->get("InputfieldRadios");
$f->attr('name', 'timeInputSelect');
$f->label = $this->_('Time Input Type');
$f->description = $this->_('Sliders (default) let the user slide controls to choose the time, where as Select lets the user select the time from a drop-down select.');
@@ -331,7 +333,7 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
$fieldset->add($f);
/** @var InputfieldText $f */
$f = $this->modules->get("InputfieldText");
$f = $modules->get("InputfieldText");
$f->attr('name', 'dateInputFormat');
$f->attr('value', $dateInputFormat ? $dateInputFormat : InputfieldDatetime::defaultDateInputFormat);
$f->attr('size', 20);
@@ -346,7 +348,7 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
$fieldset->add($f);
/** @var InputfieldText $f */
$f = $this->modules->get("InputfieldText");
$f = $modules->get("InputfieldText");
$f->attr('name', 'timeInputFormat');
$f->attr('value', $timeInputFormat ? $timeInputFormat : '');
$f->attr('size', 20);
@@ -372,8 +374,8 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
$inputfields->add($fieldset);
/** @var InputfieldText $field */
$f = $this->modules->get('InputfieldText');
/** @var InputfieldText $f */
$f = $modules->get('InputfieldText');
$f->setAttribute('name', 'placeholder');
$f->label = $this->_('Placeholder Text');
$f->setAttribute('value', $this->getAttribute('placeholder'));
@@ -382,7 +384,7 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
$inputfields->append($f);
/** @var InputfieldInteger $f */
$f = $this->modules->get('InputfieldInteger');
$f = $modules->get('InputfieldInteger');
$f->setAttribute('name', 'size');
$f->label = $this->_('Size');
$f->attr('value', $this->getAttribute('size'));
@@ -392,7 +394,7 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
$inputfields->append($f);
/** @var InputfieldText $f */
$f = $this->modules->get("InputfieldText");
$f = $modules->get("InputfieldText");
$f->attr('name', 'yearRange');
$f->attr('value', $this->getSetting('yearRange'));
$f->attr('size', 10);
@@ -408,4 +410,4 @@ class InputfieldDatetimeText extends InputfieldDatetimeType {
}
}
}

View File

@@ -118,7 +118,7 @@ class InputfieldPageName extends InputfieldName implements ConfigurableModule {
'ł' => 'l',
'ż' => 'z',
'ź' => 'z',
);
);
/**
* Whether or not the system has LanguageSupportPageNames module installed
@@ -155,13 +155,15 @@ class InputfieldPageName extends InputfieldName implements ConfigurableModule {
$this->description = $this->_("Any combination of letters (a-z), numbers (0-9), dashes or underscores (no spaces)."); // Field description describing what characters are allowed
$this->set('sanitizeMethod', 'pageName');
}
$this->hasLanguagePageNames = $this->wire('modules')->isInstalled('LanguageSupportPageNames');
$this->hasLanguagePageNames = $this->wire()->modules->isInstalled('LanguageSupportPageNames');
$this->removeClass('InputfieldNoBorder', 'wrapClass');
}
public function ___render() {
$config = $this->wire()->config;
$url = '';
$out = '';
$box = '';
@@ -181,7 +183,7 @@ class InputfieldPageName extends InputfieldName implements ConfigurableModule {
} else {
$url = $this->parentPage->path;
}
if($this->hasLanguagePageNames && $this->parentPage->id == $this->wire('config')->rootPageID) {
if($this->hasLanguagePageNames && $this->parentPage->id == $config->rootPageID) {
if($user->language->isDefault()) {
$parentName = $this->parentPage->name;
if(!trim($url, '/')) $url = ($parentName === Pages::defaultRootName ? "" : $parentName);
@@ -221,7 +223,7 @@ class InputfieldPageName extends InputfieldName implements ConfigurableModule {
if(strlen($value) && $this->hasLanguagePageNames) {
$link = trim($url, '/') . "/$value" . ($slashUrls ? '/' : '');
$link = $this->wire('config')->urls->root . ltrim($link, '/');
$link = $config->urls->root . ltrim($link, '/');
$link = "<a href='$link'>";
}
@@ -238,7 +240,7 @@ class InputfieldPageName extends InputfieldName implements ConfigurableModule {
if($this->languageSupportLabel) $out .= $box . "</div>";
// make the replacements part of the JS config
$charset = $this->wire('config')->pageNameCharset;
$charset = $config->pageNameCharset;
if($charset == 'UTF8') {
$replacements = array(':' => '-', ',' => '-');
$whitelist = $this->config->pageNameWhitelist;
@@ -246,7 +248,7 @@ class InputfieldPageName extends InputfieldName implements ConfigurableModule {
$replacements = empty($this->replacements) ? self::$defaultReplacements : $this->replacements;
$whitelist = '';
}
$this->config->js($this->className(), array(
$config->js($this->className(), array(
'replacements' => $replacements,
'charset' => $charset,
'whitelist' => $whitelist
@@ -257,14 +259,14 @@ class InputfieldPageName extends InputfieldName implements ConfigurableModule {
public function ___processInput(WireInputData $input) {
if($this->attr('disabled')) return $this;
$languages = $this->wire('languages');
$languages = $this->wire()->languages;
if($this->editPage && $this->editPage->template->noLang) $languages = false;
if($languages && $this->hasLanguagePageNames) {
$user = $this->wire('user');
$user = $this->wire()->user;
if(!$languages->editable($user->language)) return $this;
$return = parent::___processInput($input);
$process = $this->wire('process');
if($process instanceof WirePageEditor && $process->getPage()->id == $this->wire('config')->rootPageID) {
$process = $this->wire()->process;
if($process instanceof WirePageEditor && $process->getPage()->id == $this->wire()->config->rootPageID) {
if(!strlen($this->attr('value'))) {
$this->attr('value', Pages::defaultRootName);
}
@@ -278,7 +280,7 @@ class InputfieldPageName extends InputfieldName implements ConfigurableModule {
static public function replacementStringToArray($str) {
$r = preg_split('/[\r\n]+/', $str);
$a = array();
foreach($r as $key => $value) {
foreach($r as $value) {
if(!strpos($value, '=')) continue;
list($k, $v) = explode('=', $value);
$a[trim($k)] = trim($v);
@@ -293,14 +295,14 @@ class InputfieldPageName extends InputfieldName implements ConfigurableModule {
}
public function getModuleConfigInputfields(array $data) {
$modules = $this->wire()->modules;
$fields = $this->wire(new InputfieldWrapper());
if($this->wire('config')->pageNameCharset === 'UTF8') {
if($this->wire()->config->pageNameCharset === 'UTF8') {
$this->message($this->_('Character replacements configuration is disabled because $config->pageNameCharset is UTF8.'));
return $fields;
}
$modules = $this->wire('modules');
$modules->addHookBefore('saveModuleConfigData', null, 'InputfieldPageName_saveModuleConfigData');
$name = 'replacements';
@@ -317,6 +319,7 @@ class InputfieldPageName extends InputfieldName implements ConfigurableModule {
$data[$name] = self::replacementStringToArray($replacements);
}
/** @var InputfieldTextarea $field */
$field = $modules->get("InputfieldTextarea");
$field->attr('name', $name);
$field->attr('value', $replacements);
@@ -350,4 +353,3 @@ function InputfieldPageName_saveModuleConfigData(HookEvent $event) {
$arguments[1] = $data;
$event->arguments = $arguments;
}

View File

@@ -3,7 +3,7 @@
/**
* An Inputfield for handling a password
*
* ProcessWire 3.x, Copyright 2021 by Ryan Cramer
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
* https://processwire.com
*
* @property array $requirements Array of requirements (See require* constants)
@@ -27,7 +27,7 @@ class InputfieldPassword extends InputfieldText {
'summary' => __("Password input with confirmation field that doesn't ever echo the input back.", __FILE__), // Module Summary
'version' => 102,
'permanent' => true,
);
);
}
/**
@@ -106,19 +106,8 @@ class InputfieldPassword extends InputfieldText {
$this->set('requirements', array(self::requireLetter, self::requireDigit));
$this->set('complexifyFactor', 0.7);
$this->set('complexifyBanMode', 'loose');
$this->set('requirementsLabels', array(
self::requireLetter => $this->_('letter'),
self::requireLowerLetter => $this->_('lowercase letter'),
self::requireUpperLetter => $this->_('uppercase letter'),
self::requireDigit => $this->_('digit'),
self::requireOther => $this->_('symbol/punctuation'),
self::requireNone => $this->_('none (disable all above)'),
));
$this->set('showPass', false); // allow password to be rendered in renderValue and/or re-populated in form?
$this->set('unmask', false);
$this->set('oldPassLabel', $this->_('Current password'));
$this->set('newPassLabel', $this->_('New password'));
$this->set('confirmLabel', $this->_('Confirm'));
}
/**
@@ -127,8 +116,20 @@ class InputfieldPassword extends InputfieldText {
*/
public function init() {
parent::init();
$this->set('defaultLabel', $this->_('Set Password'));
$this->label = $this->defaultLabel;
$defaultLabel = $this->_('Set Password');
$this->set('defaultLabel', $defaultLabel);
$this->set('requirementsLabels', array(
self::requireLetter => $this->_('letter'),
self::requireLowerLetter => $this->_('lowercase letter'),
self::requireUpperLetter => $this->_('uppercase letter'),
self::requireDigit => $this->_('digit'),
self::requireOther => $this->_('symbol/punctuation'),
self::requireNone => $this->_('none (disable all above)'),
));
$this->set('oldPassLabel', $this->_('Current password'));
$this->set('newPassLabel', $this->_('New password'));
$this->set('confirmLabel', $this->_('Confirm'));
$this->label = $defaultLabel;
}
/**
@@ -153,13 +154,14 @@ class InputfieldPassword extends InputfieldText {
*/
public function renderReady(Inputfield $parent = null, $renderValueMode = false) {
if($this->label == 'Set Password') $this->label = $this->defaultLabel;
$config = $this->wire('config');
$url = $config->urls->InputfieldPassword . 'complexify/';
$config = $this->wire()->config;
$url = $config->urls('InputfieldPassword') . 'complexify/';
$config->scripts->add($url . 'jquery.complexify.min.js');
$config->scripts->add($url . 'jquery.complexify.banlist.js');
$this->wire('modules')->get('JqueryCore')->use('xregexp');
$page = $this->wire('page');
if(($page && $page->template == 'admin') || $this->wire('user')->isLoggedin()) {
$jQueryCore = $this->wire()->modules->get('JqueryCore'); /** @var JqueryCore $jQueryCore */
$jQueryCore->use('xregexp');
$page = $this->wire()->page;
if(($page && $page->template->name == 'admin') || $this->wire()->user->isLoggedin()) {
$this->attr('autocomplete', 'new-password'); // ProcessProfile and ProcessUser
}
return parent::renderReady($parent, $renderValueMode);
@@ -173,8 +175,7 @@ class InputfieldPassword extends InputfieldText {
*/
public function ___render() {
/** @var Sanitizer $sanitizer */
$sanitizer = $this->wire('sanitizer');
$sanitizer = $this->wire()->sanitizer;
$minlength = (int) $this->attr('minlength');
$requirements = array();
@@ -207,13 +208,13 @@ class InputfieldPassword extends InputfieldText {
if(!$this->getSetting('showPass')) {
$this->attr('value', '');
} else {
$confirmValue = $this->wire('sanitizer')->entities($value);
$confirmValue = $sanitizer->entities($value);
}
$this->attr('data-banMode', $this->complexifyBanMode ? $this->complexifyBanMode : 'loose');
$this->attr('data-factor', (float) $this->complexifyFactor >= 0 ? str_replace(',', '.', "$this->complexifyFactor") : 0);
$inputClass = $this->wire('sanitizer')->entities($this->attr('class'));
$inputClass = $sanitizer->entities($this->attr('class'));
$this->addClass('InputfieldPasswordComplexify');
$failIcon = "<i class='fa fa-fw fa-frown-o'></i>";
@@ -227,7 +228,7 @@ class InputfieldPassword extends InputfieldText {
$size = $this->attr('size');
$out = '';
if((int) $this->requireOld > 0 && $this->wire('user')->isLoggedin()) {
if((int) $this->requireOld > 0 && $this->wire()->user->isLoggedin()) {
$out .=
"<p class='InputfieldPasswordRow'>" .
"<label for='_old_$name'>$oldPassLabel</label>" .
@@ -305,7 +306,7 @@ class InputfieldPassword extends InputfieldText {
if(!$this->getSetting('showPass')) {
$value = strlen($this->attr('value')) ? '******' : '';
} else {
$value = $this->wire('sanitizer')->entities($this->attr('value'));
$value = $this->wire()->sanitizer->entities($this->attr('value'));
}
$value = strlen($value) ? "<p>$value</p>" : "";
return $value;
@@ -322,8 +323,7 @@ class InputfieldPassword extends InputfieldText {
parent::___processInput($input);
/** @var User $user */
$user = $this->wire('user');
$user = $this->wire()->user;
$key = $this->attr('name');
$value = $this->attr('value');
if($value) {}
@@ -346,7 +346,7 @@ class InputfieldPassword extends InputfieldText {
if(!strlen($oldPass)) {
$this->error($this->_('Old password is required in order to enter a new one.'));
$allowInput = false;
} else if(!$this->wire('user')->pass->matches($oldPass)) {
} else if(!$user->pass->matches($oldPass)) {
$this->error($this->_('The old password you entered is not correct.'));
$allowInput = false;
}
@@ -446,7 +446,8 @@ class InputfieldPassword extends InputfieldText {
*
*/
public function ___getConfigInputfields() {
$modules = $this->wire()->modules;
$inputfields = parent::___getConfigInputfields();
$skips = array(
'collapsed',
@@ -467,7 +468,7 @@ class InputfieldPassword extends InputfieldText {
}
/** @var InputfieldCheckboxes $f */
$f = $this->wire('modules')->get('InputfieldCheckboxes');
$f = $modules->get('InputfieldCheckboxes');
$f->attr('name', 'requirements');
$f->label = $this->_('Password requirements');
foreach($this->getSetting('requirementsLabels') as $value => $label) {
@@ -480,7 +481,7 @@ class InputfieldPassword extends InputfieldText {
$inputfields->add($f);
/** @var InputfieldRadios $f */
$f = $this->wire('modules')->get('InputfieldRadios');
$f = $modules->get('InputfieldRadios');
$f->attr('name', 'complexifyBanMode');
$f->label = $this->_('Word ban mode');
$f->description = $this->_('If you choose the strict mode, many passwords containing words will not be accepted.');
@@ -491,7 +492,7 @@ class InputfieldPassword extends InputfieldText {
$inputfields->add($f);
/** @var InputfieldFloat $f */
$f = $this->wire('modules')->get('InputfieldFloat');
$f = $modules->get('InputfieldFloat');
$f->attr('name', 'complexifyFactor');
$f->label = $this->_('Complexify factor');
$f->description = $this->_('Lower numbers allow weaker passwords, higher numbers require stronger passwords.');
@@ -502,7 +503,7 @@ class InputfieldPassword extends InputfieldText {
$inputfields->add($f);
/** @var InputfieldInteger $f */
$f = $this->wire('modules')->get('InputfieldInteger');
$f = $modules->get('InputfieldInteger');
$f->attr('name', 'minlength');
$f->label = $this->_('Minimum password length');
$f->attr('value', $this->attr('minlength'));
@@ -512,7 +513,7 @@ class InputfieldPassword extends InputfieldText {
if(!$this->getSetting('hasFieldtype')) {
/** @var InputfieldCheckbox $f */
$f = $this->wire('modules')->get('InputfieldCheckbox');
$f = $modules->get('InputfieldCheckbox');
$f->attr('name', 'showPass');
$f->label = $this->_('Allow existing passwords to be shown and/or rendered in form?');
if($this->getSetting("showPass")) $f->attr('checked', 'checked');
@@ -520,7 +521,7 @@ class InputfieldPassword extends InputfieldText {
}
/** @var InputfieldRadios $f */
$f = $this->wire('modules')->get('InputfieldRadios');
$f = $modules->get('InputfieldRadios');
$f->attr('name', 'requireOld');
$f->label = $this->_('Require old password before allowing changes?');
$f->description = $this->_('Applies to usages where this field appears to already logged-in users only.');
@@ -530,8 +531,9 @@ class InputfieldPassword extends InputfieldText {
$f->optionColumns = 1;
$f->attr('value', (int) $this->requireOld);
$inputfields->add($f);
$f = $this->wire()->modules->get('InputfieldRadios');
/** @var InputfieldRadios $f */
$f = $modules->get('InputfieldRadios');
$f->attr('name', 'unmask');
$f->label = $this->_('Allow user to show/unmask password during changes?');
$f->description = $this->_('Provides a show/hide password control so users can see what they type when in an appropriate environment.');

View File

@@ -3,7 +3,7 @@
/**
* An Inputfield for handling single line "text" form inputs
*
* ProcessWire 3.x, Copyright 2022 by Ryan Cramer
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
* https://processwire.com
*
* @property string $type Input type (typically "text")
@@ -76,7 +76,7 @@ class InputfieldText extends Inputfield {
/**
* Get the default maxlength attribute value
*
* @return mixed
* @return int
*
*/
public function getDefaultMaxlength() {
@@ -107,7 +107,7 @@ class InputfieldText extends Inputfield {
'min' => $this->_('(at least %d required)'),
'max' => $this->_('(%d max)'),
);
$config->scripts->add($config->urls->InputfieldText . 'InputfieldTextLength.js');
$config->scripts->add($config->urls('InputfieldText') . 'InputfieldTextLength.js');
$config->js('InputfieldTextLength', $labels);
}
}

View File

@@ -5,7 +5,7 @@ require_once(dirname(__FILE__) . '/FieldtypeLanguageInterface.php');
/**
* Multi-language capable text field
*
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
* https://processwire.com
*
*
@@ -20,7 +20,7 @@ class FieldtypeTextLanguage extends FieldtypeText implements FieldtypeLanguageIn
'summary' => 'Field that stores a single line of text in multiple languages',
'permanent' => false,
'requires' => array('LanguageSupportFields'),
);
);
}
/**
@@ -34,7 +34,7 @@ class FieldtypeTextLanguage extends FieldtypeText implements FieldtypeLanguageIn
*/
public function sanitizeValue(Page $page, Field $field, $value) {
if(is_object($value) && $value instanceof LanguagesPageFieldValue) {
if($value instanceof LanguagesPageFieldValue) {
// great, already what we wanted
return $value;
}
@@ -78,8 +78,9 @@ class FieldtypeTextLanguage extends FieldtypeText implements FieldtypeLanguageIn
public function getDatabaseSchema(Field $field) {
$schema = parent::getDatabaseSchema($field);
$languageSupport = $this->wire('modules')->get('LanguageSupport');
$maxIndex = (int) $this->wire('database')->getMaxIndexLength();
/** @var LanguageSupport $languageSupport */
$languageSupport = $this->wire()->modules->get('LanguageSupport');
$maxIndex = (int) $this->wire()->database->getMaxIndexLength();
// note that we use otherLanguagePageIDs rather than wire('languages') because
// it's possible that this method may be called before the languages are known
@@ -113,10 +114,11 @@ class FieldtypeTextLanguage extends FieldtypeText implements FieldtypeLanguageIn
* @param Field $field
* @param string|int|float|array|object|null $value
* @param array $options Optional settings to shape the exported value, if needed.
* @return string|float|int|array
* @return array
*
*/
public function ___exportValue(Page $page, Field $field, $value, array $options = array()) {
$languages = $this->wire()->languages;
if(isset($options['sleepValue'])) {
// allow a sleepValue option, for use by other language Fieldtypes that delegate
// their exportValue to this one, like FieldtypeTextareaLanguage
@@ -130,7 +132,7 @@ class FieldtypeTextLanguage extends FieldtypeText implements FieldtypeLanguageIn
$exportValue['default'] = $v;
} else if(strpos($k, 'data') === 0) {
$languageID = substr($k, 4);
$language = $this->wire('languages')->get((int) $languageID);
$language = $languages->get((int) $languageID);
$exportValue[$language->name] = $v;
} else {
$exportValue[$k] = $v;
@@ -149,8 +151,7 @@ class FieldtypeTextLanguage extends FieldtypeText implements FieldtypeLanguageIn
if(!is_array($value)) {
throw new WireException("Array value expected for multi-language importValue");
}
/** @var Languages $languages */
$languages = $this->wire('languages');
$languages = $this->wire()->languages;
/** @var LanguagesPageFieldValue $importValue */
$importValue = $page->get($field->name);
foreach($value as $languageName => $languageValue) {
@@ -162,4 +163,3 @@ class FieldtypeTextLanguage extends FieldtypeText implements FieldtypeLanguageIn
}
}

View File

@@ -3,7 +3,7 @@
/**
* A type of Page that represents a single Language in ProcessWire
*
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
* https://processwire.com
*
* @property LanguageTranslator $translator Get instance of LanguageTranslator for this language
@@ -68,7 +68,7 @@ class Language extends Page {
*
*/
public function translator() {
return $this->wire('languages')->translator($this);
return $this->wire()->languages->translator($this);
}
/**
@@ -98,7 +98,7 @@ class Language extends Page {
*
*/
public function isCurrent() {
return $this->id == $this->wire('user')->language->id;
return $this->id == $this->wire()->user->language->id;
}
/**
@@ -106,11 +106,11 @@ class Language extends Page {
*
* #pw-internal
*
* @return Pages|PagesType
* @return Languages
*
*/
public function getPagesManager() {
return $this->wire('languages');
return $this->wire()->languages;
}
/**
@@ -124,7 +124,7 @@ class Language extends Page {
*
*/
public function getLocale($category = LC_ALL) {
return $this->wire('languages')->getLocale($category, $this);
return $this->wire()->languages->getLocale($category, $this);
}
/**
@@ -139,7 +139,6 @@ class Language extends Page {
*
*/
public function setLocale($category = LC_ALL) {
return $this->wire('languages')->setLocale($category, $this);
return $this->wire()->languages->setLocale($category, $this);
}
}

View File

@@ -7,7 +7,7 @@
*
* Return the results by calling $parser->getUntranslated() and $parser->getComments();
*
* ProcessWire 3.x, Copyright 2020 by Ryan Cramer
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
* https://processwire.com
*
*
@@ -61,6 +61,7 @@ class LanguageParser extends Wire {
*
*/
public function __construct(LanguageTranslator $translator, $file) {
parent::__construct();
$this->translator = $translator;
$this->textdomain = $this->translator->filenameToTextdomain($file);
$this->translator->loadTextdomain($this->textdomain);
@@ -322,7 +323,7 @@ class LanguageParser extends Wire {
$this->numFound++;
// check if there are comments in the $tail and record them if so
if(($pos = strpos($tail, '//')) !== false) {
if(strpos($tail, '//') !== false) {
if(preg_match('![^:"\']//(.+)$!', $tail, $matches)) {
$comments = $matches[1];
}

View File

@@ -3,7 +3,7 @@
/**
* Serves as a multi-language value placeholder for field values that contain a value in more than one language.
*
* ProcessWire 3.x, Copyright 2022 by Ryan Cramer
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
* https://processwire.com
*
*/
@@ -117,10 +117,11 @@ class LanguagesPageFieldValue extends Wire implements LanguagesValueInterface, \
if(strpos($testKey, 'data') !== 0) {
// array does not use "data123" indexes, so work with language ID or language name indexes
// and convert to "data123" indexes
$languages = $this->wire()->languages;
$_values = array();
foreach($values as $key => $value) {
if(ctype_digit("$key")) $key = (int) $key;
$language = $this->wire()->languages->get($key);
$language = $languages->get($key);
if($language && $language->id) {
$dataKey = $language->isDefault() ? "data" : "data$language->id";
$_values[$dataKey] = $value;
@@ -419,5 +420,3 @@ class LanguagesPageFieldValue extends Wire implements LanguagesValueInterface, \
return $this->defaultLanguagePageID;
}
}

View File

@@ -64,19 +64,28 @@ class ProcessLanguage extends ProcessPageType {
$this->set('showFields', $showFields);
$this->set('jsonListLabel', 'title|name');
require_once(dirname(__FILE__) . '/LanguageParser.php');
}
/**
* Wired to ProcessWire instance
*
*/
public function wired() {
parent::wired();
$fields = $this->wire()->fields;
// make sure our files fields have CSV support
foreach(array('language_files', 'language_files_site') as $fieldName) {
$field = $this->wire('fields')->get($fieldName);
$field = $fields->get($fieldName);
if(!$field) continue;
$extensions = $field->get('extensions');
$extensions = $field->get('extensions');
if(strpos($extensions, 'csv') === false) {
$field->set('extensions', "$extensions csv");
$field->save();
$this->message("Added CSV support to field $fieldName", Notice::debug);
}
}
$this->csvImportLabel = $this->_('CSV Import:') . ' ';
}

View File

@@ -5,7 +5,7 @@ require_once(dirname(__FILE__) . '/PagerNav.php');
/**
* MarkupPagerNav Module for generating pagination markup
*
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
* https://processwire.com
*
* #pw-summary Module for generating pagination markup automatically for paginated WireArray types.
@@ -117,7 +117,7 @@ class MarkupPagerNav extends Wire implements Module {
'permanent' => false,
'singular' => false,
'autoload' => false,
);
);
}
/**
@@ -210,7 +210,7 @@ class MarkupPagerNav extends Wire implements Module {
// the queryString used in links (set automatically, based on whitelist or getVars array)
'queryString' => '',
);
);
/**
* True when the current page is also the last page
@@ -229,10 +229,11 @@ class MarkupPagerNav extends Wire implements Module {
protected $pageNumUrlPrefix = 'page';
/**
* Construct
* Wired to ProcessWire instance
*
*/
public function __construct() {
public function wired() {
parent::wired();
$this->options['nextItemLabel'] = $this->_('Next');
$this->options['previousItemLabel'] = $this->_('Prev');
$this->options['listAriaLabel'] = $this->_('Pagination links');
@@ -241,9 +242,9 @@ class MarkupPagerNav extends Wire implements Module {
$this->options['nextItemAriaLabel'] = $this->_('Next page');
$this->options['previousItemAriaLabel'] = $this->_('Previous page');
$this->options['lastItemAriaLabel'] = $this->_('Page {n}, last page');
// check for all-instance options
$options = $this->wire('config')->MarkupPagerNav;
$options = $this->wire()->config->MarkupPagerNav;
if(is_array($options)) $this->options = array_merge($this->options, $options);
}
@@ -270,7 +271,7 @@ class MarkupPagerNav extends Wire implements Module {
*/
public function ___render(WirePaginatable $items, $options = array()) {
$config = $this->wire('config');
$config = $this->wire()->config;
$this->isLastPage = true;
$this->totalItems = $items->getTotal();
if(!$this->totalItems) return '';
@@ -285,7 +286,7 @@ class MarkupPagerNav extends Wire implements Module {
}
if(!strlen($this->queryString)) {
$whitelist = $this->wire('input')->whitelist->getArray();
$whitelist = $this->wire()->input->whitelist->getArray();
if(!count($this->options['getVars']) && count($whitelist)) {
$this->setGetVars($whitelist);
} else if(count($this->options['getVars'])) {
@@ -453,13 +454,13 @@ class MarkupPagerNav extends Wire implements Module {
/**
* Retrieve a MarkupPagerNav option as an object property
*
* @param string $property
* @param string $name
* @return mixed
*
*/
public function __get($property) {
if(isset($this->options[$property])) return $this->options[$property];
if($property == 'isLastPage') return $this->isLastPage;
public function __get($name) {
if(isset($this->options[$name])) return $this->options[$name];
if($name === 'isLastPage') return $this->isLastPage;
return null;
}
@@ -677,9 +678,8 @@ class MarkupPagerNav extends Wire implements Module {
*/
protected function updateConfigVars($nextURL, $prevURL) {
/** @var Config $config */
$config = $this->wire('config');
$httpRoot = $this->wire('input')->httpHostUrl();
$config = $this->wire()->config;
$httpRoot = $this->wire()->input->httpHostUrl();
$pagerHeadTags = '';
if($nextURL) {
@@ -705,4 +705,3 @@ class MarkupPagerNav extends Wire implements Module {
public function ___uninstall() { }
}

View File

@@ -141,7 +141,7 @@ class PagePaths extends WireData implements Module, ConfigurableModule {
$query->bindValue(":language_id", $languageId, \PDO::PARAM_INT);
$path = null;
if(!$this->executeQuery($query)) return $path;
if(!$this->executeQuery($query)) return null;
if($query->rowCount()) {
$path = $query->fetchColumn();
@@ -662,7 +662,7 @@ class PagePaths extends WireData implements Module, ConfigurableModule {
/**
* Returns Languages object or false if not available
*
* @return Languages|false
* @return Languages|Language[]|false
*
*/
public function getLanguages() {

View File

@@ -252,7 +252,6 @@ class PageRender extends WireData implements Module, ConfigurableModule {
*
*/
public function ___clearCacheFilePages(PageArray $items, Page $page) {
if($page) {}
foreach($items as $p) {
if(((int) $p->template->cache_time) < 1) continue;
$cf = $this->getCacheFile($p);
@@ -357,7 +356,6 @@ class PageRender extends WireData implements Module, ConfigurableModule {
*
*/
public function ___saveCacheFileReady(Page $page, $data) {
if($page) {} // ignore
return $data;
}
@@ -570,6 +568,7 @@ class PageRender extends WireData implements Module, ConfigurableModule {
// own additional variables in it if they want to
$output->set('options', $options);
/** @var WireProfilerInterface $profiler */
$profiler = $this->wire('profiler');
$profilerEvent = $profiler ? $profiler->start($page->path, $this, array('page' => $page)) : null;
$data = $output->render();

View File

@@ -5,7 +5,7 @@
*
* Formats text with PHP's htmlspecialchars() function.
*
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
* https://processwire.com
*
*
@@ -20,11 +20,15 @@ class TextformatterEntities extends Textformatter {
'version' => 100,
);
}
protected $charset = '';
public function format(&$str) {
static $charset = false;
if($charset === false) $charset = $this->config->dbCharset;
if($charset == 'utf8') $str = htmlspecialchars($str, ENT_QUOTES, "UTF-8");
else $str = htmlspecialchars($str, ENT_QUOTES);
if($this->charset === '') $this->charset = $this->wire()->config->dbCharset;
if(stripos($this->charset, 'utf8') === 0) {
$str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
} else {
$str = htmlspecialchars($str, ENT_QUOTES);
}
}
}

View File

@@ -98,7 +98,8 @@ class TextformatterSmartypants extends Textformatter implements ConfigurableModu
*
*/
public function getModuleConfigInputfields(InputfieldWrapper $inputfields) {
$f = $this->wire('modules')->get('InputfieldRadios');
/** @var InputfieldRadios $f */
$f = $this->wire()->modules->get('InputfieldRadios');
$f->attr('name', 'useUTF8');
$f->label = $this->_('Use UTF-8 characters for replacements rather than HTML entities?');
$f->description = $this->_('The default behavior for SmartyPants is to add/update characters using HTML entities.') . ' ';

View File

@@ -33,14 +33,15 @@ class TextformatterStripTags extends Textformatter implements ConfigurableModule
$inputfields = $this->wire(new InputfieldWrapper());
$name = "allowedTags";
if(!isset($data[$name])) $data[$name] = '';
$f = $this->wire('modules')->get('InputfieldText');
/** @var InputfieldText $f */
$f = $this->wire()->modules->get('InputfieldText');
$f->attr('name', $name);
$f->attr('value', $data[$name]);
$f->label = 'Allowed Markup Tags';
$f->description =
"Enter any markup tags that are allowed, i.e. '<strong><em>'. " .
"Enter any markup tags that are allowed, i.e. `<strong><em>`. " .
"Note that this does not strip attributes for any tags you allow. " .
"As a result, you should not allow *any* tags unless the user is trusted.";
"As a result, you should not allow *any* tags unless all potential users are trusted.";
$inputfields->append($f);
return $inputfields;
}