2024.8.23
Loading...
Searching...
No Matches
ActionGenSslCertificate Class Reference

Public Member Functions

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

Data Fields

const GAUGE_SAVE = 2
 

Private Attributes

 $wbBtnCancel
 
 $wbBtnDest
 
 $wbBtnSave
 
 $wbInputDest
 
 $wbInputName
 
 $wbLabelDest
 
 $wbLabelName
 
 $wbProgressBar
 
 $wbWindow
 

Detailed Description

Class ActionGenSslCertificate

This class handles the generation of SSL certificates through a WinBinder GUI. It provides a user interface for inputting the server name and target directory, and includes functionality for browsing directories, saving the certificate, and displaying progress.

Definition at line 17 of file class.action.genSslCertificate.php.

Constructor & Destructor Documentation

◆ __construct()

ActionGenSslCertificate::__construct ( $args)

Constructor for ActionGenSslCertificate.

Initializes the WinBinder window and its controls, sets up event handlers, and starts the main loop.

Parameters
array$argsCommand line arguments passed to the script.

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

39 {
40 global $bearsamppRoot, $bearsamppLang, $bearsamppWinbinder;
41
42 $initServerName = 'test.local';
43 $initDocumentRoot = Util::formatWindowsPath($bearsamppRoot->getSslPath());
44
45 $bearsamppWinbinder->reset();
46 $this->wbWindow = $bearsamppWinbinder->createAppWindow($bearsamppLang->getValue(Lang::GENSSL_TITLE), 490, 160, WBC_NOTIFY, WBC_KEYDOWN | WBC_KEYUP);
47
48 $this->wbLabelName = $bearsamppWinbinder->createLabel($this->wbWindow, $bearsamppLang->getValue(Lang::NAME) . ' :', 15, 15, 85, null, WBC_RIGHT);
49 $this->wbInputName = $bearsamppWinbinder->createInputText($this->wbWindow, $initServerName, 105, 13, 150, null);
50
51 $this->wbLabelDest = $bearsamppWinbinder->createLabel($this->wbWindow, $bearsamppLang->getValue(Lang::TARGET) . ' :', 15, 45, 85, null, WBC_RIGHT);
52 $this->wbInputDest = $bearsamppWinbinder->createInputText($this->wbWindow, $initDocumentRoot, 105, 43, 190, null, null, WBC_READONLY);
53 $this->wbBtnDest = $bearsamppWinbinder->createButton($this->wbWindow, $bearsamppLang->getValue(Lang::BUTTON_BROWSE), 300, 43, 110);
54
55 $this->wbProgressBar = $bearsamppWinbinder->createProgressBar($this->wbWindow, self::GAUGE_SAVE + 1, 15, 97, 275);
56 $this->wbBtnSave = $bearsamppWinbinder->createButton($this->wbWindow, $bearsamppLang->getValue(Lang::BUTTON_SAVE), 300, 92);
57 $this->wbBtnCancel = $bearsamppWinbinder->createButton($this->wbWindow, $bearsamppLang->getValue(Lang::BUTTON_CANCEL), 387, 92);
58
59 $bearsamppWinbinder->setHandler($this->wbWindow, $this, 'processWindow');
60 $bearsamppWinbinder->mainLoop();
61 $bearsamppWinbinder->reset();
62 }
global $bearsamppLang
global $bearsamppRoot
const BUTTON_CANCEL
const BUTTON_SAVE
const NAME
const GENSSL_TITLE
const TARGET
const BUTTON_BROWSE
static formatWindowsPath($path)

References $bearsamppLang, $bearsamppRoot, Lang\BUTTON_BROWSE, Lang\BUTTON_CANCEL, Lang\BUTTON_SAVE, Util\formatWindowsPath(), Lang\GENSSL_TITLE, Lang\NAME, and Lang\TARGET.

Member Function Documentation

◆ processWindow()

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

Processes window events.

Handles button clicks and other window events, such as browsing for a directory, saving the SSL certificate, and closing the window.

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

Definition at line 76 of file class.action.genSslCertificate.php.

77 {
78 global $bearsamppLang, $bearsamppOpenSsl, $bearsamppWinbinder;
79
80 $name = $bearsamppWinbinder->getText($this->wbInputName[WinBinder::CTRL_OBJ]);
81 $target = $bearsamppWinbinder->getText($this->wbInputDest[WinBinder::CTRL_OBJ]);
82
83 switch ($id) {
84 case $this->wbBtnDest[WinBinder::CTRL_ID]:
85 $target = $bearsamppWinbinder->sysDlgPath($window, $bearsamppLang->getValue(Lang::GENSSL_PATH), $target);
86 if ($target && is_dir($target)) {
87 $bearsamppWinbinder->setText($this->wbInputDest[WinBinder::CTRL_OBJ], $target . '\\');
88 }
89 break;
90 case $this->wbBtnSave[WinBinder::CTRL_ID]:
91 $bearsamppWinbinder->setProgressBarMax($this->wbProgressBar, self::GAUGE_SAVE + 1);
92 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
93
94 $target = Util::formatUnixPath($target);
95 if ($bearsamppOpenSsl->createCrt($name, $target)) {
96 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
97 $bearsamppWinbinder->messageBoxInfo(
98 sprintf($bearsamppLang->getValue(Lang::GENSSL_CREATED), $name),
100 $bearsamppWinbinder->destroyWindow($window);
101 } else {
102 $bearsamppWinbinder->messageBoxError($bearsamppLang->getValue(Lang::GENSSL_CREATED_ERROR), $bearsamppLang->getValue(Lang::GENSSL_TITLE));
103 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
104 }
105 break;
106 case IDCLOSE:
107 case $this->wbBtnCancel[WinBinder::CTRL_ID]:
108 $bearsamppWinbinder->destroyWindow($window);
109 break;
110 }
111 }
const GENSSL_CREATED
const GENSSL_PATH
const GENSSL_CREATED_ERROR
static formatUnixPath($path)

References $bearsamppLang, WinBinder\CTRL_ID, WinBinder\CTRL_OBJ, Util\formatUnixPath(), Lang\GENSSL_CREATED, Lang\GENSSL_CREATED_ERROR, Lang\GENSSL_PATH, and Lang\GENSSL_TITLE.

Field Documentation

◆ $wbBtnCancel

ActionGenSslCertificate::$wbBtnCancel
private

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

◆ $wbBtnDest

ActionGenSslCertificate::$wbBtnDest
private

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

◆ $wbBtnSave

ActionGenSslCertificate::$wbBtnSave
private

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

◆ $wbInputDest

ActionGenSslCertificate::$wbInputDest
private

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

◆ $wbInputName

ActionGenSslCertificate::$wbInputName
private

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

◆ $wbLabelDest

ActionGenSslCertificate::$wbLabelDest
private

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

◆ $wbLabelName

ActionGenSslCertificate::$wbLabelName
private

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

◆ $wbProgressBar

ActionGenSslCertificate::$wbProgressBar
private

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

◆ $wbWindow

ActionGenSslCertificate::$wbWindow
private

Definition at line 19 of file class.action.genSslCertificate.php.

◆ GAUGE_SAVE

const ActionGenSslCertificate::GAUGE_SAVE = 2

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


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