Bearsampp 2026.9.23
Loading...
Searching...
No Matches
TplAppPhp Class Reference

Static Public Member Functions

static getActionEnablePhp ($enable)
static getActionSwitchPhpExtension ($extension, $switch)
static getActionSwitchPhpSetting ($setting, $enabled)
static getActionSwitchPhpVersion ($version)
static getMenuPhp ()
static getMenuPhpExtensions ()
static getMenuPhpSettings ()
static getMenuPhpVersions ()
static process ()

Data Fields

const ACTION_ENABLE = 'enablePhp'
const ACTION_SWITCH_EXTENSION = 'switchPhpExtension'
const ACTION_SWITCH_SETTING = 'switchPhpSetting'
const ACTION_SWITCH_VERSION = 'switchPhpVersion'
const MENU = 'php'
const MENU_EXTENSIONS = 'phpExtensions'
const MENU_SETTINGS = 'phpSettings'
const MENU_VERSIONS = 'phpVersions'

Static Private Member Functions

static getSubmenuPhpSettings ($passThr=array(), $result=array(), $settings=array(), $sectionCall=true)

Detailed Description

Class TplAppPhp

This class provides methods to generate menu items and actions for managing PHP within the Bearsampp application. It includes functionalities for enabling/disabling PHP, switching versions, and managing PHP settings and extensions.

Definition at line 17 of file class.tpl.app.php.php.

Member Function Documentation

◆ getActionEnablePhp()

getActionEnablePhp ( $enable)
static

Generates the action to enable or disable PHP.

Parameters
int$enableThe enable flag (1 to enable, 0 to disable).
Returns
string The generated action string to enable or disable PHP. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 155 of file class.tpl.app.php.php.

156 {
157 global $bearsamppBins;
158
159 return TplApp::getActionRun(Action::ENABLE, array($bearsamppBins->getPhp()->getName(), $enable)) . PHP_EOL .
161 }
global $bearsamppBins
const ENABLE
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)

References $bearsamppBins, Action\ENABLE, TplAppReload\getActionReload(), and TplApp\getActionRun().

Here is the call graph for this function:

◆ getActionSwitchPhpExtension()

getActionSwitchPhpExtension ( $extension,
$switch )
static

Generates the action to switch a PHP extension.

Parameters
string$extensionThe PHP extension to switch.
string$switchThe current state of the extension (on or off).
Returns
string The generated action string to switch the PHP extension.

Definition at line 354 of file class.tpl.app.php.php.

References TplAppReload\getActionReload(), TplService\getActionRestart(), TplApp\getActionRun(), BinApache\SERVICE_NAME, ActionSwitchPhpExtension\SWITCH_OFF, ActionSwitchPhpExtension\SWITCH_ON, and Action\SWITCH_PHP_EXTENSION.

Here is the call graph for this function:

◆ getActionSwitchPhpSetting()

getActionSwitchPhpSetting ( $setting,
$enabled )
static

Generates the action to switch a PHP setting.

Parameters
string$settingThe PHP setting to switch.
bool$enabledThe current state of the setting (true if enabled, false otherwise).
Returns
string The generated action string to switch the PHP setting.

Definition at line 305 of file class.tpl.app.php.php.

References TplAppReload\getActionReload(), TplService\getActionRestart(), TplApp\getActionRun(), BinApache\SERVICE_NAME, ActionSwitchPhpParam\SWITCH_OFF, ActionSwitchPhpParam\SWITCH_ON, and Action\SWITCH_PHP_PARAM.

Here is the call graph for this function:

◆ getActionSwitchPhpVersion()

getActionSwitchPhpVersion ( $version)
static

Generates the action to switch the PHP version.

Parameters
string$versionThe PHP version to switch to.
Returns
string The generated action string to switch the PHP version. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 172 of file class.tpl.app.php.php.

173 {
174 global $bearsamppBins;
175
176 return TplApp::getActionRun(Action::SWITCH_VERSION, array($bearsamppBins->getPhp()->getName(), $version)) . PHP_EOL .
178 }
const SWITCH_VERSION

References $bearsamppBins, TplAppReload\getActionReload(), TplApp\getActionRun(), and Action\SWITCH_VERSION.

Here is the call graph for this function:

◆ getMenuPhp()

getMenuPhp ( )
static

Generates the PHP menu items and actions.

Returns
string The generated PHP menu items and actions. @global object $bearsamppLang Provides language support for retrieving language-specific values.

@global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 52 of file class.tpl.app.php.php.

