Passed
Push — master ( 17bffe...10bee5 )
by Stefan
06:13
created

Menu   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 5
Bugs 3 Features 0
Metric Value
wmc 6
dl 0
loc 32
rs 10
c 5
b 3
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A printMenuLine() 0 5 2
A printMenu() 0 6 3
1
<?php
2
/*
3
 * ******************************************************************************
4
 * Copyright 2011-2017 DANTE Ltd. and GÉANT on behalf of the GN3, GN3+, GN4-1 
5
 * and GN4-2 consortia
6
 *
7
 * License: see the web/copyright.php file in the file structure
8
 * ******************************************************************************
9
 */
10
?>
11
<?php
12
/**
13
 * Front-end for the user GUI
14
 *
15
 * @author Tomasz Wolniewicz <[email protected]>
16
 * @package UserGUI
17
 */
18
error_reporting(E_ALL | E_STRICT);
19
20
$Gui->langObject->setTextDomain("web_user");
21
$Gui->loggerInstance->debug(4, "\n---------------------- index.php START --------------------------\n");
22
23
/**
24
 * Menu class helps to define the menu on the main page
25
 */
26
class Menu {
27
28
    /**
29
     * the constructor takes an array argument defining menu items.
30
     * the array must be indexed by strings which will be passed to user/cat_info.php a the page argument
31
     * the values of the array can be either a simple string which is passed to user/cat_info.php
32
     * as the title argument or an two element array - the first element of this array will be
33
     * the title and the second is a style specification applied to the given menu item
34
     */
35
    public function __construct($menuArray) {
36
        $this->menu = $menuArray;
37
    }
38
39
    private function printMenuLine($index, $title = "", $style = "") {
40
        if ($style !== "") {
41
            print "<tr><td style='$style'><a href='javascript:infoCAT(\"$index\",\"" . rawurlencode($title) . "\")'>$title</a></td></tr>\n";
42
        } else {
43
            print "<tr><td><a href='javascript:infoCAT(\"$index\",\"" . rawurlencode($title) . "\")'>$title</a></td></tr>\n";
44
        }
45
    }
46
47
    public function printMenu() {
48
        foreach ($this->menu as $index => $title) {
49
            if (is_array($title)) {
50
                $this->printMenuLine($index, $title[0], $title[1]);
0 ignored issues
show
Bug introduced by
The method printMenuLine() does not exist on Menu. Did you maybe mean printMenu()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
                $this->/** @scrutinizer ignore-call */ 
51
                       printMenuLine($index, $title[0], $title[1]);

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.

Loading history...
51
            } else {
52
                $this->printMenuLine($index, $title);
53
            }
54
        }
55
    }
56
57
    private $menu;
58
59
}
60
61
$deco = new \web\lib\admin\PageDecoration();
62
?>
63
<link rel="stylesheet" media="screen" type="text/css" href="<?php echo $Gui->skinObject->findResourceUrl("CSS","cat-user.css");?>" />
64
<!-- JQuery -->
65
<script type="text/javascript" src="<?php echo $Gui->skinObject->findResourceUrl("EXTERNAL","jquery/jquery.js") ?>"></script>
66
<script type="text/javascript" src="<?php echo $Gui->skinObject->findResourceUrl("EXTERNAL","jquery/jquery-migrate.js") ?>"></script>
67
<script type="text/javascript" src="<?php echo $Gui->skinObject->findResourceUrl("EXTERNAL","jquery/jquery-ui.js") ?>"></script>
68
<!-- JQuery -->
69
<script type="text/javascript">
70
    if (screen.width <= 480) {
71
        window.location.href = "<?php echo rtrim(dirname($_SERVER['SCRIPT_NAME']), '/') ?>/basic.php?<?php echo htmlspecialchars(filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_STRING)); ?>";
72
            }
73
</script>
74
<script type="text/javascript">
75
    var recognisedOS = '';
76
    var downloadMessage;
