HostFact - VPS
VPS server
Op deze pagina worden alle functies besproken omtrent VPS servers.
getImageList()
Haal de lijst met alle images op.
Voorbeeld implementatie
public function getImageList() { /** * Step 1) get images list */ $response = TRUE; /** * Step 2) provide feedback to HostFact */ if($response) { $images = array(); $i = 0; // loop through images and build return array foreach($response->images as $image) { $images[$i]['imageid'] = $image->id; $images[$i]['imagename'] = $image->name; $i++; } if(count($images) == 0) { return $this->__parseError(__('node has no images', 'YourName')); } return $images; } return FALSE; }
loadLanguageArray()
Functie voor ondersteuning van meertaligheid van (error) berichten van de koppeling naar HostFact.
Beschikbare variabelen | Beschrijving |
---|---|
$language_code | Taalcode |
Voorbeeld implementatie
public function loadLanguageArray($language_code) { $_LANG = array(); switch($language_code) { case 'nl_NL': $_LANG['node gave no response'] = 'Server gaf geen antwoord terug.'; $_LANG['node returned error'] = 'Server gaf een error terug.'; $_LANG['node returned wrong data'] = 'Server gaf een antwoord terug, maar niet de benodigde data.'; $_LANG['node has no images'] = 'Server heeft geen images'; $_LANG['node has no templates'] = 'Server heeft geen templates'; break; default: // In case of other language, use English $_LANG['node gave no response'] = 'No response from node'; $_LANG['node returned error'] = 'Node returned an error.'; $_LANG['node returned wrong data'] = 'Node returned incorrect data'; $_LANG['node has no images'] = 'Node has no images'; $_LANG['node has no templates'] = 'Node has no templates'; break; } // Save to global array global $_module_language_array; $_module_language_array['YourName'] = $_LANG; }
showSettingsHTML()
Deze functie maakt het mogelijk om extra instellingen of toelichting te geven op de aanmaak- en bewerkpagina van een VPS server binnen HostFact. Dit kan bijvoorbeeld nodig zijn wanneer er meer informatie nodig is dan alleen de URL, gebruikersnaam en wachtwoord van het platform.
Beschikbare variabelen | Beschrijving |
---|---|
$edit_or_show | edit|show; bepaalt of een VPS server bewerkt of getoond wordt |
Voorbeeld implementatie
public function showSettingsHTML($edit_or_show = 'edit') { $html = ''; /** * Step 1) build html based on $edit_or_show * you can use $this->ServerSettings->InputName to request the settings variabeles, see examples below * */ // example: // if($edit_or_show == 'show') // { // // Show page // $html = '<strong class="title2">Project ID (Tenant ID)</strong>' . // '<span class="title2_value">' . // ((isset($this->ServerSettings->ProjectID)) ? htmlspecialchars($this->ServerSettings->ProjectID) : '') . // '</span>' ; // } // else // { // // add/edit page // $html = '<strong class="title">Project ID (Tenant ID)</strong>' . // '<input type="text" name="module[vps][Settings][ProjectID]" class="text1 size1" value="' . ((isset($this->ServerSettings->ProjectID)) ? htmlspecialchars($this->ServerSettings->ProjectID) : '') . '" />'; // } /** * Step 2) provide feedback to HostFact */ return $html; }
validateLogin()
Valideer de inloggevens van een VPS server
Beschikbare variabelen | Beschrijving |
---|---|
$this->ServerURL | API (authenticatie) URL |
$this->ServerUser | Gebruikersnaam |
$this->ServerPass | Wachtwoord |
Voorbeeld implementatie
public function validateLogin() { // available variables: $this->ServerURL; $this->ServerUser; $this->ServerPass; /** * Step 1) send login or get command to check if login credentials are correct * */ $response = TRUE; return $response; }