53 {
55 $resultItems = $resultActions = '';
56
57 $isEnabled = $bearsamppBins->getPhp()->isEnable();
58
59 // Download
60 $resultItems .= TplAestan::getItemLink(
62 HttpClient::getWebsiteUrl('module/php', '#releases'),
63 false,
65 ) . PHP_EOL;
66
67 // Enable
68 $tplEnable = TplApp::getActionMulti(
69 self::ACTION_ENABLE,
70 array($isEnabled ? Config::DISABLED : Config::ENABLED),
71 array($bearsamppLang->getValue(Lang::MENU_ENABLE), $isEnabled ? TplAestan::GLYPH_CHECK : ''),
72 false,
73 get_called_class()
74 );
75 $resultItems .= $tplEnable[TplApp::SECTION_CALL] . PHP_EOL;
76 $resultActions .= $tplEnable[TplApp::SECTION_CONTENT] . PHP_EOL;
77
78 if ($isEnabled) {
79 $resultItems .= TplAestan::getItemSeparator() . PHP_EOL;
80
81 // Versions
82 $tplVersions = TplApp::getMenu($bearsamppLang->getValue(Lang::VERSIONS), self::MENU_VERSIONS, get_called_class());
83 $resultItems .= $tplVersions[TplApp::SECTION_CALL] . PHP_EOL;
84 $resultActions .= $tplVersions[TplApp::SECTION_CONTENT] . PHP_EOL;
85
86 // Settings
87 $tplSettings = TplApp::getMenu($bearsamppLang->getValue(Lang::SETTINGS), self::MENU_SETTINGS, get_called_class());
88 $resultItems .= $tplSettings[TplApp::SECTION_CALL] . PHP_EOL;
89 $resultActions .= $tplSettings[TplApp::SECTION_CONTENT] . PHP_EOL;
90
91 // Extensions
92 $tplExtensions = TplApp::getMenu($bearsamppLang->getValue(Lang::EXTENSIONS), self::MENU_EXTENSIONS, get_called_class());
93 $resultItems .= $tplExtensions[TplApp::SECTION_CALL] . PHP_EOL;
94 $resultActions .= $tplExtensions[TplApp::SECTION_CONTENT];
95
96 // Conf
97 $resultItems .= TplAestan::getItemNotepad(basename($bearsamppBins->getPhp()->getConf()), $bearsamppBins->getPhp()->getConf()) . PHP_EOL;
98
99 // Errors log
100 $resultItems .= TplAestan::getItemNotepad($bearsamppLang->getValue(Lang::MENU_ERROR_LOGS), $bearsamppBins->getPhp()->getErrorLog()) . PHP_EOL;
101 }
102
103 return $resultItems . PHP_EOL . $resultActions;
104 }
global $bearsamppLang
const DISABLED
const ENABLED
static getWebsiteUrl($path='', $fragment='', $utmSource=true)
const MENU_ENABLE
const DOWNLOAD_MORE
const MENU_ERROR_LOGS
const SETTINGS
const EXTENSIONS
const VERSIONS
static getItemLink($caption, $link, $local=false, $glyph=self::GLYPH_WEB_PAGE)
static getItemNotepad($caption, $path)
static getItemSeparator()
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
static getMenu($caption, $menu, $class)
const SECTION_CALL
const SECTION_CONTENT

References $bearsamppBins, $bearsamppLang, Config\DISABLED, Lang\DOWNLOAD_MORE, Config\ENABLED, Lang\EXTENSIONS, TplApp\getActionMulti(), TplAestan\getItemLink(), TplAestan\getItemNotepad(), TplAestan\getItemSeparator(), TplApp\getMenu(), HttpClient\getWebsiteUrl(), TplAestan\GLYPH_BROWSER, TplAestan\GLYPH_CHECK, Lang\MENU_ENABLE, Lang\MENU_ERROR_LOGS, TplApp\SECTION_CALL, TplApp\SECTION_CONTENT, Lang\SETTINGS, and Lang\VERSIONS.

Here is the call graph for this function:

◆ getMenuPhpExtensions()

getMenuPhpExtensions ( )
static

Generates the PHP extensions menu items and actions.

Returns
string The generated PHP extensions menu items and actions. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 321 of file class.tpl.app.php.php.

322 {
323 global $bearsamppBins;
324 $items = '';
325 $actions = '';
326
327 foreach ($bearsamppBins->getPhp()->getExtensions() as $extension => $switch) {
328 $tplSwitchPhpExtension = TplApp::getActionMulti(
329 self::ACTION_SWITCH_EXTENSION,
330 array($extension, $switch),
331 array($extension, ($switch == ActionSwitchPhpExtension::SWITCH_ON ? TplAestan::GLYPH_CHECK : '')),
332 false,
333 get_called_class()
334 );
335
336 // Item
337 $items .= $tplSwitchPhpExtension[TplApp::SECTION_CALL] . PHP_EOL;
338
339 // Action
340 $actions .= PHP_EOL . $tplSwitchPhpExtension[TplApp::SECTION_CONTENT];
341 }
342
343 return $items . $actions;
344 }

