forked from evad37/wm-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
46 lines (40 loc) · 1.54 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
require "inc/external/getDefaultLanguage.php";
require "inc/formatting.php";
require "inc/core.php";
// When there's no valid item id, nor a page title & site, show the about page instead
$has_title_and_site = !!$page_title && !! $page_site;
if ( !preg_match("/^Q\d+$/", $item_id) && !$has_title_and_site ) {
echo_html_top();
require "web/about.php";
require "web/qr.php";
echo makefooter();
echo "</body></html>";
die();
}
// Backwards compatibility, when given page title & site instead of id
if ( !$item_id && $has_title_and_site ) {
$page_id = $api->lookupIdForPage($page_title, $page_site);
if ( !preg_match("/^Q\d+$/", $page_id) ) {
echo_html_top();
echo "<p style='font-size:120%;margin:0.5em;'>Sorry, page <span style='font-style: italic;'>{$page_title}</span>
was not found on site <span style='font-style: italic;'>{$page_site}</span>.</p>
<p style='margin:0.5em;'>Either the page does not exist on that wiki, or it is not connected to Wikidata.</p>
<hr>";
require "web/about.php";
echo makefooter();
echo "</body></html>";
die();
}
header("Location:{$self}/{$page_id}");
die();
}
$available_langs = json_decode(file_get_contents("i18n/_langs.json"), true);
if ( !isset($available_langs[$lang_code]) ) {
echo "Sorry, the tool interface has not yet been translated for <code>{$lang_code}</code> language.";
$i18n = json_decode(file_get_contents("i18n/en.json"), true);
} else {
$i18n = json_decode(file_get_contents("i18n/{$lang_code}.json"), true);
}
require "web/portal.php";
?>