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:
@@ -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('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('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_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_RSS', 'Content-Type: application/rss+xml; charset=utf-8');
|
define('MIME_TYPE_OPENSEARCH', 'Content-Type: application/x-suggestions+json; charset=utf-8');
|
||||||
define('MIME_TYPE_JPEG', 'Content-Type: image/jpeg');
|
define('MIME_TYPE_RSS', 'Content-Type: application/rss+xml; charset=utf-8');
|
||||||
define('MIME_TYPE_PNG', 'Content-Type: image/png');
|
define('MIME_TYPE_JPEG', 'Content-Type: image/jpeg');
|
||||||
|
define('MIME_TYPE_PNG', 'Content-Type: image/png');
|
||||||
|
|
||||||
// shared setup strings
|
// shared setup strings
|
||||||
define('ERR_CREATE_FILE', 'could not create file at destination %s');
|
define('ERR_CREATE_FILE', 'could not create file at destination %s');
|
||||||
|
|||||||
@@ -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([$this->search, [], []]));
|
||||||
exit(Util::toJSON($result));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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