Bearsampp 2026.9.23
Loading...
Searching...
No Matches
ActionDialogBase Class Reference
Inheritance diagram for ActionDialogBase:

Public Member Functions

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

Data Fields

const GAUGE_DELETE = 2
const GAUGE_SAVE = 2

Protected Member Functions

 createButtons ($bearsamppWinbinder)
 createFormFields ($bearsamppWinbinder)
 deleteItem ()
 getDeleteConfirmMessage ()
 getDeleteDialogTitle ()
 getDeleteErrorMessage ()
 getDeleteSuccessMessage ()
 getDialogTitle ()
 getFormValues ($bearsamppWinbinder)
 getGaugeDelete ()
 getGaugeSave ()
 getSaveErrorMessage ()
 getSaveSuccessMessage ($values)
 getWindowTitle ()
 handleCustomEvent ($window, $id, $ctrl, $param1, $param2)
 handleDelete ($window)
 handleSave ($window)
 initializeDialog ($args)
 isEditMode ()
 itemExists ($values)
 restartService ()
 saveItem ($values)
 validateInput ($values)

Protected Attributes

 $initValue
 $wbBtnCancel
 $wbBtnDelete
 $wbBtnSave
 $wbProgressBar
 $wbWindow

Detailed Description

Class ActionDialogBase

Base class for dialog-based actions (Add/Edit Alias/Vhost). This class provides common functionality for creating and managing dialog windows with form fields, validation, and save/delete operations.

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

Constructor & Destructor Documentation

◆ __construct()

__construct ( $args)

Constructor for dialog actions

Parameters
array$argsCommand line arguments

Definition at line 204 of file class.action.dialogBase.php.

205 {
206 global $bearsamppWinbinder;
207
208 // Initialize dialog (child class can load data, etc.)
209 if (!$this->initializeDialog($args)) {
210 return;
211 }
212
213 $bearsamppWinbinder->reset();
214 $this->wbWindow = $bearsamppWinbinder->createAppWindow(
215 $this->getWindowTitle(),
216 490,
217 200,
218 WBC_NOTIFY,
219 WBC_KEYDOWN | WBC_KEYUP
220 );
221
222 // Create form fields (implemented by child class)
223 $this->createFormFields($bearsamppWinbinder);
224
225 // Create progress bar and buttons
226 $this->createButtons($bearsamppWinbinder);
227
228 // Set up event handler
229 $bearsamppWinbinder->setHandler($this->wbWindow, $this, 'processWindow');
230 $bearsamppWinbinder->mainLoop();
231 $bearsamppWinbinder->reset();
232 }
createFormFields($bearsamppWinbinder)
createButtons($bearsamppWinbinder)

References createButtons(), createFormFields(), getWindowTitle(), and initializeDialog().

Here is the call graph for this function:

Member Function Documentation

◆ createButtons()

createButtons ( $bearsamppWinbinder)
protected

Create standard buttons (Save, Delete, Cancel)

Parameters
object$bearsamppWinbinderThe WinBinder instance
Returns
void

Definition at line 241 of file class.action.dialogBase.php.

242 {
243 global $bearsamppLang;
244
245 $this->wbProgressBar = $bearsamppWinbinder->createProgressBar(
246 $this->wbWindow,
247 $this->getGaugeSave() + 1,
248 15,
249 137,
250 $this->isEditMode() ? 190 : 275
251 );
252
253 if ($this->isEditMode()) {
254 // Edit mode: Save, Delete, Cancel
255 $this->wbBtnSave = $bearsamppWinbinder->createButton(
256 $this->wbWindow,
258 215,
259 132
260 );
261 $this->wbBtnDelete = $bearsamppWinbinder->createButton(
262 $this->wbWindow,
264 300,
265 132
266 );
267 $this->wbBtnCancel = $bearsamppWinbinder->createButton(
268 $this->wbWindow,
270 385,
271 132
272 );
273 } else {
274 // Add mode: Save, Cancel
275 $this->wbBtnSave = $bearsamppWinbinder->createButton(
276 $this->wbWindow,
278 300,
279 132
280 );
281 $this->wbBtnCancel = $bearsamppWinbinder->createButton(
282 $this->wbWindow,
284 387,
285 132
286 );
287 }
288 }
global $bearsamppLang
const BUTTON_CANCEL
const BUTTON_DELETE
const BUTTON_SAVE

References $bearsamppLang, Lang\BUTTON_CANCEL, Lang\BUTTON_DELETE, Lang\BUTTON_SAVE, getGaugeSave(), and isEditMode().

Referenced by __construct().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createFormFields()

createFormFields ( $bearsamppWinbinder)
abstractprotected

Create form fields specific to the dialog This method should create all input fields, labels, and buttons

Parameters
object$bearsamppWinbinderThe WinBinder instance
Returns
void

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by __construct().

Here is the caller graph for this function:

◆ deleteItem()

deleteItem ( )
abstractprotected

Delete the item

Returns
bool True on success, false on failure

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by handleDelete().

Here is the caller graph for this function:

