Divs::divMainButton()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 14
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/*
3
 * *****************************************************************************
4
 * Contributions to this work were made on behalf of the GÉANT project, a 
5
 * project that has received funding from the European Union’s Framework 
6
 * Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus),
7
 * Horizon 2020 research and innovation programme under Grant Agreements No. 
8
 * 691567 (GN4-1) and No. 731122 (GN4-2).
9
 * On behalf of the aforementioned projects, GEANT Association is the sole owner
10
 * of the copyright in all material which was developed by a member of the GÉANT
11
 * project. GÉANT Vereniging (Association) is registered with the Chamber of 
12
 * Commerce in Amsterdam with registration number 40535155 and operates in the 
13
 * UK as a branch of GÉANT Vereniging.
14
 * 
15
 * Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. 
16
 * UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK
17
 *
18
 * License: see the web/copyright.inc.php file in the file structure or
19
 *          <base_url>/copyright.php after deploying the software
20
 */
21
namespace web\skins\msp;
22
23
use web\lib\user;
24
25
/**
26
 * This class delivers various <div> elements for the front page.
27
 * 
28
 * @author Tomasz Wolniewicz <[email protected]>
29
 */
30
class Divs {
31
32
    /**
33
     * The Gui object we are working with.
34
     * 
35
     * @var user\Gui
36
     */
37
    private $Gui;
38
39
    public function __construct(user\Gui $Gui) {
40
        $this->Gui = $Gui;
41
    }
42
43
    public function divHeading($visibility = 'all') {
44
        $selectedLang = $this->Gui->languageInstance->getLang();
0 ignored issues
show
Unused Code introduced by
The assignment to $selectedLang is dead and can be removed.
Loading history...
45
        $retval = "<div id='heading'>";
46
        $location = $this->Gui->skinObject->findResourceUrl("IMAGES", "consortium_logo.png");
47
        if ($location !== FALSE) {
48
            $retval .= "<div id='cat_logo'>
49
            <a href='".\config\ConfAssistant::CONSORTIUM['homepage']."'><img id='logo_img' src='$location' alt='Consortium Logo'/></a>
50
            <span>Managed SP Service</span>
51
            </div>";
52
        }
53
        $retval .= "<div id='motd'>".(isset(\config\Master::APPEARANCE['MOTD']) ? \config\Master::APPEARANCE['MOTD'] : '&nbsp')."</div>";
54
        if ($visibility !== 'index') {
55
            $retval .= "<div id='menu_top'>";
56
            if ($visibility === 'start') {
57
                $retval .= $menu->printMinimalMenu();
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $menu seems to be never defined.
Loading history...
58
            } else {
59
                $retval .= $menu->printMenu();
60
            }
61
            $retval .= "</div>\n";
62
        }
63
        $retval .= "</div>\n";
64
        return $retval;
65
    }
66
67
    public function divSilverbullet() {
68
        $retval = "
69
<div id='silverbullet'>"
70
    . $this->Gui->textTemplates->templates[user\SB_GO_AWAY] . 
71
    "</div>
72
    ";
73
        return $retval;
74
    }
75
76
    public function divTopWelcome() {
77
        return "
78
<div id='welcome_top1'>
79
    Welcome to the eduroam Managed SP service.<p>
80
    If you are an administrator for an institution serviced here or and NRO admin please use the login button below.
81
</div>
82
";
83
    }
84
85
    public function divRoller() {
86
        $retval = "
87
<div id='roller'>
88
    <div id='slides'></div></div>
89
        ";  
90
        return $retval;
91
    }
92
93
    public function divMainButton() {
94
        $retval = "
95
<div id='user_button_td'>
96
  <span id='signin'>
97
     <button class='large_button signin_large' id='user_button1' onclick='goAdmin(); return(false);'>
98
        <span id='user_button'>";
99
                
100
        $retval .= "Administrator login
101
        </span>
102
     </button>
103
  </span>
104
  <span style='padding-left:50px'>&nbsp;</span>
105
</div>";
106
        return $retval;
107
    }
108
109
    public function divProfiles() {
110
        return "
111
<div id='profiles'> <!-- this is the profile selection filled during run time -->
112
    <div id='profiles_h' class='sub_h'>" . $this->Gui->textTemplates->templates[user\PROFILE_SELECTION] . "
113
    </div>" .
114
"<select id='profile_list'></select><div id='profile_desc' class='profile_desc'></div>" .
115
                "</div>";
116
    }
117
118
    public function divPagetitle($mainText, $extraText = '') {
119
        return "
120
<div id='institution_name'>
121
    <span id='inst_name_span'>$mainText</span> <div id='inst_extra_text'>$extraText</div> 
122
</div>";
123
    }
124
    
125
126
    public function divInstitution($selectButton = TRUE) {
127
        $retval = "<div id='institution_name'>
128
    <span id='inst_name_span'></span> <div id='inst_extra_text'></div><!-- this will be filled with the IdP name -->" .
129
                ($selectButton ? "<a  id='select_another' class='signin' href=\"\">" . $this->Gui->textTemplates->templates[user\INSTITUTION_SELECTION] . "</a>" : "") .
130
                "</div>";
131
        $retval .= $this->emptyImage('idp_logo', 'IdP Logo');
132
        return $retval;
133
    }
134
    
135
    public function divFederation() {
136
        $retval = $this->emptyImage('fed_logo', 'Federation Logo');
137
        return $retval;
138
    }
139
140
    public function divOtherinstallers() {
141
        $retval = "
142
<div class='sub_h'>
143
    <div id='other_installers'>".$this->Gui->textTemplates->templates[user\DOWNLOAD_CHOOSE] . "
144
         <table id='device_list' style='padding:0px;'>";
145
146
        foreach ($this->Gui->listDevices(isset($_REQUEST['hidden']) ? $_REQUEST['hidden'] : 0) as $group => $deviceGroup) {
147
            $groupIndex = count($deviceGroup);
148
            $deviceIndex = 0;
149
150
            $imgTag = "";
151
            $imgLocation = $this->Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/" . $group . ".png");
152
            if ($imgLocation !== FALSE) {
153
                $imgTag = '<img src="' . $imgLocation . '" alt="' . $group . ' Device" title="' . $group . ' Device">';
154
            }
155
            $retval .= '<tbody><tr><td class="vendor" rowspan="' . $groupIndex . '">' . $imgTag . '</td>';
156
            foreach ($deviceGroup as $d => $D) {
157
                if ($deviceIndex) {
158
                    $retval .= '<tr>';
159
                }
160
                $retval .= "<td><button id='" . $d . "'>" . $D['display'] . "</button>"
161
                        . "<div class='device_info' id='info_" . $d . "'></div></td>"
162
                        . "<td><button class='more_info_b' id='info_b_" . $d . "'>i</button></td></tr>\n";
163
                $deviceIndex++;
164
            }
165
            $retval .= "</tbody>";
166
        }
167
        $retval .= "    
168
        </table>
169
    </div>
170
</div>";
171
        return $retval;
172
    }
173
174
    public function divGuessOs($operatingSystem) {
175
        $vendorlogo = $this->Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/" . $operatingSystem['group'] . ".png");
176
        $vendorstyle = "";
177
        if ($vendorlogo !== FALSE) {
178
            $vendorstyle = "style='background-image:url(\"" . $vendorlogo . "\")'";
179
        }
180
        $deleteIcon = $this->Gui->skinObject->findResourceUrl("IMAGES", "icons/delete_32.png");
181
        $deleteImg = "";
182
        if ($deleteIcon !== FALSE) {
183
            $deleteImg = "<img id='cross_icon_" . $operatingSystem['device'] . "' src='$deleteIcon' >";
184
        }
185
        return "
186
<div class='sub_h' id='guess_os'>
187
    <!-- table browser -->
188
    <table id='browser'>
189
        <tr>
190
            <td>
191
                <button class='large_button guess_os' $vendorstyle id='g_" . $operatingSystem['device'] . "'>
192
                    $deleteImg
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 divFooter() {
213
        $retval = "
214
<div class='footer' id='footer'>
215
    <table>
216
        <tr>
217
            <td>" .
218
                $this->Gui->catCopyright
219
                . "
220
            </td>";
221
            
222
        if (!empty(\config\Master::APPEARANCE['privacy_notice_url'])) {
223
            $retval .= "<td><a href='".\config\Master::APPEARANCE['privacy_notice_url']."'>".sprintf(_("%s Privacy Notice"), \config\ConfAssistant::CONSORTIUM['display_name'])."</a></td>";
224
        }
225
        $retval .= "<td>";
226
        if (\config\ConfAssistant::CONSORTIUM['name'] == "eduroam" && isset(\config\ConfAssistant::CONSORTIUM['deployment-voodoo']) && \config\ConfAssistant::CONSORTIUM['deployment-voodoo'] == "Operations Team") {
227
            $geant = $this->Gui->skinObject->findResourceUrl("IMAGES", "dante.png");
228
            $eu = $this->Gui->skinObject->findResourceUrl("IMAGES", "eu.png");
229
            if ($geant !== FALSE && $eu !== FALSE) {
230
                $retval .= "<span id='logos'><img src='$geant' alt='GEANT' style='height:23px;width:47px'/>
231
              <img src='$eu' alt='EU' style='height:23px;width:27px;border-width:0px;'/></span>";
232
            }
233
            $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>";
234
        } else {
235
            $retval .= "&nbsp;";
236
        }
237
238
        $retval .= "
239
            </td>
240
        </tr>
241
    </table>
242
</div>";
243
        return $retval;
244
    }
245
246
    private function emptyImage($id, $alt) {
247
        $empty = $this->Gui->skinObject->findResourceUrl("IMAGES", "empty.png");
248
        $retval = '';
249
        if ($empty !== FALSE) {
250
            $retval = "<div>
251
    <img id='$id' src='$empty' alt='$alt'/>
252
 </div>";
253
        }
254
        return $retval;
255
    }
256
257
}
258