Passed
Push — master ( 287ee3...1adfd2 )
by Stefan
13:39 queued 07:14
created

Divs::emptyImage()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
/*
4
 * *****************************************************************************
5
 * Contributions to this work were made on behalf of the GÉANT project, a 
6
 * project that has received funding from the European Union’s Framework 
7
 * Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus),
8
 * Horizon 2020 research and innovation programme under Grant Agreements No. 
9
 * 691567 (GN4-1) and No. 731122 (GN4-2).
10
 * On behalf of the aforementioned projects, GEANT Association is the sole owner
11
 * of the copyright in all material which was developed by a member of the GÉANT
12
 * project. GÉANT Vereniging (Association) is registered with the Chamber of 
13
 * Commerce in Amsterdam with registration number 40535155 and operates in the 
14
 * UK as a branch of GÉANT Vereniging.
15
 * 
16
 * Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. 
17
 * UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK
18
 *
19
 * License: see the web/copyright.inc.php file in the file structure or
20
 *          <base_url>/copyright.php after deploying the software
21
 */
22
23
namespace web\skins\modern;
24
use web\lib\user;
25
26
require_once "Menu.php";
27
28
/**
29
 * This class delivers various <div> elements for the front page.
30
 * 
31
 * @author Tomasz Wolniewicz <[email protected]>
32
 */
33
class Divs {
34
35
    /**
36
     * The Gui object we are working with.
37
     * 
38
     * @var user\Gui
39
     */
40
    private $Gui;
41
42
    public function __construct(user\Gui $Gui) {
43
        $this->Gui = $Gui;
44
    }
45
46
    public function divHeading($visibility = 'all') {
47
        $selectedLang = $this->Gui->langObject->getLang();
48
        $menu = new Menu($visibility, $selectedLang);
49
        $retval = "<div id='heading'>";
50
        $location = $this->Gui->skinObject->findResourceUrl("IMAGES", "consortium_logo.png");
51
        if ($location !== FALSE) {
52
            $retval .= "<div id='cat_logo'>
53
            <a href='" . CONFIG_CONFASSISTANT['CONSORTIUM']['homepage'] . "'><img id='logo_img' src='$location' alt='Consortium Logo'/></a>
54
            <span>Configuration Assistant Tool</span>
55
            </div>";
56
        }
57
        $retval .= "<div id='motd'>" . (isset(CONFIG['APPEARANCE']['MOTD']) ? CONFIG['APPEARANCE']['MOTD'] : '&nbsp') . "</div>";
58
        $loc2 = $this->Gui->skinObject->findResourceUrl("IMAGES", "icons/menu.png");
59
        if ($loc2 !== FALSE) {
60
            $retval .= "<img id='hamburger' src='$loc2' alt='Menu'/>";
61
        }
62
        $retval .= "<div id='menu_top'>";
63
        if ($visibility === 'start') {
64
            $retval .= $menu->printMinimalMenu();
65
        } else {
66
            $retval .= $menu->printMenu();
67
        }
68
        $retval .= "</div></div>\n";
69
        return $retval;
70
    }
71
72
    public function divUserWelcome() {
73
        $retval = "
74
<div id='user_welcome'> <!-- this information is shown just before the download -->
75
    <strong>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_PAGEHEADING] . "</strong>
76
    <p>
77
    <span id='download_info'>
78
    <!-- the empty href is dynamically exchanged with the actual path by jQuery at runtime -->
79
        " . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_DOWNLOAD] . "
80
    </span>
81
    <p>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_HEADING] . "
82
    <br/>
83
    <br/>";
84
        switch (CONFIG_CONFASSISTANT['CONSORTIUM']['name']) {
85
            case "eduroam": $retval .= $this->Gui->textTemplates->templates[user\EDUROAM_WELCOME_ADVERTISING];
86
                break;
87
            default:
88
        }
89
        $retval .= "
90
    </p>
91
    <p>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_USAGE] . "
92
    <p>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_PROBLEMS] . "
93
    </p>
94
    <p>
95
    <a href='javascript:back_to_downloads()'><strong>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_BACKTODOWNLOADS] . "</strong></a>
96
    </p>
97
</div> <!-- id='user_welcomer_page' -->
98
";
99
        return $retval;
100
    }
101
102
    public function divSilverbullet() {
103
        $retval = "
104
<div id='silverbullet'>"
105
                . $this->Gui->textTemplates->templates[user\SB_GO_AWAY] .
106
                "</div>
107
    ";
108
        return $retval;
109
    }
