Edit File: LswsConfigViewModel.php
<?php /* * ****************************************** * LiteSpeed web server Cache Manager * @author: LiteSpeed Technologies, Inc. (https://www.litespeedtech.com) * @copyright: (c) 2018 * ******************************************* */ namespace LsPanel\View\Model; use \LsPanel\WhmMod_LiteSpeed_Util; use \Lsc\Wp\Context\Context; use \Lsc\Wp\Logger; use \Lsc\Wp\LSCMException; class LswsConfigViewModel { const FLD_ICON_DIR = 'iconDir'; const FLD_ADMIN_CONSOLE_URL = 'adminConsoleUrl'; const FLD_SUEXEC_STATE = 'suExecState'; const FLD_IS_EA3 = 'isEA3'; const FLD_HAS_CACHE = 'hasCache'; /** * @var WhmMod_LiteSpeed_Util */ private $util; /** * @var (boolean|string|string[])[] */ private $tplData = array(); /** * * @param WhmMod_LiteSpeed_Util $util */ public function __construct( WhmMod_LiteSpeed_Util $util ) { $this->util = $util; $this->init(); } private function init() { $this->setIconDir(); $this->setAdminConsoleUrl(); $this->setSuExecState(); $this->setIsEA3(); $this->setHasCache(); } /** * * @param string $field * @return null|boolean|string|string[] */ public function getTplData( $field ) { if ( !isset($this->tplData[$field]) ) { return null; } return $this->tplData[$field]; } private function setIconDir() { $iconDir = ''; try { $iconDir = Context::getOption()->getIconDir(); } catch ( LSCMException $e ) { Logger::debug($e->getMessage() . ' Could not get icon directory.'); } $this->tplData[self::FLD_ICON_DIR] = $iconDir; } private function setAdminConsoleUrl() { $lsPid = $this->util->getLSPID(); if ( $lsPid > 0 ) { $adminConsoleUrl = $this->util->GetAdminUrl(); } else { $adminConsoleUrl = ''; } $this->tplData[self::FLD_ADMIN_CONSOLE_URL] = $adminConsoleUrl; } private function setSuExecState() { $c = $this->util->GetLSConfig('phpSuExec'); $phpSuExacVal = $c['phpSuExec']; switch ($phpSuExacVal) { case '1': $state = 'enabled'; break; case '2': $state = 'enabled in user home directory only'; break; default: $state = 'disabled'; } $this->tplData[self::FLD_SUEXEC_STATE] = $state; } private function setIsEA3() { $this->tplData[self::FLD_IS_EA3] = (!file_exists('/etc/cpanel/ea4/is_ea4')); } private function setHasCache() { $res = $this->util->GetLicenseType(); if ( $res['has_cache'] == WhmMod_LiteSpeed_Util::LSCACHE_STATUS_NOT_SUPPORTED ) { $hasCache = false; } else { $hasCache = true; } $this->tplData[self::FLD_HAS_CACHE] = $hasCache; } public function getTpl() { return realpath(__DIR__ . '/../Tpl') . '/LswsConfig.tpl'; } }