Passed
Push — master ( 938f46...25d030 )
by Tomasz
03:36
created

Divs::div_pagetitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
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
                _("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.") .
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'>" . $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_CUSTOMBUILT] . "</span>
114
        <span id='line5'>";
115
        if (!empty(CONFIG_CONFASSISTANT['CONSORTIUM']['signer_name'])) {
116
            $retval .= $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_SIGNEDBY];
117
        }
118
        $retval .= "
119
        </span>
120
    </div>";
121
        $rollLocation = $this->Gui->skinObject->findResourceUrl("IMAGES", "empty.png");
122
        if ($rollLocation !== FALSE) {
123
            $retval .= "<div id = 'img_roll'>
124
                <img id='img_roll_0' src='$rollLocation' alt='Rollover 0'/> <img id='img_roll_1' src='$rollLocation' alt='Rollover 1'/>
125
            </div>";
126
        }
127
        $retval .= "</div>";
128
        return $retval;
129
    }
130
131
    public function div_main_button() {
132
        return "
133
<div id='user_button_td'>
134
  <span id='signin'>
135
     <button class='large_button signin signin_large' id='user_button1'>
136
        <span id='user_button'>" . $this->Gui->textTemplates->templates[user\FRONTPAGE_BIGDOWNLOADBUTTON] . "
137
        </span>
138
     </button>
139
  </span>
140
  <span style='padding-left:50px'>&nbsp;</span>
141
</div>";
142
    }
143
144
    public function div_profiles() {
145
        return "
146
<div id='profiles'> <!-- this is the profile selection filled during run time -->
147
    <div id='profiles_h' class='sub_h'>" . $this->Gui->textTemplates->templates[user\PROFILE_SELECTION] . "
148
    </div>
149
    <table>
150
        <tr>
151
            <td><select id='profile_list'></select></td>
152
            <td><div id='profile_desc' class='profile_desc'></div></td>
153
        </tr>
154
    </table>
155
</div>";
156
    }
157
158
    public function div_pagetitle($mainText, $extraText = '') {
159
        return "
160
<div id='institution_name'>
161
    <span id='inst_name_span'>$mainText</span> <div id='inst_extra_text'>$extraText</div> 
162
</div>";
163
    }
164
    
165
166
    public function div_institution($selectButton = TRUE) {
167
        $retval = "<div id='institution_name'>
168
    <span id='inst_name_span'></span> <div id='inst_extra_text'></div><!-- this will be filled with the IdP name -->" .
169
                ($selectButton ? "<a  id='select_another' class='signin' href=\"\">" . $this->Gui->textTemplates->templates[user\INSTITUTION_SELECTION] . "</a>" : "") .
170
                "</div>";
171
        $retval .= $this->emptyImage('idp_logo', 'IdP Logo');
172
        return $retval;
173
    }
174
    
175
    public function div_federation() {
176
        $retval = $this->emptyImage('fed_logo', 'Federation Logo');
177
        return $retval;
178
    }
179
180
    public function div_otherinstallers() {
181
        $retval = "
182
<div class='sub_h'>
183
    <div id='other_installers'>" . $this->Gui->textTemplates->templates[user\DOWNLOAD_CHOOSE] . "
184
         <table id='device_list' style='padding:0px;'>";
185
186
        $this->Gui->langObject->setTextDomain("devices");
187
        foreach ($this->Gui->listDevices(isset($_REQUEST['hidden']) ? $_REQUEST['hidden'] : 0) as $group => $deviceGroup) {
188
            $groupIndex = count($deviceGroup);
189
            $deviceIndex = 0;
190
191
            $imgTag = "";
192
            $imgLocation = $this->Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/" . $group . ".png");
193
            if ($imgLocation !== FALSE) {
194
                $imgTag = '<img src="' . $imgLocation . '" alt="' . $group . ' Device" title="' . $group . ' Device">';
195
            }
196
            $retval .= '<tbody><tr><td class="vendor" rowspan="' . $groupIndex . '">' . $imgTag . '</td>';
197
            foreach ($deviceGroup as $d => $D) {
198
                if ($deviceIndex) {
199
                    $retval .= '<tr>';
200
                }
201
                $retval .= "<td><button id='" . $d . "'>" . $D['display'] . "</button>"
202
                        . "<div class='device_info' id='info_" . $d . "'></div></td>"
203
                        . "<td><button class='more_info_b' id='info_b_" . $d . "'>i</button></td></tr>\n";
204
                $deviceIndex++;
205
            }
206
            $retval .= "</tbody>";
207
        }
208
        $this->Gui->langObject->setTextDomain("web_user");
209
        $retval .= "    
210
        </table>
211
    </div>
212
</div>";
213
        return $retval;
214
    }
