Passed
Push — master ( da2c08...a384aa )
by Tomasz
07:04 queued 03:10
created

Divs::div_silverbullet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * ******************************************************************************
5
 * Copyright 2011-2017 DANTE Ltd. and GÉANT on behalf of the GN3, GN3+, GN4-1 
6
 * and GN4-2 consortia
7
 *
8
 * License: see the web/copyright.php file in the file structure
9
 * ******************************************************************************
10
 */
11
12
use web\lib\user;
13
require("Menu.php");
14
15
/**
16
 * This class delivers various <div> elements for the front page.
17
 * 
18
 * @author Tomasz Wolniewicz <[email protected]>
19
 */
20
class Divs {
21
22
    /**
23
     * The Gui object we are working with.
24
     * 
25
     * @var user\Gui
26
     */
27
    private $Gui;
28
29
    public function __construct(user\Gui $Gui) {
30
        $this->Gui = $Gui;
31
    }
32
33
    public function div_heading($visibility = 'all') {
34
        $selectedLang = $this->Gui->langObject->getLang();
35
        $menu = new Menu($visibility, $selectedLang);
0 ignored issues
show
Unused Code introduced by
The call to Menu::__construct() has too many arguments starting with $selectedLang.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
36
        $retval = "
37
    <div id='heading'>
38
        <div id='cat_logo'>
39
            <img id='logo_img' src='" . $this->Gui->skinObject->findResourceUrl("IMAGES", "consortium_logo.png") . "' alt='Consortium Logo'/>
40
            <span>Configuration Assistant Tool</span>
41
        </div>
42
        <div id='motd'>" . (isset(CONFIG['APPEARANCE']['MOTD']) ? CONFIG['APPEARANCE']['MOTD'] : '&nbsp') . "</div>
43
        <img id='hamburger' src='" . $this->Gui->skinObject->findResourceUrl("IMAGES", "icons/menu.png") . "' alt='Menu'/>
44
        <div id='menu_top'>
45
";
46
        $retval .= $menu->printMenu();
47
48
        $retval .= "</div></div>\n";
49
        return $retval;
50
    }
51
52
    public function div_user_welcome() {
53
        $retval = "
54
<div id='user_welcome'> <!-- this information is shown just before the download -->
55
    <strong>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_PAGEHEADING] . "</strong>
56
    <p>
57
    <span id='download_info'>
58
    <!-- the empty href is dynamically exchanged with the actual path by jQuery at runtime -->
59
        " . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_DOWNLOAD] . "
60
    </span>
61
    <p>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_HEADING] . "
62
    <br/>
63
    <br/>";
64
        switch (CONFIG_CONFASSISTANT['CONSORTIUM']['name']) {
65
            case "eduroam": $retval .= $this->Gui->textTemplates->templates[user\EDUROAM_WELCOME_ADVERTISING];
66
                break;
67
            default:
68
        }
69
        $retval .= "
70
    </p>
71
    <p>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_USAGE] . "
72
    <p>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_PROBLEMS] . "
73
    </p>
74
    <p>
75
    <a href='javascript:back_to_downloads()'><strong>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_BACKTODOWNLOADS] . "</strong></a>
76
    </p>
77
</div> <!-- id='user_welcomer_page' -->
78
";
79
        return $retval;
80
    }
81
    
82
    public function div_silverbullet() {
83
        $retval = "
84
<div id='silverbullet'>" .
85
_("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.") .
86
"</div>
87
    ";
88
        return $retval;
89
    }
90
91
    public function div_top_welcome() {
92
        return "
93
<div id='welcome_top1'>
94
    " . $this->Gui->textTemplates->templates[user\HEADING_TOPLEVEL_GREET] . "
95
</div>
96
<div id='top_invite' class='signin'>
97
    " . $this->Gui->textTemplates->templates[user\HEADING_TOPLEVEL_PURPOSE] . "
98
</div>";
99
    }
100
101
    public function div_roller() {
102
        $retval = "
103
<div id='roller'>
104
    <div id='slides'>
105
        <span id='line1'>" . $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_EASY] . "</span>
106
        <span id='line2'></span>
107
        <span id='line3'></span>
108
        <span id='line4'>" . $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_CUSTOMBUILT] . "</span>
109
        <span id='line5'>";
110
        if (!empty(CONFIG_CONFASSISTANT['CONSORTIUM']['signer_name'])) {
111
            $retval .= $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_CUSTOMBUILT];
112
        }
113
        $retval .= "
114
        </span>
115
    </div>
116
    <div id = 'img_roll'>
117
        <img id='img_roll_0' src='" . $this->Gui->skinObject->findResourceUrl("IMAGES", "empty.png") . "' alt='Rollover 0'/> <img id='img_roll_1' src='" . $this->Gui->skinObject->findResourceUrl("IMAGES", "empty.png") . "' alt='Rollover 1'/>
118
    </div>
119
</div>";
120
        return $retval;
121
    }
122
123
    public function div_main_button() {
124
        return "
125
<div id='user_button_td'>
126
  <span id='signin'>
127
     <button class='large_button signin signin_large' id='user_button1'>
128
        <span id='user_button'>" . $this->Gui->textTemplates->templates[user\FRONTPAGE_BIGDOWNLOADBUTTON] . "
129
        </span>
130
     </button>
131
  </span>
132
  <span style='padding-left:50px'>&nbsp;</span>
133
</div>";
134
    }
135
136
    public function div_profiles() {
137
        return "
138
<div id='profiles'> <!-- this is the profile selection filled during run time -->
139
    <div id='profiles_h' class='sub_h'>" . $this->Gui->textTemplates->templates[user\PROFILE_SELECTION] . "
140
    </div>
141
    <table>
142
        <tr>
143
            <td><select id='profile_list'></select></td>
144
            <td><div id='profile_desc' class='profile_desc'></div></td>
145
        </tr>
146
    </table>
147
</div>";
148
    }