77
<?php
78
$operatingSystem = $Gui->detectOS();
79
$Gui->loggerInstance->debug(4, print_r($operatingSystem, true));
80
if ($operatingSystem) {
81
    print "recognisedOS = '" . $operatingSystem['device'] . "';\n";
82
}
83
$downloadMessage = sprintf(_("Download your %s installer"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']);
84
print 'downloadMessage = "' . $downloadMessage . '";';
85
//TODO modify this based on OS detection
86
if (preg_match('/Android/', $_SERVER['HTTP_USER_AGENT'])) {
87
    $profile_list_size = 1;
88
} else {
89
    $profile_list_size = 4;
90
}
91
include("user/js/roll.php");
92
include("user/js/cat_js.php");
93
?>
94
    var loading_ico = new Image();
95
    loading_ico.src = "<?php echo $Gui->skinObject->findResourceUrl("IMAGES", "icons/loading51.gif"); ?>";
96
</script>
97
<?php $Gui->langObject->setTextDomain("web_user"); ?>
98
<!-- DiscoJuice -->
99
<script type="text/javascript" src="<?php echo $Gui->skinObject->findResourceUrl("EXTERNAL", "discojuice/discojuice.js"); ?>"></script>
100
<script type="text/javascript">
101
    var lang = "<?php echo($Gui->langObject->getLang()) ?>";
102
</script>
103
<link rel="stylesheet" type="text/css" href="<?php echo $Gui->skinObject->findResourceUrl("EXTERNAL", "discojuice/css/discojuice.css"); ?>" />
104
</head>
105
<body>
106
    <div id="heading">
107
        <?php
108
        print '<img src="' . $Gui->skinObject->findResourceUrl("IMAGES", "consortium_logo.png") . '" alt="Consortium Logo" style="float:right; padding-right:20px; padding-top:20px"/>';
109
        print '<div id="motd">' . ( isset(CONFIG['APPEARANCE']['MOTD']) ? CONFIG['APPEARANCE']['MOTD'] : '&nbsp' ) . '</div>';
110
        print '<h1 style="padding-bottom:0px; height:1em;">' . sprintf(_("Welcome to %s"), CONFIG['APPEARANCE']['productname']) . '</h1>
111
<h2 style="padding-bottom:0px; height:0px; vertical-align:bottom;">' . CONFIG['APPEARANCE']['productname_long'] . '</h2>';
112
        echo '<table id="lang_select"><tr><td>';
113
        echo _("View this page in");
114
        ?>
115
        <?php
116 View Code Duplication
        foreach (CONFIG['LANGUAGES'] as $lang => $value) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
117
            echo "<a href='javascript:changeLang(\"$lang\")'>" . $value['display'] . "</a> ";
118
        }
119
        echo '</td><td style="text-align:right;padding-right:20px"><a href="' . dirname($_SERVER['SCRIPT_NAME']) . '?lang=' . $Gui->langObject->getLang() . '">' . _("Start page") . '</a></td></tr></table>';
120
        ?>
121
    </div> <!-- id="heading" -->
122
    <div id="loading_ico">
123
        <?php echo _("Authenticating") . "..." ?><br><img src="<?php echo $Gui->skinObject->findResourceUrl("IMAGES", "icons/loading51.gif"); ?>" alt="Authenticating ..."/>
124
    </div>
125
    <div id="info_overlay">
126
        <div id="info_window"></div>
127
        <span id="close_button"><?php echo _("Close") ?></span>
128
    </div>
129
    <form id="cat_form" name="cat_form" method="POST"  accept-charset="UTF-8" action="<?php echo rtrim(dirname($_SERVER['SCRIPT_NAME']), '/'); ?>/">
130
        <div id="main_body">
131
            <?php if (!isset($_REQUEST['idp']) || !$_REQUEST['idp']) { ?>
132
                <table id="front_page">
133
                    <tr>
134
                        <td rowspan=2 id="menu_column">
135
                            <table id="left_menu">
136
                                <?php
137
                                $menu = new Menu([
0 ignored issues
show
Bug introduced by
array('about_consortium'..., 'padding-top:30px;')) of type array<string,string|array<integer,string>> is incompatible with the type string expected by parameter $visibility of Menu::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

137
                                $menu = new Menu(/** @scrutinizer ignore-type */ [
Loading history...
138
                                    "about_consortium" => [sprintf(_("About %s"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']), 'padding-bottom:20px;font-weight: bold; '],
139
                                    "about" => sprintf(_("About %s"), CONFIG['APPEARANCE']['productname']),
140
                                    "tou" => sprintf(_("Terms of use")),
141
                                    "faq" => sprintf(_("FAQ")),
142
                                    "report" => sprintf(_("Report a problem")),
143
                                    "develop" => sprintf(_("Become a CAT developer")),
144
                                    "admin" => [sprintf(_("%s admin:<br>manage your %s"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'], $Gui->nomenclature_inst), 'padding-top:30px;'],
145
                                ]);
146
147
                                $menu->printMenu();
148
                                ?>
149
                            </table>
150
                        </td>
151
                        <td style="vertical-align: top; height:280px; background: #fff; padding-left: 20px; padding-right: 20px">
152
                            <div id="main_menu_info" style="display:none">
153
                                <img id="main_menu_close" src="<?php echo $Gui->skinObject->findResourceUrl("IMAGES", "icons/button_cancel.png"); ?>" ALT="Close"  style="float:right"/>
154
                                <div id="main_menu_content"></div>
155
                            </div>
156
                            <table style="background: #fff; width:100%; padding-top: 5px">
157
                                <tr>
158
                                    <td id="slides" style="background: #fff url(<?php echo $Gui->skinObject->findResourceUrl("IMAGES", "gradient-bg.png"); ?>) repeat-x; height:272px; border-radius: 16px; width: 100%; padding-left:20px;">
159
                                        <div>
160
                                            <span id="line1"><?php printf(_("%s installation made easy:"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']) ?></span>
161
                                            <span id="line2"></span>
162
                                            <span id="line3"></span>
163
                                            <span id="line4"><?php echo sprintf(_("Custom built for your %s"),$Gui->nomenclature_inst) ?></span>
164
                                            <span id="line5">
165
                                                <?php
166
                                                if (isset(CONFIG_CONFASSISTANT['CONSORTIUM']['signer_name']) && CONFIG_CONFASSISTANT['CONSORTIUM']['signer_name'] != "") {
167
                                                    echo sprintf(_("Digitally signed by the organisation that coordinates %s: %s"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'], CONFIG_CONFASSISTANT['CONSORTIUM']['signer_name']);
168
                                                }
169
                                                ?>
170
                                            </span>
171
                                        </div>
172
                                        <div id = "img_roll">
173
                                            <img id="img_roll_0" src="<?php echo $Gui->skinObject->findResourceUrl("IMAGES", "empty.png"); ?>" alt="Rollover 0"/> <img id="img_roll_1" src="<?php echo $Gui->skinObject->findResourceUrl("IMAGES", "empty.png"); ?>" alt="Rollover 1"/></div>
174
                                    </td>
175
                                </tr>
176
                            </table>
177
                        </td>
178
                    </tr>
179
                    <tr>
180
                        <td id="user_button_td">
181
                            <?php print '<span id="signin"><button class="signin signin_large" id="user_button1"><span id="user_button">' . sprintf(_("%s user:<br>download your %s installer"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'], CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']) . '</span></button></span><span style="padding-left:50px">&nbsp;</span>'; ?>
182
183
                        </td>
184
                    </tr>
185
                </table> <!-- id="front_page" -->
186
            <?php } ?>
187
            <!-- the user_page div contains all information for a given IdP, i.e. the profile selection (if multiple profiles are defined)
188
                 and the device selection (including the automatic OS detection ) -->
189
            <div id="user_page">
190
                <div id="institution_name">
191
                    <span id="inst_name_span"></span> <!-- this will be filled with the IdP name -->
192
                    <button class="signin">
193
                        <?php echo _("select another"); ?>
194
                    </button>
195
                </div>
196
                <div> <!-- IdP logo, if present -->
197
                    <img id="idp_logo" src="<?php echo $Gui->skinObject->findResourceUrl("IMAGES", "empty.png"); ?>" alt="IdP Logo"/>
198
                </div>
199
                <div id="profiles"> <!-- this is the profile selection filled during run time -->
200
                    <div id="profiles_h" class="sub_h">
201
                        <?php echo _("Select the user group"); ?>
202
                    </div>
203
                    <table>
204
                        <tr>
205
                            <td><select id="profile_list"></select></td>
206
                            <td><div id="profile_desc" class="profile_desc"></div></td>
207
                        </tr>
208
                    </table>
209
                </div>
210
                <div id="user_info"></div> <!-- this will be filled with the profile contact information -->
211
                <div id="user_welcome" style="display:none"> <!-- this information is shown just pefore the download -->
212
                    <strong><?php echo _("Welcome aboard the eduroam® user community!") ?></strong>
213
                    <p>
214
                        <span id="download_info"><?php
215
/// the empty href is dynamically exchanged with the actual path by jQuery at runtime
216
                            echo _("Your download will start shortly. In case of problems with the automatic download please use this direct <a href=''>link</a>.");
217
                            ?></span>
218
                    <p>
219
                        <?php printf(_("Dear user from %s,"), "<span class='inst_name'></span>") ?>
220
                        <br/>
221
                        <br/>
222
                        <?php echo _("we would like to warmly welcome you among the several million users of eduroam®! From now on, you will be able to use internet access resources on thousands of universities, research centres and other places all over the globe. All of this completely free of charge!") ?>
223
                    </p>
224
                    <p>
225
                        <?php echo _("Now that you have downloaded and installed a client configurator, all you need to do is find an eduroam® hotspot in your vicinity and enter your user credentials (this is our fancy name for 'username and password' or 'personal certificate') - and be online!") ?>
226
                    <p>
227
                        <?php printf(_("Should you have any problems using this service, please always contact the helpdesk of %s. They will diagnose the problem and help you out. You can reach them via the means shown above."), "<span class='inst_name'></span>") ?>
228
                    </p>
229
                    <p>
230
                        <a href="javascript:back_to_downloads()"><strong><?php echo _("Back to downloads") ?></strong></a>
231
                    </p>
232
                </div> <!-- id="user_welcomer_page" -->
233
                <div id="silverbullet">
234
                    <?php echo _("You can download your eduroam installer via a personalised invitation link sent from your IT support. Please talk to the IT department to get this link."); ?>
235
                </div>
236
                <div id="profile_redirect"> <!-- this is shown when the entire profile is redirected -->
237
                    <?php echo _("Your local administrator has specified a redirect to a local support page.<br>
238
                            When you click <b>Continue</b> this support page will be opened in a new window/tab."); ?>
239
                    <br>
240
                    <span class="redirect_link">
241
                        <a id="profile_redirect_bt" href="" target="_blank"><?php echo _("Continue"); ?>
242
                        </a>
243
                    </span>
244
                </div> <!-- id="profile_redirect" -->
245
                <div id="devices" class="device_list">
246
                    <?php if ($operatingSystem) { ?>  <!-- this part is shown when we have guessed the OS -->
247
248
                        <div class="sub_h" id="guess_os"> 
249
                            <table id='browser'>
250
                                <tr>
251
                                    <td>
252
                                        <button style='height:70px; width:450px; padding-bottom:0px;
253
                                                position:relative; 
254
                                                background-image:url("<?php echo $Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/" . $operatingSystem['group'] . ".png"); ?>");
255
                                                background-repeat:no-repeat;
256
                                                background-position: 10px 10px;' id='g_<?php echo $operatingSystem['device'] ?>'>
257
                                            <img id='cross_icon_<?php echo $operatingSystem['device'] ?>' src='<?php echo $Gui->skinObject->findResourceUrl("IMAGES", "icons/delete_32.png"); ?>' 
258
                                                 style='position:absolute; left:16px; top:25px; opacity:0.9; display:none; '>
259
                                            <div class='download_button_text' 
260
                                                 style='font-size:12px; top:5px; height: 30px'
261
                                                 id='download_button_header_<?php echo $operatingSystem['device'] ?>'>
262
                                                     <?php print $downloadMessage ?>
263
                                            </div>
264
                                            <div class='download_button_text' style='font-size:20px; bottom: 5px; '>
265
                                                <?php echo $operatingSystem['display'] ?>
266
                                            </div>
267
                                        </button>
268
                                        <div class='device_info' id='info_g_<?php echo $operatingSystem['device'] ?>'></div>
269
                                    </td>
270
                                    <td style='vertical-align:top'>
271
                                        <button class='more_info_b' 
272
                                                style='height:70px; width:70px; 
273
                                                position:relative;
274
                                                background-image:url("<?php echo $Gui->skinObject->findResourceUrl("IMAGES", "icons/info_b.png"); ?>");
275
                                                background-repeat:no-repeat;
276
                                                background-position: 2px 7px;' 
277
                                                id='g_info_b_<?php echo $operatingSystem['device'] ?>'>
278
                                        </button>
279
                                    </td>
280
                                </tr>
281
                            </table> <!-- id='browser' -->
282
                            <div class="sub_h">
283
                                <a href="javascript:other_installers()"><?php echo _("All platforms"); ?></a>
284
                            </div>
285
                        </div> <!-- id="guess_os" -->
286
                    <?php } ?>
287
                    <div class="sub_h">
288
                        <div id="other_installers">
289
                            <?php echo _("Choose an installer to download"); ?>
290
                            <table id="device_list" style="padding:0px;">
291
                                <?php
292
                                $Gui->langObject->setTextDomain("devices");
293
                                foreach ($Gui->listDevices(isset($_REQUEST['hidden']) ? $_REQUEST['hidden'] : 0) as $group => $deviceGroup) {
294
                                    $groupIndex = count($deviceGroup);
295
                                    $deviceIndex = 0;
296
                                    print '<tbody><tr><td class="vendor" rowspan="' . $groupIndex . '"><img src="' . $Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/$group.png") . '" alt="' . $group . ' Device"></td>';
297
                                    foreach ($deviceGroup as $d => $D) {
298
                                        if ($deviceIndex) {
299
                                            print '<tr>';
300
                                        }
301
                                        $j = ($deviceIndex + 1) * 20;
302
                                        print "<td><button id='" . $d . "'>" . $D['display'] . "</button>";
303
                                        print "<div class='device_info' id='info_" . $d . "'></div></td>";
304
                                        print "<td><button class='more_info_b' id='info_b_" . $d . "'></button></td></tr>\n";
305
                                        $deviceIndex++;
306
                                    }
307
                                    print "</tbody>";
308
                                }
309
                                $Gui->langObject->setTextDomain("web_user");
310
                                ?>
311
                            </table>
312
                        </div>
313
                    </div>
314
                </div> <!-- id="devices" -->
315
                <input type="hidden" name="profile" id="profile_id"/>
316
                <input type="hidden" name="idp" id="inst_id"/>
317
                <input type="hidden" name="inst_name" id="inst_name"/>
318
                <input type="hidden" name="lang" id="lang"/>
319
            </div> <!-- id="user_page" -->
320
        </div> <!-- id="main_body" -->
321
    </form>
322
    <div class='footer' id='footer'>
323
        <table style='width:100%'>
324
            <tr>
325
                <td style="padding-left:20px; text-align:left">
326
                    <?php
327
                    echo $Gui->CAT_COPYRIGHT;
328
                    ?>
329
                </td>
330
                <td style="padding-left:80px; text-align:right;">
331
                    <?php
332
                    echo $deco->attributionEurope();
333
                    ?>
334
                </td>
335
            </tr>
336
        </table>
337
    </div>
338
</body>
339
</html>
340