Edit File: CacheRootSetupViewModel.php
<?php /* * ****************************************** * LiteSpeed web server Cache Manager * @author: LiteSpeed Technologies, Inc. (https://www.litespeedtech.com) * @copyright: (c) 2018 * ******************************************* */ namespace LsPanel\View\Model; use \Lsc\Wp\Panel\ControlPanel; use \Lsc\Wp\Context\Context; use \Lsc\Wp\LSCMException; use \Lsc\Wp\Logger; class CacheRootSetupViewModel { const FLD_ICON = 'icon'; const FLD_SVR_CACHE_ROOT = 'svr_cache_root'; const FLD_VH_CACHE_ROOT = 'vh_cache_root'; const FLD_MISSING = 'missing'; const FLD_ERR_MSGS = 'errMsgs'; /** * @var ControlPanel */ private $panelEnv; /** * @var (boolean|string|string[])[] */ private $tplData = array(); /** * * @param ControlPanel $panelEnv */ public function __construct( ControlPanel $panelEnv ) { $this->panelEnv = $panelEnv; $this->init(); } private function init() { $this->setIconPath(); $this->setCacheRootData(); $this->setErrMsgsData(); } /** * * @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 setIconPath() { $iconPath = ''; try { $iconDir = Context::getOption()->getIconDir(); $iconPath = "{$iconDir}/cacheRootSetup.svg"; } catch ( LSCMException $e ) { Logger::debug($e->getMessage() . ' Could not get icon directory.'); } $this->tplData[self::FLD_ICON] = $iconPath; } private function setCacheRootData() { $missing = false; $svrCacheRoot = $this->panelEnv->getServerCacheRoot(); $vhCacheRoot = $this->panelEnv->getVHCacheRoot(); if ( $svrCacheRoot != ControlPanel::NOT_SET ) { $svr = ' ' . htmlspecialchars(rtrim($svrCacheRoot, '/')) . '/ '; } else { $svr = 'not set!'; $missing = true; } $this->tplData[self::FLD_SVR_CACHE_ROOT] = $svr; if ( $vhCacheRoot != ControlPanel::NOT_SET ) { $vh = ' ' . htmlspecialchars(rtrim($vhCacheRoot, '/')); if ( $vhCacheRoot[0] != '/' ) { $vh .= '<b>*</b> '; } } else { $vh = 'not set!'; $missing = true; } $this->tplData[self::FLD_VH_CACHE_ROOT] = $vh; $this->tplData[self::FLD_MISSING] = $missing; } private function setErrMsgsData() { $errMsgs = Logger::getUiMsgs(Logger::UI_ERR); $this->tplData[self::FLD_ERR_MSGS] = $errMsgs; } /** * * @return string */ public function getTpl() { return realpath(__DIR__ . '/../Tpl') . '/CacheRootSetup.tpl'; } }