Subversion Repositories oidplus

Rev

Rev 348 | Rev 362 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 daniel-mar 1
<?php
2
 
3
/*
4
 * OIDplus 2.0
5
 * Copyright 2019 Daniel Marschall, ViaThinkSoft
6
 *
7
 * Licensed under the Apache License, Version 2.0 (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
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
 
20
class OIDplusGui {
21
 
22
        public static function generateContentPage($id) {
23
                $out = array();
24
 
25
                $handled = false;
26
                $out['title'] = '';
32 daniel-mar 27
                $out['icon'] = '';
2 daniel-mar 28
                $out['text'] = '';
29
 
281 daniel-mar 30
                foreach (OIDplus::getPagePlugins() as $plugin) {
348 daniel-mar 31
                        try {
32
                                $plugin->gui($id, $out, $handled);
33
                        } catch (Exception $e) {
360 daniel-mar 34
                                $out['title'] = _L('Error');
348 daniel-mar 35
                                $out['icon'] = 'img/error_big.png';
36
                                $out['text'] = $e->getMessage();
37
                        }
281 daniel-mar 38
                        if ($handled) break;
61 daniel-mar 39
                }
2 daniel-mar 40
 
41
                if (!$handled) {
360 daniel-mar 42
                        $out['title'] = _L('Error');
256 daniel-mar 43
                        $out['icon'] = 'img/error_big.png';
360 daniel-mar 44
                        $out['text'] = _L('The resource cannot be found.');
2 daniel-mar 45
                }
46
 
47
                return $out;
48
        }
250 daniel-mar 49
 
327 daniel-mar 50
        public static function link($goto, $new_window=false) {
51
                if ($new_window) {
52
                        return 'href="?goto='.urlencode($goto).'" target="_blank"';
250 daniel-mar 53
                } else {
327 daniel-mar 54
                        if (strpos($goto, '#') !== false) {
55
                                list($goto, $anchor) = explode('#', $goto, 2);
56
                                return 'href="?goto='.urlencode($goto).'#'.htmlentities($anchor).'" onclick="openOidInPanel('.js_escape($goto).', true, '.js_escape($anchor).'); return false;"';
57
                        } else {
58
                                return 'href="?goto='.urlencode($goto).'" onclick="openOidInPanel('.js_escape($goto).', true); return false;"';
59
                        }
250 daniel-mar 60
                }
61
        }
360 daniel-mar 62
}