◆ getDeleteConfirmMessage()

getDeleteConfirmMessage ( )
abstractprotected

Get delete confirmation message

Returns
string The confirmation message

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by handleDelete().

Here is the caller graph for this function:

◆ getDeleteDialogTitle()

getDeleteDialogTitle ( )
abstractprotected

Get the delete dialog title

Returns
string The delete dialog title

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by handleDelete().

Here is the caller graph for this function:

◆ getDeleteErrorMessage()

getDeleteErrorMessage ( )
abstractprotected

Get error message after delete failure

Returns
string The error message

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by handleDelete().

Here is the caller graph for this function:

◆ getDeleteSuccessMessage()

getDeleteSuccessMessage ( )
abstractprotected

Get success message after delete

Returns
string The success message

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by handleDelete().

Here is the caller graph for this function:

◆ getDialogTitle()

getDialogTitle ( )
abstractprotected

Get the dialog title for messages

Returns
string The dialog title

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by handleSave().

Here is the caller graph for this function:

◆ getFormValues()

getFormValues ( $bearsamppWinbinder)
abstractprotected

Get the current form values

Parameters
object$bearsamppWinbinderThe WinBinder instance
Returns
array Associative array of form values

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by handleSave().

Here is the caller graph for this function:

◆ getGaugeDelete()

getGaugeDelete ( )
protected

Get the gauge value for delete operation (can be overridden)

Returns
int The gauge value

Definition at line 60 of file class.action.dialogBase.php.

61 {
62 return self::GAUGE_DELETE;
63 }

Referenced by handleDelete().

Here is the caller graph for this function:

◆ getGaugeSave()

getGaugeSave ( )
protected

Get the gauge value for save operation (can be overridden)

Returns
int The gauge value

Reimplemented in ActionEditVhost.

Definition at line 50 of file class.action.dialogBase.php.

51 {
52 return self::GAUGE_SAVE;
53 }

Referenced by createButtons(), and handleSave().

Here is the caller graph for this function:

◆ getSaveErrorMessage()

getSaveErrorMessage ( )
abstractprotected

Get error message after save failure

Returns
string The error message

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by handleSave().

Here is the caller graph for this function:

◆ getSaveSuccessMessage()

getSaveSuccessMessage ( $values)
abstractprotected

Get success message after save

Parameters
array$valuesThe form values
Returns
string The success message

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by handleSave().

Here is the caller graph for this function:

◆ getWindowTitle()

getWindowTitle ( )
abstractprotected

Get the dialog window title

Returns
string The window title

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by __construct().

Here is the caller graph for this function:

◆ handleCustomEvent()

handleCustomEvent ( $window,
$id,
$ctrl,
$param1,
$param2 )
protected

Handle custom events (can be overridden by child classes)

Parameters
resource$windowThe window resource
int$idThe control ID
resource$ctrlThe control resource
mixed$param1Additional parameter 1
mixed$param2Additional parameter 2
Returns
void

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Definition at line 341 of file class.action.dialogBase.php.

342 {
343 // Default: do nothing
344 // Child classes can override to handle specific events
345 }

Referenced by processWindow().

Here is the caller graph for this function:

◆ handleDelete()

handleDelete ( $window)
protected

Handle delete operation

Parameters
resource$windowThe window resource
Returns
void

Definition at line 413 of file class.action.dialogBase.php.

414 {
415 global $bearsamppWinbinder;
416
417 $bearsamppWinbinder->setProgressBarMax($this->wbProgressBar, $this->getGaugeDelete() + 1);
418
419 // Confirm deletion
420 $confirm = $bearsamppWinbinder->messageBoxYesNo(
422 $this->getDeleteDialogTitle()
423 );
424
425 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
426
427 if ($confirm) {
428 if ($this->deleteItem()) {
429 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
430
431 // Restart service
432 $this->restartService();
433 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
434
435 // Show success message
436 $bearsamppWinbinder->messageBoxInfo(
438 $this->getDeleteDialogTitle()
439 );
440 $bearsamppWinbinder->destroyWindow($window);
441 } else {
442 $bearsamppWinbinder->messageBoxError(
443 $this->getDeleteErrorMessage(),
444 $this->getDeleteDialogTitle()
445 );
446 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
447 }
448 } else {
449 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
450 }
451 }

References deleteItem(), getDeleteConfirmMessage(), getDeleteDialogTitle(), getDeleteErrorMessage(), getDeleteSuccessMessage(), getGaugeDelete(), and restartService().

Referenced by processWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleSave()

handleSave ( $window)
protected

Handle save operation

Parameters
resource$windowThe window resource
Returns
void

Definition at line 354 of file class.action.dialogBase.php.

