1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-10 16:54:44 +02:00
This commit is contained in:
Ryan Cramer
2022-11-18 12:42:02 -05:00
parent 2aedd2b6f5
commit b0d5f14a27
5 changed files with 20 additions and 17 deletions

View File

@@ -1622,7 +1622,7 @@ class Modules extends WireArray {
$module = true; $module = true;
} else { } else {
// module in root namespace or some other namespace // module in root namespace or some other namespace
$namespace = $this->getModuleNamespace($moduleName, array('file' => $file)); $namespace = (string) $this->getModuleNamespace($moduleName, array('file' => $file));
$className = trim($namespace, "\\") . "\\$moduleName"; $className = trim($namespace, "\\") . "\\$moduleName";
if(class_exists($className, false)) { if(class_exists($className, false)) {
// successful include module // successful include module
@@ -1888,6 +1888,8 @@ class Modules extends WireArray {
public function isInstalled($class) { public function isInstalled($class) {
if(is_object($class)) $class = $this->getModuleClass($class); if(is_object($class)) $class = $this->getModuleClass($class);
$class = (string) $class;
if(empty($class)) return false;
$operator = null; $operator = null;
$requiredVersion = null; $requiredVersion = null;

View File

@@ -142,6 +142,7 @@ class Selectors extends WireArray {
* *
*/ */
public function setSelectorString($selectorStr) { public function setSelectorString($selectorStr) {
$selectorStr = (string) $selectorStr;
$this->selectorStr = $selectorStr; $this->selectorStr = $selectorStr;
$this->extractString(trim($selectorStr)); $this->extractString(trim($selectorStr));
} }

View File

@@ -312,8 +312,7 @@ class InputfieldPage extends Inputfield implements ConfigurableModule {
* *
*/ */
protected function ___findPagesCode(Page $page) { protected function ___findPagesCode(Page $page) {
if($page) {} $pages = $this->wire()->pages; // so that it is locally scoped to the eval
$pages = $this->wire('pages'); // so that it is locally scoped to the eval
if(empty($this->findPagesCode)) return $pages->newPageArray(); if(empty($this->findPagesCode)) return $pages->newPageArray();
return eval($this->findPagesCode); return eval($this->findPagesCode);
} }
@@ -469,6 +468,7 @@ class InputfieldPage extends Inputfield implements ConfigurableModule {
/** @var InputfieldWrapper $repeaterWrapper */ /** @var InputfieldWrapper $repeaterWrapper */
$value = null; $value = null;
foreach($repeaterWrapper->getAll() as $in) { foreach($repeaterWrapper->getAll() as $in) {
/** @var Inputfield $in */
if("$in->hasField" !== $field) continue; if("$in->hasField" !== $field) continue;
$value = $in->val(); $value = $in->val();
break; break;
@@ -592,9 +592,9 @@ class InputfieldPage extends Inputfield implements ConfigurableModule {
} else if($this->labelFieldName) { } else if($this->labelFieldName) {
$label = $page->get($this->labelFieldName); $label = $page->get($this->labelFieldName);
} }
if(!strlen($label)) $label = $page->name; if(!strlen("$label")) $label = $page->name;
if($page->hasStatus(Page::statusUnpublished)) $label .= ' ' . $this->_('(unpublished)'); if($page->hasStatus(Page::statusUnpublished)) $label .= ' ' . $this->_('(unpublished)');
if(!$allowMarkup) $label = $this->wire('sanitizer')->markupToLine($label); if(!$allowMarkup) $label = $this->wire()->sanitizer->markupToLine($label);
return $label; return $label;
} }
@@ -633,7 +633,7 @@ class InputfieldPage extends Inputfield implements ConfigurableModule {
$process = $this->wire()->process; $process = $this->wire()->process;
if($this->derefAsPage) $inputfield->set('maxSelectedItems', 1); if($this->derefAsPage) $inputfield->set('maxSelectedItems', 1);
if($process && $process instanceof WirePageEditor) $page = $process->getPage(); if($process instanceof WirePageEditor) $page = $process->getPage();
$inputfield->attr('name', $this->attr('name')); $inputfield->attr('name', $this->attr('name'));
$inputfield->attr('id', $this->attr('id')); $inputfield->attr('id', $this->attr('id'));
@@ -1070,7 +1070,7 @@ class InputfieldPage extends Inputfield implements ConfigurableModule {
if(!$this->getSetting('addable') || !$parent_id || !$template_id) return; if(!$this->getSetting('addable') || !$parent_id || !$template_id) return;
$user = $this->wire('user'); $user = $this->wire()->user;
$key = "_{$this->name}_add_items"; $key = "_{$this->name}_add_items";
$value = trim($input->$key); $value = trim($input->$key);
@@ -1150,7 +1150,6 @@ class InputfieldPage extends Inputfield implements ConfigurableModule {
} else if($value instanceof PageArray) { } else if($value instanceof PageArray) {
// derefAsPageArray // derefAsPageArray
/** @var PageArray $value */
if(!count($value)) return true; if(!count($value)) return true;
} else { } else {
@@ -1515,7 +1514,8 @@ class InputfieldPage extends Inputfield implements ConfigurableModule {
if(!isset($data[$name]) || !is_array($data[$name])) $data[$name] = self::$defaultInputfieldClasses; if(!isset($data[$name]) || !is_array($data[$name])) $data[$name] = self::$defaultInputfieldClasses;
$fields = $this->wire(new InputfieldWrapper()); $fields = $this->wire(new InputfieldWrapper());
$modules = $this->wire('modules'); $this->wire($fields);
$modules = $this->wire()->modules;
/** @var InputfieldAsmSelect $field */ /** @var InputfieldAsmSelect $field */
$field = $modules->get("InputfieldAsmSelect"); $field = $modules->get("InputfieldAsmSelect");
$field->attr('name', $name); $field->attr('name', $name);

View File

@@ -168,7 +168,7 @@ class InputfieldTextTags extends Inputfield implements
*/ */
public function setAttribute($key, $value) { public function setAttribute($key, $value) {
if($key === 'value') { if($key === 'value') {
if(is_object($value) && $value instanceof WireArray) { if($value instanceof WireArray) {
$value = explode('|', (string) $value); $value = explode('|', (string) $value);
} }
if(is_array($value)) { if(is_array($value)) {
@@ -218,11 +218,11 @@ class InputfieldTextTags extends Inputfield implements
* *
*/ */
public function tagStringToArray($tagString) { public function tagStringToArray($tagString) {
$tagString = trim($tagString); $tagString = trim("$tagString");
$tagArray = array(); $tagArray = array();
if(!strlen($tagString)) return $tagArray; if(!strlen($tagString)) return $tagArray;
$a = explode($this->delimiter(), $tagString); $a = explode($this->delimiter(), $tagString);
foreach($a as $key => $tag) { foreach($a as $tag) {
$tag = trim("$tag"); $tag = trim("$tag");
if(!strlen($tag)) continue; if(!strlen($tag)) continue;
if(strpos($tag, '_') === 0 && ctype_digit(substr($tag, 1))) $tag = ltrim($tag, '_'); if(strpos($tag, '_') === 0 && ctype_digit(substr($tag, 1))) $tag = ltrim($tag, '_');
@@ -288,7 +288,7 @@ class InputfieldTextTags extends Inputfield implements
$regex = $allowLabels ? '/[\r\n\t]+/' : '/[\s\r\n\t]+/'; $regex = $allowLabels ? '/[\r\n\t]+/' : '/[\s\r\n\t]+/';
$a = preg_split($regex, $tagString); $a = preg_split($regex, $tagString);
foreach($a as $key => $tag) { foreach($a as $tag) {
$tag = trim("$tag"); $tag = trim("$tag");
if(!strlen($tag)) continue; if(!strlen($tag)) continue;
if(strpos($tag, '=') !== false) { if(strpos($tag, '=') !== false) {
@@ -597,7 +597,7 @@ class InputfieldTextTags extends Inputfield implements
/** /**
* Get tags ready for use by renderReady() or render() * Get tags ready for use by renderReady() or render()
* *
* @return array|string * @return array
* @throws WireException * @throws WireException
* *
*/ */
@@ -866,7 +866,7 @@ class InputfieldTextTags extends Inputfield implements
protected function isPageField() { protected function isPageField() {
if($this->hasField && $this->hasFieldtype instanceof FieldtypePage) { if($this->hasField && $this->hasFieldtype instanceof FieldtypePage) {
return $this->hasField; return $this->hasField;
} else if($this->hasInputfield && $this->hasInputfield instanceof InputfieldPage) { } else if($this->hasInputfield instanceof InputfieldPage) {
return $this->hasInputfield; return $this->hasInputfield;
} else { } else {
return false; return false;
@@ -1027,7 +1027,7 @@ class InputfieldTextTags extends Inputfield implements
} else { } else {
$selector = ''; $selector = '';
$hasInputfield = $this->hasInputfield; $hasInputfield = $this->hasInputfield;
if($hasInputfield && $hasInputfield instanceof InputfieldPage) $selector = $hasInputfield->createFindPagesSelector(); if($hasInputfield instanceof InputfieldPage) $selector = $hasInputfield->createFindPagesSelector();
if(!strlen($selector)) $selector = $this->_('your page finding selector here'); if(!strlen($selector)) $selector = $this->_('your page finding selector here');
$exampleCode = $exampleCode =
'$wire->addHook("/' . $examplePath . '/", function($e) { ' . '$wire->addHook("/' . $examplePath . '/", function($e) { ' .

View File

@@ -197,7 +197,7 @@ class ProcessPageClone extends Process {
/** @var Language $language */ /** @var Language $language */
if($language->isDefault()) continue; if($language->isDefault()) continue;
$value = $page->get("name$language"); $value = $page->get("name$language");
if(!strlen($value)) continue; if(!strlen("$value")) continue;
$result["name$language"] = $pages->names()->incrementName($value, $n); $result["name$language"] = $pages->names()->incrementName($value, $n);
} }
} }