Subversion Repositories oidplus

Rev

Rev 356 | Rev 362 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 356 Rev 360
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * OIDplus 2.0
4
 * OIDplus 2.0
5
 * Copyright 2019 Daniel Marschall, ViaThinkSoft
5
 * Copyright 2019-2020 Daniel Marschall, ViaThinkSoft
6
 *
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
9
 * You may obtain a copy of the License at
10
 *
10
 *
Line 22... Line 22...
22
require_once __DIR__ . '/includes/oidplus.inc.php';
22
require_once __DIR__ . '/includes/oidplus.inc.php';
23
 
23
 
24
set_exception_handler('html_exception_handler');
24
set_exception_handler('html_exception_handler');
25
function html_exception_handler($exception) {
25
function html_exception_handler($exception) {
26
        if ($exception instanceof OIDplusConfigInitializationException) {
26
        if ($exception instanceof OIDplusConfigInitializationException) {
27
                echo "<h1>OIDplus initialization error</h1>";
27
                echo '<h1>'._L('OIDplus initialization error').'</h1>';
28
                echo '<p>'.htmlentities($exception->getMessage(), ENT_SUBSTITUTE).'</p>';
28
                echo '<p>'.htmlentities($exception->getMessage(), ENT_SUBSTITUTE).'</p>';
29
                echo '<p>Please check <b>userdata/baseconfig/config.inc.php</b>';
29
                echo '<p>'._L('Please check file %1','<b>userdata/baseconfig/config.inc.php</b>');
30
                if (is_dir(__DIR__ . '/setup')) {
30
                if (is_dir(__DIR__ . '/setup')) {
31
                        echo ' or run <a href="'.OIDplus::getSystemUrl().'setup/">setup</a> again';
31
                        echo ' '._L('or run <a href="%1">setup</a> again',OIDplus::getSystemUrl().'setup/');
32
                }
32
                }
33
                echo '</p>';
33
                echo '</p>';
34
        } else {
34
        } else {
35
                echo "<h1>OIDplus error</h1>";
35
                echo '<h1>'._L('OIDplus error').'</h1>';
36
                // ENT_SUBSTITUTE because ODBC drivers might return ANSI instead of UTF-8 stuff
36
                // ENT_SUBSTITUTE because ODBC drivers might return ANSI instead of UTF-8 stuff
37
                echo '<p>'.htmlentities($exception->getMessage(), ENT_SUBSTITUTE).'</p>';
37
                echo '<p>'.htmlentities($exception->getMessage(), ENT_SUBSTITUTE).'</p>';
38
                echo '<p><b>Technical information about the problem:</b></p>';
38
                echo '<p><b>'._L('Technical information about the problem').':</b></p>';
39
                echo '<pre>';
39
                echo '<pre>';
40
                echo get_class($exception)."\n";
40
                echo get_class($exception)."\n";
-
 
41
                var_dump($exception->getFile());
-
 
42
                var_dump($exception->getLine());
41
                echo 'at '.$exception->getFile().'('.$exception->getLine().")\n";
43
                echo _L('at file %1 (line %2)',$exception->getFile(),"".$exception->getLine())."\n";
42
                echo "Stacktrace:\n";
44
                echo _L('Stacktrace').":\n";
43
                echo $exception->getTraceAsString();
45
                echo $exception->getTraceAsString();
44
                echo '</pre>';
46
                echo '</pre>';
45
        }
47
        }
46
}
48
}
47
 
49
 
Line 63... Line 65...
63
                return $pagetitle . ' - ' . $systemtitle;
65
                return $pagetitle . ' - ' . $systemtitle;
64
        }
66
        }
65
}
67
}
66
 
68
 
67
$sysid_oid = OIDplus::getSystemId(true);
69
$sysid_oid = OIDplus::getSystemId(true);
68
if (!$sysid_oid) $sysid_oid = 'unknown';
70
if (!$sysid_oid) $sysid_oid = 'unknown'; // do not translate
69
header('X-OIDplus-SystemID:'.$sysid_oid);
71
header('X-OIDplus-SystemID:'.$sysid_oid);
70
 
72
 
71
$sys_url = OIDplus::getSystemUrl();
73
$sys_url = OIDplus::getSystemUrl();
72
header('X-OIDplus-SystemURL:'.$sys_url);
74
header('X-OIDplus-SystemURL:'.$sys_url);
73
 
75
 
