@@ -18,7 +18,7 @@ function __construct($resource_dir = false)
1818 {
1919 $ this ->path_executable = __DIR__ . '/../JasperStarter/bin ' ; //Path to executable
2020 if (strtoupper (substr (PHP_OS , 0 , 3 )) === 'WIN ' )
21- $ this ->windows = true ;
21+ $ this ->windows = true ;
2222
2323 if (!$ resource_dir ) {
2424 $ this ->resource_directory = __DIR__ . '/../../../vendor/geekcom/jasperphp/src/JasperStarter/bin ' ;
@@ -41,7 +41,7 @@ public static function __callStatic($method, $parameters)
4141
4242 public function compile ($ input_file , $ output_file = false , $ background = true , $ redirect_output = true )
4343 {
44- if (is_null ($ input_file ) || empty ($ input_file ))
44+ if (is_null ($ input_file ) || empty ($ input_file ))
4545 throw new \Exception ('No input file ' , 1 );
4646
4747 $ command = ($ this ->windows ) ? $ this ->executable : './ ' . $ this ->executable ;
@@ -50,31 +50,29 @@ public function compile($input_file, $output_file = false, $background = true, $
5050
5151 $ command .= "\"$ input_file \"" ;
5252
53- if ( $ output_file !== false )
53+ if ( $ output_file !== false )
5454 $ command .= ' -o ' . "\"$ output_file \"" ;
5555
56- $ this ->redirect_output = $ redirect_output ;
57- $ this ->background = $ background ;
58- $ this ->the_command = $ command ;
56+ $ this ->redirect_output = $ redirect_output ;
57+ $ this ->background = $ background ;
58+ $ this ->the_command = $ command ;
5959
6060 return $ this ;
6161 }
6262
6363 public function process ($ input_file , $ output_file = false , $ format = array ('pdf ' ), $ parameters = array (), $ db_connection = array (), $ locale = false , $ background = true , $ redirect_output = true )
6464 {
65- if (is_null ($ input_file ) || empty ($ input_file ))
65+ if (is_null ($ input_file ) || empty ($ input_file ))
6666 throw new \Exception ('No input file ' , 1 );
6767
68- if ( is_array ($ format ) )
69- {
70- foreach ($ format as $ key )
71- {
72- if ( !in_array ($ key , $ this ->formats ))
68+ if (is_array ($ format )) {
69+ foreach ($ format as $ key ) {
70+ if (!in_array ($ key , $ this ->formats ))
7371 throw new \Exception ('Invalid format! ' , 1 );
7472 }
7573 } else {
76- if ( !in_array ($ format , $ this ->formats ))
77- throw new \Exception ('Invalid format! ' , 1 );
74+ if ( !in_array ($ format , $ this ->formats ))
75+ throw new \Exception ('Invalid format! ' , 1 );
7876 }
7977
8078 $ command = ($ this ->windows ) ? $ this ->executable : './ ' . $ this ->executable ;
@@ -85,78 +83,75 @@ public function process($input_file, $output_file = false, $format = array('pdf'
8583
8684 $ command .= "\"$ input_file \"" ;
8785
88- if ( $ output_file !== false )
86+ if ( $ output_file !== false )
8987 $ command .= ' -o ' . "\"$ output_file \"" ;
9088
91- if ( is_array ($ format ) )
89+ if ( is_array ($ format ))
9290 $ command .= ' -f ' . join (' ' , $ format );
9391 else
9492 $ command .= ' -f ' . $ format ;
95-
96-
97- if ( count ($ parameters ) > 0 )
98- {
93+
94+
95+ if (count ($ parameters ) > 0 ) {
9996 $ command .= ' -P ' ;
10097
101- foreach ($ parameters as $ key => $ value )
102- {
98+ foreach ($ parameters as $ key => $ value ) {
10399 $ param = $ key . '=" ' . $ value . '" ' ;
104- $ command .= " " .$ param . " " ;
100+ $ command .= " " . $ param . " " ;
105101 }
106102
107103 }
108104
109- if ( count ($ db_connection ) > 0 )
110- {
105+ if (count ($ db_connection ) > 0 ) {
111106 $ command .= ' -t ' . $ db_connection ['driver ' ];
112107
113- if (isset ($ db_connection ['username ' ]))
108+ if (isset ($ db_connection ['username ' ]))
114109 $ command .= " -u " . $ db_connection ['username ' ];
115110
116- if ( isset ($ db_connection ['password ' ]) && !empty ($ db_connection ['password ' ]) )
111+ if ( isset ($ db_connection ['password ' ]) && !empty ($ db_connection ['password ' ]))
117112 $ command .= ' -p ' . $ db_connection ['password ' ];
118113
119- if ( isset ($ db_connection ['host ' ]) && !empty ($ db_connection ['host ' ]) )
114+ if ( isset ($ db_connection ['host ' ]) && !empty ($ db_connection ['host ' ]))
120115 $ command .= ' -H ' . $ db_connection ['host ' ];
121116
122- if ( isset ($ db_connection ['database ' ]) && !empty ($ db_connection ['database ' ]) )
117+ if ( isset ($ db_connection ['database ' ]) && !empty ($ db_connection ['database ' ]))
123118 $ command .= ' -n ' . $ db_connection ['database ' ];
124119
125- if ( isset ($ db_connection ['port ' ]) && !empty ($ db_connection ['port ' ]) )
120+ if ( isset ($ db_connection ['port ' ]) && !empty ($ db_connection ['port ' ]))
126121 $ command .= ' --db-port ' . $ db_connection ['port ' ];
127122
128- if ( isset ($ db_connection ['jdbc_driver ' ]) && !empty ($ db_connection ['jdbc_driver ' ]) )
123+ if ( isset ($ db_connection ['jdbc_driver ' ]) && !empty ($ db_connection ['jdbc_driver ' ]))
129124 $ command .= ' --db-driver ' . $ db_connection ['jdbc_driver ' ];
130125
131- if ( isset ($ db_connection ['jdbc_url ' ]) && !empty ($ db_connection ['jdbc_url ' ]) )
126+ if ( isset ($ db_connection ['jdbc_url ' ]) && !empty ($ db_connection ['jdbc_url ' ]))
132127 $ command .= ' --db-url ' . $ db_connection ['jdbc_url ' ];
133128
134- if ( isset ($ db_connection ['jdbc_dir ' ]) && !empty ($ db_connection ['jdbc_dir ' ]) )
129+ if (isset ($ db_connection ['jdbc_dir ' ]) && !empty ($ db_connection ['jdbc_dir ' ]))
135130 $ command .= ' --jdbc-dir ' . $ db_connection ['jdbc_dir ' ];
136131
137- if ( isset ($ db_connection ['db_sid ' ]) && !empty ($ db_connection ['db_sid ' ]) )
132+ if (isset ($ db_connection ['db_sid ' ]) && !empty ($ db_connection ['db_sid ' ]))
138133 $ command .= ' --db-sid ' . $ db_connection ['db_sid ' ];
139134
140- if ( isset ($ db_connection ['xml_xpath ' ]) )
135+ if (isset ($ db_connection ['xml_xpath ' ]))
141136 $ command .= ' --xml-xpath ' . $ db_connection ['xml_xpath ' ];
142137
143- if ( isset ($ db_connection ['data_file ' ]) )
138+ if (isset ($ db_connection ['data_file ' ]))
144139 $ command .= ' --data-file ' . $ db_connection ['data_file ' ];
145140
146- if ( isset ($ db_connection ['json_query ' ]) )
141+ if (isset ($ db_connection ['json_query ' ]))
147142 $ command .= ' --json-query ' . $ db_connection ['json_query ' ];
148143 }
149144
150- $ this ->redirect_output = $ redirect_output ;
151- $ this ->background = $ background ;
152- $ this ->the_command = $ command ;
145+ $ this ->redirect_output = $ redirect_output ;
146+ $ this ->background = $ background ;
147+ $ this ->the_command = $ command ;
153148
154149 return $ this ;
155150 }
156151
157152 public function list_parameters ($ input_file )
158153 {
159- if (is_null ($ input_file ) || empty ($ input_file ))
154+ if (is_null ($ input_file ) || empty ($ input_file ))
160155 throw new \Exception ('No input file ' , 1 );
161156
162157 $ command = ($ this ->windows ) ? $ this ->executable : './ ' . $ this ->executable ;
@@ -178,20 +173,20 @@ public function output()
178173 public function execute ($ run_as_user = false )
179174 {
180175
181- if ( $ run_as_user !== false && strlen ($ run_as_user > 0 ) && !$ this ->windows )
176+ if ( $ run_as_user !== false && strlen ($ run_as_user > 0 ) && !$ this ->windows )
182177 $ this ->the_command = 'su -u ' . $ run_as_user . " -c \"" . $ this ->the_command . "\"" ;
183178
184179 $ output = array ();
185180 $ return_var = 0 ;
186181
187- if (is_dir ($ this ->path_executable )){
182+ if (is_dir ($ this ->path_executable )) {
188183 chdir ($ this ->path_executable );
189184 exec ($ this ->the_command , $ output , $ return_var );
190185 } else {
191186 throw new \Exception ('Invalid resource directory. ' , 1 );
192187 }
193188
194- if ($ return_var != 0 )
189+ if ($ return_var != 0 )
195190 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 );
196191
197192 return $ output ;
0 commit comments