Passed
Branch master (f8ffed)
by Tomasz
11:38 queued 05:23
created

Divs::div_roller()   B

Complexity

Conditions 5
Paths 12

Size

Total Lines 31
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 31
rs 8.439
cc 5
eloc 16
nc 12
nop 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
14
require("Menu.php");
15
16
/**
17
 * This class delivers various <div> elements for the front page.
18
 * 
19
 * @author Tomasz Wolniewicz <[email protected]>
20
 */
21
class Divs {
22
23
    /**
24
     * The Gui object we are working with.
25
     * 
26
     * @var user\Gui
27
     */
28
    private $Gui;
29
30
    public function __construct(user\Gui $Gui) {
31
        $this->Gui = $Gui;
32
    }
33
34
    public function div_heading($visibility = 'all') {
35
        $selectedLang = $this->Gui->langObject->getLang();
36
        $menu = new Menu($visibility, $selectedLang);
37
        $retval = "<div id='heading'>";
38
        $location = $this->Gui->skinObject->findResourceUrl("IMAGES", "consortium_logo.png");
39
        if ($location !== FALSE) {
40
            $retval .= "<div id='cat_logo'>
41
            <img id='logo_img' src='$location' alt='Consortium Logo'/>
42
            <span>Configuration Assistant Tool</span>
43
            </div>";
44
        }
45
        $retval .= "<div id='motd'>" . (isset(CONFIG['APPEARANCE']['MOTD']) ? CONFIG['APPEARANCE']['MOTD'] : '&nbsp') . "</div>";
46
        $loc2 = $this->Gui->skinObject->findResourceUrl("IMAGES", "icons/menu.png");
47
        if ($loc2 !== FALSE) {
48
            $retval .= "<img id='hamburger' src='$loc2' alt='Menu'/>";
49
        }
50
        $retval .= "<div id='menu_top'>";
51
        $retval .= $menu->printMenu();
52
53
        $retval .= "</div></div>\n";
54
        return $retval;
55
    }
56
57
    public function div_user_welcome() {
58
        $retval = "
59
<div id='user_welcome'> <!-- this information is shown just before the download -->
60
    <strong>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_PAGEHEADING] . "</strong>
61
    <p>
62
    <span id='download_info'>
63
    <!-- the empty href is dynamically exchanged with the actual path by jQuery at runtime -->
64
        " . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_DOWNLOAD] . "
65
    </span>
66
    <p>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_HEADING] . "
67
    <br/>
68
    <br/>";
69
        switch (CONFIG_CONFASSISTANT['CONSORTIUM']['name']) {
70
            case "eduroam": $retval .= $this->Gui->textTemplates->templates[user\EDUROAM_WELCOME_ADVERTISING];
71
                break;
72
            default:
73
        }
74
        $retval .= "
75
    </p>
76
    <p>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_USAGE] . "
77
    <p>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_PROBLEMS] . "
78
    </p>
79
    <p>
80
    <a href='javascript:back_to_downloads()'><strong>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_BACKTODOWNLOADS] . "</strong></a>
81
    </p>
82
</div> <!-- id='user_welcomer_page' -->
83
";
84
        return $retval;
85
    }
86
87
    public function div_silverbullet() {
88
        $retval = "
89
<div id='silverbullet'>"
90
    . $this->Gui->textTemplates->templates[user\SB_GO_AWAY] . 
91
    "</div>
92
    ";
93
        return $retval;
94
    }
95
96
    public function div_top_welcome() {
97
        return "
98
<div id='welcome_top1'>
99
    " . $this->Gui->textTemplates->templates[user\HEADING_TOPLEVEL_GREET] . "
100
</div>
101
<div id='top_invite' class='signin'>
102
    " . $this->Gui->textTemplates->templates[user\HEADING_TOPLEVEL_PURPOSE] . "
103
</div>";
104
    }
105
106
    public function div_roller() {
107
        $retval = "
108
<div id='roller'>
109
    <div id='slides'>
110
        <span id='line1'>" . $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_EASY] . "</span>
111
        <span id='line2'></span>
112
        <span id='line3'></span>
113
        <span id='line4'>";
114
        
115
        if (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_RADIUS'] == "LOCAL") {
116
            $retval .= $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_CUSTOMBUILT];
117
        } elseif (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == "LOCAL") {
118
            $retval .= $this->Gui->textTemplates->templates[user\SB_FRONTPAGE_ROLLER_CUSTOMBUILT];
119
        }
