2024.8.23
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
10
/**
11
* Class ToolGhostscript
12
*
13
* This class represents the Ghostscript tool module in the Bearsampp application.
14
* It extends the Module class and provides functionalities specific to Ghostscript,
15
* such as loading configurations, setting versions, and retrieving executable paths.
16
*/
17
class
ToolGhostscript
extends
Module
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
26
/**
27
* Constructor for the ToolGhostscript class.
28
*
29
* @param string $id The ID of the module.
30
* @param string $type The type of the module.
31
*/
32
public
function
__construct
(
$id
,
$type
) {
33
Util::logInitClass
($this);
34
$this->
reload
(
$id
,
$type
);
35
}
36
37
/**
38
* Reloads the Ghostscript module configuration based on the provided ID and type.
39
*
40
* @param string|null $id The ID of the module. If null, the current ID is used.
41
* @param string|null $type The type of the module. If null, the current type is used.
42
*/
43
public
function
reload
(
$id
=
null
,
$type
=
null
) {
44
global
$bearsamppConfig
,
$bearsamppLang
;
45
Util::logReloadClass
($this);
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
78
/**
79
* Sets the version of the Ghostscript module and reloads the configuration.
80
*
81
* @param string $version The version to set.
82
*/
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
90
/**
91
* Gets the path to the Ghostscript executable.
92
*
93
* @return string The path to the Ghostscript executable.
94
*/
95
public
function
getExe
() {
96
return
$this->exe
;
97
}
98
99
/**
100
* Gets the path to the Ghostscript console executable.
101
*
102
* @return string The path to the Ghostscript console executable.
103
*/
104
public
function
getExeConsole
() {
105
return
$this->exeConsole
;
106
}
107
}
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
Lang\ERROR_FILE_NOT_FOUND
const ERROR_FILE_NOT_FOUND
Definition
class.lang.php:160
Lang\ERROR_CONF_NOT_FOUND
const ERROR_CONF_NOT_FOUND
Definition
class.lang.php:158
Lang\ERROR_EXE_NOT_FOUND
const ERROR_EXE_NOT_FOUND
Definition
class.lang.php:159
Lang\GHOSTSCRIPT
const GHOSTSCRIPT
Definition
class.lang.php:148
Module
Definition
class.module.php:15
Module\$type
$type
Definition
class.module.php:18
Module\$version
$version
Definition
class.module.php:22
Module\$id
$id
Definition
class.module.php:19
ToolGhostscript
Definition
class.tool.ghostscript.php:18
ToolGhostscript\LOCAL_CFG_EXE
const LOCAL_CFG_EXE
Definition
class.tool.ghostscript.php:20
ToolGhostscript\getExeConsole
getExeConsole()
Definition
class.tool.ghostscript.php:104
ToolGhostscript\reload
reload($id=null, $type=null)
Definition
class.tool.ghostscript.php:43
ToolGhostscript\$exe
$exe
Definition
class.tool.ghostscript.php:23
ToolGhostscript\LOCAL_CFG_EXE_CONSOLE
const LOCAL_CFG_EXE_CONSOLE
Definition
class.tool.ghostscript.php:21
ToolGhostscript\setVersion
setVersion($version)
Definition
class.tool.ghostscript.php:83
ToolGhostscript\ROOT_CFG_VERSION
const ROOT_CFG_VERSION
Definition
class.tool.ghostscript.php:19
ToolGhostscript\$exeConsole
$exeConsole
Definition
class.tool.ghostscript.php:24
ToolGhostscript\getExe
getExe()
Definition
class.tool.ghostscript.php:95
ToolGhostscript\__construct
__construct($id, $type)
Definition
class.tool.ghostscript.php:32
Util\logReloadClass
static logReloadClass($classInstance)
Definition
class.util.php:822
Util\logError
static logError($data, $file=null)
Definition
class.util.php:802
Util\logInitClass
static logInitClass($classInstance)
Definition
class.util.php:812
Util\logInfo
static logInfo($data, $file=null)
Definition
class.util.php:778
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:26
Bearsampp-development
sandbox
core
classes
tools
class.tool.ghostscript.php
Generated by
1.11.0