Bearsampp 2025.8.29
Loading...
Searching...
No Matches
ActionCheckVersion Class Reference

Public Member Functions

 __construct ($args)
 processWindow ($window, $id, $ctrl, $param1, $param2)

Data Fields

const DISPLAY_OK = 'displayOk'

Private Member Functions

 showVersionOkMessageBox ($lang, $winbinder)
 showVersionUpdateWindow ($lang, $winbinder, $core, $githubLatestVersion)

Private Attributes

 $currentVersion
 $githubLatestVersionUrl
 $latestVersion
 $wbBtnOk
 $wbImage
 $wbLinkChangelog
 $wbLinkFull
 $wbWindow

Detailed Description

Definition at line 20 of file class.action.checkVersion.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $args)

Constructor for the ActionCheckVersion class.

Parameters
array$argsCommand line arguments passed to the script.

Definition at line 39 of file class.action.checkVersion.php.

40 {
41 global $bearsamppCore, $bearsamppLang, $bearsamppWinbinder, $appGithubHeader;
42
43 // Check if we're being called from the version check menu item
44 $isMenuCheck = !empty($args[0]) && $args[0] == self::DISPLAY_OK;
45
46 // Start loading only if the exec file doesn't exist or if we're doing a menu check
47 if (!file_exists($bearsamppCore->getExec()) || $isMenuCheck) {
49 $this->currentVersion = $bearsamppCore->getAppVersion();
50
51 // Assuming getLatestVersion now returns an array with version and URL
53
54 if ($githubVersionData != null && isset($githubVersionData['version'], $githubVersionData['html_url'])) {
56 $this->githubLatestVersionUrl = $githubVersionData['html_url']; // URL of the latest version
57 if (version_compare($this->currentVersion, $githubLatestVersion, '<')) {
59 } elseif ($isMenuCheck) {
60 $this->showVersionOkMessageBox($bearsamppLang, $bearsamppWinbinder);
61 }
62 }
63 }
64 }
global $bearsamppLang
global $githubVersionData
$githubLatestVersion
global $bearsamppCore
showVersionUpdateWindow($lang, $winbinder, $core, $githubLatestVersion)
showVersionOkMessageBox($lang, $winbinder)
static getLatestVersion($url)
static startLoading()
const APP_GITHUB_LATEST_URL
Definition root.php:19

References $bearsamppCore, $bearsamppLang, $githubLatestVersion, $githubVersionData, APP_GITHUB_LATEST_URL, Util\getLatestVersion(), showVersionOkMessageBox(), showVersionUpdateWindow(), and Util\startLoading().

Member Function Documentation

◆ processWindow()

processWindow ( $window,
$id,
$ctrl,
$param1,
$param2 )

Processes window events and handles user interactions.

Parameters
resource$windowThe window resource.
int$idThe control ID that triggered the event.
resource$ctrlThe control resource.
mixed$param1Additional parameter 1.
mixed$param2Additional parameter 2.

Definition at line 118 of file class.action.checkVersion.php.

119 {
120 global $bearsamppConfig, $bearsamppWinbinder;
121
122 switch ($id) {
123 case $this->wbLinkFull[WinBinder::CTRL_ID]:
124 $latestVersionInfo = Util::getLatestVersion(APP_GITHUB_LATEST_URL);
125 if ($latestVersionInfo && isset($latestVersionInfo['html_url'])) {
126 $browserPath = $bearsamppConfig->getBrowser();
127 if (!$bearsamppWinbinder->exec($browserPath, $latestVersionInfo['html_url'])) {
128 Util::logError("Failed to open browser at path: $browserPath with URL: " . $latestVersionInfo['html_url']);
129 }
130 } else {
131 Util::logError("Failed to retrieve latest version info or 'html_url' not set.");
132 }
133 break;
134 case IDCLOSE:
135 case $this->wbBtnOk[WinBinder::CTRL_ID]:
136 $bearsamppWinbinder->destroyWindow($window);
137 break;
138 default:
139 Util::logError("Unhandled window control ID: $id");
140 }
141 }
static logError($data, $file=null)
global $bearsamppConfig
Definition homepage.php:27

References $bearsamppConfig, APP_GITHUB_LATEST_URL, WinBinder\CTRL_ID, Util\getLatestVersion(), and Util\logError().