74
$sys_ver = OIDplus::getVersion();
76
$sys_ver = OIDplus::getVersion();
75
if (!$sys_ver) $sys_ver = 'unknown';
77
if (!$sys_ver) $sys_ver = 'unknown'; // do not translate
76
header('X-OIDplus-SystemVersion:'.$sys_ver);
78
header('X-OIDplus-SystemVersion:'.$sys_ver);
77
 
79
 
78
$sys_install_type = OIDplus::getInstallType();
80
$sys_install_type = OIDplus::getInstallType();
79
header('X-OIDplus-SystemInstallType:'.$sys_install_type);
81
header('X-OIDplus-SystemInstallType:'.$sys_install_type);
80
 
82
 
Line 126... Line 128...
126
                echo '<h1 id="real_title">';
128
                echo '<h1 id="real_title">';
127
                if ($static_icon != '') echo '<img src="'.htmlentities($static_icon).'" width="48" height="48" alt=""> ';
129
                if ($static_icon != '') echo '<img src="'.htmlentities($static_icon).'" width="48" height="48" alt=""> ';
128
                echo htmlentities($static_title).'</h1>';
130
                echo htmlentities($static_title).'</h1>';
129
                echo '<div id="real_content">'.$static_content.'</div>';
131
                echo '<div id="real_content">'.$static_content.'</div>';
130
                if ((!isset($_SERVER['REQUEST_METHOD'])) || ($_SERVER['REQUEST_METHOD'] == 'GET')) {
132
                if ((!isset($_SERVER['REQUEST_METHOD'])) || ($_SERVER['REQUEST_METHOD'] == 'GET')) {
131
                        echo '<br><p><img src="img/share.png" width="15" height="15" alt="Share"> <a href="?goto='.htmlentities($static_node_id).'" id="static_link" class="gray_footer_font">Static link to this page</a>';
133
                        echo '<br><p><img src="img/share.png" width="15" height="15" alt="'._L('Share').'"> <a href="?goto='.htmlentities($static_node_id).'" id="static_link" class="gray_footer_font">'._L('Static link to this page').'</a>';
132
                        echo '</p>';
134
                        echo '</p>';
133
                }
135
                }
134
                echo '<br>';
136
                echo '<br>';
135
                ?>
137
                ?>
136
        </div>
138
        </div>
137
 
139
 
138
        <div id="system_title_bar">
140
        <div id="system_title_bar">
-
 
141
                <?php
139
                <div id="system_title_menu" onclick="mobileNavButtonClick(this)" onmouseenter="mobileNavButtonHover(this)" onmouseleave="mobileNavButtonHover(this)">
142
                echo '<div id="system_title_menu" onclick="mobileNavButtonClick(this)" onmouseenter="mobileNavButtonHover(this)" onmouseleave="mobileNavButtonHover(this)">';
140
                        <div id="bar1"></div>
143
                echo '  <div id="bar1"></div>';
141
                        <div id="bar2"></div>
144
                echo '  <div id="bar2"></div>';
142
                        <div id="bar3"></div>
145
                echo '  <div id="bar3"></div>';
143
                </div>
146
                echo '</div>';
144
 
147
                echo '';
145
                <div id="system_title_text">
148
                echo '<div id="system_title_text">';
146
                        <a <?php echo OIDplus::gui()->link('oidplus:system'); ?>>
149
                echo '  <a '.OIDplus::gui()->link('oidplus:system').'>';
147
                                <span id="system_title_1">ViaThinkSoft OIDplus 2.0</span><br>
150
                echo '          <span id="system_title_1">'._L('ViaThinkSoft OIDplus 2.0').'</span><br>';
148
                                <span id="system_title_2"><?php echo htmlentities(OIDplus::config()->getValue('system_title')); ?></span>
151
                echo '          <span id="system_title_2">'.htmlentities(OIDplus::config()->getValue('system_title')).'</span>';
149
                        </a>
152
                echo '  </a>';
150
                </div>
153
                echo '</div>';
-
 
154
                ?>
151
        </div>
155
        </div>
152
 
156
 
153
        <div id="languageBox">
157
        <div id="languageBox">
154
                <?php
158
                <?php
155
 
159
 
-
 
