diff --git a/includes/defines.php b/includes/defines.php index 4fec740c..a8401f55 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -11,12 +11,13 @@ define('E_AOWOW', E_ALL & ~(E_DEPRECATED | E_USER_DEPRECATED | E define('JSON_AOWOW_POWER', JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); define('FILTER_FLAG_STRIP_AOWOW', FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK); -define('MIME_TYPE_TEXT', 'Content-Type: text/plain; charset=utf-8'); -define('MIME_TYPE_XML', 'Content-Type: text/xml; charset=utf-8'); -define('MIME_TYPE_JSON', 'Content-Type: application/x-javascript; charset=utf-8'); -define('MIME_TYPE_RSS', 'Content-Type: application/rss+xml; charset=utf-8'); -define('MIME_TYPE_JPEG', 'Content-Type: image/jpeg'); -define('MIME_TYPE_PNG', 'Content-Type: image/png'); +define('MIME_TYPE_TEXT', 'Content-Type: text/plain; charset=utf-8'); +define('MIME_TYPE_XML', 'Content-Type: text/xml; charset=utf-8'); +define('MIME_TYPE_JSON', 'Content-Type: application/x-javascript; charset=utf-8'); +define('MIME_TYPE_OPENSEARCH', 'Content-Type: application/x-suggestions+json; charset=utf-8'); +define('MIME_TYPE_RSS', 'Content-Type: application/rss+xml; charset=utf-8'); +define('MIME_TYPE_JPEG', 'Content-Type: image/jpeg'); +define('MIME_TYPE_PNG', 'Content-Type: image/png'); // shared setup strings define('ERR_CREATE_FILE', 'could not create file at destination %s'); diff --git a/pages/search.php b/pages/search.php index 203ff3f0..ca59f8c1 100644 --- a/pages/search.php +++ b/pages/search.php @@ -223,12 +223,15 @@ class SearchPage extends GenericPage parent::display(); // errors are handled in the search-template itself } else if ($this->searchMask & SEARCH_TYPE_OPEN) - $result = [$this->search, []]; + { + header(MIME_TYPE_OPENSEARCH); + exit(Util::toJSON([$this->search, []])); + } else if ($this->searchMask & SEARCH_TYPE_JSON) - $result = [$this->search, [], []]; - - header(MIME_TYPE_JSON); - exit(Util::toJSON($result)); + { + header(MIME_TYPE_JSON); + exit(Util::toJSON([$this->search, [], []])); + } } public function display(string $override = '') : void @@ -236,7 +239,7 @@ class SearchPage extends GenericPage if ($override || ($this->searchMask & SEARCH_TYPE_REGULAR)) parent::display($override); else if ($this->searchMask & SEARCH_TYPE_OPEN) - $this->displayExtra([$this, 'generateOpenSearch']); + $this->displayExtra([$this, 'generateOpenSearch'], MIME_TYPE_OPENSEARCH); else if ($this->searchMask & SEARCH_TYPE_JSON) $this->displayExtra([$this, 'generateJsonSearch']); }