2024.8.23
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 19 of file class.action.checkVersion.php.

Constructor & Destructor Documentation

◆ __construct()

ActionCheckVersion::__construct ( $args)

Constructor for the ActionCheckVersion class.

Parameters
array$argsCommand line arguments passed to the script.

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

39 {
40 global $bearsamppCore, $bearsamppLang, $bearsamppWinbinder, $appGithubHeader;
41
42 if (!file_exists($bearsamppCore->getExec())) {
44 $this->currentVersion = $bearsamppCore->getAppVersion();
45
46 // Assuming getLatestVersion now returns an array with version and URL
48
49 if ($githubVersionData != null && isset($githubVersionData['version'], $githubVersionData['html_url'])) {
51 $this->githubLatestVersionUrl = $githubVersionData['html_url']; // URL of the latest version
52 if (version_compare($this->currentVersion, $githubLatestVersion, '<')) {
53 $this->showVersionUpdateWindow($bearsamppLang, $bearsamppWinbinder, $bearsamppCore, $githubLatestVersion);
54 } elseif (!empty($args[0]) && $args[0] == self::DISPLAY_OK) {
55 $this->showVersionOkMessageBox($bearsamppLang, $bearsamppWinbinder);
56 }
57 }
58 }
59 }
global $bearsamppLang
global $githubVersionData
$githubLatestVersion
global $bearsamppCore
showVersionOkMessageBox($lang, $winbinder)
showVersionUpdateWindow($lang, $winbinder, $core, $githubLatestVersion)
static getLatestVersion($url)
static startLoading()
const APP_GITHUB_LATEST_URL
Definition root.php:18

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

Member Function Documentation

◆ processWindow()

ActionCheckVersion::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 113 of file class.action.checkVersion.php.

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

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

◆ showVersionOkMessageBox()

ActionCheckVersion::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 95 of file class.action.checkVersion.php.

96 {
98 $winbinder->messageBoxInfo(
99 $lang->getValue(Lang::CHECK_VERSION_LATEST_TEXT),
100 $lang->getValue(Lang::CHECK_VERSION_TITLE)
101 );
102 }
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().

+ Here is the caller graph for this function:

◆ showVersionUpdateWindow()

ActionCheckVersion::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 69 of file class.action.checkVersion.php.

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

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

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $currentVersion

ActionCheckVersion::$currentVersion
private

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

◆ $githubLatestVersionUrl

ActionCheckVersion::$githubLatestVersionUrl
private

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

◆ $latestVersion

ActionCheckVersion::$latestVersion
private

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

◆ $wbBtnOk

ActionCheckVersion::$wbBtnOk
private

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

◆ $wbImage

ActionCheckVersion::$wbImage
private

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

◆ $wbLinkChangelog

ActionCheckVersion::$wbLinkChangelog
private

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

◆ $wbLinkFull

ActionCheckVersion::$wbLinkFull
private

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

◆ $wbWindow

ActionCheckVersion::$wbWindow
private

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

◆ DISPLAY_OK

const ActionCheckVersion::DISPLAY_OK = 'displayOk'

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

Referenced by TplApp\getSectionMenuRight().


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