120
                
121
        $retval .= "</span>
122
        <span id='line5'>";
123
        if (!empty(CONFIG_CONFASSISTANT['CONSORTIUM']['signer_name'])) {
124
            $retval .= $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_SIGNEDBY];
125
        }
126
        $retval .= "
127
        </span>
128
    </div>";
129
        $rollLocation = $this->Gui->skinObject->findResourceUrl("IMAGES", "empty.png");
130
        if ($rollLocation !== FALSE) {
131
            $retval .= "<div id = 'img_roll'>
132
                <img id='img_roll_0' src='$rollLocation' alt='Rollover 0'/> <img id='img_roll_1' src='$rollLocation' alt='Rollover 1'/>
133
            </div>";
134
        }
135
        $retval .= "</div>";
136
        return $retval;
137
    }
138
139
    public function div_main_button() {
140
        $retval = "
141
<div id='user_button_td'>
142
  <span id='signin'>
143
     <button class='large_button signin signin_large' id='user_button1'>
144
        <span id='user_button'>";
145
        if (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_RADIUS'] == "LOCAL") {
146
            $retval .= $this->Gui->textTemplates->templates[user\FRONTPAGE_BIGDOWNLOADBUTTON];
147
        } elseif (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == "LOCAL") {
148
            $retval .= $this->Gui->textTemplates->templates[user\SB_FRONTPAGE_BIGDOWNLOADBUTTON];
149
        }
150
        
151
        $retval .= "
152
        </span>
153
     </button>
154
  </span>
155
  <span style='padding-left:50px'>&nbsp;</span>
156
</div>";
157
        return $retval;
158
    }
159
160
    public function div_profiles() {
161
        return "
162
<div id='profiles'> <!-- this is the profile selection filled during run time -->
163
    <div id='profiles_h' class='sub_h'>" . $this->Gui->textTemplates->templates[user\PROFILE_SELECTION] . "
164
    </div>
165
    <table>
166
        <tr>
167
            <td><select id='profile_list'></select></td>
168
            <td><div id='profile_desc' class='profile_desc'></div></td>
169
        </tr>
170
    </table>
171
</div>";
172
    }
173
174
    public function div_pagetitle($mainText, $extraText = '') {
175
        return "
176
<div id='institution_name'>
177
    <span id='inst_name_span'>$mainText</span> <div id='inst_extra_text'>$extraText</div> 
178
</div>";
179
    }
180
    
181
182
    public function div_institution($selectButton = TRUE) {
183
        $retval = "<div id='institution_name'>
184
    <span id='inst_name_span'></span> <div id='inst_extra_text'></div><!-- this will be filled with the IdP name -->" .
185
                ($selectButton ? "<a  id='select_another' class='signin' href=\"\">" . $this->Gui->textTemplates->templates[user\INSTITUTION_SELECTION] . "</a>" : "") .
186
                "</div>";
187
        $retval .= $this->emptyImage('idp_logo', 'IdP Logo');
188
        return $retval;
189
    }
190
    
191
    public function div_federation() {
192
        $retval = $this->emptyImage('fed_logo', 'Federation Logo');
193
        return $retval;
194
    }
195
196
    public function div_otherinstallers() {
197
        $retval = "
198
<div class='sub_h'>
199
    <div id='other_installers'>" . $this->Gui->textTemplates->templates[user\DOWNLOAD_CHOOSE] . "
200
         <table id='device_list' style='padding:0px;'>";
201
202
        $this->Gui->langObject->setTextDomain("devices");
203
        foreach ($this->Gui->listDevices(isset($_REQUEST['hidden']) ? $_REQUEST['hidden'] : 0) as $group => $deviceGroup) {
204
            $groupIndex = count($deviceGroup);
205
            $deviceIndex = 0;
206
207
            $imgTag = "";
208
            $imgLocation = $this->Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/" . $group . ".png");
209
            if ($imgLocation !== FALSE) {
210
                $imgTag = '<img src="' . $imgLocation . '" alt="' . $group . ' Device" title="' . $group . ' Device">';
211
            }
212
            $retval .= '<tbody><tr><td class="vendor" rowspan="' . $groupIndex . '">' . $imgTag . '</td>';
213
            foreach ($deviceGroup as $d => $D) {
214
                if ($deviceIndex) {
215
                    $retval .= '<tr>';
216
                }
217
                $retval .= "<td><button id='" . $d . "'>" . $D['display'] . "</button>"
218
                        . "<div class='device_info' id='info_" . $d . "'></div></td>"
219
                        . "<td><button class='more_info_b' id='info_b_" . $d . "'>i</button></td></tr>\n";
220
                $deviceIndex++;
221
            }
222
            $retval .= "</tbody>";
223
        }
224
        $this->Gui->langObject->setTextDomain("web_user");
225
        $retval .= "    
226
        </table>
227
    </div>
228
</div>";
229
        return $retval;
230
    }
