Bearsampp 2025.8.29
Loading...
Searching...
No Matches
class.tool.ghostscript.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
18{
19 const ROOT_CFG_VERSION = 'ghostscriptVersion';
20 const LOCAL_CFG_EXE = 'ghostscriptExe';
21 const LOCAL_CFG_EXE_CONSOLE = 'ghostscriptExeConsole';
22
23 private $exe;
24 private $exeConsole;
25
32 public function __construct($id, $type) {
33 Util::logInitClass($this);
34 $this->reload($id, $type);
35 }
36
43 public function reload($id = null, $type = null) {
46
47 $this->name = $bearsamppLang->getValue(Lang::GHOSTSCRIPT);
48 $this->version = $bearsamppConfig->getRaw(self::ROOT_CFG_VERSION);
49 parent::reload($id, $type);
50
51 if ($this->bearsamppConfRaw !== false) {
52 $this->exe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
53 $this->exeConsole = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE_CONSOLE];
54 }
55
56 if (!$this->enable) {
57 Util::logInfo($this->name . ' is not enabled!');
58 return;
59 }
60 if (!is_dir($this->currentPath)) {
61 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
62 }
63 if (!is_dir($this->symlinkPath)) {
64 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
65 return;
66 }
67 if (!is_file($this->bearsamppConf)) {
68 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
69 }
70 if (!is_file($this->exe)) {
71 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe));
72 }
73 if (!is_file($this->exeConsole)) {
74 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exeConsole));
75 }
76 }
77
83 public function setVersion($version) {
84 global $bearsamppConfig;
85 $this->version = $version;
86 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
87 $this->reload();
88 }
89
95 public function getExe() {
96 return $this->exe;
97 }
98
104 public function getExeConsole() {
105 return $this->exeConsole;
106 }
107}
global $bearsamppLang
const GHOSTSCRIPT
const ERROR_EXE_NOT_FOUND
const ERROR_CONF_NOT_FOUND
const ERROR_FILE_NOT_FOUND
reload($id=null, $type=null)
static logError($data, $file=null)
static logInitClass($classInstance)
static logInfo($data, $file=null)
static logReloadClass($classInstance)
global $bearsamppConfig
Definition homepage.php:27