149
150
    public function div_pagetitle($mainText, $extraText = '') {
151
        return "
152
<div id='institution_name'>
153
    <span id='inst_name_span'>$mainText</span> <div id='inst_extra_text'>$extraText</div> 
154
</div>";
155
    }
156
    
157
    public function div_institution($selectButton = TRUE) {
158
        return "
159
<div id='institution_name'>
160
    <span id='inst_name_span'></span> <div id='inst_extra_text'></div><!-- this will be filled with the IdP name -->" . 
161
($selectButton ? "<a  id='select_another' class='signin' href=\"\">" . $this->Gui->textTemplates->templates[user\INSTITUTION_SELECTION] . "</a>" : "") .
162
"</div>
163
<div> <!-- IdP logo, if present -->
164
    <img id='idp_logo' src='" . $this->Gui->skinObject->findResourceUrl("IMAGES", "empty.png") . "' alt='IdP Logo'/>
165
</div>";
166
    }
167
168
    public function div_otherinstallers() {
169
        $retval = "
170
<div class='sub_h'>
171
    <div id='other_installers'>" . $this->Gui->textTemplates->templates[user\DOWNLOAD_CHOOSE] . "
172
         <table id='device_list' style='padding:0px;'>";
173
174
        $this->Gui->langObject->setTextDomain("devices");
175
        foreach ($this->Gui->listDevices(isset($_REQUEST['hidden']) ? $_REQUEST['hidden'] : 0) as $group => $deviceGroup) {
176
            $groupIndex = count($deviceGroup);
177
            $deviceIndex = 0;
178
            $retval .= '<tbody><tr><td class="vendor" rowspan="' . $groupIndex . '"><img src="' . $this->Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/" . $group . ".png") . '" alt="' . $group . ' Device" title="' . $group . ' Device"></td>';
179
            foreach ($deviceGroup as $d => $D) {
180
                if ($deviceIndex) {
181
                    $retval .= '<tr>';
182
                }
183
                $j = ($deviceIndex + 1) * 20;
0 ignored issues
show
Unused Code introduced by
$j is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
184
                $retval .= "<td><button id='" . $d . "'>" . $D['display'] . "</button>"
185
                        . "<div class='device_info' id='info_" . $d . "'></div></td>"
186
                        . "<td><button class='more_info_b' id='info_b_" . $d . "'>i</button></td></tr>\n";
187
                $deviceIndex++;
188
            }
189
            $retval .= "</tbody>";
190
        }
191
        $this->Gui->langObject->setTextDomain("web_user");
192
        $retval .= "    
193
        </table>
194
    </div>
195
</div>";
196
        return $retval;
197
    }
198
199
    public function div_guess_os($operatingSystem) {
200
        return "
201
<div class='sub_h' id='guess_os'>
202
    <!-- table browser -->
203
    <table id='browser'>
204
        <tr>
205
            <td>
206
                <button class='large_button guess_os' style='background-image:url(\"" . $this->Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/" . $operatingSystem['group'] . ".png") . "\"'
207
                                                    id='g_" . $operatingSystem['device'] . "'>
208
                    <img id='cross_icon_" . $operatingSystem['device'] . "' src='" . $this->Gui->skinObject->findResourceUrl("IMAGES", "icons/delete_32.png") . "' >
209
                    <div class='download_button_text_1' id='download_button_header_" . $operatingSystem['device'] . "'> " . $this->Gui->textTemplates->templates[user\DOWNLOAD_MESSAGE] . "
210
                    </div>
211
                    <div class='download_button_text'>" .
212
                $operatingSystem['display'] . "
213
                    </div>
214
                </button>
215
                <div class='device_info' id='info_g_" . $operatingSystem['device'] . "'></div>
216
          </td>
217
          <td style='vertical-align:top'>
218
               <button class='more_info_b large_button' id='g_info_b_" . $operatingSystem['device'] . "'>i</button>
219
          </td>
220
      </tr>
221
    </table> <!-- id='browser' -->
222
    <div class='sub_h'>
223
       <a href='javascript:other_installers()'>" . $this->Gui->textTemplates->templates[user\DOWNLOAD_CHOOSE] . "</a>
224
    </div>
225
</div> <!-- id='guess_os' -->";
226
    }
227
228
    public function div_footer() {
229
        $retval = "
230
<div class='footer' id='footer'>
231
    <table>
232
        <tr>
233
            <td>" .
234
                $this->Gui->CAT_COPYRIGHT
235
                . "
236
            </td>
237
            <td>";
238
        if (CONFIG_CONFASSISTANT['CONSORTIUM']['name'] == "eduroam" && isset(CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo']) && CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo'] == "Operations Team") {
239
            $retval .= "<span id='logos'><img src='" . $this->Gui->skinObject->findResourceUrl("IMAGES", "dante.png") . "' alt='DANTE' style='height:23px;width:47px'/>
240
              <img src='" . $this->Gui->skinObject->findResourceUrl("IMAGES", "eu.png") . "' alt='EU' style='height:23px;width:27px;border-width:0px;'/></span>
241
              <span id='eu_text' style='text-align:right; padding-left: 60px; display: block; '><a href='http://ec.europa.eu/dgs/connect/index_en.htm' style='text-decoration:none; vertical-align:top; text-align:right'>European Commission Communications Networks, Content and Technology</a></span>";
242
        } else {
243
            $retval .= "&nbsp;";
244
        }
245
246
        $retval .= "
247
            </td>
248
        </tr>
249
    </table>
250
</div>";
251
        return $retval;
252
    }
253
254
}
255