2024.8.23
Loading...
Searching...
No Matches
class.tpl.app.online.php
Go to the documentation of this file.
1
<?php
2
/*
3
* Copyright (c) 2021-2024 Bearsampp
4
* License: GNU General Public License version 3 or later; see LICENSE.txt
5
* Author: bear
6
* Website: https://bearsampp.com
7
* Github: https://github.com/Bearsampp
8
*/
9
10
/**
11
* Class TplAppOnline
12
*
13
* This class provides methods to handle the online/offline status of the Bearsampp application.
14
* It includes functionalities for generating actions and menu items to switch the application
15
* between online and offline states.
16
*/
17
class
TplAppOnline
18
{
19
// Constant for the status action identifier
20
const
ACTION
=
'status'
;
21
22
/**
23
* Generates the menu item and associated actions for switching the online/offline status.
24
*
25
* This method creates a menu item for switching the application's online/offline status and defines
26
* the actions to be taken when the menu item is selected. It uses the global configuration and language
27
* objects to retrieve the current status and localized strings.
28
*
29
* @global object $bearsamppConfig Provides access to the application's configuration settings.
30
* @global object $bearsamppLang Provides language support for retrieving language-specific values.
31
*
32
* @return array The generated menu item and actions for switching the online/offline status.
33
*/
34
public
static
function
process
()
35
{
36
global
$bearsamppConfig
,
$bearsamppLang
;
37
38
return
TplApp::getActionMulti
(
39
self::ACTION, array(
$bearsamppConfig
->isOnline() ?
Config::DISABLED
:
Config::ENABLED
),
40
array(
$bearsamppConfig
->isOnline() ?
$bearsamppLang
->getValue(
Lang::MENU_PUT_OFFLINE
) :
$bearsamppLang
->getValue(
Lang::MENU_PUT_ONLINE
)),
41
false
, get_called_class()
42
);
43
}
44
45
/**
46
* Generates the action string to switch the online/offline status.
47
*
48
* This method creates the action string for switching the application's online/offline status. It includes
49
* commands to restart relevant services and reload the application. The action string is used to define
50
* what happens when the status switch action is triggered.
51
*
52
* @param int $status The status to switch to (enabled or disabled).
53
*
54
* @return string The generated action string for switching the online/offline status.
55
*/
56
public
static
function
getActionStatus
($status)
57
{
58
return
TplApp::getActionRun
(
Action::SWITCH_ONLINE
, array($status)) . PHP_EOL .
59
TplService::getActionRestart
(
BinApache::SERVICE_NAME
) . PHP_EOL .
60
TplService::getActionRestart
(
BinFilezilla::SERVICE_NAME
) . PHP_EOL .
61
TplAppReload::getActionReload
() . PHP_EOL;
62
}
63
}
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
Action\SWITCH_ONLINE
const SWITCH_ONLINE
Definition
class.action.php:50
BinApache\SERVICE_NAME
const SERVICE_NAME
Definition
class.bin.apache.php:18
BinFilezilla\SERVICE_NAME
const SERVICE_NAME
Definition
class.bin.filezilla.php:18
Config\DISABLED
const DISABLED
Definition
class.config.php:33
Config\ENABLED
const ENABLED
Definition
class.config.php:32
Lang\MENU_PUT_OFFLINE
const MENU_PUT_OFFLINE
Definition
class.lang.php:106
Lang\MENU_PUT_ONLINE
const MENU_PUT_ONLINE
Definition
class.lang.php:107
TplAppOnline
Definition
class.tpl.app.online.php:18
TplAppOnline\process
static process()
Definition
class.tpl.app.online.php:34
TplAppOnline\getActionStatus
static getActionStatus($status)
Definition
class.tpl.app.online.php:56
TplAppOnline\ACTION
const ACTION
Definition
class.tpl.app.online.php:20
TplAppReload\getActionReload
static getActionReload()
Definition
class.tpl.app.reload.php:52
TplApp\getActionMulti
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
Definition
class.tpl.app.php:152
TplApp\getActionRun
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)
Definition
class.tpl.app.php:115
TplService\getActionRestart
static getActionRestart($sName)
Definition
class.tpl.service.php:51
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:26
Bearsampp-development
sandbox
core
classes
tpls
app
class.tpl.app.online.php
Generated by
1.11.0