2024.8.23
|
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 | |
const | API_KEY = '4abe15e5-95f2-4663-ad12-eadb245b28b4' |
const | API_URL = 'https://bearsampp.com/index.php?option=com_osmembership&task=api.get_active_plan_ids&api_key=' |
const | JSON_URL = 'https://raw.githubusercontent.com/Bearsampp/Bearsampp/main/core/resources/quickpick-releases.json' |
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 17 of file class.action.quickPick.php.
QuickPick::__construct | ( | ) |
Constructor to initialize the jsonFilePath.
Definition at line 77 of file class.action.quickPick.php.
References $bearsamppCore.
QuickPick::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 295 of file class.action.quickPick.php.
References $bearsamppConfig, $response, Util\logDebug(), and Util\logError().
Referenced by getQuickpickMenu().
QuickPick::checkQuickpickJson | ( | ) |
Checks if the local quickpick-releases.json
file is up-to-date with the remote version.
This method 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 123 of file class.action.quickPick.php.
References $result, and rebuildQuickpickJson().
Referenced by loadQuickpick().
QuickPick::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 407 of file class.action.quickPick.php.
References $bearsamppCore, $bearsamppRoot, $result, getModuleDestinationPath(), Util\logDebug(), and Util\logError().
Referenced by installModule().
QuickPick::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 487 of file class.action.quickPick.php.
References $bearsamppRoot.
Referenced by fetchAndUnzipModule().
QuickPick::getModules | ( | ) |
Retrieves the list of available modules.
Definition at line 88 of file class.action.quickPick.php.
Referenced by loadQuickpick().
QuickPick::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 263 of file class.action.quickPick.php.
References getVersions(), Util\logDebug(), and Util\logError().
Referenced by installModule().
QuickPick::getQuickpickJson | ( | ) |
Retrieves the QuickPick JSON data from the local file.
Definition at line 158 of file class.action.quickPick.php.
References Util\logError().
Referenced by getVersions().
QuickPick::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 520 of file class.action.quickPick.php.
References $imagesPath, checkDownloadId(), Util\checkInternetState(), and Util\getWebsiteUrl().
Referenced by loadQuickpick().
QuickPick::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 218 of file class.action.quickPick.php.
References $versions, getQuickpickJson(), Util\logDebug(), and Util\logError().
Referenced by getModuleUrl(), and loadQuickpick().
QuickPick::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 368 of file class.action.quickPick.php.
References $response, Util\checkInternetState(), fetchAndUnzipModule(), getModuleUrl(), Util\logDebug(), and Util\logError().
QuickPick::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 102 of file class.action.quickPick.php.
References $modules, $versions, checkQuickpickJson(), getModules(), getQuickpickMenu(), and getVersions().
QuickPick::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 183 of file class.action.quickPick.php.
References $result, JSON_URL, and Util\logDebug().
Referenced by checkQuickpickJson().
|
private |
The file path to the local quickpick-releases.json file.
Definition at line 72 of file class.action.quickPick.php.
QuickPick::$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 35 of file class.action.quickPick.php.
Referenced by 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 65 of file class.action.quickPick.php.
Referenced by getVersions(), and loadQuickpick().
const QuickPick::API_KEY = '4abe15e5-95f2-4663-ad12-eadb245b28b4' |
Definition at line 20 of file class.action.quickPick.php.
const QuickPick::API_URL = 'https://bearsampp.com/index.php?option=com_osmembership&task=api.get_active_plan_ids&api_key=' |
Definition at line 21 of file class.action.quickPick.php.
const QuickPick::JSON_URL = 'https://raw.githubusercontent.com/Bearsampp/Bearsampp/main/core/resources/quickpick-releases.json' |
Definition at line 24 of file class.action.quickPick.php.
Referenced by rebuildQuickpickJson().