| 1 | <?php |
| 2 | /** |
| 3 | * The web entry point for generating an OpenSearch description document. |
| 4 | * |
| 5 | * See <http://www.opensearch.org/> for the specification of the OpenSearch |
| 6 | * "description" document. In a nut shell, this tells browsers how and where |
| 7 | * to submit submit search queries to get a search results page back, |
| 8 | * as well as how to get typeahead suggestions (see ApiOpenSearch). |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License along |
| 21 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 23 | * http://www.gnu.org/copyleft/gpl.html |
| 24 | * |
| 25 | * @file |
| 26 | * @ingroup entrypoint |
| 27 | */ |
| 28 | |
| 29 | // This endpoint is supposed to be independent of request cookies and other |
| 30 | // details of the session. Enforce this constraint with respect to session use. |
| 31 | define( 'MW_NO_SESSION', 1 ); |
| 32 | |
| 33 | define( 'MW_ENTRY_POINT', 'opensearch_desc' ); |
| 34 | |
| 35 | require_once __DIR__ . '/includes/WebStart.php'; |
| 36 | |
| 37 | $url = wfScript( 'rest' ) . '/v1/search'; |
| 38 | $ctype = $wgRequest->getRawVal( 'ctype' ); |
| 39 | |
| 40 | if ( $ctype !== null ) { |
| 41 | $url = wfAppendQuery( $url, [ 'ctype' => $ctype ] ); |
| 42 | } |
| 43 | |
| 44 | $wgRequest->response()->header( 'Location: ' . $url, true, 308 ); |
| 45 | $wgRequest->response()->header( 'Cache-control: max-age=600' ); |