diff --git a/wire/core/DatabaseQuery.php b/wire/core/DatabaseQuery.php index 8d0d6320..279c80c2 100644 --- a/wire/core/DatabaseQuery.php +++ b/wire/core/DatabaseQuery.php @@ -430,11 +430,12 @@ abstract class DatabaseQuery extends WireData { * Implied parameters (using "?") was added in 3.0.157. * * @param string $method - * @param array $args + * @param array $arguments * @return $this * */ - public function __call($method, $args) { + public function __call($method, $arguments) { + $args = &$arguments; // if(!$this->has($method)) return parent::__call($method, $args); if(!isset($this->queryMethods[$method])) return parent::__call($method, $args); @@ -443,11 +444,10 @@ abstract class DatabaseQuery extends WireData { if(!is_array($curValue)) $curValue = array(); $value = $args[0]; - if(is_object($value) && $value instanceof DatabaseQuery) { + if($value instanceof DatabaseQuery) { // if we've been given another DatabaseQuery, load from its $method // note that if using bindValues you should also copy them separately // behavior deprecated in 3.l0.157+, please use the copyTo() method instead - /** @var DatabaseQuery $query */ $query = $value; $value = $query->$method; // array if(!is_array($value) || !count($value)) return $this; // nothing to import diff --git a/wire/core/DatabaseQuerySelect.php b/wire/core/DatabaseQuerySelect.php index 416e0e92..6e5f22da 100644 --- a/wire/core/DatabaseQuerySelect.php +++ b/wire/core/DatabaseQuerySelect.php @@ -25,11 +25,11 @@ * @property array $limit * @property string $comment Comments for query * - * @method $this select($sql, array $params = array()) + * @method $this select($sql, $params = array()) * @method $this from($sql) - * @method $this join($sql, array $params = array()) - * @method $this leftjoin($sql, array $params = array()) - * @method $this where($sql, array $params = array()) + * @method $this join($sql, $params = array()) + * @method $this leftjoin($sql, $params = array()) + * @method $this where($sql, $params = array()) * @method $this groupby($sql) * @method $this limit($sql) * diff --git a/wire/core/WireMail.php b/wire/core/WireMail.php index e03efeed..20e78e3f 100644 --- a/wire/core/WireMail.php +++ b/wire/core/WireMail.php @@ -3,7 +3,7 @@ /** * ProcessWire WireMail * - * ProcessWire 3.x, Copyright 2021 by Ryan Cramer + * ProcessWire 3.x, Copyright 2022 by Ryan Cramer * https://processwire.com * * #pw-summary A module type that handles sending of email in ProcessWire @@ -92,7 +92,7 @@ class WireMail extends WireData implements WireMailInterface { 'header' => array(), 'param' => array(), 'attachments' => array(), - ); + ); /** * Construct @@ -148,6 +148,7 @@ class WireMail extends WireData implements WireMailInterface { * */ protected function sanitizeEmail($email) { + $email = (string) $email; if(!strlen($email)) return ''; $email = strtolower(trim($email)); if(strpos($email, ':') && preg_match('/^(.+):\d+$/', $email, $matches)) { @@ -155,14 +156,15 @@ class WireMail extends WireData implements WireMailInterface { // so remove trailing port, i.e. ':8888', if present since it will not validate $email = $matches[1]; } - $clean = $this->wire('sanitizer')->email($email); + $sanitizer = $this->wire()->sanitizer; + $clean = $sanitizer->email($email); if($email !== $clean) { - throw new WireException("Invalid email address: " . $this->wire('sanitizer')->entities($email)); + throw new WireException("Invalid email address: " . $sanitizer->entities($email)); } /** @var WireMailTools $mail */ $mail = $this->wire('mail'); if($mail && $mail->isBlacklistEmail($email)) { - throw new WireException("Email address not allowed: " . $this->wire('sanitizer')->entities($email)); + throw new WireException("Email address not allowed: " . $sanitizer->entities($email)); } return $clean; } @@ -176,8 +178,7 @@ class WireMail extends WireData implements WireMailInterface { * */ protected function ___sanitizeHeaderName($name) { - /** @var Sanitizer $sanitizer */ - $sanitizer = $this->wire('sanitizer'); + $sanitizer = $this->wire()->sanitizer; $name = $sanitizer->emailHeader($name, true); // ensure consistent capitalization for header names $name = ucwords(str_replace('-', ' ', $name)); @@ -194,7 +195,7 @@ class WireMail extends WireData implements WireMailInterface { * */ protected function ___sanitizeHeaderValue($value) { - return $this->wire('sanitizer')->emailHeader($value); + return $this->wire()->sanitizer->emailHeader($value); } /** @@ -219,6 +220,7 @@ class WireMail extends WireData implements WireMailInterface { */ protected function extractEmailAndName($email) { $name = ''; + $email = (string) $email; if(strpos($email, '<') !== false && strpos($email, '>') !== false) { // email has separate from name and email if(preg_match('/^(.*?)<([^>]+)>.*$/', $email, $matches)) { @@ -598,7 +600,7 @@ class WireMail extends WireData implements WireMailInterface { } // prep any additional PHP mail params - $param = $this->wire('config')->phpMailAdditionalParameters; + $param = $this->wire()->config->phpMailAdditionalParameters; if(is_null($param)) $param = ''; foreach($this->param as $value) { $param .= " $value"; @@ -629,12 +631,13 @@ class WireMail extends WireData implements WireMailInterface { */ protected function renderMailHeader() { - $settings = $this->wire()->config->wireMail; + $config = $this->wire()->config; + $settings = $config->wireMail; $from = $this->from; if(!strlen($from) && !empty($settings['from'])) $from = $settings['from']; - if(!strlen($from)) $from = $this->wire('config')->adminEmail; - if(!strlen($from)) $from = 'processwire@' . $this->wire('config')->httpHost; + if(!strlen($from)) $from = $config->adminEmail; + if(!strlen($from)) $from = 'processwire@' . $config->httpHost; $header = "From: " . ($this->fromName ? $this->bundleEmailAndName($from, $this->fromName) : $from); @@ -741,10 +744,11 @@ class WireMail extends WireData implements WireMailInterface { protected function renderMailAttachments() { $body = ''; $boundary = $this->multipartBoundary(); + $sanitizer = $this->wire()->sanitizer; foreach($this->attachments as $filename => $file) { - $filename = $this->wire('sanitizer')->text($filename, array( + $filename = $sanitizer->text($filename, array( 'maxLength' => 512, 'truncateTail' => false, 'stripSpace' => '-', @@ -802,7 +806,7 @@ class WireMail extends WireData implements WireMailInterface { * */ protected function ___htmlToText($html) { - $text = $this->wire('sanitizer')->getTextTools()->markupToText($html); + $text = $this->wire()->sanitizer->getTextTools()->markupToText($html); $text = str_replace("\n", "\r\n", $text); $text = $this->strReplace($text, $this->multipartBoundary()); return $text; diff --git a/wire/modules/Fieldtype/FieldtypeDatetime.module b/wire/modules/Fieldtype/FieldtypeDatetime.module index 364878f3..3e318a4f 100644 --- a/wire/modules/Fieldtype/FieldtypeDatetime.module +++ b/wire/modules/Fieldtype/FieldtypeDatetime.module @@ -8,7 +8,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 2022 by Ryan Cramer * https://processwire.com * */ @@ -184,8 +184,7 @@ class FieldtypeDatetime extends Fieldtype { * @param Field $field * @param int $value * @param array $options - * - * @return array|false|float|int|string + * @return string * */ public function ___exportValue(Page $page, Field $field, $value, array $options = array()) { @@ -203,7 +202,7 @@ class FieldtypeDatetime extends Fieldtype { */ public function isEmptyValue(Field $field, $value) { - if(is_object($value) && $value instanceof Selector) { + if($value instanceof Selector) { // PageFinder is asking if it should let this Fieldtype handle the operator/value // combination with potential empty value present in a Selector $selector = $value; @@ -366,12 +365,13 @@ class FieldtypeDatetime extends Fieldtype { */ public function ___getConfigInputfields(Field $field) { + $modules = $this->wire()->modules; $inputfields = parent::___getConfigInputfields($field); $wdt = $this->wire('datetime'); /** @var WireDateTime $wdt */ $dateOutputFormat = (string) $field->get('dateOutputFormat'); /** @var InputfieldSelect $f */ - $f = $this->modules->get('InputfieldSelect'); + $f = $modules->get('InputfieldSelect'); $f->attr('name', '_dateOutputFormat'); $f->label = $this->_('Date Output Format'); $f->description = $this->_('Select the format to be used when outputting dates with this field.') . ' '; @@ -382,7 +382,7 @@ class FieldtypeDatetime extends Fieldtype { $date = strlen(date('jn')) < 4 ? time() : strtotime('2016-04-08 5:10:02 PM'); $found = false; foreach($wdt->getDateFormats() as $format) { - $dateFormatted = $wdt->formatDate($date, $format); + $dateFormatted = (string) $wdt->formatDate($date, $format); if($format == 'U') $dateFormatted .= " " . $this->_('(unix timestamp)'); $f->addOption($format, "$dateFormatted [$format]"); if(!$found && strpos($dateOutputFormat, $format) !== false) { @@ -393,7 +393,8 @@ class FieldtypeDatetime extends Fieldtype { $f->attr('onchange', "$('#Inputfield_dateOutputFormat').val($(this).val() + ' ' + $('#Inputfield__timeOutputFormat').val());"); $inputfields->add($f); - $f = $this->modules->get('InputfieldSelect'); + /** @var InputfieldSelect $f */ + $f = $modules->get('InputfieldSelect'); $f->attr('name', '_timeOutputFormat'); $f->label = $this->_('Time Output Format'); $f->description = $this->_('If you want to output time in addition to the date, select the format to be used when outputting time with this field. This will be combined with the date format.'); @@ -414,18 +415,19 @@ class FieldtypeDatetime extends Fieldtype { $inputfields->add($f); /** @var InputfieldText $f */ - $f = $this->modules->get("InputfieldText"); + $f = $modules->get("InputfieldText"); $f->attr('name', 'dateOutputFormat'); $f->attr('value', $field->get('dateOutputFormat')); $f->attr('size', 20); $f->label = $this->_('Date/Time Output Format Code'); $f->description = $this->_('The date/time will be output according to the format below. This is automatically built from the date/time selections above, but you may change it as needed to suit your needs.') . ' '; - $f->description .= $this->_('See the [PHP date](http://www.php.net/manual/en/function.date.php) function reference for more information on how to customize this format. Alternatively, you may use a [PHP strftime](http://www.php.net/manual/en/function.strftime.php) format if desired for localization.'); + $f->description .= $this->_('See the [PHP date](https://www.php.net/manual/en/function.date.php) function reference for more information on how to customize this format. Alternatively, you may use a [PHP strftime](https://www.php.net/manual/en/function.strftime.php) format if desired for localization.'); $f->icon = 'code'; $f->collapsed = Inputfield::collapsedYes; if($this->languages) { $f->useLanguages = true; foreach($this->languages as $language) { + /** @var Language $language */ if($language->isDefault()) continue; $f->set("value$language", (string) $field->get('dateOutputFormat' . $language)); } diff --git a/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module b/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module index 255728ed..477bf818 100644 --- a/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module +++ b/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module @@ -5,7 +5,7 @@ * * This Inputfield connects the jQuery UI Autocomplete widget with the ProcessWire ProcessPageSearch AJAX API. * - * ProcessWire 3.x, Copyright 2019 by Ryan Cramer + * ProcessWire 3.x, Copyright 2022 by Ryan Cramer * https://processwire.com * * @property int $parent_id Limit results to this parent, or if combined with findPagesSelector, the search is performed as $pages->get($parent_id)->find() rather than $pages->find(). @@ -34,7 +34,7 @@ class InputfieldPageAutocomplete extends Inputfield implements InputfieldHasArra 'title' => __('Page Auto Complete', __FILE__), // Module Title 'summary' => __('Multiple Page selection using auto completion and sorting capability. Intended for use as an input field for Page reference fields.', __FILE__), // Module Summary 'version' => 112, - ); + ); } /** @@ -104,8 +104,8 @@ class InputfieldPageAutocomplete extends Inputfield implements InputfieldHasArra */ protected function ___renderListItem($label, $value, $class = '') { if($class) $class = " $class"; - if(strpos($label, '&') !== false) $label = $this->wire('sanitizer')->unentities($label); - $label = $this->wire('sanitizer')->entities($label); + if(strpos($label, '&') !== false) $label = $this->wire()->sanitizer->unentities($label); + $label = $this->wire()->sanitizer->entities($label); $out = "
  • " . " " . @@ -146,8 +146,7 @@ class InputfieldPageAutocomplete extends Inputfield implements InputfieldHasArra * */ public function ___render() { - /** @var Sanitizer $sanitizer */ - $sanitizer = $this->wire('sanitizer'); + $sanitizer = $this->wire()->sanitizer; if($this->maxSelectedItems == 1) $this->useList = false; $out = $this->useList ? $this->renderList() : ''; @@ -157,7 +156,7 @@ class InputfieldPageAutocomplete extends Inputfield implements InputfieldHasArra // convert our list of search fields to a CSV string for use in the ProcessPageSearch query $searchField = ''; $searchFields = str_replace(array(',', '|'), ' ', $this->searchFields); - foreach(explode(' ', $searchFields) as $key => $name) { + foreach(explode(' ', $searchFields) as /* $key => */ $name) { $name = trim($name); // @esrch pr#994 -- if(strpos($name, '.')) { @@ -206,7 +205,7 @@ class InputfieldPageAutocomplete extends Inputfield implements InputfieldHasArra $remove = ''; if(!$this->useList) { if(count($this->value)) { - $item = $this->wire('pages')->getById($this->value)->first(); + $item = $this->wire()->pages->getById($this->value)->first(); if($item && $item->id) { $textValue = $this->labelFieldFormat ? $item->getText($this->labelFieldFormat, true, false) : $item->get($labelField); if(!strlen($textValue)) $textValue = $item->get('title|name'); @@ -285,7 +284,7 @@ _OUT; protected function getAjaxUrl() { $pipe = '%7C'; // encoded pipe "|" - $selector = $this->findPagesSelector; + $selector = (string) $this->findPagesSelector; if($this->parent_id) { if($selector) { @@ -329,7 +328,9 @@ _OUT; // specify what label field we want to retrieve if($this->labelFieldFormat) { $name = "autocomplete_" . $this->attr('name'); - $this->wire('modules')->get('ProcessPageSearch')->setDisplayFormat($name, $this->labelFieldFormat, true); + /** @var ProcessPageSearch $pps */ + $pps = $this->wire()->modules->get('ProcessPageSearch'); + $pps->setDisplayFormat($name, $this->labelFieldFormat, true); $selector .= "&format_name=$name"; } $selector .= "&get=" . $this->labelFieldName; @@ -371,10 +372,11 @@ _OUT; * */ public function ___getConfigInputfields() { + $modules = $this->wire()->modules; $inputfields = parent::___getConfigInputfields(); /** @var InputfieldRadios $field */ - $field = $this->modules->get('InputfieldRadios'); + $field = $modules->get('InputfieldRadios'); $field->setAttribute('name', 'operator'); $field->label = $this->_('Autocomplete search operator'); $field->description = $this->_("The search operator that is used in the API when performing autocomplete matches."); @@ -396,7 +398,7 @@ _OUT; $inputfields->add($field); /** @var InputfieldText $field */ - $field = $this->modules->get('InputfieldText'); + $field = $modules->get('InputfieldText'); $field->attr('name', 'searchFields'); $field->label = $this->_('Fields to query for autocomplete'); $field->description = $this->_('Enter the names of the fields that should have their text queried for autocomplete matches.'); @@ -405,7 +407,8 @@ _OUT; $field->collapsed = Inputfield::collapsedNo; $field->attr('value', $this->searchFields); $notes = $this->_('Indexed text fields include:'); - foreach($this->wire('fields') as $f) { + foreach($this->wire()->fields as $f) { + /** @var Field $f */ if(!$f->type instanceof FieldtypeText) continue; $notes .= ' ' . $f->name . ','; } diff --git a/wire/modules/LanguageSupport/LanguageSupportPageNames.module b/wire/modules/LanguageSupport/LanguageSupportPageNames.module index adda0329..396bbcf0 100644 --- a/wire/modules/LanguageSupport/LanguageSupportPageNames.module +++ b/wire/modules/LanguageSupport/LanguageSupportPageNames.module @@ -3,7 +3,7 @@ /** * Multi-language support page names module * - * ProcessWire 3.x, Copyright 2021 by Ryan Cramer + * ProcessWire 3.x, Copyright 2022 by Ryan Cramer * https://processwire.com * * @property int $moduleVersion @@ -253,8 +253,8 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM $testPath = trim($path, '/') . '/'; $segments = $this->wire()->pages->pathFinder()->languageSegments(); - foreach($segments as $languageId => $segment) { - if(!strlen($segment)) continue; + foreach($segments as /* $languageId => */ $segment) { + if(!strlen("$segment")) continue; $name = "$segment/"; if(strpos($testPath, $name) !== 0) continue; $path = substr($testPath, strlen($name)); @@ -456,12 +456,11 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM * * @param Page $page * @param Language $language - * @return bool|string|array + * @return bool|array * @since 3.0.186 * */ public function ___pageNotAvailableInLanguage(Page $page, Language $language) { - if($language) {} // ignore if($page->editable()) return true; if($page->id == $this->wire()->config->http404PageID) return true; $redirect404 = (int) $this->redirect404; @@ -627,7 +626,6 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM * */ public function hookPageRender(HookEvent $event) { - if($event) {} if($this->force404) { $this->force404 = false; // prevent another 404 on the 404 page throw new Wire404Exception('Not available in requested language', Wire404Exception::codeLanguage); @@ -728,6 +726,7 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM // add labels and inputs for other languages foreach($languages as $language) { + /** @var Language $language */ if($language->isDefault()) continue; $user->setLanguage($language); $value = $page->get("name$language"); @@ -784,6 +783,7 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM $sanitizer = $this->wire()->sanitizer; foreach($languages as $language) { + /** @var Language $language */ if($language->isDefault()) continue; if(!$languages->editable($language)) continue; @@ -1016,7 +1016,7 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM $language = $languages->get($language); } - if(!$language || !$language->id || !$language instanceof Language) { + if(!$language instanceof Language || !$language->id) { $language = $languages->getDefault(); } @@ -1134,6 +1134,7 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM if(!is_array($extraData)) $extraData = array(); foreach($this->wire()->languages as $language) { + /** @var Language $language */ if($language->isDefault()) continue; $language_id = (int) $language->id; @@ -1206,6 +1207,7 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM if($userTrackChanges) $user->setTrackChanges(false); foreach($this->wire()->languages as $language) { + /** @var Language $language */ if($language->isDefault()) continue; $user->setLanguage($language); $name = $page->get("name$language"); @@ -1244,6 +1246,7 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM // go into this only if we know the renamed hook hasn't already been called $renamed = false; foreach($this->wire()->languages as $language) { + /** @var Language $language */ if($language->isDefault()) continue; $namePrevious = $page->get("-name$language"); if(!$namePrevious) continue; @@ -1318,6 +1321,7 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM if(!$p->id) continue; $duplicates = 0; // count duplicate names, which would invalidate any $foundLanguage foreach($languages as $language) { + /** @var Language $language */ $key = 'name' . ($language->isDefault() ? '' : $language->id); $name = $p->get($key); if($name === $part) { @@ -1361,6 +1365,7 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM if($query->rowCount() < 2) { foreach($this->wire()->languages as $language) { + /** @var Language $language */ if($language->isDefault()) continue; $status = "status" . (int) $language->id; $database->exec("ALTER TABLE pages ADD $status INT UNSIGNED NOT NULL DEFAULT " . Page::statusOn); @@ -1394,6 +1399,7 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM $defaultUrlPrefix = $config->get('_pageNumUrlPrefix|pageNumUrlPrefix'); foreach($this->wire()->languages as $language) { + /** @var Language $language */ /** @var InputfieldName $f */ $f = $modules->get('InputfieldName'); $name = "pageNumUrlPrefix$language"; @@ -1469,6 +1475,7 @@ class LanguageSupportPageNames extends WireData implements Module, ConfigurableM $database = $this->wire()->database; $sqls = array(); foreach($languages as $language) { + /** @var Language $language */ if($language->isDefault()) continue; $name = 'name' . $language->id; if(!$database->columnExists("pages", $name)) continue; diff --git a/wire/modules/PagePathHistory.module b/wire/modules/PagePathHistory.module index ab5da255..6429b4ed 100644 --- a/wire/modules/PagePathHistory.module +++ b/wire/modules/PagePathHistory.module @@ -6,7 +6,7 @@ * Keeps track of past URLs where pages have lived and automatically 301 redirects * to the new location whenever the past URL is accessed. * - * ProcessWire 3.x, Copyright 2021 by Ryan Cramer + * ProcessWire 3.x, Copyright 2022 by Ryan Cramer * https://processwire.com * * @method upgrade($fromVersion, $toVersion) @@ -87,7 +87,7 @@ class PagePathHistory extends WireData implements Module, ConfigurableModule { */ protected function getVersion() { if($this->version) return $this->version; - $this->version = $this->wire('modules')->getModuleInfoProperty($this, 'version'); + $this->version = $this->wire()->modules->getModuleInfoProperty($this, 'version'); if(!$this->version) $this->version = 1; return $this->version; } @@ -118,10 +118,10 @@ class PagePathHistory extends WireData implements Module, ConfigurableModule { // ok } else if($language === 0) { $language = $languages->getDefault(); - } else if(is_int($language) || ctype_digit($language)) { + } else if(is_int($language) || ctype_digit("$language")) { $language = $languages->get((int) $language); } else if(is_string($language) && $language) { - $language = $languages->get($this->wire('sanitizer')->pageNameUTF8($language)); + $language = $languages->get($this->wire()->sanitizer->pageNameUTF8($language)); } if($language && !$language->id) $language = null; return $language; @@ -138,7 +138,7 @@ class PagePathHistory extends WireData implements Module, ConfigurableModule { */ public function setPathHistory(Page $page, $path, $language = null) { - $database = $this->wire('database'); + $database = $this->wire()->database; $table = self::dbTableName; $result = $this->addPathHistory($page, $path, $language); @@ -655,7 +655,7 @@ class PagePathHistory extends WireData implements Module, ConfigurableModule { if($matchRow) { // ok found $result['matchType'] = 'exact'; - } else if($rowCount) { + } else { // select from multiple matched rows (urlSegments mode only) // order by quantity of slashes (most to least) arsort($pathCounts); @@ -668,8 +668,6 @@ class PagePathHistory extends WireData implements Module, ConfigurableModule { $result['matchType'] = 'partial'; break; } - } else { - // no match } if($matchRow) { diff --git a/wire/modules/Process/ProcessPageLister/ProcessPageLister.module b/wire/modules/Process/ProcessPageLister/ProcessPageLister.module index 0fb29458..bc8d70d7 100644 --- a/wire/modules/Process/ProcessPageLister/ProcessPageLister.module +++ b/wire/modules/Process/ProcessPageLister/ProcessPageLister.module @@ -383,7 +383,7 @@ class ProcessPageLister extends Process implements ConfigurableModule { * Check for a bookmark specified in GET variable $n * * @param string $bookmarkID - * @return null|int|bool Returns NULL if not applicable, boolean false if bookmark not found, or integer of bookmark ID if applied + * @return null|string|false Returns NULL if not applicable, boolean false if bookmark not found, or integer of bookmark ID if applied * */ public function checkBookmark($bookmarkID = '') { @@ -399,7 +399,7 @@ class ProcessPageLister extends Process implements ConfigurableModule { $this->set('defaultSort', $bookmark['sort']); $this->sessionSet('sort', $bookmark['sort']); $this->set('columns', $bookmark['columns']); - $this->headline($this->wire('page')->title . ' - ' . $bookmark['title']); + $this->headline($this->wire()->page->title . ' - ' . $bookmark['title']); return $bookmarkID; } @@ -724,6 +724,7 @@ class ProcessPageLister extends Process implements ConfigurableModule { // custom fields (sort) foreach($fields as $field) { + /** @var Field $field */ if(!$this->allowColumnField($field)) continue; if($useLabels) { if($template) { @@ -916,13 +917,13 @@ class ProcessPageLister extends Process implements ConfigurableModule { $selectors2 = new Selectors(); } - foreach($selectors1 as $key1 => $selector1) { + foreach($selectors1 as /* $key1 => */ $selector1) { //$value = $selector1->value; //if(is_array($value) || strlen($value)) continue; $fieldName1 = $selector1->field; if(is_array($fieldName1)) $fieldName1 = implode('|', $fieldName1); // see if we have the same field in selectors2 - foreach($selectors2 as $key2 => $selector2) { + foreach($selectors2 as /* $key2 => */ $selector2) { $fieldName2 = $selector2->field; if(is_array($fieldName2)) $fieldName2 = implode('|', $fieldName2); if($fieldName1 == $fieldName2) { @@ -1209,7 +1210,7 @@ class ProcessPageLister extends Process implements ConfigurableModule { $templatesAPI = $this->wire()->templates; foreach($template as $t) { $t = $templatesAPI->get($t); - if($t && $t instanceof Template) $templates[] = $t; + if($t instanceof Template) $templates[] = $t; } return $templates; } @@ -1394,7 +1395,7 @@ class ProcessPageLister extends Process implements ConfigurableModule { $p->of(false); $values = array(); - foreach($columns as $cnt => $name) { + foreach($columns as /* $cnt => */ $name) { $value = $this->buildListerTableCol($p, $fields, $name); $values[] = $value; } @@ -1529,12 +1530,11 @@ class ProcessPageLister extends Process implements ConfigurableModule { //if($value instanceof Pageimages && $this->imageFirst) $value = array($value->first()); $values = array(); $isImage = false; - foreach($value as $k => $v) { + foreach($value as /* $k => */ $v) { if(empty($v)) continue; if($subname == 'data') $v = (string) $v; if($subname && is_object($v)) $v = $v->$subname; if($v instanceof Pageimage) { - /** @var Pageimage $v */ $vfull = $v; if($this->imageWidth || $this->imageHeight) $v = $v->size($this->imageWidth, $this->imageHeight); $alt = $vfull->basename . ($vfull->description ? ' - ' . $sanitizer->entities1($vfull->description) : ""); @@ -1626,8 +1626,6 @@ class ProcessPageLister extends Process implements ConfigurableModule { $languages = $this->wire()->languages; if(!$languages) return null; - $language = null; - if(strpos($name, '-') && preg_match('/-([-_a-z0-9]+)$/', $name, $matches)) { // i.e. title-de or categories.title-de $language = $languages->get($matches[1]); @@ -1759,31 +1757,25 @@ class ProcessPageLister extends Process implements ConfigurableModule { $target = $editMode == self::windowModeBlank ? "_blank" : ""; if($editMode == self::windowModeDirect) $directURL = $actions['edit']['url']; $actionsOut .= $this->renderListerTableColAction($actions['edit'], $class, $target); - unset($actions['edit']); - } else { - unset($actions['edit']); } - + unset($actions['edit']); + if($viewable) { $class = $viewMode == self::windowModeModal ? "modal" : ""; $target = $viewMode == self::windowModeBlank ? "_blank" : ""; if($viewMode == self::windowModeDirect) $directURL = $p->url; $actionsOut .= $this->renderListerTableColAction($actions['view'], $class, $target); - unset($actions['view']); - } else { - unset($actions['view']); } - + unset($actions['view']); + if($addable) { $actions['new']['url'] = $this->addURL . "?parent_id=$p->id"; $class = $editMode == self::windowModeModal ? "modal" : ""; $target = $editMode == self::windowModeBlank ? "_blank" : ""; $actionsOut .= $this->renderListerTableColAction($actions['new'], "$class PageAdd PageEdit", $target); - unset($actions['new']); - } else { - unset($actions['new']); } - + unset($actions['new']); + if($directURL) { // click goes directly to edit or view $value = "$icon$value$statusIcon"; @@ -1858,12 +1850,13 @@ class ProcessPageLister extends Process implements ConfigurableModule { static $pageListRender = null; if(is_null($pageListRender)) { - require_once($this->wire()->config->paths->ProcessPageList . 'ProcessPageListRenderJSON.php'); + require_once($this->wire()->config->paths('ProcessPageList') . 'ProcessPageListRenderJSON.php'); $pageListRender = new ProcessPageListRenderJSON($this->wire()->page, $this->wire()->pages->newPageArray()); - $pageListRender = $this->wire($pageListRender); + $this->wire($pageListRender); $pageListRender->setUseTrash($this->wire()->user->isSuperuser()); } - + + /** @var ProcessPageListRenderJSON $pageListRender */ $actions = $pageListRender->getPageActions($p); if(isset($actions['edit']) && $this->editURL && strpos($actions['edit']['url'], '/page/edit/') !== false) { @@ -1988,8 +1981,6 @@ class ProcessPageLister extends Process implements ConfigurableModule { $pagerOut = $pager->render($results); $pageURL = $this->wire()->page->url; $pagerOut = str_replace($pageURL . "'", $pageURL . "?pageNum=1'", $pagerOut); // specifically identify page1 - } else { - $pagerOut = ''; } } else { @@ -1998,6 +1989,7 @@ class ProcessPageLister extends Process implements ConfigurableModule { } foreach($this->wire()->notices as $notice) { + /** @var Notice $notice */ if($notice instanceof NoticeError) { $out .= "

    $notice->text

    "; } else { @@ -2144,7 +2136,8 @@ class ProcessPageLister extends Process implements ConfigurableModule { $out = ''; if($minimal) { /** @var InputfieldHidden $f */ - $sort = htmlspecialchars($this->sessionGet('sort')); + $sort = (string) $this->sessionGet('sort'); + $sort = htmlspecialchars($sort); $out .= ""; $out .= ""; $out .= "";