Skip to content

Commit 8bb58c3

Browse files
committed
functionality update in Linux
1 parent 0bf81d6 commit 8bb58c3

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/JasperPHP/JasperPHP.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class JasperPHP
66
{
77
protected $executable = "jasperstarter"; //executable jasperstarter
8-
protected $path_executable = __DIR__ . '\..\JasperStarter\bin\\'; //Path to executable
8+
protected $path_executable = __DIR__ . '/../JasperStarter/bin/'; //Path to executable
99
protected $the_command;
1010
protected $redirect_output;
1111
protected $background;
@@ -20,7 +20,7 @@ function __construct($resource_dir = false)
2020
$this->windows = true;
2121

2222
if (!$resource_dir) {
23-
$this->resource_directory = __DIR__ . "\..\..\..\\vendor\cossou\jasperphp\src\JasperStarter\bin\\";
23+
$this->resource_directory = __DIR__ . "/../../../vendor/cossou/jasperphp/src/JasperStarter/bin";
2424
} else {
2525
if (!file_exists($resource_dir))
2626
throw new \Exception("Invalid resource directory.", 1);
@@ -43,7 +43,7 @@ public function compile($input_file, $output_file = false, $background = true, $
4343
if(is_null($input_file) || empty($input_file))
4444
throw new \Exception("No input file", 1);
4545

46-
$command = $this->executable;
46+
$command = ($this->windows) ? $this->executable : './' . $this->executable;
4747

4848
$command .= " compile ";
4949

@@ -76,7 +76,7 @@ public function process($input_file, $output_file = false, $format = array("pdf"
7676
throw new \Exception("Invalid format!", 1);
7777
}
7878

79-
$command = $this->executable;
79+
$command = ($this->windows) ? $this->executable : './' . $this->executable;
8080

8181
$command .= " process ";
8282

@@ -145,7 +145,7 @@ public function list_parameters($input_file)
145145
if(is_null($input_file) || empty($input_file))
146146
throw new \Exception("No input file", 1);
147147

148-
$command = $this->executable;
148+
$command = ($this->windows) ? $this->executable : './' . $this->executable;
149149

150150
$command .= " list_parameters ";
151151

@@ -163,11 +163,6 @@ public function output()
163163

164164
public function execute($run_as_user = false)
165165
{
166-
if( $this->redirect_output && !$this->windows)
167-
$this->the_command .= " > /dev/null 2>&1";
168-
169-
if( $this->background && !$this->windows )
170-
$this->the_command .= " &";
171166

172167
if( $run_as_user !== false && strlen($run_as_user > 0) && !$this->windows )
173168
$this->the_command = "su -u " . $run_as_user . " -c \"" . $this->the_command . "\"";
@@ -176,7 +171,6 @@ public function execute($run_as_user = false)
176171
$return_var = 0;
177172

178173
if (is_dir($this->path_executable)){
179-
180174
chdir($this->path_executable);
181175
exec($this->the_command, $output, $return_var);
182176
} else {
@@ -185,7 +179,7 @@ public function execute($run_as_user = false)
185179

186180
if($return_var != 0)
187181
throw new \Exception("Your report has an error and couldn't be processed! Try to output the command using the function `output();` and run it manually in the console.", 1);
188-
182+
189183
return $output;
190184
}
191-
}
185+
}

0 commit comments

Comments
 (0)