110
111
    public function divTopWelcome() {
112
        $retval = '';
113
        if (CONFIG_CONFASSISTANT['CONSORTIUM']['name'] == "eduroam" && isset(CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo']) && CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo'] == "Operations Team") { // SW: APPROVED
114
            $retval = "<br><div id='top_invite_ad'>".$this->Gui->textTemplates->templates[user\FRONTPAGE_EDUROAM_AD]."</div>";
115
        }
116
        return "
117
<div id='welcome_top1'>
118
    " . $this->Gui->textTemplates->templates[user\HEADING_TOPLEVEL_GREET] . "
119
</div>
120
<div id='top_invite'>
121
    " . $this->Gui->textTemplates->templates[user\HEADING_TOPLEVEL_PURPOSE] . $retval . "
122
</div>";
123
    }
124
125
    public function divRoller() {
126
        $retval = "
127
<div id='roller'>
128
    <div id='slides'>
129
        <span id='line1'>" . $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_EASY] . "</span>
130
        <span id='line2'></span>
131
        <span id='line3'></span>
132
        <span id='line4'>";
133
134
        if (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_RADIUS'] == "LOCAL") {
135
            $retval .= $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_CUSTOMBUILT];
136
        } elseif (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == "LOCAL") {
137
            $retval .= $this->Gui->textTemplates->templates[user\SB_FRONTPAGE_ROLLER_CUSTOMBUILT];
138
        }
139
140
        $retval .= "</span>
141
        <span id='line5'>";
142
        if (!empty(CONFIG_CONFASSISTANT['CONSORTIUM']['signer_name'])) {
143
            $retval .= $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_SIGNEDBY];
144
        }
145
        $retval .= "
146
        </span>
147
    </div>";
148
        $rollLocation = $this->Gui->skinObject->findResourceUrl("IMAGES", "empty.png");
149
        if ($rollLocation !== FALSE) {
150
            $retval .= "<div id = 'img_roll'>
151
                <img id='img_roll_0' src='$rollLocation' alt='Rollover 0'/> <img id='img_roll_1' src='$rollLocation' alt='Rollover 1'/>
152
            </div>";
153
        }
154
        $retval .= "</div>";
155
        return $retval;
156
    }
157
158
    public function divMainButton() {
159
        $retval = "<div id='user_button_td'>";
160
        $retval .= "<span id='signin'>
161
     <button class='large_button signin signin_large' id='user_button1'>
162
        <span id='user_button'>";
163
        if (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_RADIUS'] == "LOCAL") {
164
            $retval .= $this->Gui->textTemplates->templates[user\FRONTPAGE_BIGDOWNLOADBUTTON];
165
        } elseif (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == "LOCAL") {
166
            $retval .= $this->Gui->textTemplates->templates[user\SB_FRONTPAGE_BIGDOWNLOADBUTTON];
167
        }
168
169
        $retval .= "
170
        </span>
171
     </button>
172
  </span>
173
  <span style='padding-left:50px'>&nbsp;</span>
174
</div>";
175
        return $retval;
176
    }
177
178
    public function divProfiles() {
179
        return "
180
<div id='profiles'> <!-- this is the profile selection filled during run time -->
181
    <div id='profiles_h' class='sub_h'>" . $this->Gui->textTemplates->templates[user\PROFILE_SELECTION] . "
182
    </div>" .
183
                "<select id='profile_list'></select><div id='profile_desc' class='profile_desc'></div>" .
184
                "</div>";
185
    }
186
187
    public function divPagetitle($mainText, $extraText = '') {
188
        return "
189
<div id='institution_name'>
190
    <span id='inst_name_span'>$mainText</span> <div id='inst_extra_text'>$extraText</div> 
191
</div>";
192
    }
193
194
    public function divInstitution($selectButton = TRUE) {
195
        $retval = "<div id='institution_name'>
196
    <span id='inst_name_span'></span> <div id='inst_extra_text'></div><!-- this will be filled with the IdP name -->" .
197
                ($selectButton ? "<a  id='select_another' class='signin' href=\"\">" . $this->Gui->textTemplates->templates[user\INSTITUTION_SELECTION] . "</a>" : "") .
198
                "</div>";
199
        $retval .= $this->emptyImage('idp_logo', 'IdP Logo');
200
        return $retval;
201
    }
202
203
    public function divFederation() {
204
        $retval = $this->emptyImage('fed_logo', 'Federation Logo');
205
        return $retval;
206
    }