References $bearsamppBins, TplApp\getActionMulti(), TplAestan\GLYPH_CHECK, TplApp\SECTION_CALL, TplApp\SECTION_CONTENT, and ActionSwitchPhpExtension\SWITCH_ON.

Here is the call graph for this function:

◆ getMenuPhpSettings()

getMenuPhpSettings ( )
static

Generates the PHP settings menu items and actions.

Returns
string The generated PHP settings menu items and actions. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 187 of file class.tpl.app.php.php.

188 {
189 global $bearsamppBins;
190
191 $menuItems = '';
192 $menuActions = '';
193 foreach ($bearsamppBins->getPhp()->getSettings() as $key => $value) {
194 if (is_array($value)) {
195 $menuItems .= 'Type: submenu; ' .
196 'Caption: "' . $key . '"; ' .
197 'SubMenu: MenuPhpSetting-' . md5($key) . '; ' .
198 'Glyph: ' . TplAestan::GLYPH_FOLDER_CLOSE . PHP_EOL;
199 } else {
200 $glyph = '';
201 $settingEnabled = $bearsamppBins->getPhp()->isSettingActive($value);
202 if (!$bearsamppBins->getPhp()->isSettingExists($value)) {
204 } elseif ($settingEnabled) {
205 $glyph = TplAestan::GLYPH_CHECK;
206 }
207 $tplSwitchPhpSetting = TplApp::getActionMulti(
208 self::ACTION_SWITCH_SETTING,
209 array($value, $settingEnabled),
210 array($key, $glyph),
211 false,
212 get_called_class()
213 );
214
215 $menuItems .= $tplSwitchPhpSetting[TplApp::SECTION_CALL] . PHP_EOL;
216 $menuActions .= $tplSwitchPhpSetting[TplApp::SECTION_CONTENT];
217 }
218 }
219
220 $submenusItems = '';
221 $submenusActions = '';
222 $submenuKeys = self::getSubmenuPhpSettings();
223 foreach ($submenuKeys as $submenuKey) {
224 $submenusItems .= PHP_EOL . '[MenuPhpSetting-' . md5($submenuKey) . ']' .
225 PHP_EOL . self::getSubmenuPhpSettings($submenuKey);
226
227 $submenusActions .= self::getSubmenuPhpSettings($submenuKey, array(), array(), false);
228 }
229
230 return $menuItems . $submenusItems . PHP_EOL . $menuActions . $submenusActions;
231 }
const GLYPH_FOLDER_CLOSE
static getSubmenuPhpSettings($passThr=array(), $result=array(), $settings=array(), $sectionCall=true)

References $bearsamppBins, TplApp\getActionMulti(), getSubmenuPhpSettings(), TplAestan\GLYPH_CHECK, TplAestan\GLYPH_FOLDER_CLOSE, TplAestan\GLYPH_WARNING, TplApp\SECTION_CALL, and TplApp\SECTION_CONTENT.

Here is the call graph for this function:

◆ getMenuPhpVersions()

getMenuPhpVersions ( )
static

Generates the PHP versions menu items and actions.

Returns
string The generated PHP versions menu items and actions. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 113 of file class.tpl.app.php.php.

114 {
115 global $bearsamppBins;
116 $items = '';
117 $actions = '';
118
119 foreach ($bearsamppBins->getPhp()->getVersionList() as $version) {
120 $glyph = '';
121 $apachePhpModule = $bearsamppBins->getPhp()->getApacheModule($bearsamppBins->getApache()->getVersion(), $version);
122 if ($apachePhpModule === false) {
124 } elseif ($version == $bearsamppBins->getPhp()->getVersion()) {
125 $glyph = TplAestan::GLYPH_CHECK;
126 }
127
128 $tplSwitchPhpVersion = TplApp::getActionMulti(
129 self::ACTION_SWITCH_VERSION,
130 array($version),
131 array($version, $glyph),
132 false,
133 get_called_class()
134 );
135
136 // Item
137 $items .= $tplSwitchPhpVersion[TplApp::SECTION_CALL] . PHP_EOL;
138
139 // Action
140 $actions .= PHP_EOL . $tplSwitchPhpVersion[TplApp::SECTION_CONTENT];
141 }
142
143 return $items . $actions;
144 }

References $bearsamppBins, TplApp\getActionMulti(), TplAestan\GLYPH_CHECK, TplAestan\GLYPH_WARNING, TplApp\SECTION_CALL, and TplApp\SECTION_CONTENT.

Here is the call graph for this function:

◆ getSubmenuPhpSettings()

getSubmenuPhpSettings ( $passThr = array(),
$result = array(),
$settings = array(),
$sectionCall = true )
staticprivate