355 {
356 global $bearsamppWinbinder;
357
358 $bearsamppWinbinder->setProgressBarMax($this->wbProgressBar, $this->getGaugeSave() + 1);
359 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
360
361 // Get form values
362 $values = $this->getFormValues($bearsamppWinbinder);
363
364 // Validate input
365 $validation = $this->validateInput($values);
366 if (!$validation['valid']) {
367 $bearsamppWinbinder->messageBoxError(
368 $validation['error'],
369 $this->getDialogTitle()
370 );
371 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
372
373 return;
374 }
375
376 // Check if item already exists (for add or rename operations)
377 if ($this->itemExists($values)) {
378 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
379
380 return;
381 }
382
383 // Save the item
384 if ($this->saveItem($values)) {
385 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
386
387 // Restart service
388 $this->restartService();
389 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
390
391 // Show success message
392 $bearsamppWinbinder->messageBoxInfo(
393 $this->getSaveSuccessMessage($values),
394 $this->getDialogTitle()
395 );
396 $bearsamppWinbinder->destroyWindow($window);
397 } else {
398 $bearsamppWinbinder->messageBoxError(
399 $this->getSaveErrorMessage(),
400 $this->getDialogTitle()
401 );
402 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
403 }
404 }
validateInput($values)
getSaveSuccessMessage($values)
saveItem($values)
getFormValues($bearsamppWinbinder)
itemExists($values)

References getDialogTitle(), getFormValues(), getGaugeSave(), getSaveErrorMessage(), getSaveSuccessMessage(), itemExists(), restartService(), saveItem(), and validateInput().

Referenced by processWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initializeDialog()

initializeDialog ( $args)
protected

Initialize the dialog window

Parameters
array$argsCommand line arguments
Returns
bool True if initialization successful, false otherwise

Reimplemented in ActionEditAlias, and ActionEditVhost.

Definition at line 193 of file class.action.dialogBase.php.

194 {
195 // To be implemented by child classes if needed
196 return true;
197 }

Referenced by __construct().

Here is the caller graph for this function:

◆ isEditMode()

isEditMode ( )
protected

Check if this is an edit operation (has delete button)

Returns
bool True if edit operation, false if add operation

Definition at line 174 of file class.action.dialogBase.php.

175 {
176 return isset($this->initValue) && !empty($this->initValue);
177 }

Referenced by createButtons(), and processWindow().

Here is the caller graph for this function:

◆ itemExists()

itemExists ( $values)
abstractprotected

Check if the item already exists (for add/edit operations)

Parameters
array$valuesThe form values
Returns
bool True if exists, false otherwise

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by handleSave().

Here is the caller graph for this function:

◆ processWindow()

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

Process window events

Parameters
resource$windowThe window resource
int$idThe control ID
resource$ctrlThe control resource
mixed$param1Additional parameter 1
mixed$param2Additional parameter 2
Returns
void

Definition at line 301 of file class.action.dialogBase.php.

302 {
303 global $bearsamppWinbinder;
304
305 // Handle save button
306 if ($id == $this->wbBtnSave[WinBinder::CTRL_ID]) {
307 $this->handleSave($window);
308
309 return;
310 }
311
312 // Handle delete button (if in edit mode)
313 if ($this->isEditMode() && $id == $this->wbBtnDelete[WinBinder::CTRL_ID]) {
314 $this->handleDelete($window);
315
316 return;
317 }
318
319 // Handle cancel button or window close
320 if ($id == IDCLOSE || $id == $this->wbBtnCancel[WinBinder::CTRL_ID]) {
321 $bearsamppWinbinder->destroyWindow($window);
322
323 return;
324 }
325
326 // Handle custom events (implemented by child class)
327 $this->handleCustomEvent($window, $id, $ctrl, $param1, $param2);
328 }
handleCustomEvent($window, $id, $ctrl, $param1, $param2)

References WinBinder\CTRL_ID, handleCustomEvent(), handleDelete(), handleSave(), and isEditMode().

Here is the call graph for this function:

◆ restartService()

restartService ( )
abstractprotected

Restart the service after save/delete

Returns
void

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by handleDelete(), and handleSave().

Here is the caller graph for this function:

◆ saveItem()

saveItem ( $values)
abstractprotected

Save the item (create or update)

Parameters
array$valuesThe form values
Returns
bool True on success, false on failure

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by handleSave().

Here is the caller graph for this function:

◆ validateInput()

validateInput ( $values)
abstractprotected

Validate the form input

Parameters
array$valuesThe form values
Returns
array ['valid' => bool, 'error' => string|null]

Reimplemented in ActionAddAlias, ActionAddVhost, ActionEditAlias, and ActionEditVhost.

Referenced by handleSave().

Here is the caller graph for this function:

Field Documentation

◆ $initValue

$initValue
protected

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

◆ $wbBtnCancel

$wbBtnCancel
protected

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

◆ $wbBtnDelete

$wbBtnDelete
protected

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

◆ $wbBtnSave

$wbBtnSave
protected

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

◆ $wbProgressBar

$wbProgressBar
protected

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

◆ $wbWindow

$wbWindow
protected

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

◆ GAUGE_DELETE

const GAUGE_DELETE = 2

Definition at line 36 of file class.action.dialogBase.php.

◆ GAUGE_SAVE

const GAUGE_SAVE = 2

Definition at line 34 of file class.action.dialogBase.php.


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