Bearsampp 2026.9.23
Loading...
Searching...
No Matches
class.tool.ghostscript.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
18{
22 const ROOT_CFG_VERSION = 'ghostscriptVersion';
26 const LOCAL_CFG_EXE = 'ghostscriptExe';
30 const LOCAL_CFG_EXE_CONSOLE = 'ghostscriptExeConsole';
31
35 private $exe;
39 private $exeConsole;
40
47 public function __construct($id, $type)
48 {
49 Log::initClass($this);
50 $this->reload($id, $type);
51 }
52
59 public function reload($id = null, $type = null)
60 {
62 Log::reloadClass($this);
63
64 $this->name = $bearsamppLang->getValue(Lang::GHOSTSCRIPT);
65 $this->version = $bearsamppConfig->getRaw(self::ROOT_CFG_VERSION);
66 parent::reload($id, $type);
67
68 if ($this->bearsamppConfRaw !== false) {
69 $this->exe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
70 $this->exeConsole = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE_CONSOLE];
71 }
72
73 if (!$this->enable) {
74 Log::info($this->name . ' is not enabled!');
75
76 return;
77 }
78 if (!is_dir($this->currentPath)) {
79 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
80 }
81 if (!is_dir($this->symlinkPath)) {
82 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
83
84 return;
85 }
86 if (!is_file($this->bearsamppConf)) {
87 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
88 }
89 if (!is_file($this->exe)) {
90 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe));
91 }
92 if (!is_file($this->exeConsole)) {
93 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exeConsole));
94 }
95 }
96
102 public function setVersion($version)
103 {
104 global $bearsamppConfig;
105 $this->version = $version;
106 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
107 $this->reload();
108 }
109
115 public function getExe()
116 {
117 return $this->exe;
118 }
119
125 public function getExeConsole()
126 {
127 return $this->exeConsole;
128 }
129}
130
global $bearsamppLang
const GHOSTSCRIPT
const ERROR_EXE_NOT_FOUND
const ERROR_CONF_NOT_FOUND
const ERROR_FILE_NOT_FOUND
static info($data, $file=null)
static reloadClass($classInstance)
static error($data, $file=null)
static initClass($classInstance)
reload($id=null, $type=null)
global $bearsamppConfig
Definition homepage.php:46