1 | <?php |
||||||
2 | |||||||
3 | /** |
||||||
4 | * Use Composer autoloader to automatically load library classes. |
||||||
5 | */ |
||||||
6 | try { |
||||||
7 | if (!file_exists('../vendor/autoload.php')) { |
||||||
8 | throw new Exception('Dependencies managed by Composer missing. Please run "php composer.phar install".'); |
||||||
9 | } |
||||||
10 | require_once '../vendor/autoload.php'; |
||||||
11 | } catch (Exception $e) { |
||||||
12 | echo "Error: " . $e->getMessage(); |
||||||
13 | return; |
||||||
14 | } |
||||||
15 | |||||||
16 | try { |
||||||
17 | $model = new Model(); |
||||||
18 | } catch (Exception $e) { |
||||||
19 | header("HTTP/1.1 500 Internal Server Error"); |
||||||
20 | echo "Error: " . $e->getMessage(); |
||||||
21 | exit(1); |
||||||
22 | } |
||||||
23 | |||||||
24 | $controller = new WebController($model); |
||||||
25 | $request = new Request($model); |
||||||
26 | |||||||
27 | // PATH_INFO, for example "/ysa/fi" |
||||||
28 | $path = $request->getServerConstant('PATH_INFO') ? $request->getServerConstant('PATH_INFO') : ''; |
||||||
29 | $parts = explode('/', $path); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
30 | |||||||
31 | |||||||
32 | if (sizeof($parts) <= 2) { |
||||||
33 | // if language code missing, redirect to guessed language |
||||||
34 | // in any case, redirect to <lang>/ |
||||||
35 | $lang = sizeof($parts) == 2 && $parts[1] !== '' ? $parts[1] : $controller->guessLanguage($request); |
||||||
36 | header("Location: " . $lang . "/"); |
||||||
37 | } else { |
||||||
38 | if (array_key_exists($parts[1], $model->getConfig()->getLanguages())) { // global pages |
||||||
39 | $request->setLang($parts[1]); |
||||||
40 | $model->setLocale($parts[1]); |
||||||
41 | $content_lang = $request->getQueryParam('clang'); |
||||||
42 | $request->setContentLang($content_lang); |
||||||
43 | ($parts[2] == 'about' || $parts[2] == 'feedback' || $parts[2] == 'search') ? $request->setPage($parts[2]) : $request->setPage(''); |
||||||
44 | if ($request->getPage() == '') { |
||||||
45 | $controller->invokeLandingPage($request); |
||||||
46 | } elseif ($request->getPage() == 'about') { |
||||||
47 | $controller->invokeAboutPage($request); |
||||||
48 | } elseif ($request->getPage() == 'feedback') { |
||||||
49 | $controller->invokeFeedbackForm($request); |
||||||
50 | } elseif ($request->getPage() == 'search') { |
||||||
51 | $controller->invokeGlobalSearch($request); |
||||||
52 | } else { |
||||||
53 | $controller->invokeGenericErrorPage($request); |
||||||
54 | } |
||||||
55 | } else { // vocabulary-specific pages |
||||||
56 | $vocab = $parts[1]; |
||||||
57 | try { |
||||||
58 | $request->setVocab($parts[1]); |
||||||
59 | } catch (Exception | ValueError $e) { |
||||||
60 | $request->setLang($controller->guessLanguage($request)); |
||||||
61 | $controller->invokeGenericErrorPage($request); |
||||||
62 | return; |
||||||
63 | } |
||||||
64 | if (sizeof($parts) == 3) { // language code missing |
||||||
65 | $lang = $controller->guessLanguage($request); |
||||||
66 | $newurl = $controller->getBaseHref() . $vocab . "/" . $lang . "/"; |
||||||
67 | header("Location: " . $newurl); |
||||||
68 | } else { |
||||||
69 | if (array_key_exists($parts[2], $model->getConfig()->getLanguages())) { |
||||||
70 | $lang = $parts[2]; |
||||||
71 | $content_lang = $request->getQueryParam('clang') ? $request->getQueryParam('clang') : $lang; |
||||||
72 | $request->setContentLang($content_lang); |
||||||
73 | $request->setLang($parts[2]); |
||||||
74 | $request->setPage($parts[3]); |
||||||
75 | if (!$request->getPage()) { |
||||||
76 | $request->setPage('vocab'); |
||||||
77 | $controller->invokeVocabularyHome($request); |
||||||
78 | } elseif ($request->getPage() == 'feedback') { |
||||||
79 | $controller->invokeFeedbackForm($request); |
||||||
80 | } elseif ($request->getPage() == 'search') { |
||||||
81 | $controller->invokeVocabularySearch($request); |
||||||
82 | } elseif ($request->getPage() == 'index') { |
||||||
83 | if ((sizeof($parts) == 5) && $parts[4] !== '') { |
||||||
84 | // letter given |
||||||
85 | $request->setLetter($parts[4]); |
||||||
86 | } |
||||||
87 | |||||||
88 | $controller->invokeAlphabeticalIndex($request); |
||||||
0 ignored issues
–
show
The method
invokeAlphabeticalIndex() does not exist on WebController .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
89 | } elseif ($request->getPage() == 'page') { |
||||||
90 | ($request->getQueryParam('uri')) ? $request->setUri($request->getQueryParam('uri')) : $request->setUri($parts[4]); |
||||||
91 | if ($request->getUri() === null || $request->getUri() === '') { |
||||||
92 | $controller->invokeGenericErrorPage($request); |
||||||
93 | } else { |
||||||
94 | $controller->invokeVocabularyConcept($request); |
||||||
95 | } |
||||||
96 | |||||||
97 | } elseif ($request->getPage() == 'groups') { |
||||||
98 | $controller->invokeGroupIndex($request); |
||||||
0 ignored issues
–
show
The method
invokeGroupIndex() does not exist on WebController .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
99 | } elseif ($request->getPage() == 'changes') { |
||||||
100 | $controller->invokeChangeList($request, 'dc:modified'); |
||||||
0 ignored issues
–
show
The method
invokeChangeList() does not exist on WebController .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
101 | } elseif ($request->getPage() == 'new') { |
||||||
102 | $controller->invokeChangeList($request); |
||||||
103 | } else { |
||||||
104 | $controller->invokeGenericErrorPage($request); |
||||||
105 | } |
||||||
106 | } else { // language code missing, redirect to some language version |
||||||
107 | $lang = $controller->guessLanguage($request, $vocab); |
||||||
108 | $newurl = $controller->getBaseHref() . $vocab . "/" . $lang . "/" . implode('/', array_slice($parts, 2)); |
||||||
109 | $qs = $request->getServerConstant('QUERY_STRING'); |
||||||
110 | if ($qs) { |
||||||
111 | $newurl .= "?" . $qs; |
||||||
112 | } |
||||||
113 | header("Location: $newurl"); |
||||||
114 | } |
||||||
115 | } |
||||||
116 | } |
||||||
117 | } |
||||||
118 |