Bearsampp
2026.7.11
Toggle main menu visibility
Loading...
Searching...
No Matches
class.tpl.app.memcached.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
16
class
TplAppMemcached
17
{
18
// Constants for menu and action identifiers
19
const
MENU
=
'memcached'
;
20
const
MENU_VERSIONS
=
'memcachedVersions'
;
21
const
MENU_SERVICE
=
'memcachedService'
;
22
23
const
ACTION_ENABLE
=
'enableMemcached'
;
24
const
ACTION_SWITCH_VERSION
=
'switchMemcachedVersion'
;
25
const
ACTION_CHANGE_PORT
=
'changeMemcachedPort'
;
26
const
ACTION_INSTALL_SERVICE
=
'installMemcachedService'
;
27
const
ACTION_REMOVE_SERVICE
=
'removeMemcachedService'
;
28
40
public
static
function
process
()
41
{
42
global
$bearsamppLang
,
$bearsamppBins
;
43
44
return
TplApp::getMenuEnable
(
$bearsamppLang
->getValue(
Lang::MEMCACHED
), self::MENU, get_called_class(),
$bearsamppBins
->getMemcached()->isEnable());
45
}
46
59
public
static
function
getMenuMemcached
()
60
{
61
global
$bearsamppRoot
,
$bearsamppBins
,
$bearsamppLang
;
62
$resultItems = $resultActions =
''
;
63
64
$isEnabled =
$bearsamppBins
->getMemcached()->isEnable();
65
66
// Download
67
$resultItems .=
TplAestan::getItemLink
(
$bearsamppLang
->getValue(
Lang::DOWNLOAD_MORE
),
68
HttpClient::getWebsiteUrl
(
'module/memcached'
,
'#releases'
),
69
false
,
70
TplAestan::GLYPH_BROWSER
71
) . PHP_EOL;
72
73
// Enable
74
$tplEnable =
TplApp::getActionMulti
(
75
self::ACTION_ENABLE, array($isEnabled ?
Config::DISABLED
:
Config::ENABLED
),
76
array(
$bearsamppLang
->getValue(
Lang::MENU_ENABLE
), $isEnabled ?
TplAestan::GLYPH_CHECK
:
''
),
77
false
, get_called_class()
78
);
79
$resultItems .= $tplEnable[
TplApp::SECTION_CALL
] . PHP_EOL;
80
$resultActions .= $tplEnable[
TplApp::SECTION_CONTENT
] . PHP_EOL;
81
82
if
($isEnabled) {
83
$resultItems .=
TplAestan::getItemSeparator
() . PHP_EOL;
84
85
// Versions
86
$tplVersions =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::VERSIONS
), self::MENU_VERSIONS, get_called_class());
87
$resultItems .= $tplVersions[
TplApp::SECTION_CALL
] . PHP_EOL;
88
$resultActions .= $tplVersions[
TplApp::SECTION_CONTENT
] . PHP_EOL;
89
90
// Service
91
$tplService =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::SERVICE
), self::MENU_SERVICE, get_called_class());
92
$resultItems .= $tplService[
TplApp::SECTION_CALL
] . PHP_EOL;
93
$resultActions .= $tplService[
TplApp::SECTION_CONTENT
];
94
95
// Update environment PATH
96
$resultItems .=
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_UPDATE_ENV_PATH
),
Path::getRootPath
() .
'/nssmEnvPaths.dat'
) . PHP_EOL;
97
98
// Log
99
$resultItems .=
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_LOGS
),
$bearsamppBins
->getMemcached()->getLog()) . PHP_EOL;
100
}
101
102
return
$resultItems . PHP_EOL . $resultActions;
103
}
104
115
public
static
function
getMenuMemcachedVersions
()
116
{
117
global
$bearsamppBins
;
118
$items =
''
;
119
$actions =
''
;
120
121
foreach
(
$bearsamppBins
->getMemcached()->getVersionList() as $version) {
122
$tplSwitchMemcachedVersion =
TplApp::getActionMulti
(
123
self::ACTION_SWITCH_VERSION, array($version),
124
array($version, $version ==
$bearsamppBins
->getMemcached()->getVersion() ?
TplAestan::GLYPH_CHECK
:
''
),
125
false
, get_called_class()
126
);
127
128
// Item
129
$items .= $tplSwitchMemcachedVersion[
TplApp::SECTION_CALL
] . PHP_EOL;
130
131
// Action
132
$actions .= PHP_EOL . $tplSwitchMemcachedVersion[
TplApp::SECTION_CONTENT
];
133
}
134
135
return
$items . $actions;
136
}
137
149
public
static
function
getActionEnableMemcached
($enable)
150
{
151
global
$bearsamppBins
;
152
153
return
TplApp::getActionRun
(
Action::ENABLE
, array(
$bearsamppBins
->getMemcached()->getName(), $enable)) . PHP_EOL .
154
TplAppReload::getActionReload
();
155
}
156
168
public
static
function
getActionSwitchMemcachedVersion
($version)
169
{
170
global
$bearsamppBins
;
171
172
return
TplApp::getActionRun
(
Action::SWITCH_VERSION
, array(
$bearsamppBins
->getMemcached()->getName(), $version)) . PHP_EOL .
173
TplAppReload::getActionReload
() . PHP_EOL;
174
}
175
188
public
static
function
getMenuMemcachedService
()
189
{
190
global
$bearsamppLang
,
$bearsamppBins
;
191
192
$tplChangePort =
TplApp::getActionMulti
(
193
self::ACTION_CHANGE_PORT,
null
,
194
array(
$bearsamppLang
->getValue(
Lang::MENU_CHANGE_PORT
),
TplAestan::GLYPH_NETWORK
),
195
false
, get_called_class()
196
);
197
198
$isInstalled =
$bearsamppBins
->getMemcached()->getService()->isInstalled();
199
200
$result
=
TplAestan::getItemActionServiceStart
(
$bearsamppBins
->getMemcached()->getService()->getName()) . PHP_EOL .
201
TplAestan::getItemActionServiceStop
(
$bearsamppBins
->getMemcached()->getService()->getName()) . PHP_EOL .
202
TplAestan::getItemActionServiceRestart
(
$bearsamppBins
->getMemcached()->getService()->getName()) . PHP_EOL .
203
TplAestan::getItemSeparator
() . PHP_EOL .
204
TplApp::getActionRun
(
205
Action::CHECK_PORT
, array(
$bearsamppBins
->getMemcached()->getName(),
$bearsamppBins
->getMemcached()->getPort()),
206
array(sprintf(
$bearsamppLang
->getValue(
Lang::MENU_CHECK_PORT
),
$bearsamppBins
->getMemcached()->getPort()),
TplAestan::GLYPH_LIGHT
)
207
) . PHP_EOL .
208
$tplChangePort[
TplApp::SECTION_CALL
] . PHP_EOL;
209
210
if
(!$isInstalled) {
211
$tplInstallService =
TplApp::getActionMulti
(
212
self::ACTION_INSTALL_SERVICE,
null
,
213
array(
$bearsamppLang
->getValue(
Lang::MENU_INSTALL_SERVICE
),
TplAestan::GLYPH_SERVICE_INSTALL
),
214
$isInstalled, get_called_class()
215
);
216
217
$result
.= $tplInstallService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
218
$tplInstallService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
219
}
else
{
220
$tplRemoveService =
TplApp::getActionMulti
(
221
self::ACTION_REMOVE_SERVICE,
null
,
222
array(
$bearsamppLang
->getValue(
Lang::MENU_REMOVE_SERVICE
),
TplAestan::GLYPH_SERVICE_REMOVE
),
223
!$isInstalled, get_called_class()
224
);
225
226
$result
.= $tplRemoveService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
227
$tplRemoveService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
228
}
229
230
$result
.= $tplChangePort[
TplApp::SECTION_CONTENT
] . PHP_EOL;
231
232
return
$result
;
233
}
234
245
public
static
function
getActionChangeMemcachedPort
()
246
{
247
global
$bearsamppBins
;
248
249
return
TplApp::getActionRun
(
Action::CHANGE_PORT
, array(
$bearsamppBins
->getMemcached()->getName())) . PHP_EOL .
250
TplAppReload::getActionReload
();
251
}
252
261
public
static
function
getActionInstallMemcachedService
()
262
{
263
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinMemcached::SERVICE_NAME
,
ActionService::INSTALL
)) . PHP_EOL .
264
TplAppReload::getActionReload
();
265
}
266
275
public
static
function
getActionRemoveMemcachedService
()
276
{
277
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinMemcached::SERVICE_NAME
,
ActionService::REMOVE
)) . PHP_EOL .
278
TplAppReload::getActionReload
();
279
}
280
}
281
$result
$result
Definition
ajax.apache.php:19
$bearsamppBins
global $bearsamppBins
Definition
ajax.apache.php:16
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
$bearsamppRoot
global $bearsamppRoot
Definition
ajax.apache.php:16
Action\SWITCH_VERSION
const SWITCH_VERSION
Definition
class.action.php:56
Action\SERVICE
const SERVICE
Definition
class.action.php:46
Action\CHANGE_PORT
const CHANGE_PORT
Definition
class.action.php:21
Action\CHECK_PORT
const CHECK_PORT
Definition
class.action.php:22
Action\ENABLE
const ENABLE
Definition
class.action.php:31
ActionService\REMOVE
const REMOVE
Definition
class.action.service.php:22
ActionService\INSTALL
const INSTALL
Definition
class.action.service.php:21
BinMemcached\SERVICE_NAME
const SERVICE_NAME
Definition
class.bin.memcached.php:18
Config\DISABLED
const DISABLED
Definition
class.config.php:36
Config\ENABLED
const ENABLED
Definition
class.config.php:35
HttpClient\getWebsiteUrl
static getWebsiteUrl($path='', $fragment='', $utmSource=true)
Definition
class.httpclient.php:134
Lang\MENU_ENABLE
const MENU_ENABLE
Definition
class.lang.php:98
Lang\SERVICE
const SERVICE
Definition
class.lang.php:67
Lang\DOWNLOAD_MORE
const DOWNLOAD_MORE
Definition
class.lang.php:41
Lang\MENU_CHANGE_PORT
const MENU_CHANGE_PORT
Definition
class.lang.php:90
Lang\MENU_INSTALL_SERVICE
const MENU_INSTALL_SERVICE
Definition
class.lang.php:102
Lang\MEMCACHED
const MEMCACHED
Definition
class.lang.php:129
Lang\MENU_UPDATE_ENV_PATH
const MENU_UPDATE_ENV_PATH
Definition
class.lang.php:122
Lang\MENU_LOGS
const MENU_LOGS
Definition
class.lang.php:105
Lang\MENU_REMOVE_SERVICE
const MENU_REMOVE_SERVICE
Definition
class.lang.php:110
Lang\MENU_CHECK_PORT
const MENU_CHECK_PORT
Definition
class.lang.php:92
Lang\VERSIONS
const VERSIONS
Definition
class.lang.php:80
Path\getRootPath
static getRootPath($aetrayPath=false)
Definition
class.path.php:309
TplAestan\GLYPH_LIGHT
const GLYPH_LIGHT
Definition
class.tpl.aestan.php:71
TplAestan\GLYPH_CHECK
const GLYPH_CHECK
Definition
class.tpl.aestan.php:61
TplAestan\GLYPH_NETWORK
const GLYPH_NETWORK
Definition
class.tpl.aestan.php:74
TplAestan\GLYPH_SERVICE_REMOVE
const GLYPH_SERVICE_REMOVE
Definition
class.tpl.aestan.php:55
TplAestan\getItemActionServiceStop
static getItemActionServiceStop($service)
Definition
class.tpl.aestan.php:335
TplAestan\GLYPH_SERVICE_INSTALL
const GLYPH_SERVICE_INSTALL
Definition
class.tpl.aestan.php:56
TplAestan\GLYPH_BROWSER
const GLYPH_BROWSER
Definition
class.tpl.aestan.php:53
TplAestan\getItemLink
static getItemLink($caption, $link, $local=false, $glyph=self::GLYPH_WEB_PAGE)
Definition
class.tpl.aestan.php:188
TplAestan\getItemNotepad
static getItemNotepad($caption, $path)
Definition
class.tpl.aestan.php:211
TplAestan\getItemActionServiceStart
static getItemActionServiceStart($service)
Definition
class.tpl.aestan.php:313
TplAestan\getItemSeparator
static getItemSeparator()
Definition
class.tpl.aestan.php:125
TplAestan\getItemActionServiceRestart
static getItemActionServiceRestart($service)
Definition
class.tpl.aestan.php:357
TplApp\getActionMulti
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
Definition
class.tpl.app.php:152
TplApp\getMenu
static getMenu($caption, $menu, $class)
Definition
class.tpl.app.php:190
TplApp\getActionRun
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)
Definition
class.tpl.app.php:115
TplApp\SECTION_CALL
const SECTION_CALL
Definition
class.tpl.app.php:23
TplApp\SECTION_CONTENT
const SECTION_CONTENT
Definition
class.tpl.app.php:24
TplApp\getMenuEnable
static getMenuEnable($caption, $menu, $class, $enabled=true)
Definition
class.tpl.app.php:212
TplAppMemcached
Definition
class.tpl.app.memcached.php:17
TplAppMemcached\getActionRemoveMemcachedService
static getActionRemoveMemcachedService()
Definition
class.tpl.app.memcached.php:275
TplAppMemcached\getMenuMemcachedService
static getMenuMemcachedService()
Definition
class.tpl.app.memcached.php:188
TplAppMemcached\ACTION_ENABLE
const ACTION_ENABLE
Definition
class.tpl.app.memcached.php:23
TplAppMemcached\MENU
const MENU
Definition
class.tpl.app.memcached.php:19
TplAppMemcached\process
static process()
Definition
class.tpl.app.memcached.php:40
TplAppMemcached\ACTION_SWITCH_VERSION
const ACTION_SWITCH_VERSION
Definition
class.tpl.app.memcached.php:24
TplAppMemcached\getActionEnableMemcached
static getActionEnableMemcached($enable)
Definition
class.tpl.app.memcached.php:149
TplAppMemcached\MENU_VERSIONS
const MENU_VERSIONS
Definition
class.tpl.app.memcached.php:20
TplAppMemcached\getMenuMemcached
static getMenuMemcached()
Definition
class.tpl.app.memcached.php:59
TplAppMemcached\MENU_SERVICE
const MENU_SERVICE
Definition
class.tpl.app.memcached.php:21
TplAppMemcached\getMenuMemcachedVersions
static getMenuMemcachedVersions()
Definition
class.tpl.app.memcached.php:115
TplAppMemcached\ACTION_INSTALL_SERVICE
const ACTION_INSTALL_SERVICE
Definition
class.tpl.app.memcached.php:26
TplAppMemcached\ACTION_REMOVE_SERVICE
const ACTION_REMOVE_SERVICE
Definition
class.tpl.app.memcached.php:27
TplAppMemcached\ACTION_CHANGE_PORT
const ACTION_CHANGE_PORT
Definition
class.tpl.app.memcached.php:25
TplAppMemcached\getActionSwitchMemcachedVersion
static getActionSwitchMemcachedVersion($version)
Definition
class.tpl.app.memcached.php:168
TplAppMemcached\getActionInstallMemcachedService
static getActionInstallMemcachedService()
Definition
class.tpl.app.memcached.php:261
TplAppMemcached\getActionChangeMemcachedPort
static getActionChangeMemcachedPort()
Definition
class.tpl.app.memcached.php:245
TplAppReload\getActionReload
static getActionReload()
Definition
class.tpl.app.reload.php:44
sandbox
core
classes
tpls
app
class.tpl.app.memcached.php
Generated by
1.17.0