feat: auto-create custom fields, add try/catch coverage, PHPDoc, and Pint formatting
All checks were successful
Publish Release / release (push) Successful in 10s
All checks were successful
Publish Release / release (push) Successful in 10s
- Auto-create 'Initial Operating System' and 'Initial SSH Key' custom fields via Database::ensureCustomFields() on module load, eliminating the manual modify.sql step - Delete modify.sql (no longer needed) - Add try/catch blocks around every DB operation and API call across all PHP files per CLAUDE.md error handling rules - Add comprehensive PHPDoc to all classes, methods, and properties - Set up Laravel Pint (laravel/pint) with Laravel-style preset for consistent code formatting across the codebase - Add git pre-commit hook (hooks/pre-commit) that runs Pint on staged PHP files, auto-installed via Composer post-install/post-update scripts - Simplify README installation to a single copy-paste command Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,41 +2,73 @@
|
||||
|
||||
namespace WHMCS\Module\Server\VirtFusionDirect;
|
||||
|
||||
/**
|
||||
* Static methods that generate HTML fragments for the WHMCS admin services tab.
|
||||
*/
|
||||
class AdminHTML
|
||||
{
|
||||
|
||||
/**
|
||||
* Render the "Impersonate Server Owner" button for the admin services tab.
|
||||
*
|
||||
* @param string $systemUrl WHMCS system URL
|
||||
* @param int $serviceId VirtFusion server ID
|
||||
* @return string HTML button markup
|
||||
*/
|
||||
public static function options($systemUrl, $serviceId)
|
||||
{
|
||||
$systemUrl = htmlspecialchars($systemUrl, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
return <<<EOT
|
||||
<button onclick="impersonateServerOwner('${serviceId}', '${systemUrl}')" type="button" class="btn btn-primary">Impersonate Server Owner</button>
|
||||
<span class="text-info"> A valid VirtFusion admin session in the same browser is required for this functionality to work.</span>
|
||||
EOT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a read-only textarea containing the raw VirtFusion server JSON object.
|
||||
*
|
||||
* @param string $serverObject JSON-encoded server object from the VirtFusion API
|
||||
* @return string HTML textarea markup
|
||||
*/
|
||||
public static function serverObject($serverObject)
|
||||
{
|
||||
$serverObject = htmlspecialchars($serverObject, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
return <<<EOT
|
||||
<textarea class="form-control" name="modulefields[1]" rows="10" style="width: 100%" disabled>${serverObject}</textarea>
|
||||
EOT;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an editable text input for the VirtFusion server ID field.
|
||||
*
|
||||
* @param int $serverId Current VirtFusion server ID
|
||||
* @return string HTML input markup with a warning note
|
||||
*/
|
||||
public static function serverId($serverId)
|
||||
{
|
||||
$serverId = (int) $serverId;
|
||||
|
||||
return <<<EOT
|
||||
<input type="text" class="form-control input-200 input-inline" name="modulefields[0]" size="20" value="${serverId}" />
|
||||
<span class="text-info"> Changing the Sever ID manually is not recommended. Alterations to this field are usually handled automatically.</span>
|
||||
EOT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the inline server info panel for the admin services tab, including CSS/JS assets.
|
||||
*
|
||||
* @param string $systemUrl WHMCS system URL (used to build asset and AJAX URLs)
|
||||
* @param int $serviceId VirtFusion server ID passed to the JS data-loader
|
||||
* @return string HTML panel markup with embedded script and asset tags
|
||||
*/
|
||||
public static function serverInfo($systemUrl, $serviceId)
|
||||
{
|
||||
$systemUrl = htmlspecialchars($systemUrl, ENT_QUOTES, 'UTF-8');
|
||||
$serviceId = (int) $serviceId;
|
||||
$cacheV = time();
|
||||
|
||||
return <<<EOT
|
||||
<link href="${systemUrl}modules/servers/VirtFusionDirect/templates/css/module.css?v=${cacheV}" rel="stylesheet">
|
||||
<script src="${systemUrl}modules/servers/VirtFusionDirect/templates/js/module.js?v=${cacheV}"></script>
|
||||
@@ -117,4 +149,4 @@ EOT;
|
||||
<script>vfServerDataAdmin("${serviceId}","${systemUrl}");</script>
|
||||
EOT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user