207
208
    public function divOtherinstallers() {
209
        $retval = "
210
<div class='sub_h'>
211
    <div id='other_installers'>" . $this->Gui->textTemplates->templates[user\DOWNLOAD_CHOOSE] . "
212
         <table id='device_list' style='padding:0px;'>";
213
214
        foreach ($this->Gui->listDevices(isset($_REQUEST['hidden']) ? $_REQUEST['hidden'] : 0) as $group => $deviceGroup) {
215
            $groupIndex = count($deviceGroup);
216
            $deviceIndex = 0;
217
218
            $imgTag = "";
219
            $imgLocation = $this->Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/" . $group . ".png");
220
            if ($imgLocation !== FALSE) {
221
                $imgTag = '<img src="' . $imgLocation . '" alt="' . $group . ' Device" title="' . $group . ' Device">';
222
            }
223
            $retval .= '<tbody><tr><td class="vendor" rowspan="' . $groupIndex . '">' . $imgTag . '</td>';
224
            foreach ($deviceGroup as $d => $D) {
225
                if ($deviceIndex) {
226
                    $retval .= '<tr>';
227
                }
228
                $retval .= "<td><button id='" . $d . "'>" . $D['display'] . "</button>"
229
                        . "<div class='device_info' id='info_" . $d . "'></div></td>"
230
                        . "<td><button class='more_info_b' id='info_b_" . $d . "'>i</button></td></tr>\n";
231
                $deviceIndex++;
232
            }
233
            $retval .= "</tbody>";
234
        }
235
236
        $retval .= "    
237
        </table>
238
    </div>
239
</div>";
240
        return $retval;
241
    }
242
243
    public function divGuessOs($operatingSystem) {
244
        $vendorlogo = $this->Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/" . $operatingSystem['group'] . ".png");
245
        $vendorstyle = "";
246
        if ($vendorlogo !== FALSE) {
247
            $vendorstyle = "style='background-image:url(\"" . $vendorlogo . "\")'";
248
        }
249
        $deleteIcon = $this->Gui->skinObject->findResourceUrl("IMAGES", "icons/delete_32.png");
250
        $deleteImg = "";
251
        if ($deleteIcon !== FALSE) {
252
            $deleteImg = "<img id='cross_icon_" . $operatingSystem['device'] . "' src='$deleteIcon' >";
253
        }
254
        return "
255
<div class='sub_h' id='guess_os'>
256
    <!-- table browser -->
257
    <table id='browser'>
258
        <tr>
259
            <td>
260
                <button class='large_button guess_os' $vendorstyle id='g_" . $operatingSystem['device'] . "'>
261
                    $deleteImg
262
                    <div class='download_button_text_1' id='download_button_header_" . $operatingSystem['device'] . "'> " . $this->Gui->textTemplates->templates[user\DOWNLOAD_MESSAGE] . "
263
                    </div>
264
                    <div class='download_button_text'>" .
265
                $operatingSystem['display'] . "
266
                    </div>
267
                </button>
268
                <div class='device_info' id='info_g_" . $operatingSystem['device'] . "'></div>
269
          </td>
270
          <td style='vertical-align:top'>
271
               <button class='more_info_b large_button' id='g_info_b_" . $operatingSystem['device'] . "'>i</button>
272
          </td>
273
      </tr>
274
    </table> <!-- id='browser' -->
275
    <div class='sub_h'>
276
       <a href='javascript:other_installers()'>" . $this->Gui->textTemplates->templates[user\DOWNLOAD_CHOOSE] . "</a>
277
    </div>
278
</div> <!-- id='guess_os' -->";
279
    }
280
281
    public function divFooter() {
282
        $retval = "
283
<div class='footer' id='footer'>
284
    <table>
285
        <tr>
286
            <td>" .
287
                $this->Gui->CAT_COPYRIGHT
288
                . "
289
            </td>";
290
291
        if (!empty(CONFIG['APPEARANCE']['privacy_notice_url'])) {
292
            $retval .= "<td><a href='" . CONFIG['APPEARANCE']['privacy_notice_url'] . "'>" . sprintf(_("%s Privacy Notice"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']) . "</a></td>";
293
        }
294
        $retval .= "<td>";
295
        if (CONFIG_CONFASSISTANT['CONSORTIUM']['name'] == "eduroam" && isset(CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo']) && CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo'] == "Operations Team") {
296
            $geant = $this->Gui->skinObject->findResourceUrl("IMAGES", "dante.png");
297
            $eu = $this->Gui->skinObject->findResourceUrl("IMAGES", "eu.png");
298
            if ($geant !== FALSE && $eu !== FALSE) {
299
                $retval .= "<span id='logos'><img src='$geant' alt='GEANT' style='height:23px;width:47px'/>
300
              <img src='$eu' alt='EU' style='height:23px;width:27px;border-width:0px;'/></span>";
301
            }
302
            $retval .= "<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>";
303
        } else {
304
            $retval .= "&nbsp;";
305
        }
306
307
        $retval .= "
308
            </td>
309
        </tr>
310
    </table>
311
</div>";
312
        return $retval;
313
    }
314
315
    private function emptyImage($id, $alt) {
316
        $empty = $this->Gui->skinObject->findResourceUrl("IMAGES", "empty.png");
317
        $retval = '';
318
        if ($empty !== FALSE) {
319
            $retval = "<div>
320
    <img id='$id' src='$empty' alt='$alt'/>
321
 </div>";
322
        }
323
        return $retval;
324
    }
325
326
}
327