![]() |
Bearsampp 2025.8.29
|
Public Member Functions | |
__construct () | |
checkDownloadId () | |
checkQuickpickJson () | |
fetchAndUnzipModule (string $moduleUrl, string $module) | |
getModuleDestinationPath (string $moduleType, string $moduleName) | |
getModules () | |
getModuleUrl (string $module, string $version) | |
getQuickpickJson () | |
getQuickpickMenu (array $modules, array $versions, string $imagesPath) | |
getVersions () | |
installModule (string $module, string $version) | |
loadQuickpick (string $imagesPath) | |
rebuildQuickpickJson () |
Data Fields | |
$modules |
Private Member Functions | |
formatVersionLabel ($version, $isPrerelease=false) | |
getLocalFileCreationTime () | |
isValidHeaderResponse ($headers) | |
logHeaders (array $headers) |
Private Attributes | |
$jsonFilePath | |
$versions = [] |
Class QuickPick
The QuickPick class provides functionalities for managing and installing various modules within the Bearsampp application. It includes methods for retrieving available modules, fetching module versions, parsing release properties, and validating license keys.
Definition at line 18 of file class.action.quickPick.php.
__construct | ( | ) |
Constructor to initialize the jsonFilePath.
Definition at line 69 of file class.action.quickPick.php.
References $bearsamppCore.
checkDownloadId | ( | ) |
Validates the format of a given username key by checking it against an external API.
This method performs several checks to ensure the validity of the username key:
Definition at line 341 of file class.action.quickPick.php.
References $bearsamppConfig, $response, Util\logDebug(), Util\logError(), QUICKPICK_API_KEY, and QUICKPICK_API_URL.
Referenced by getQuickpickMenu().
checkQuickpickJson | ( | ) |
Checks if the local quickpick-releases.json file is up-to-date with the remote version.
Compares the creation time of the local JSON file with the remote file's last modified time. If the remote file is newer or the local file does not exist, it fetches the latest JSON data by calling the rebuildQuickpickJson method.
Exception |
Definition at line 133 of file class.action.quickPick.php.
References $bearsamppConfig, getLocalFileCreationTime(), isValidHeaderResponse(), logHeaders(), QUICKPICK_JSON_URL, and rebuildQuickpickJson().
Referenced by loadQuickpick().
fetchAndUnzipModule | ( | string | $moduleUrl, |
string | $module ) |
Fetches the module URL and stores it in /tmp, then unzips the file based on its extension.
string | $moduleUrl | The URL of the module to fetch. |
string | $module | The name of the module. |
Definition at line 453 of file class.action.quickPick.php.
References $bearsamppCore, $bearsamppRoot, $result, getModuleDestinationPath(), Util\logDebug(), and Util\logError().
Referenced by installModule().
|
private |
Format version label with PR indicator if it's a prerelease
string | $version | The version to format |
bool | $isPrerelease | Whether this version is a prerelease |
Definition at line 82 of file class.action.quickPick.php.
References $bearsamppConfig.
|
private |
Returns the local file's creation time, or triggers and returns 0 if file does not exist.
Definition at line 163 of file class.action.quickPick.php.
References rebuildQuickpickJson().
Referenced by checkQuickpickJson().
getModuleDestinationPath | ( | string | $moduleType, |
string | $moduleName ) |
Get the destination path for a given module type and name.
This method constructs the destination path based on the type of module (application, binary, or tools) and the module name. It utilizes the bearsamppRoot global object to retrieve the base paths for each module type.
string | $moduleType | The type of the module ('application', 'binary', or 'tools'). |
string | $moduleName | The name of the module. |
Definition at line 530 of file class.action.quickPick.php.
References $bearsamppRoot.
Referenced by fetchAndUnzipModule().
getModules | ( | ) |
Retrieves the list of available modules.
Definition at line 98 of file class.action.quickPick.php.
Referenced by loadQuickpick().
getModuleUrl | ( | string | $module, |
string | $version ) |
Fetches the URL of a specified module version from the local quickpick-releases.json file.
This method reads the quickpick-releases.json file to find the URL associated with the given module and version. It logs the process and returns the URL if found, or an error message if not.
string | $module | The name of the module. |
string | $version | The version of the module. |
Definition at line 309 of file class.action.quickPick.php.
References getVersions(), Util\logDebug(), and Util\logError().
Referenced by installModule().
getQuickpickJson | ( | ) |
Retrieves the QuickPick JSON data from the local file.
Definition at line 207 of file class.action.quickPick.php.
References Util\logError().
Referenced by getVersions().
getQuickpickMenu | ( | array | $modules, |
array | $versions, | ||
string | $imagesPath ) |
Generates the HTML content for the QuickPick menu.
This method creates the HTML structure for the QuickPick interface, including a dropdown for selecting modules and their respective versions. It checks if the license key is valid before displaying the modules. If the license key is invalid, it displays a subscription prompt. If there is no internet connection, it displays a message indicating the lack of internet.
array | $modules | An array of available modules. |
array | $versions | An associative array where the key is the module name and the value is an array containing the module versions. |
string | $imagesPath | The path to the images directory. |
Definition at line 563 of file class.action.quickPick.php.
References $bearsamppConfig, $imagesPath, $modules, $versions, checkDownloadId(), Util\checkInternetState(), and Util\getWebsiteUrl().
Referenced by loadQuickpick().
getVersions | ( | ) |
Retrieves the list of available versions for all modules.
This method fetches the QuickPick JSON data and returns an array of versions or If no versions are found, an error message is logged and returned.
Definition at line 264 of file class.action.quickPick.php.
References $versions, getQuickpickJson(), Util\logDebug(), and Util\logError().
Referenced by getModuleUrl(), and loadQuickpick().
installModule | ( | string | $module, |
string | $version ) |
Installs a specified module by fetching its URL and unzipping its contents.
This method retrieves the URL of the specified module and version from the QuickPick JSON data. If the URL is found, it fetches and unzips the module. If the URL is not found, it logs an error and returns an error message.
string | $module | The name of the module to install. |
string | $version | The version of the module to install. |
Definition at line 414 of file class.action.quickPick.php.
References $response, Util\checkInternetState(), fetchAndUnzipModule(), getModuleUrl(), Util\logDebug(), and Util\logError().
|
private |
Determines whether the header response is valid and includes a 'Date' key.
mixed | $headers | Headers retrieved from get_headers(). |
Definition at line 179 of file class.action.quickPick.php.
Referenced by checkQuickpickJson().
loadQuickpick | ( | string | $imagesPath | ) |
Loads the QuickPick interface with the available modules and their versions.
string | $imagesPath | The path to the images directory. |
Exception |
Definition at line 112 of file class.action.quickPick.php.
References $imagesPath, $modules, $versions, checkQuickpickJson(), getModules(), getQuickpickMenu(), and getVersions().
|
private |
Logs the headers in debug mode if logsVerbose is set to 2.
array | $headers | The headers returned by get_headers(). |
Definition at line 193 of file class.action.quickPick.php.
References $bearsamppConfig, and Util\logDebug().
Referenced by checkQuickpickJson().
rebuildQuickpickJson | ( | ) |
Rebuilds the local quickpick-releases.json file by fetching the latest data from the remote URL.
Exception | If the JSON content cannot be fetched or saved. |
Definition at line 232 of file class.action.quickPick.php.
References $result, Util\logDebug(), and QUICKPICK_JSON_URL.
Referenced by checkQuickpickJson(), and getLocalFileCreationTime().
|
private |
The file path to the local quickpick-releases.json file.
Definition at line 64 of file class.action.quickPick.php.
$modules |
An associative array where the key is the module name and the value is an array containing the module type. The module type can be one of the following:
Definition at line 29 of file class.action.quickPick.php.
Referenced by getQuickpickMenu(), and loadQuickpick().
|
private |
An associative array where the key is the module name and the value is an array containing the module versions.
Definition at line 57 of file class.action.quickPick.php.
Referenced by getQuickpickMenu(), getVersions(), and loadQuickpick().