| Total Complexity | 44 |
| Total Lines | 291 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
Complex classes like Divs often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Divs, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 32 | class Divs { |
||
| 33 | |||
| 34 | /** |
||
| 35 | * The Gui object we are working with. |
||
| 36 | * |
||
| 37 | * @var user\Gui |
||
| 38 | */ |
||
| 39 | private $Gui; |
||
| 40 | |||
| 41 | public function __construct(user\Gui $Gui) { |
||
| 43 | } |
||
| 44 | |||
| 45 | public function divHeading($visibility = 'all') { |
||
| 46 | $selectedLang = $this->Gui->langObject->getLang(); |
||
| 47 | $menu = new Menu($visibility, $selectedLang); |
||
| 48 | $retval = "<div id='heading'>"; |
||
| 49 | $location = $this->Gui->skinObject->findResourceUrl("IMAGES", "consortium_logo.png"); |
||
| 50 | if ($location !== FALSE) { |
||
| 51 | $retval .= "<div id='cat_logo'> |
||
| 52 | <a href='" . CONFIG_CONFASSISTANT['CONSORTIUM']['homepage'] . "'><img id='logo_img' src='$location' alt='Consortium Logo'/></a> |
||
| 53 | <span>Configuration Assistant Tool</span> |
||
| 54 | </div>"; |
||
| 55 | } |
||
| 56 | $retval .= "<div id='motd'>" . (isset(CONFIG['APPEARANCE']['MOTD']) ? CONFIG['APPEARANCE']['MOTD'] : ' ') . "</div>"; |
||
| 57 | $loc2 = $this->Gui->skinObject->findResourceUrl("IMAGES", "icons/menu.png"); |
||
| 58 | if ($loc2 !== FALSE) { |
||
| 59 | $retval .= "<img id='hamburger' src='$loc2' alt='Menu'/>"; |
||
| 60 | } |
||
| 61 | $retval .= "<div id='menu_top'>"; |
||
| 62 | if ($visibility === 'start') { |
||
| 63 | $retval .= $menu->printMinimalMenu(); |
||
| 64 | } else { |
||
| 65 | $retval .= $menu->printMenu(); |
||
| 66 | } |
||
| 67 | $retval .= "</div></div>\n"; |
||
| 68 | return $retval; |
||
| 69 | } |
||
| 70 | |||
| 71 | public function divUserWelcome() { |
||
| 72 | $retval = " |
||
| 73 | <div id='user_welcome'> <!-- this information is shown just before the download --> |
||
| 74 | <strong>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_PAGEHEADING] . "</strong> |
||
| 75 | <p> |
||
| 76 | <span id='download_info'> |
||
| 77 | <!-- the empty href is dynamically exchanged with the actual path by jQuery at runtime --> |
||
| 78 | " . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_DOWNLOAD] . " |
||
| 79 | </span> |
||
| 80 | <p>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_HEADING] . " |
||
| 81 | <br/> |
||
| 82 | <br/>"; |
||
| 83 | switch (CONFIG_CONFASSISTANT['CONSORTIUM']['name']) { |
||
| 84 | case "eduroam": $retval .= $this->Gui->textTemplates->templates[user\EDUROAM_WELCOME_ADVERTISING]; |
||
| 85 | break; |
||
| 86 | default: |
||
| 87 | } |
||
| 88 | $retval .= " |
||
| 89 | </p> |
||
| 90 | <p>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_USAGE] . " |
||
| 91 | <p>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_PROBLEMS] . " |
||
| 92 | </p> |
||
| 93 | <p> |
||
| 94 | <a href='javascript:back_to_downloads()'><strong>" . $this->Gui->textTemplates->templates[user\WELCOME_ABOARD_BACKTODOWNLOADS] . "</strong></a> |
||
| 95 | </p> |
||
| 96 | </div> <!-- id='user_welcomer_page' --> |
||
| 97 | "; |
||
| 98 | return $retval; |
||
| 99 | } |
||
| 100 | |||
| 101 | public function divSilverbullet() { |
||
| 102 | $retval = " |
||
| 103 | <div id='silverbullet'>" |
||
| 104 | . $this->Gui->textTemplates->templates[user\SB_GO_AWAY] . |
||
| 105 | "</div> |
||
| 106 | "; |
||
| 107 | return $retval; |
||
| 108 | } |
||
| 109 | |||
| 110 | public function divTopWelcome() { |
||
| 111 | $retval = ''; |
||
| 112 | if (CONFIG_CONFASSISTANT['CONSORTIUM']['name'] == "eduroam" && isset(CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo']) && CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo'] == "Operations Team") { // SW: APPROVED |
||
| 113 | $retval = "<br><div id='top_invite_ad'>".$this->Gui->textTemplates->templates[user\FRONTPAGE_EDUROAM_AD]."</div>"; |
||
| 114 | } |
||
| 115 | return " |
||
| 116 | <div id='welcome_top1'> |
||
| 117 | " . $this->Gui->textTemplates->templates[user\HEADING_TOPLEVEL_GREET] . " |
||
| 118 | </div> |
||
| 119 | <div id='top_invite'> |
||
| 120 | " . $this->Gui->textTemplates->templates[user\HEADING_TOPLEVEL_PURPOSE] . $retval . " |
||
| 121 | </div>"; |
||
| 122 | } |
||
| 123 | |||
| 124 | public function divRoller() { |
||
| 125 | $retval = " |
||
| 126 | <div id='roller'> |
||
| 127 | <div id='slides'> |
||
| 128 | <span id='line1'>" . $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_EASY] . "</span> |
||
| 129 | <span id='line2'></span> |
||
| 130 | <span id='line3'></span> |
||
| 131 | <span id='line4'>"; |
||
| 132 | |||
| 133 | if (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_RADIUS'] == "LOCAL") { |
||
| 134 | $retval .= $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_CUSTOMBUILT]; |
||
| 135 | } elseif (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == "LOCAL") { |
||
| 136 | $retval .= $this->Gui->textTemplates->templates[user\SB_FRONTPAGE_ROLLER_CUSTOMBUILT]; |
||
| 137 | } |
||
| 138 | |||
| 139 | $retval .= "</span> |
||
| 140 | <span id='line5'>"; |
||
| 141 | if (!empty(CONFIG_CONFASSISTANT['CONSORTIUM']['signer_name'])) { |
||
| 142 | $retval .= $this->Gui->textTemplates->templates[user\FRONTPAGE_ROLLER_SIGNEDBY]; |
||
| 143 | } |
||
| 144 | $retval .= " |
||
| 145 | </span> |
||
| 146 | </div>"; |
||
| 147 | $rollLocation = $this->Gui->skinObject->findResourceUrl("IMAGES", "empty.png"); |
||
| 148 | if ($rollLocation !== FALSE) { |
||
| 149 | $retval .= "<div id = 'img_roll'> |
||
| 150 | <img id='img_roll_0' src='$rollLocation' alt='Rollover 0'/> <img id='img_roll_1' src='$rollLocation' alt='Rollover 1'/> |
||
| 151 | </div>"; |
||
| 152 | } |
||
| 153 | $retval .= "</div>"; |
||
| 154 | return $retval; |
||
| 155 | } |
||
| 156 | |||
| 157 | public function divMainButton() { |
||
| 158 | $retval = "<div id='user_button_td'>"; |
||
| 159 | $retval .= "<span id='signin'> |
||
| 160 | <button class='large_button signin signin_large' id='user_button1'> |
||
| 161 | <span id='user_button'>"; |
||
| 162 | if (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_RADIUS'] == "LOCAL") { |
||
| 163 | $retval .= $this->Gui->textTemplates->templates[user\FRONTPAGE_BIGDOWNLOADBUTTON]; |
||
| 164 | } elseif (CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == "LOCAL") { |
||
| 165 | $retval .= $this->Gui->textTemplates->templates[user\SB_FRONTPAGE_BIGDOWNLOADBUTTON]; |
||
| 166 | } |
||
| 167 | |||
| 168 | $retval .= " |
||
| 169 | </span> |
||
| 170 | </button> |
||
| 171 | </span> |
||
| 172 | <span style='padding-left:50px'> </span> |
||
| 173 | </div>"; |
||
| 174 | return $retval; |
||
| 175 | } |
||
| 176 | |||
| 177 | public function divProfiles() { |
||
| 178 | return " |
||
| 179 | <div id='profiles'> <!-- this is the profile selection filled during run time --> |
||
| 180 | <div id='profiles_h' class='sub_h'>" . $this->Gui->textTemplates->templates[user\PROFILE_SELECTION] . " |
||
| 181 | </div>" . |
||
| 182 | "<select id='profile_list'></select><div id='profile_desc' class='profile_desc'></div>" . |
||
| 183 | "</div>"; |
||
| 184 | } |
||
| 185 | |||
| 186 | public function divPagetitle($mainText, $extraText = '') { |
||
| 187 | return " |
||
| 188 | <div id='institution_name'> |
||
| 189 | <span id='inst_name_span'>$mainText</span> <div id='inst_extra_text'>$extraText</div> |
||
| 190 | </div>"; |
||
| 191 | } |
||
| 192 | |||
| 193 | public function divInstitution($selectButton = TRUE) { |
||
| 194 | $retval = "<div id='institution_name'> |
||
| 195 | <span id='inst_name_span'></span> <div id='inst_extra_text'></div><!-- this will be filled with the IdP name -->" . |
||
| 196 | ($selectButton ? "<a id='select_another' class='signin' href=\"\">" . $this->Gui->textTemplates->templates[user\INSTITUTION_SELECTION] . "</a>" : "") . |
||
| 197 | "</div>"; |
||
| 198 | $retval .= $this->emptyImage('idp_logo', 'IdP Logo'); |
||
| 199 | return $retval; |
||
| 200 | } |
||
| 201 | |||
| 202 | public function divFederation() { |
||
| 203 | $retval = $this->emptyImage('fed_logo', 'Federation Logo'); |
||
| 204 | return $retval; |
||
| 205 | } |
||
| 206 | |||
| 207 | public function divOtherinstallers() { |
||
| 208 | $retval = " |
||
| 209 | <div class='sub_h'> |
||
| 210 | <div id='other_installers'>" . $this->Gui->textTemplates->templates[user\DOWNLOAD_CHOOSE] . " |
||
| 211 | <table id='device_list' style='padding:0px;'>"; |
||
| 212 | |||
| 213 | foreach ($this->Gui->listDevices(isset($_REQUEST['hidden']) ? $_REQUEST['hidden'] : 0) as $group => $deviceGroup) { |
||
| 214 | $groupIndex = count($deviceGroup); |
||
| 215 | $deviceIndex = 0; |
||
| 216 | |||
| 217 | $imgTag = ""; |
||
| 218 | $imgLocation = $this->Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/" . $group . ".png"); |
||
| 219 | if ($imgLocation !== FALSE) { |
||
| 220 | $imgTag = '<img src="' . $imgLocation . '" alt="' . $group . ' Device" title="' . $group . ' Device">'; |
||
| 221 | } |
||
| 222 | $retval .= '<tbody><tr><td class="vendor" rowspan="' . $groupIndex . '">' . $imgTag . '</td>'; |
||
| 223 | foreach ($deviceGroup as $d => $D) { |
||
| 224 | if ($deviceIndex) { |
||
| 225 | $retval .= '<tr>'; |
||
| 226 | } |
||
| 227 | $retval .= "<td><button id='" . $d . "'>" . $D['display'] . "</button>" |
||
| 228 | . "<div class='device_info' id='info_" . $d . "'></div></td>" |
||
| 229 | . "<td><button class='more_info_b' id='info_b_" . $d . "'>i</button></td></tr>\n"; |
||
| 230 | $deviceIndex++; |
||
| 231 | } |
||
| 232 | $retval .= "</tbody>"; |
||
| 233 | } |
||
| 234 | |||
| 235 | $retval .= " |
||
| 236 | </table> |
||
| 237 | </div> |
||
| 238 | </div>"; |
||
| 239 | return $retval; |
||
| 240 | } |
||
| 241 | |||
| 242 | public function divGuessOs($operatingSystem) { |
||
| 243 | $vendorlogo = $this->Gui->skinObject->findResourceUrl("IMAGES", "vendorlogo/" . $operatingSystem['group'] . ".png"); |
||
| 244 | $vendorstyle = ""; |
||
| 245 | if ($vendorlogo !== FALSE) { |
||
| 246 | $vendorstyle = "style='background-image:url(\"" . $vendorlogo . "\")'"; |
||
| 247 | } |
||
| 248 | $deleteIcon = $this->Gui->skinObject->findResourceUrl("IMAGES", "icons/delete_32.png"); |
||
| 249 | $deleteImg = ""; |
||
| 250 | if ($deleteIcon !== FALSE) { |
||
| 251 | $deleteImg = "<img id='cross_icon_" . $operatingSystem['device'] . "' src='$deleteIcon' >"; |
||
| 252 | } |
||
| 253 | return " |
||
| 254 | <div class='sub_h' id='guess_os'> |
||
| 255 | <!-- table browser --> |
||
| 256 | <table id='browser'> |
||
| 257 | <tr> |
||
| 258 | <td> |
||
| 259 | <button class='large_button guess_os' $vendorstyle id='g_" . $operatingSystem['device'] . "'> |
||
| 260 | $deleteImg |
||
| 261 | <div class='download_button_text_1' id='download_button_header_" . $operatingSystem['device'] . "'> " . $this->Gui->textTemplates->templates[user\DOWNLOAD_MESSAGE] . " |
||
| 262 | </div> |
||
| 263 | <div class='download_button_text'>" . |
||
| 264 | $operatingSystem['display'] . " |
||
| 265 | </div> |
||
| 266 | </button> |
||
| 267 | <div class='device_info' id='info_g_" . $operatingSystem['device'] . "'></div> |
||
| 268 | </td> |
||
| 269 | <td style='vertical-align:top'> |
||
| 270 | <button class='more_info_b large_button' id='g_info_b_" . $operatingSystem['device'] . "'>i</button> |
||
| 271 | </td> |
||
| 272 | </tr> |
||
| 273 | </table> <!-- id='browser' --> |
||
| 274 | <div class='sub_h'> |
||
| 275 | <a href='javascript:other_installers()'>" . $this->Gui->textTemplates->templates[user\DOWNLOAD_CHOOSE] . "</a> |
||
| 276 | </div> |
||
| 277 | </div> <!-- id='guess_os' -->"; |
||
| 278 | } |
||
| 279 | |||
| 280 | public function divFooter() { |
||
| 281 | $retval = " |
||
| 282 | <div class='footer' id='footer'> |
||
| 283 | <table> |
||
| 284 | <tr> |
||
| 285 | <td>" . |
||
| 286 | $this->Gui->CAT_COPYRIGHT |
||
| 287 | . " |
||
| 288 | </td>"; |
||
| 289 | |||
| 290 | if (!empty(CONFIG['APPEARANCE']['privacy_notice_url'])) { |
||
| 291 | $retval .= "<td><a href='" . CONFIG['APPEARANCE']['privacy_notice_url'] . "'>" . sprintf(_("%s Privacy Notice"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']) . "</a></td>"; |
||
| 292 | } |
||
| 293 | $retval .= "<td>"; |
||
| 294 | if (CONFIG_CONFASSISTANT['CONSORTIUM']['name'] == "eduroam" && isset(CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo']) && CONFIG_CONFASSISTANT['CONSORTIUM']['deployment-voodoo'] == "Operations Team") { |
||
| 295 | $geant = $this->Gui->skinObject->findResourceUrl("IMAGES", "dante.png"); |
||
| 296 | $eu = $this->Gui->skinObject->findResourceUrl("IMAGES", "eu.png"); |
||
| 297 | if ($geant !== FALSE && $eu !== FALSE) { |
||
| 298 | $retval .= "<span id='logos'><img src='$geant' alt='GEANT' style='height:23px;width:47px'/> |
||
| 299 | <img src='$eu' alt='EU' style='height:23px;width:27px;border-width:0px;'/></span>"; |
||
| 300 | } |
||
| 301 | $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>"; |
||
| 302 | } else { |
||
| 303 | $retval .= " "; |
||
| 304 | } |
||
| 305 | |||
| 306 | $retval .= " |
||
| 307 | </td> |
||
| 308 | </tr> |
||
| 309 | </table> |
||
| 310 | </div>"; |
||
| 311 | return $retval; |
||
| 312 | } |
||
| 313 | |||
| 314 | private function emptyImage($id, $alt) { |
||
| 323 | } |
||
| 324 | |||
| 325 | } |
||
| 326 |