Passed
Push — master ( e491a2...15ec75 )
by Tomasz
03:40
created

Divs::div_institution()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 10
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_top_welcome() {
83
        return "
84
<div id='welcome_top1'>
85
    " . $this->Gui->textTemplates->templates[user\HEADING_TOPLEVEL_GREET] . "
86
</div>
87
<div id='top_invite' class='signin'>
88
    " . $this->Gui->textTemplates->templates[user\HEADING_TOPLEVEL_PURPOSE] . "
89
</div>";
90
    }
91
92
    public function div_roller() {
93
        $retval = "
94
<div id='roller'>
95
    <div id='slides'>
96
        <span id='line1'>" . $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_EASY] . "</span>
97
        <span id='line2'></span>
98
        <span id='line3'></span>
99
        <span id='line4'>" . $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_CUSTOMBUILT] . "</span>
100
        <span id='line5'>";
101
        if (!empty(CONFIG_CONFASSISTANT['CONSORTIUM']['signer_name'])) {
102
            $retval .= $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_CUSTOMBUILT];
103
        }
104
        $retval .= "
105
        </span>
106
    </div>
107
    <div id = 'img_roll'>
108
        <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'/>
109
    </div>
110
</div>";
111
        return $retval;
112
    }
113
114
    public function div_main_button() {
115
        return "
116
<div id='user_button_td'>
117
  <span id='signin'>
118
     <button class='large_button signin signin_large' id='user_button1'>
119
        <span id='user_button'>" . $this->Gui->textTemplates->templates[user\FRONTPAGE_BIGDOWNLOADBUTTON] . "
120
        </span>
121
     </button>
122
  </span>
123
  <span style='padding-left:50px'>&nbsp;</span>
124
</div>";
125
    }
126
127
    public function div_profiles() {
128
        return "
129
<div id='profiles'> <!-- this is the profile selection filled during run time -->
130
    <div id='profiles_h' class='sub_h'>" . $this->Gui->textTemplates->templates[user\PROFILE_SELECTION] . "
131
    </div>
132
    <table>
133
        <tr>
134
            <td><select id='profile_list'></select></td>
135
            <td><div id='profile_desc' class='profile_desc'></div></td>
136
        </tr>
137
    </table>
138
</div>";
139
    }
140
141
    public function div_institution($selectButton = TRUE) {
142
        return "
143
<div id='institution_name'>
144
    <span id='inst_name_span'></span> <div id='inst_extra_text'></div><!-- this will be filled with the IdP name -->" . 
145
($selectButton ? "<a  id='select_another' class='signin' href=\"\">" . $this->Gui->textTemplates->templates[user\INSTITUTION_SELECTION] . "</a>" : "") .
146
"</div>
147
<div> <!-- IdP logo, if present -->
148
    <img id='idp_logo' src='" . $this->Gui->skinObject->findResourceUrl("IMAGES", "empty.png") . "' alt='IdP Logo'/>
149
</div>";
150
    }
151
152
    public function div_otherinstallers() {
153
        $retval = "
154
<div class='sub_h'>
155
    <div id='other_installers'>" . $this->Gui->textTemplates->templates[user\DOWNLOAD_CHOOSE] . "
156
         <table id='device_list' style='padding:0px;'>";
157
158
        $this->Gui->langObject->setTextDomain("devices");
159
        foreach ($this->Gui->listDevices(isset($_REQUEST['hidden']) ? $_REQUEST['hidden'] : 0) as $group => $deviceGroup) {
160
            $groupIndex = count($deviceGroup);
161
            $deviceIndex = 0;
162
            $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>';
163
            foreach ($deviceGroup as $d => $D) {
164
                if ($deviceIndex) {
165
                    $retval .= '<tr>';
166
                }
167
                $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...
168
                $retval .= "<td><button id='" . $d . "'>" . $D['display'] . "</button>"
169
                        . "<div class='device_info' id='info_" . $d . "'></div></td>"
170
                        . "<td><button class='more_info_b' id='info_b_" . $d . "'>i</button></td></tr>\n";
171
                $deviceIndex++;
172
            }
173
            $retval .= "</tbody>";
174
        }
175
        $this->Gui->langObject->setTextDomain("web_user");
176
        $retval .= "    
177
        </table>
178
    </div>
179
</div>";
180
        return $retval;
181
    }
182
183
    public function div_guess_os($operatingSystem) {
184
        return "
185
<div class='sub_h' id='guess_os'>
186
    <!-- table browser -->
187
    <table id='browser'>
188
        <tr>
189
            <td>
190
                <button class='large_button guess_os' style='background-image:url(\"" . $this->Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/" . $operatingSystem['group'] . ".png") . "\"'
191
                                                    id='g_" . $operatingSystem['device'] . "'>
192
                    <img id='cross_icon_" . $operatingSystem['device'] . "' src='" . $this->Gui->skinObject->findResourceUrl("IMAGES", "icons/delete_32.png") . "' >
193
                    <div class='download_button_text_1' id='download_button_header_" . $operatingSystem['device'] . "'> " . $this->Gui->textTemplates->templates[user\DOWNLOAD_MESSAGE] . "
194
                    </div>
195
                    <div class='download_button_text'>" .
196
                $operatingSystem['display'] . "
197
                    </div>
198
                </button>
199
                <div class='device_info' id='info_g_" . $operatingSystem['device'] . "'></div>
200
          </td>
201
          <td style='vertical-align:top'>
202
               <button class='more_info_b large_button' id='g_info_b_" . $operatingSystem['device'] . "'>i</button>
203
          </td>
204
      </tr>
205
    </table> <!-- id='browser' -->
206
    <div class='sub_h'>
207
       <a href='javascript:other_installers()'>" . $this->Gui->textTemplates->templates[user\DOWNLOAD_CHOOSE] . "</a>
208
    </div>
209
</div> <!-- id='guess_os' -->";
210
    }
211
212
    public function div_footer() {
213
        $retval = "
214
<div class='footer' id='footer'>
215
    <table>
216
        <tr>
217
            <td>" .
218
                $this->Gui->CAT_COPYRIGHT
219
                . "
220
            </td>
221
            <td>";
222
        if (CONFIG_CONFASSISTANT['CONSORTIUM']['name'] == "eduroam" && isset(CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo']) && CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo'] == "Operations Team") {
223
            $retval .= "<span id='logos'><img src='" . $this->Gui->skinObject->findResourceUrl("IMAGES", "dante.png") . "' alt='DANTE' style='height:23px;width:47px'/>
224
              <img src='" . $this->Gui->skinObject->findResourceUrl("IMAGES", "eu.png") . "' alt='EU' style='height:23px;width:27px;border-width:0px;'/></span>
225
              <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>";
226
        } else {
227
            $retval .= "&nbsp;";
228
        }
229
230
        $retval .= "
231
            </td>
232
        </tr>
233
    </table>
234
</div>";
235
        return $retval;
236
    }
237
238
}
239