160
                if (isset($_GET['lang'])) {
-
 
161
                        // The "?lang=" argument is only for NoScript-Browsers/SearchEngines
-
 
162
                        // In case someone who has JavaScript clicks a ?lang= link, they should get
-
 
163
                        // the page in that language, but the cookie must be set, otherwise
-
 
164
                        // the menu and other stuff would be in their cookie-based-language and not the
-
 
165
                        // argument-based-language.
-
 
166
                        $cookie_path = OIDplus::getSystemUrl(true);
-
 
167
                        if (empty($cookie_path)) $cookie_path = '/';
-
 
168
                        setcookie('LANGUAGE', $_GET['lang'], 0, $cookie_path, '', false, false/*HttpOnly off, because JavaScript also needs translation*/);
-
 
169
                } else if (isset($_POST['lang'])) {
-
 
170
                        $cookie_path = OIDplus::getSystemUrl(true);
-
 
171
                        if (empty($cookie_path)) $cookie_path = '/';
-
 
172
                        setcookie('LANGUAGE', $_POST['lang'], 0, $cookie_path, '', false, false/*HttpOnly off, because JavaScript also needs translation*/);
-
 
173
                }
-
 
174
 
-
 
175
                $langbox_entries = array();
-
 
176
                $non_default_languages = 0;
156
                foreach (OIDplus::getAllPluginManifests('language') as $pluginManifest) {
177
                foreach (OIDplus::getAllPluginManifests('language') as $pluginManifest) {
157
                        $xmldata = $pluginManifest->getRawXml();
178
                        $xmldata = $pluginManifest->getRawXml();
158
                        $flag = $xmldata->language->flag->__toString();
179
                        $flag = $xmldata->language->flag->__toString();
159
                        $code = $xmldata->language->code->__toString();
180
                        $code = $xmldata->language->code->__toString();
-
 
181
                        if ($code != OIDplus::DEFAULT_LANGUAGE) $non_default_languages++;
160
                        if ($code == OIDplus::getCurrentLang()) {
182
                        if ($code == OIDplus::getCurrentLang()) {
161
                                $class = 'lng_flag';
183
                                $class = 'lng_flag';
162
                        } else {
184
                        } else {
163
                                $class = 'lng_flag picture_ghost';
185
                                $class = 'lng_flag picture_ghost';
164
                        }
186
                        }
165
                        echo '<img src="plugins/language/'.$code.'/'.$flag.'" alt="'.$pluginManifest->getName().'" title="'.$pluginManifest->getName().'" class="'.$class.'" id="lng_flag_'.$code.'" height="20" onclick="setLanguage(\''.$code.'\')"> ';
187
                        $langbox_entries[] = '<a onclick="setLanguage(\''.$code.'\'); return false" href="?lang='.$code.'&amp;goto='.$static_node_id.'"><img src="plugins/language/'.$code.'/'.$flag.'" alt="'.$pluginManifest->getName().'" title="'.$pluginManifest->getName().'" class="'.$class.'" id="lng_flag_'.$code.'" height="20"></a> ';
-
 
188
                }
-
 
189
                if ($non_default_languages > 0) {
-
 
190
                        echo implode("\n\t\t",$langbox_entries);
166
                }
191
                }
167
 
192
 
168
                ?>
193
                ?>
169
        </div>
194
        </div>
170
 
195
 
171
        <div id="gotobox">
196
        <div id="gotobox">
-
 
197
                <?php
172
                <input type="text" name="goto" id="gotoedit" value="<?php echo htmlentities($static_node_id); ?>">
198
                echo '<input type="text" name="goto" id="gotoedit" value="'.htmlentities($static_node_id).'">';
173
                <input type="button" value="Go" onclick="gotoButtonClicked()" id="gotobutton">
199
                echo '<input type="button" value="'._L('Go').'" onclick="gotoButtonClicked()" id="gotobutton">';
-
 
200
                ?>
174
        </div>
201
        </div>
175
 
202
 
176
        <div id="oidtree" class="borderbox">
203
        <div id="oidtree" class="borderbox">
177
                <!-- <noscript>
204
                <!-- <noscript>
178
                        <p><b>Please enable JavaScript to use all features</b></p>
205
                        <p><b><?php echo _L('Please enable JavaScript to use all features'); ?></b></p>
179
                </noscript> -->
206
                </noscript> -->
180
                <?php OIDplus::menuUtils()->nonjs_menu(); ?>
207
                <?php OIDplus::menuUtils()->nonjs_menu(); ?>
181
        </div>
208
        </div>
182
</div>
209
</div>
183
 
210