Generates the submenu items and actions for PHP settings.

Parameters
array$passThrThe pass-through array for nested settings.
array$resultThe result array to store submenu items.
array$settingsThe settings array to process.
bool$sectionCallWhether to generate section calls or content.
Returns
string The generated submenu items and actions for PHP settings. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 245 of file class.tpl.app.php.php.

246 {
247 global $bearsamppBins;
248 $settings = empty($settings) ? $bearsamppBins->getPhp()->getSettings() : $settings;
249
250 foreach ($settings as $key => $value) {
251 if (is_array($value)) {
252 if (is_array($passThr)) {
253 array_push($result, $key);
254 $result = self::getSubmenuPhpSettings($passThr, $result, $value);
255 } else {
256 $result = is_array($result) ? '' : $result;
257 if ($key == $passThr) {
258 foreach ($value as $key2 => $value2) {
259 if (is_array($value2) && $sectionCall) {
260 $result .= 'Type: submenu; ' .
261 'Caption: "' . $key2 . '"; ' .
262 'SubMenu: MenuPhpSetting-' . md5($key2) . '; ' .
263 'Glyph: ' . TplAestan::GLYPH_FOLDER_CLOSE . PHP_EOL;
264 } elseif (!is_array($value2)) {
265 $glyph = '';
266 $settingEnabled = $bearsamppBins->getPhp()->isSettingActive($value2);
267 if (!$bearsamppBins->getPhp()->isSettingExists($value2)) {
269 } elseif ($settingEnabled) {
270 $glyph = TplAestan::GLYPH_CHECK;
271 }
272 $tplSwitchPhpSetting = TplApp::getActionMulti(
273 self::ACTION_SWITCH_SETTING,
274 array($value2, $settingEnabled),
275 array($key2, $glyph),
276 false,
277 get_called_class()
278 );
279
280 if ($sectionCall) {
281 $result .= $tplSwitchPhpSetting[TplApp::SECTION_CALL] . PHP_EOL;
282 } else {
283 $result .= $tplSwitchPhpSetting[TplApp::SECTION_CONTENT] . PHP_EOL;
284 }
285 }
286 }
287 } else {
288 $result .= self::getSubmenuPhpSettings($passThr, null, $value, $sectionCall);
289 }
290 }
291 }
292 }
293
294 return $result;
295 }
$result

References $bearsamppBins, $result, TplApp\getActionMulti(), getSubmenuPhpSettings(), TplAestan\GLYPH_CHECK, TplAestan\GLYPH_FOLDER_CLOSE, TplAestan\GLYPH_WARNING, TplApp\SECTION_CALL, and TplApp\SECTION_CONTENT.

Referenced by getMenuPhpSettings(), and getSubmenuPhpSettings().

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

◆ process()

process ( )
static

Processes the PHP menu and returns the menu items and actions.

Returns
array The generated menu items and actions for the PHP menu. @global object $bearsamppBins Provides access to system binaries and their configurations.

@global object $bearsamppLang Provides language support for retrieving language-specific values.

Definition at line 37 of file class.tpl.app.php.php.

38 {
40
41 return TplApp::getMenuEnable($bearsamppLang->getValue(Lang::PHP), self::MENU, get_called_class(), $bearsamppBins->getPhp()->isEnable());
42 }
const PHP
static getMenuEnable($caption, $menu, $class, $enabled=true)

References $bearsamppBins, $bearsamppLang, TplApp\getMenuEnable(), and Lang\PHP.

Referenced by TplApp\getSectionMenuLeft().

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

Field Documentation

◆ ACTION_ENABLE

const ACTION_ENABLE = 'enablePhp'

Definition at line 24 of file class.tpl.app.php.php.

◆ ACTION_SWITCH_EXTENSION

const ACTION_SWITCH_EXTENSION = 'switchPhpExtension'

Definition at line 27 of file class.tpl.app.php.php.

◆ ACTION_SWITCH_SETTING

const ACTION_SWITCH_SETTING = 'switchPhpSetting'

Definition at line 26 of file class.tpl.app.php.php.

◆ ACTION_SWITCH_VERSION

const ACTION_SWITCH_VERSION = 'switchPhpVersion'

Definition at line 25 of file class.tpl.app.php.php.

◆ MENU

const MENU = 'php'

Definition at line 19 of file class.tpl.app.php.php.

◆ MENU_EXTENSIONS

const MENU_EXTENSIONS = 'phpExtensions'

Definition at line 22 of file class.tpl.app.php.php.

◆ MENU_SETTINGS

const MENU_SETTINGS = 'phpSettings'

Definition at line 21 of file class.tpl.app.php.php.

◆ MENU_VERSIONS

const MENU_VERSIONS = 'phpVersions'

Definition at line 20 of file class.tpl.app.php.php.


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