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 */
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 {
37
39 self::ACTION, array($bearsamppConfig->isOnline() ? Config::DISABLED : Config::ENABLED),
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 .
62 }
63}
global $bearsamppLang
const SWITCH_ONLINE
const DISABLED
const ENABLED
const MENU_PUT_OFFLINE
const MENU_PUT_ONLINE
static getActionStatus($status)
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)
static getActionRestart($sName)
global $bearsamppConfig
Definition homepage.php:26