231
232
    public function div_guess_os($operatingSystem) {
233
        $vendorlogo = $this->Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/" . $operatingSystem['group'] . ".png");
234
        $vendorstyle = "";
235
        if ($vendorlogo !== FALSE) {
236
            $vendorstyle = "style='background-image:url(\"" . $vendorlogo . "\")'";
237
        }
238
        $deleteIcon = $this->Gui->skinObject->findResourceUrl("IMAGES", "icons/delete_32.png");
239
        $deleteImg = "";
240
        if ($deleteIcon !== FALSE) {
241
            $deleteImg = "<img id='cross_icon_" . $operatingSystem['device'] . "' src='$deleteIcon' >";
242
        }
243
        return "
244
<div class='sub_h' id='guess_os'>
245
    <!-- table browser -->
246
    <table id='browser'>
247
        <tr>
248
            <td>
249
                <button class='large_button guess_os' $vendorstyle id='g_" . $operatingSystem['device'] . "'>
250
                    $deleteImg
251
                    <div class='download_button_text_1' id='download_button_header_" . $operatingSystem['device'] . "'> " . $this->Gui->textTemplates->templates[user\DOWNLOAD_MESSAGE] . "
252
                    </div>
253
                    <div class='download_button_text'>" .
254
                $operatingSystem['display'] . "
255
                    </div>
256
                </button>
257
                <div class='device_info' id='info_g_" . $operatingSystem['device'] . "'></div>
258
          </td>
259
          <td style='vertical-align:top'>
260
               <button class='more_info_b large_button' id='g_info_b_" . $operatingSystem['device'] . "'>i</button>
261
          </td>
262
      </tr>
263
    </table> <!-- id='browser' -->
264
    <div class='sub_h'>
265
       <a href='javascript:other_installers()'>" . $this->Gui->textTemplates->templates[user\DOWNLOAD_CHOOSE] . "</a>
266
    </div>
267
</div> <!-- id='guess_os' -->";
268
    }
269
270
    public function div_footer() {
271
        $retval = "
272
<div class='footer' id='footer'>
273
    <table>
274
        <tr>
275
            <td>" .
276
                $this->Gui->CAT_COPYRIGHT
277
                . "
278
            </td>
279
            <td>";
280
        if (CONFIG_CONFASSISTANT['CONSORTIUM']['name'] == "eduroam" && isset(CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo']) && CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo'] == "Operations Team") {
281
            $geant = $this->Gui->skinObject->findResourceUrl("IMAGES", "dante.png");
282
            $eu = $this->Gui->skinObject->findResourceUrl("IMAGES", "eu.png");
283
            if ($geant !== FALSE && $eu !== FALSE) {
284
                $retval .= "<span id='logos'><img src='$geant' alt='GEANT' style='height:23px;width:47px'/>
285
              <img src='$eu' alt='EU' style='height:23px;width:27px;border-width:0px;'/></span>";
286
            }
287
            $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>";
288
        } else {
289
            $retval .= "&nbsp;";
290
        }
291
292
        $retval .= "
293
            </td>
294
        </tr>
295
    </table>
296
</div>";
297
        return $retval;
298
    }
299
300
    private function emptyImage($id, $alt) {
301
        $empty = $this->Gui->skinObject->findResourceUrl("IMAGES", "empty.png");
302
        $retval = '';
303
        if ($empty !== FALSE) {
304
            $retval = "<div>
305
    <img id='$id' src='$empty' alt='$alt'/>
306
 </div>";
307
        }
308
        return $retval;
309
    }
310
311
}
312