mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Search/Opensearch
* return results with correct mime type.
This commit is contained in:
@@ -14,6 +14,7 @@ define('FILTER_FLAG_STRIP_AOWOW', FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH
|
|||||||
define('MIME_TYPE_TEXT', 'Content-Type: text/plain; charset=utf-8');
|
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_XML', 'Content-Type: text/xml; charset=utf-8');
|
||||||
define('MIME_TYPE_JSON', 'Content-Type: application/x-javascript; 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_RSS', 'Content-Type: application/rss+xml; charset=utf-8');
|
||||||
define('MIME_TYPE_JPEG', 'Content-Type: image/jpeg');
|
define('MIME_TYPE_JPEG', 'Content-Type: image/jpeg');
|
||||||
define('MIME_TYPE_PNG', 'Content-Type: image/png');
|
define('MIME_TYPE_PNG', 'Content-Type: image/png');
|
||||||
|
|||||||
@@ -223,12 +223,15 @@ class SearchPage extends GenericPage
|
|||||||
parent::display(); // errors are handled in the search-template itself
|
parent::display(); // errors are handled in the search-template itself
|
||||||
}
|
}
|
||||||
else if ($this->searchMask & SEARCH_TYPE_OPEN)
|
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)
|
else if ($this->searchMask & SEARCH_TYPE_JSON)
|
||||||
$result = [$this->search, [], []];
|
{
|
||||||
|
|
||||||
header(MIME_TYPE_JSON);
|
header(MIME_TYPE_JSON);
|
||||||
exit(Util::toJSON($result));
|
exit(Util::toJSON([$this->search, [], []]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function display(string $override = '') : void
|
public function display(string $override = '') : void
|
||||||
@@ -236,7 +239,7 @@ class SearchPage extends GenericPage
|
|||||||
if ($override || ($this->searchMask & SEARCH_TYPE_REGULAR))
|
if ($override || ($this->searchMask & SEARCH_TYPE_REGULAR))
|
||||||
parent::display($override);
|
parent::display($override);
|
||||||
else if ($this->searchMask & SEARCH_TYPE_OPEN)
|
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)
|
else if ($this->searchMask & SEARCH_TYPE_JSON)
|
||||||
$this->displayExtra([$this, 'generateJsonSearch']);
|
$this->displayExtra([$this, 'generateJsonSearch']);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user