| Total Complexity | 68 |
| Total Lines | 559 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like UIElements 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 UIElements, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 32 | class UIElements extends \core\common\Entity { |
||
| 33 | |||
| 34 | /** |
||
| 35 | * the custom displayable variant of the term 'federation' |
||
| 36 | * |
||
| 37 | * @var string |
||
| 38 | */ |
||
| 39 | public $nomenclatureFed; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * the custom displayable variant of the term 'institution' |
||
| 43 | * |
||
| 44 | * @var string |
||
| 45 | */ |
||
| 46 | public $nomenclatureInst; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * the custom displayable variant of the term 'hotspot' |
||
| 50 | * |
||
| 51 | * @var string |
||
| 52 | */ |
||
| 53 | public $nomenclatureHotspot; |
||
| 54 | |||
| 55 | /** |
||
| 56 | * the custom displayable variant of the term 'hotspot' |
||
| 57 | * |
||
| 58 | * @var string |
||
| 59 | */ |
||
| 60 | public $nomenclatureParticipant; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Initialises the class. |
||
| 64 | * |
||
| 65 | * Mainly fetches various nomenclature from the config and attempts to translate those into local language. Needs pre-loading some terms. |
||
| 66 | */ |
||
| 67 | public function __construct() { |
||
| 68 | // pick up the nomenclature translations from core - no need to repeat |
||
| 69 | // them here in this catalogue |
||
| 70 | parent::__construct(); |
||
| 71 | $this->nomenclatureFed = \core\common\Entity::$nomenclature_fed; |
||
| 72 | $this->nomenclatureInst = \core\common\Entity::$nomenclature_inst; |
||
| 73 | $this->nomenclatureHotspot = \core\common\Entity::$nomenclature_hotspot; |
||
| 74 | $this->nomenclatureParticipant = \core\common\Entity::$nomenclature_participant; |
||
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * provides human-readable text for the various option names as stored in DB. |
||
| 79 | * |
||
| 80 | * @param string $input raw text in need of a human-readable display variant |
||
| 81 | * @return string the human-readable variant |
||
| 82 | * @throws \Exception |
||
| 83 | */ |
||
| 84 | public function displayName($input) { |
||
| 85 | \core\common\Entity::intoThePotatoes(); |
||
| 86 | $ssidText = _("SSID"); |
||
| 87 | $ssidLegacyText = _("SSID (with WPA/TKIP)"); |
||
| 88 | $passpointOiText = _("HS20 Consortium OI"); |
||
| 89 | |||
| 90 | if (count(\config\ConfAssistant::CONFIG['CONSORTIUM']['ssid']) > 0) { |
||
| 91 | $ssidText = _("Additional SSID"); |
||
| 92 | $ssidLegacyText = _("Additional SSID (with WPA/TKIP)"); |
||
| 93 | } |
||
| 94 | if (!empty(\config\ConfAssistant::CONFIG['CONSORTIUM']['interworking-consortium-oi']) && count(\config\ConfAssistant::CONFIG['CONSORTIUM']['interworking-consortium-oi']) > 0) { |
||
| 95 | $passpointOiText = _("Additional HS20 Consortium OI"); |
||
| 96 | } |
||
| 97 | |||
| 98 | $displayNames = [_("Support: Web") => "support:url", |
||
| 99 | _("Support: EAP Types") => "support:eap_types", |
||
| 100 | _("Support: Phone") => "support:phone", |
||
| 101 | _("Support: E-Mail") => "support:email", |
||
| 102 | sprintf(_("%s Name"), $this->nomenclatureParticipant) => "general:instname", |
||
| 103 | _("Location") => "general:geo_coordinates", |
||
| 104 | _("Logo URL") => "general:logo_url", |
||
| 105 | _("Logo image") => "general:logo_file", |
||
| 106 | _("Configure Wired Ethernet") => "media:wired", |
||
| 107 | _("Name (CN) of Authentication Server") => "eap:server_name", |
||
| 108 | _("Enable device assessment") => "eap:enable_nea", |
||
| 109 | _("Terms of Use") => "support:info_file", |
||
| 110 | _("CA Certificate URL") => "eap:ca_url", |
||
| 111 | _("CA Certificate File") => "eap:ca_file", |
||
| 112 | _("Profile Display Name") => "profile:name", |
||
| 113 | _("Production-Ready") => "profile:production", |
||
| 114 | _("Admin Accepted Terms of Use") => 'hiddenprofile:tou_accepted', |
||
| 115 | _("Extra text on downloadpage for device") => "device-specific:customtext", |
||
| 116 | _("Redirection Target") => "device-specific:redirect", |
||
| 117 | _("Extra text on downloadpage for EAP method") => "eap-specific:customtext", |
||
| 118 | _("Turn on selection of EAP-TLS User-Name") => "eap-specific:tls_use_other_id", |
||
| 119 | _("Use GEANTlink TTLS supplicant for W8") => "device-specific:geantlink", |
||
| 120 | _("Use builtin TTLS supplicant for Windows 10") => "device-specific:builtin_ttls", |
||
| 121 | _("Profile Description") => "profile:description", |
||
| 122 | _("Custom Installer Name Suffix") => "profile:customsuffix", |
||
| 123 | sprintf(_("%s Administrator"), $this->nomenclatureFed) => "user:fedadmin", |
||
| 124 | _("Real Name") => "user:realname", |
||
| 125 | _("E-Mail Address") => "user:email", |
||
| 126 | _("Remove/Disable SSID") => "media:remove_SSID", |
||
| 127 | _("Mandatory Content Filtering Proxy") => "media:force_proxy", |
||
| 128 | _("Custom CSS file for User Area") => "fed:css_file", |
||
| 129 | sprintf(_("%s Logo"), $this->nomenclatureFed) => "fed:logo_file", |
||
| 130 | _("Preferred Skin for User Area") => "fed:desired_skin", |
||
| 131 | sprintf(_("Include %s branding in installers"), $this->nomenclatureFed) => "fed:include_logo_installers", |
||
| 132 | sprintf(_("%s Name"), $this->nomenclatureFed) => "fed:realname", |
||
| 133 | sprintf(_("%s Homepage"), $this->nomenclatureFed) => "fed:url", |
||
| 134 | sprintf(_("Custom text in %s Invitations"), $this->nomenclatureInst) => "fed:custominvite", |
||
| 135 | sprintf(_("Enable %s"), \core\ProfileSilverbullet::PRODUCTNAME) => "fed:silverbullet", |
||
| 136 | sprintf(_("%s: Do not terminate EAP"), \core\ProfileSilverbullet::PRODUCTNAME) => "fed:silverbullet-noterm", |
||
| 137 | sprintf(_("%s: max users per profile"), \core\ProfileSilverbullet::PRODUCTNAME) => "fed:silverbullet-maxusers", |
||
| 138 | sprintf(_("Mint %s with CA on creation"), $this->nomenclatureInst) => "fed:minted_ca_file", |
||
| 139 | $ssidText => "media:SSID", |
||
| 140 | $ssidLegacyText => "media:SSID_with_legacy", |
||
| 141 | $passpointOiText => "media:consortium_OI", |
||
| 142 | _("VLAN for own users") => "managedsp:vlan", |
||
| 143 | _("Realm to be considered own users") => "managedsp:realmforvlan", |
||
| 144 | _("Custom Operator-Name attribute") => "managedsp:operatorname", |
||
| 145 | ]; |
||
| 146 | |||
| 147 | $find = array_keys($displayNames, $input, TRUE); |
||
| 148 | |||
| 149 | if (count($find) == 0) { // this is an error! throw an Exception |
||
| 150 | throw new \Exception("The translation of an option name was requested, but the option is not known to the system: " . htmlentities($input)); |
||
| 151 | } |
||
| 152 | \core\common\Entity::outOfThePotatoes(); |
||
| 153 | return $find[0]; |
||
| 154 | } |
||
| 155 | |||
| 156 | /** |
||
| 157 | * creates an HTML information block with a list of options from a given category and level |
||
| 158 | * @param array $optionlist list of options |
||
| 159 | * @param string $class option class of interest |
||
| 160 | * @param string $level option level of interest |
||
| 161 | * @return string HTML code |
||
| 162 | */ |
||
| 163 | public function infoblock(array $optionlist, string $class, string $level) { |
||
| 164 | \core\common\Entity::intoThePotatoes(); |
||
| 165 | $locationMarkers = []; |
||
| 166 | $retval = ""; |
||
| 167 | $optioninfo = \core\Options::instance(); |
||
| 168 | |||
| 169 | foreach ($optionlist as $option) { |
||
| 170 | $type = $optioninfo->optionType($option['name']); |
||
| 171 | if (preg_match('/^' . $class . '/', $option['name']) && $option['level'] == "$level") { |
||
| 172 | // all non-multilang attribs get this assignment ... |
||
| 173 | $language = ""; |
||
| 174 | $content = $option['value']; |
||
| 175 | // ... override them with multilang tags if needed |
||
| 176 | if ($type["flag"] == "ML") { |
||
| 177 | $language = _("default/other languages"); |
||
| 178 | if ($option['lang'] != 'C') { |
||
| 179 | $language = \config\Master::CONFIG['LANGUAGES'][$option['lang']]['display'] ?? "(unsupported language)"; |
||
| 180 | } |
||
| 181 | } |
||
| 182 | |||
| 183 | switch ($type["type"]) { |
||
| 184 | case "coordinates": |
||
| 185 | $coords = json_decode($option['value'], true); |
||
| 186 | $locationMarkers[] = $coords; |
||
| 187 | break; |
||
| 188 | case "file": |
||
| 189 | $retval .= "<tr><td>" . $this->displayName($option['name']) . "</td><td>$language</td><td>"; |
||
| 190 | switch ($option['name']) { |
||
| 191 | case "general:logo_file": |
||
| 192 | case "fed:logo_file": |
||
| 193 | $retval .= $this->previewImageinHTML('ROWID-' . $option['level'] . '-' . $option['row']); |
||
| 194 | break; |
||
| 195 | case "eap:ca_file": |
||
| 196 | // fall-through intended: display both the same way |
||
| 197 | case "fed:minted_ca_file": |
||
| 198 | $retval .= $this->previewCAinHTML('ROWID-' . $option['level'] . '-' . $option['row']); |
||
| 199 | break; |
||
| 200 | case "support:info_file": |
||
| 201 | $retval .= $this->previewInfoFileinHTML('ROWID-' . $option['level'] . '-' . $option['row']); |
||
| 202 | break; |
||
| 203 | default: |
||
| 204 | } |
||
| 205 | break; |
||
| 206 | case "boolean": |
||
| 207 | if ($option['name'] == "fed:silverbullet" && \config\Master::CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_SILVERBULLET'] == "LOCAL" && \config\Master::CONFIG['FUNCTIONALITY_LOCATIONS']['CONFASSISTANT_RADIUS'] != "LOCAL") { |
||
| 208 | // do not display the option at all; it gets auto-set by the ProfileSilverbullet constructor and doesn't have to be seen |
||
| 209 | break; |
||
| 210 | } |
||
| 211 | $retval .= "<tr><td>" . $this->displayName($option['name']) . "</td><td>$language</td><td><strong>" . ($content == "on" ? _("on") : _("off") ) . "</strong></td></tr>"; |
||
| 212 | break; |
||
| 213 | default: |
||
| 214 | $retval .= "<tr><td>" . $this->displayName($option['name']) . "</td><td>$language</td><td><strong>$content</strong></td></tr>"; |
||
| 215 | } |
||
| 216 | } |
||
| 217 | } |
||
| 218 | if (count($locationMarkers)) { |
||
| 219 | $marker = '<markers>'; |
||
| 220 | $locationCount = 0; |
||
| 221 | foreach ($locationMarkers as $g) { |
||
| 222 | $locationCount++; |
||
| 223 | $marker .= '<marker name="' . $locationCount . '" lat="' . $g['lat'] . '" lng="' . $g['lon'] . '" />'; |
||
| 224 | } |
||
| 225 | $marker .= '<\/markers>'; // some validator says this should be escaped |
||
| 226 | $jMarker = json_encode($locationMarkers); |
||
| 227 | $retval .= '<tr><td><script>markers=\'' . $marker . '\'; jmarkers = \'' . $jMarker . '\';</script></td><td></td><td></td></tr>'; |
||
| 228 | } |
||
| 229 | \core\common\Entity::outOfThePotatoes(); |
||
| 230 | return $retval; |
||
| 231 | } |
||
| 232 | |||
| 233 | /** |
||
| 234 | * creates HTML code to display all information boxes for an IdP |
||
| 235 | * |
||
| 236 | * @param \core\IdP $myInst the IdP in question |
||
| 237 | * @return string HTML code |
||
| 238 | */ |
||
| 239 | public function instLevelInfoBoxes(\core\IdP $myInst) { |
||
| 240 | \core\common\Entity::intoThePotatoes(); |
||
| 241 | $idpoptions = $myInst->getAttributes(); |
||
| 242 | $retval = "<div class='infobox'> |
||
| 243 | <h2>" . sprintf(_("General %s details"), $this->nomenclatureInst) . "</h2> |
||
| 244 | <table> |
||
| 245 | <tr> |
||
| 246 | <td> |
||
| 247 | " . _("Country:") . " |
||
| 248 | </td> |
||
| 249 | <td> |
||
| 250 | </td> |
||
| 251 | <td> |
||
| 252 | <strong>"; |
||
| 253 | $myFed = new \core\Federation($myInst->federation); |
||
| 254 | $retval .= $myFed->name; |
||
| 255 | $retval .= "</strong> |
||
| 256 | </td> |
||
| 257 | </tr>" . $this->infoblock($idpoptions, "general", "IdP") . " |
||
| 258 | </table> |
||
| 259 | </div>"; |
||
| 260 | |||
| 261 | $blocks = [["support", _("Global Helpdesk Details")], ["media", _("Media Properties")]]; |
||
| 262 | foreach ($blocks as $block) { |
||
| 263 | $retval .= "<div class='infobox'> |
||
| 264 | <h2>" . $block[1] . "</h2> |
||
| 265 | <table>" . |
||
| 266 | $this->infoblock($idpoptions, $block[0], "IdP") . |
||
| 267 | "</table> |
||
| 268 | </div>"; |
||
| 269 | } |
||
| 270 | \core\common\Entity::outOfThePotatoes(); |
||
| 271 | return $retval; |
||
| 272 | } |
||
| 273 | |||
| 274 | /** |
||
| 275 | * pretty-prints a file size number in SI "bi" units |
||
| 276 | * @param int $number the size of the file |
||
| 277 | * @return string the pretty-print representation of the file size |
||
| 278 | */ |
||
| 279 | private function displaySize(int $number) { |
||
| 280 | if ($number > 1024 * 1024) { |
||
| 281 | return round($number / 1024 / 1024, 2) . " MiB"; |
||
| 282 | } |
||
| 283 | if ($number > 1024) { |
||
| 284 | return round($number / 1024, 2) . " KiB"; |
||
| 285 | } |
||
| 286 | return $number . " B"; |
||
| 287 | } |
||
| 288 | |||
| 289 | /** |
||
| 290 | * |
||
| 291 | * @param string $table the database table |
||
| 292 | * @param integer $rowindex the database row |
||
| 293 | * @param boolean $checkpublic should we check if the requested piece of data is public? |
||
| 294 | * @return string|boolean the requested data, or FALSE if something went wrong |
||
| 295 | */ |
||
| 296 | public static function getBlobFromDB($table, $rowindex, $checkpublic) { |
||
| 297 | // the data is either public (just give it away) or not; in this case, only |
||
| 298 | // release if the data belongs to admin himself |
||
| 299 | if ($checkpublic) { |
||
| 300 | |||
| 301 | $owners = \core\EntityWithDBProperties::isDataRestricted($table, $rowindex); |
||
| 302 | |||
| 303 | $ownersCondensed = []; |
||
| 304 | |||
| 305 | if ($owners !== FALSE) { // restricted data, see if we're authenticated and owners of the data |
||
| 306 | $auth = new \web\lib\admin\Authentication(); |
||
| 307 | if (!$auth->isAuthenticated()) { |
||
| 308 | return FALSE; // admin-only, but we are not an admin |
||
| 309 | } |
||
| 310 | // we might be called without session context (filepreview) so get the |
||
| 311 | // context if needed |
||
| 312 | \core\CAT::sessionStart(); |
||
| 313 | |||
| 314 | foreach ($owners as $oneowner) { |
||
| 315 | $ownersCondensed[] = $oneowner['ID']; |
||
| 316 | } |
||
| 317 | if (array_search($_SESSION['user'], $ownersCondensed) === FALSE) { |
||
| 318 | return FALSE; // wrong guy |
||
| 319 | } |
||
| 320 | // carry on and get the data |
||
| 321 | } |
||
| 322 | } |
||
| 323 | |||
| 324 | $blob = \core\EntityWithDBProperties::fetchRawDataByIndex($table, $rowindex); |
||
| 325 | return $blob; // this means we might return FALSE here if something was wrong with the original requested reference |
||
| 326 | } |
||
| 327 | |||
| 328 | /** |
||
| 329 | * creates HTML code to display a nice UI representation of a CA |
||
| 330 | * |
||
| 331 | * @param string $cAReference ROWID pointer to the CA to display |
||
| 332 | * @return string HTML code |
||
| 333 | */ |
||
| 334 | public function previewCAinHTML($cAReference) { |
||
| 335 | \core\common\Entity::intoThePotatoes(); |
||
| 336 | $validator = new \web\lib\common\InputValidation(); |
||
| 337 | $ref = $validator->databaseReference($cAReference); |
||
| 338 | $rawResult = UIElements::getBlobFromDB($ref['table'], $ref['rowindex'], FALSE); |
||
| 339 | if (is_bool($rawResult)) { // we didn't actually get a CA! |
||
| 340 | $retval = "<div class='ca-summary'>" . _("There was an error while retrieving the certificate from the database!") . "</div>"; |
||
| 341 | \core\common\Entity::outOfThePotatoes(); |
||
| 342 | return $retval; |
||
| 343 | } |
||
| 344 | $cAblob = base64_decode($rawResult); |
||
| 345 | |||
| 346 | $func = new \core\common\X509; |
||
| 347 | $details = $func->processCertificate($cAblob); |
||
| 348 | if ($details === FALSE) { |
||
| 349 | $retval = _("There was an error processing the certificate!"); |
||
| 350 | \core\common\Entity::outOfThePotatoes(); |
||
| 351 | return $retval; |
||
| 352 | } |
||
| 353 | |||
| 354 | $details['name'] = preg_replace('/(.)\/(.)/', "$1<br/>$2", $details['name']); |
||
| 355 | $details['name'] = preg_replace('/\//', "", $details['name']); |
||
| 356 | $certstatus = ( $details['root'] == 1 ? "R" : "I"); |
||
| 357 | if ($details['ca'] == 0 && $details['root'] != 1) { |
||
| 358 | $retval = "<div class='ca-summary' style='background-color:red'><div style='position:absolute; right: 0px; width:20px; height:20px; background-color:maroon; border-radius:10px; text-align: center;'><div style='padding-top:3px; font-weight:bold; color:#ffffff;'>S</div></div>" . _("This is a <strong>SERVER</strong> certificate!") . "<br/>" . $details['name'] . "</div>"; |
||
| 359 | \core\common\Entity::outOfThePotatoes(); |
||
| 360 | return $retval; |
||
| 361 | } |
||
| 362 | $retval = "<div class='ca-summary' ><div style='position:absolute; right: 0px; width:20px; height:20px; background-color:#0000ff; border-radius:10px; text-align: center;'><div style='padding-top:3px; font-weight:bold; color:#ffffff;'>$certstatus</div></div>" . $details['name'] . "</div>"; |
||
| 363 | \core\common\Entity::outOfThePotatoes(); |
||
| 364 | return $retval; |
||
| 365 | } |
||
| 366 | |||
| 367 | /** |
||
| 368 | * creates HTML code to display a nice UI representation of an image |
||
| 369 | * |
||
| 370 | * @param string $imageReference ROWID pointer to the image to display |
||
| 371 | * @return string HTML code |
||
| 372 | */ |
||
| 373 | public function previewImageinHTML($imageReference) { |
||
| 374 | \core\common\Entity::intoThePotatoes(); |
||
| 375 | $retval = "<img style='max-width:150px' src='inc/filepreview.php?id=" . $imageReference . "' alt='" . _("Preview of logo file") . "'/>"; |
||
| 376 | \core\common\Entity::outOfThePotatoes(); |
||
| 377 | return $retval; |
||
| 378 | } |
||
| 379 | |||
| 380 | /** |
||
| 381 | * creates HTML code to display a nice UI representation of a TermsOfUse file |
||
| 382 | * |
||
| 383 | * @param string $fileReference ROWID pointer to the file to display |
||
| 384 | * @return string HTML code |
||
| 385 | */ |
||
| 386 | public function previewInfoFileinHTML($fileReference) { |
||
| 387 | \core\common\Entity::intoThePotatoes(); |
||
| 388 | $validator = new \web\lib\common\InputValidation(); |
||
| 389 | $ref = $validator->databaseReference($fileReference); |
||
| 390 | $fileBlob = UIElements::getBlobFromDB($ref['table'], $ref['rowindex'], FALSE); |
||
| 391 | if (is_bool($fileBlob)) { // we didn't actually get a file! |
||
| 392 | $retval = "<div class='ca-summary'>" . _("There was an error while retrieving the file from the database!") . "</div>"; |
||
| 393 | \core\common\Entity::outOfThePotatoes(); |
||
| 394 | return $retval; |
||
| 395 | } |
||
| 396 | $decodedFileBlob = base64_decode($fileBlob); |
||
| 397 | $fileinfo = new \finfo(); |
||
| 398 | $retval = "<div class='ca-summary'>" . _("File exists") . " (" . $fileinfo->buffer($decodedFileBlob, FILEINFO_MIME_TYPE) . ", " . $this->displaySize(strlen($decodedFileBlob)) . ")<br/><a href='inc/filepreview.php?id=$fileReference'>" . _("Preview") . "</a></div>"; |
||
| 399 | \core\common\Entity::outOfThePotatoes(); |
||
| 400 | return $retval; |
||
| 401 | } |
||
| 402 | |||
| 403 | /** |
||
| 404 | * creates HTML code for a UI element which informs the user about something. |
||
| 405 | * |
||
| 406 | * @param int $level what kind of information is to be displayed? |
||
| 407 | * @param string $text the text to display |
||
| 408 | * @param string $caption the caption to display |
||
| 409 | * @param bool $omittabletags the output usually has tr/td table tags, this option suppresses them |
||
| 410 | * @return string |
||
| 411 | */ |
||
| 412 | public function boxFlexible(int $level, string $text = NULL, string $caption = NULL, bool $omittabletags = FALSE) { |
||
| 413 | \core\common\Entity::intoThePotatoes(); |
||
| 414 | $uiMessages = [ |
||
| 415 | \core\common\Entity::L_OK => ['icon' => '../resources/images/icons/Quetto/check-icon.png', 'text' => _("OK")], |
||
| 416 | \core\common\Entity::L_REMARK => ['icon' => '../resources/images/icons/Quetto/info-icon.png', 'text' => _("Remark")], |
||
| 417 | \core\common\Entity::L_WARN => ['icon' => '../resources/images/icons/Quetto/danger-icon.png', 'text' => _("Warning!")], |
||
| 418 | \core\common\Entity::L_ERROR => ['icon' => '../resources/images/icons/Quetto/no-icon.png', 'text' => _("Error!")], |
||
| 419 | ]; |
||
| 420 | |||
| 421 | $retval = ""; |
||
| 422 | if (!$omittabletags) { |
||
| 423 | $retval .= "<tr><td>"; |
||
| 424 | } |
||
| 425 | $finalCaption = ($caption !== NULL ? $caption : $uiMessages[$level]['text']); |
||
| 426 | $retval .= "<img class='icon' src='" . $uiMessages[$level]['icon'] . "' alt='" . $finalCaption . "' title='" . $finalCaption . "'/>"; |
||
| 427 | if (!$omittabletags) { |
||
| 428 | $retval .= "</td><td>"; |
||
| 429 | } |
||
| 430 | if ($text !== NULL) { |
||
| 431 | $retval .= $text; |
||
| 432 | } |
||
| 433 | if (!$omittabletags) { |
||
| 434 | $retval .= "</td></tr>"; |
||
| 435 | } |
||
| 436 | \core\common\Entity::outOfThePotatoes(); |
||
| 437 | return $retval; |
||
| 438 | } |
||
| 439 | |||
| 440 | /** |
||
| 441 | * creates HTML code to display an "all is okay" message |
||
| 442 | * |
||
| 443 | * @param string $text the text to display |
||
| 444 | * @param string $caption the caption to display |
||
| 445 | * @param bool $omittabletags the output usually has tr/td table tags, this option suppresses them |
||
| 446 | * @return string HTML: the box |
||
| 447 | */ |
||
| 448 | public function boxOkay(string $text = NULL, string $caption = NULL, bool $omittabletags = FALSE) { |
||
| 449 | return $this->boxFlexible(\core\common\Entity::L_OK, $text, $caption, $omittabletags); |
||
| 450 | } |
||
| 451 | |||
| 452 | /** |
||
| 453 | * creates HTML code to display a "smartass comment" message |
||
| 454 | * |
||
| 455 | * @param string $text the text to display |
||
| 456 | * @param string $caption the caption to display |
||
| 457 | * @param bool $omittabletags the output usually has tr/td table tags, this option suppresses them |
||
| 458 | * @return string HTML: the box |
||
| 459 | */ |
||
| 460 | public function boxRemark(string $text = NULL, string $caption = NULL, bool $omittabletags = FALSE) { |
||
| 461 | return $this->boxFlexible(\core\common\Entity::L_REMARK, $text, $caption, $omittabletags); |
||
| 462 | } |
||
| 463 | |||
| 464 | /** |
||
| 465 | * creates HTML code to display a "something's a bit wrong" message |
||
| 466 | * |
||
| 467 | * @param string $text the text to display |
||
| 468 | * @param string $caption the caption to display |
||
| 469 | * @param bool $omittabletags the output usually has tr/td table tags, this option suppresses them |
||
| 470 | * @return string HTML: the box |
||
| 471 | */ |
||
| 472 | public function boxWarning(string $text = NULL, string $caption = NULL, bool $omittabletags = FALSE) { |
||
| 473 | return $this->boxFlexible(\core\common\Entity::L_WARN, $text, $caption, $omittabletags); |
||
| 474 | } |
||
| 475 | |||
| 476 | /** |
||
| 477 | * creates HTML code to display a "Whoa! Danger, Will Robinson!" message |
||
| 478 | * |
||
| 479 | * @param string $text the text to display |
||
| 480 | * @param string $caption the caption to display |
||
| 481 | * @param bool $omittabletags the output usually has tr/td table tags, this option suppresses them |
||
| 482 | * @return string HTML: the box |
||
| 483 | */ |
||
| 484 | public function boxError(string $text = NULL, string $caption = NULL, bool $omittabletags = FALSE) { |
||
| 486 | } |
||
| 487 | |||
| 488 | const QRCODE_PIXELS_PER_SYMBOL = 12; |
||
| 489 | |||
| 490 | /** |
||
| 491 | * Injects the consortium logo in the middle of a given PNG. |
||
| 492 | * |
||
| 493 | * Usually used on QR code PNGs - the parameters inform about the structure of |
||
| 494 | * the QR code so that the logo does not prevent parsing of the QR code. |
||
| 495 | * |
||
| 496 | * @param string $inputpngstring the PNG to edit |
||
| 497 | * @param int $symbolsize size in pixels of one QR "pixel" |
||
| 498 | * @param int $marginsymbols size in pixels of border around the actual QR |
||
| 499 | * @return string the image with logo centered in the middle |
||
| 500 | */ |
||
| 501 | public function pngInjectConsortiumLogo(string $inputpngstring, int $symbolsize, int $marginsymbols = 4) { |
||
| 541 | } |
||
| 542 | |||
| 543 | /** |
||
| 544 | * Something went wrong. We display the error cause and then throw an Exception. |
||
| 545 | * |
||
| 546 | * @param string $headerDisplay error to put in the page header |
||
| 547 | * @param string $uiDisplay error string to display |
||
| 548 | * @return void direct output |
||
| 549 | * @throws Exception |
||
| 550 | */ |
||
| 551 | public function errorPage($headerDisplay, $uiDisplay) { |
||
| 557 | } |
||
| 558 | |||
| 559 | /** |
||
| 560 | * creates the HTML code displaying the result of a test that was run previously |
||
| 561 | * |
||
| 562 | * @param \core\SanityTests $test the test that was run |
||
| 563 | * @return string |
||
| 564 | * @throws Exception |
||
| 565 | */ |
||
| 566 | public function sanityTestResultHTML($test) { |
||
| 594 |