◆ showVersionOkMessageBox()

showVersionOkMessageBox ( $lang,
$winbinder )
private

Displays a message box indicating that the current version is the latest.

Parameters
Lang$langLanguage processor instance.
WinBinder$winbinderWinBinder instance for creating windows and controls.

Definition at line 100 of file class.action.checkVersion.php.

101 {
103 $winbinder->messageBoxInfo(
104 $lang->getValue(Lang::CHECK_VERSION_LATEST_TEXT),
105 $lang->getValue(Lang::CHECK_VERSION_TITLE)
106 );
107 }
const CHECK_VERSION_LATEST_TEXT
const CHECK_VERSION_TITLE
static stopLoading()

References Lang\CHECK_VERSION_LATEST_TEXT, Lang\CHECK_VERSION_TITLE, and Util\stopLoading().

Referenced by __construct().

◆ showVersionUpdateWindow()

showVersionUpdateWindow ( $lang,
$winbinder,
$core,
$githubLatestVersion )
private

Displays a window with the latest version information.

Parameters
Lang$langLanguage processor instance.
WinBinder$winbinderWinBinder instance for creating windows and controls.
Core$coreCore instance for accessing application resources.
string$githubLatestVersionThe latest version available on GitHub.

Definition at line 74 of file class.action.checkVersion.php.

75 {
76 $labelFullLink = $lang->getValue(Lang::DOWNLOAD) . ' ' . APP_TITLE . ' ' . $githubLatestVersion;
77
78 $winbinder->reset();
79 $this->wbWindow = $winbinder->createAppWindow($lang->getValue(Lang::CHECK_VERSION_TITLE), 380, 170, WBC_NOTIFY, WBC_KEYDOWN | WBC_KEYUP);
80
81 $winbinder->createLabel($this->wbWindow, $lang->getValue(Lang::CHECK_VERSION_AVAILABLE_TEXT), 80, 35, 370, 120);
82
83 $this->wbLinkFull = $winbinder->createHyperLink($this->wbWindow, $labelFullLink, 80, 87, 200, 20, WBC_LINES | WBC_RIGHT);
84
85 $this->wbBtnOk = $winbinder->createButton($this->wbWindow, $lang->getValue(Lang::BUTTON_OK), 280, 103);
86 $this->wbImage = $winbinder->drawImage($this->wbWindow, $core->getImagesPath() . '/about.bmp');
87
89 $winbinder->setHandler($this->wbWindow, $this, 'processWindow');
90 $winbinder->mainLoop();
91 $winbinder->reset();
92 }
const CHECK_VERSION_AVAILABLE_TEXT
const DOWNLOAD
const BUTTON_OK
const APP_TITLE
Definition root.php:13

References $githubLatestVersion, APP_TITLE, Lang\BUTTON_OK, Lang\CHECK_VERSION_AVAILABLE_TEXT, Lang\CHECK_VERSION_TITLE, Lang\DOWNLOAD, and Util\stopLoading().

Referenced by __construct().

Field Documentation

◆ $currentVersion

$currentVersion
private

Definition at line 30 of file class.action.checkVersion.php.

◆ $githubLatestVersionUrl

$githubLatestVersionUrl
private

Definition at line 32 of file class.action.checkVersion.php.

◆ $latestVersion

$latestVersion
private

Definition at line 31 of file class.action.checkVersion.php.

◆ $wbBtnOk

$wbBtnOk
private

Definition at line 28 of file class.action.checkVersion.php.

◆ $wbImage

$wbImage
private

Definition at line 25 of file class.action.checkVersion.php.

◆ $wbLinkChangelog

$wbLinkChangelog
private

Definition at line 26 of file class.action.checkVersion.php.

◆ $wbLinkFull

$wbLinkFull
private

Definition at line 27 of file class.action.checkVersion.php.

◆ $wbWindow

$wbWindow
private

Definition at line 24 of file class.action.checkVersion.php.

◆ DISPLAY_OK

const DISPLAY_OK = 'displayOk'

Definition at line 22 of file class.action.checkVersion.php.

Referenced by TplApp\getSectionMenuRight().


The documentation for this class was generated from the following file: