From 6f794328255b570b1d99017ebd429c525c68fd4e Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Tue, 3 Oct 2023 17:12:29 +0200 Subject: [PATCH] add search input, fix warnings in UA class --- classes/document.php-class | 36 ++++++++++++++++++++++++++++++++++++ classes/useragent.php-class | 12 ++++++------ 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/classes/document.php-class b/classes/document.php-class index 4490589..211ae44 100755 --- a/classes/document.php-class +++ b/classes/document.php-class @@ -65,6 +65,10 @@ class ExtendedDocument extends DOMDocument { // appends an ExtendedDocument::createElementInputRange() as a child of this document (see there for params) // returns the new child // + // public function appendInputSearch($name, $maxlength, $size, [$id], [$value]) + // appends an ExtendedDocument::createElementInputSearch() as a child of this document (see there for params) + // returns the new child + // // public function appendInputUrl($name, $maxlength, $size, [$id], [$value]) // appends an ExtendedDocument::createElementInputUrl() as a child of this document (see there for params) // returns the new child @@ -202,6 +206,10 @@ class ExtendedDocument extends DOMDocument { // returns an ExtendedElement that is an HTML of type 'url' with the given name, maxlength, size, // and optionally id and value // + // public function createElementInputSearch($name, $maxlength, $size, [$id], [$value]) + // returns an ExtendedElement that is an HTML of type 'search' with the given name, maxlength, size, + // and optionally id and value + // // public function createElementInputEmail($name, $maxlength, $size, [$id], [$value]) // returns an ExtendedElement that is an HTML of type 'email' with the given name, maxlength, size, // and optionally id and value @@ -350,6 +358,9 @@ class ExtendedDocument extends DOMDocument { public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) { return $this->appendChild($this->createElementInputRange($name, $id, $min, $max, $step, $value)); } + public function appendInputSearch($name, $maxlength, $size, $id = null, $value = null) { + return $this->appendChild($this->createElementInputSearch($name, $maxlength, $size, $id, $value)); + } public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->createElementInputUrl($name, $maxlength, $size, $id, $value)); } @@ -529,6 +540,17 @@ class ExtendedDocument extends DOMDocument { return $rgfield; } + public function createElementInputSearch($name, $maxlength, $size, $id = null, $value = null) { + $urlfield = $this->createElement('input'); + $urlfield->setAttribute('type', 'search'); + if (!is_null($id)) { $urlfield->setAttribute('id', $id); } + $urlfield->setAttribute('name', $name); + $urlfield->setAttribute('maxlength', $maxlength); + $urlfield->setAttribute('size', $size); + if (!is_null($value)) { $urlfield->setAttribute('value', $value); } + return $urlfield; + } + public function createElementInputUrl($name, $maxlength, $size, $id = null, $value = null) { $urlfield = $this->createElement('input'); $urlfield->setAttribute('type', 'url'); @@ -760,6 +782,10 @@ class ExtendedElement extends DOMElement { // appends an ExtendedDocument::createElementInputRange() as a child of this element (see there for params) // returns the new child // + // public function appendInputSearch($name, $maxlength, $size, [$id], [$value]) + // appends an ExtendedDocument::createElementInputSearch() as a child of this element (see there for params) + // returns the new child + // // public function appendInputUrl($name, $maxlength, $size, [$id], [$value]) // appends an ExtendedDocument::createElementInputUrl() as a child of this element (see there for params) // returns the new child @@ -910,6 +936,9 @@ class ExtendedElement extends DOMElement { public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputRange($name, $id, $min, $max, $step, $value)); } + public function appendInputSearch($name, $maxlength, $size, $id = null, $value = null) { + return $this->appendChild($this->ownerDocument->createElementInputSearch($name, $maxlength, $size, $id, $value)); + } public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputUrl($name, $maxlength, $size, $id, $value)); } @@ -1052,6 +1081,10 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { // appends an ExtendedDocument::createElementInputRange() as a child of this fragment (see there for params) // returns the new child // + // public function appendInputSearch($name, $maxlength, $size, [$id], [$value]) + // appends an ExtendedDocument::createElementInputSearch() as a child of this fragment (see there for params) + // returns the new child + // // public function appendInputUrl($name, $maxlength, $size, [$id], [$value]) // appends an ExtendedDocument::createElementInputUrl() as a child of this fragment (see there for params) // returns the new child @@ -1192,6 +1225,9 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputRange($name, $id, $min, $max, $step, $value)); } + public function appendInputSearch($name, $maxlength, $size, $id = null, $value = null) { + return $this->appendChild($this->ownerDocument->createElementInputSearch($name, $maxlength, $size, $id, $value)); + } public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputUrl($name, $maxlength, $size, $id, $value)); } diff --git a/classes/useragent.php-class b/classes/useragent.php-class index 00ceb3a..190e539 100755 --- a/classes/useragent.php-class +++ b/classes/useragent.php-class @@ -1519,18 +1519,18 @@ class userAgent { elseif ($this->uadata['os'] == 'WinNT') { $this->uadata['os'] = 'Windows NT'; } elseif ($this->uadata['os'] == 'Win32') { $this->uadata['os'] = 'Windows (32bit)'; } elseif ($this->uadata['os'] == 'Win64') { $this->uadata['os'] = 'Windows (64bit)'; } - elseif (preg_match('/iPhone OS ([\d_]+)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'iOS '.str_replace('_', '.', $regs[1]); } - elseif (preg_match('/Mac ?OS ?X/i', $this->uadata['os'])) { $this->uadata['os'] = 'MacOS X'; } - elseif (preg_match('/Mac_P(ower|)PC/i', $this->uadata['os'])) { $this->uadata['os'] = 'MacOS'; } + elseif (preg_match('/iPhone OS ([\d_]+)/i', ($this->uadata['os'] ?? ''), $regs)) { $this->uadata['os'] = 'iOS '.str_replace('_', '.', $regs[1]); } + elseif (preg_match('/Mac ?OS ?X/i', ($this->uadata['os'] ?? ''))) { $this->uadata['os'] = 'MacOS X'; } + elseif (preg_match('/Mac_P(ower|)PC/i', ($this->uadata['os'] ?? ''))) { $this->uadata['os'] = 'MacOS'; } elseif (strpos($this->uadata['os'] ?? '', 'darwin') !== false) { $this->uadata['os'] = 'MacOS X'; } elseif (strpos($this->uadata['os'] ?? '', 'Darwin') !== false) { $this->uadata['os'] = 'MacOS X'; } elseif (strpos($this->uadata['os'] ?? '', 'apple') !== false) { $this->uadata['os'] = 'MacOS'; } elseif (strpos($this->uadata['os'] ?? '', 'Macintosh') !== false) { $this->uadata['os'] = 'MacOS'; } - elseif (preg_match('/(?:web|hpw)OS\/([0-9a-zA-Z\._+]+)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'webOS '.$regs[1]; } - elseif (preg_match('/Android \(Linux (.+)\)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'Android '.$regs[1]; } + elseif (preg_match('/(?:web|hpw)OS\/([0-9a-zA-Z\._+]+)/i', ($this->uadata['os'] ?? ''), $regs)) { $this->uadata['os'] = 'webOS '.$regs[1]; } + elseif (preg_match('/Android \(Linux (.+)\)/i', ($this->uadata['os'] ?? ''), $regs)) { $this->uadata['os'] = 'Android '.$regs[1]; } elseif (strpos($this->uadata['os'] ?? '', 'linux') !== false) { $this->uadata['os'] = 'Linux'; } elseif (preg_match('/SymbianOS[\/ ]([0-9a-zA-Z\._+]+)/i', $this->uastring, $regs)) { $this->uadata['os'] = 'SymbianOS '.$regs[1]; } - elseif (preg_match('/Symbian ?OS/i', $this->uadata['os'])) { $this->uadata['os'] = 'SymbianOS'; } + elseif (preg_match('/Symbian ?OS/i', ($this->uadata['os'] ?? ''))) { $this->uadata['os'] = 'SymbianOS'; } if (strpos($this->uadata['os'] ?? '', 'Win') !== false) { $this->uadata['platform'] = 'Windows'; } elseif (strpos($this->uadata['os'] ?? '', 'Mac') !== false) { $this->uadata['platform'] = 'Macintosh'; } -- 2.35.3