Bearsampp 2026.9.23
Loading...
Searching...
No Matches
class.tool.perl.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (c) 2021-2026 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
16class ToolPerl extends Module
17{
21 const ROOT_CFG_VERSION = 'perlVersion';
22
26 const LOCAL_CFG_EXE = 'perlExe';
27
31 private $exe;
32
39 public function __construct($id, $type)
40 {
41 Log::initClass($this);
42 $this->reload($id, $type);
43 }
44
51 public function reload($id = null, $type = null)
52 {
54 Log::reloadClass($this);
55
56 $this->name = $bearsamppLang->getValue(Lang::PERL);
57 $this->version = $bearsamppConfig->getRaw(self::ROOT_CFG_VERSION);
58 parent::reload($id, $type);
59
60 if ($this->bearsamppConfRaw !== false) {
61 $this->exe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
62 }
63
64 if (!$this->enable) {
65 Log::info($this->name . ' is not enabled!');
66
67 return;
68 }
69 if (!is_dir($this->currentPath)) {
70 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
71 }
72 if (!is_dir($this->symlinkPath)) {
73 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
74
75 return;
76 }
77 if (!is_file($this->bearsamppConf)) {
78 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
79 }
80 if (!is_file($this->exe)) {
81 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe));
82 }
83 }
84
90 public function setVersion($version)
91 {
92 global $bearsamppConfig;
93 $this->version = $version;
94 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
95 $this->reload();
96 }
97
103 public function getExe()
104 {
105 return $this->exe;
106 }
107}
108
global $bearsamppLang
const ERROR_EXE_NOT_FOUND
const ERROR_CONF_NOT_FOUND
const PERL
const ERROR_FILE_NOT_FOUND
static info($data, $file=null)
static reloadClass($classInstance)
static error($data, $file=null)
static initClass($classInstance)
const LOCAL_CFG_EXE
setVersion($version)
reload($id=null, $type=null)
const ROOT_CFG_VERSION
__construct($id, $type)
global $bearsamppConfig
Definition homepage.php:46