215
216
    public function div_guess_os($operatingSystem) {
217
        $vendorlogo = $this->Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/" . $operatingSystem['group'] . ".png");
218
        $vendorstyle = "";
219
        if ($vendorlogo !== FALSE) {
220
            $vendorstyle = "style='background-image:url(\"" . $vendorlogo . "\")'";
221
        }
222
        $deleteIcon = $this->Gui->skinObject->findResourceUrl("IMAGES", "icons/delete_32.png");
223
        $deleteImg = "";
224
        if ($deleteIcon !== FALSE) {
225
            $deleteImg = "<img id='cross_icon_" . $operatingSystem['device'] . "' src='$deleteIcon' >";
226
        }
227
        return "
228
<div class='sub_h' id='guess_os'>
229
    <!-- table browser -->
230
    <table id='browser'>
231
        <tr>
232
            <td>
233
                <button class='large_button guess_os' $vendorstyle id='g_" . $operatingSystem['device'] . "'>
234
                    $deleteImg
235
                    <div class='download_button_text_1' id='download_button_header_" . $operatingSystem['device'] . "'> " . $this->Gui->textTemplates->templates[user\DOWNLOAD_MESSAGE] . "
236
                    </div>
237
                    <div class='download_button_text'>" .
238
                $operatingSystem['display'] . "
239
                    </div>
240
                </button>
241
                <div class='device_info' id='info_g_" . $operatingSystem['device'] . "'></div>
242
          </td>
243
          <td style='vertical-align:top'>
244
               <button class='more_info_b large_button' id='g_info_b_" . $operatingSystem['device'] . "'>i</button>
245
          </td>
246
      </tr>
247
    </table> <!-- id='browser' -->
248
    <div class='sub_h'>
249
       <a href='javascript:other_installers()'>" . $this->Gui->textTemplates->templates[user\DOWNLOAD_CHOOSE] . "</a>
250
    </div>
251
</div> <!-- id='guess_os' -->";
252
    }
253
254
    public function div_footer() {
255
        $retval = "
256
<div class='footer' id='footer'>
257
    <table>
258
        <tr>
259
            <td>" .
260
                $this->Gui->CAT_COPYRIGHT
261
                . "
262
            </td>
263
            <td>";
264
        if (CONFIG_CONFASSISTANT['CONSORTIUM']['name'] == "eduroam" && isset(CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo']) && CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo'] == "Operations Team") {
265
            $geant = $this->Gui->skinObject->findResourceUrl("IMAGES", "dante.png");
266
            $eu = $this->Gui->skinObject->findResourceUrl("IMAGES", "eu.png");
267
            if ($geant !== FALSE && $eu !== FALSE) {
268
                $retval .= "<span id='logos'><img src='$geant' alt='GEANT' style='height:23px;width:47px'/>
269
              <img src='$eu' alt='EU' style='height:23px;width:27px;border-width:0px;'/></span>";
270
            }
271
            $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>";
272
        } else {
273
            $retval .= "&nbsp;";
274
        }
275
276
        $retval .= "
277
            </td>
278
        </tr>
279
    </table>
280
</div>";
281
        return $retval;
282
    }
283
284
    private function emptyImage($id, $alt) {
285
        $empty = $this->Gui->skinObject->findResourceUrl("IMAGES", "empty.png");
286
        $retval = '';
287
        if ($empty !== FALSE) {
288
            $retval = "<div>
289
    <img id='$id' src='$empty' alt='$alt'/>
290
 </div>";
291
        }
292
        return $retval;
293
    }
294
295
}
296