From 2f219a8a4328d3a8182b7fe6fd450f85f82cabc2 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Thu, 24 Aug 2017 14:29:15 +0200 Subject: [PATCH 1/3] added locale support and fix formatting --- src/JasperPHP/JasperPHP.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/JasperPHP/JasperPHP.php b/src/JasperPHP/JasperPHP.php index 8a06c89..58d84ea 100644 --- a/src/JasperPHP/JasperPHP.php +++ b/src/JasperPHP/JasperPHP.php @@ -14,7 +14,7 @@ class JasperPHP function __construct($resource_dir = false) { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') - $this->windows = true; + $this->windows = true; if (!$resource_dir) { $this->resource_directory = __DIR__ . "/../../../../../"; @@ -56,7 +56,7 @@ public function compile($input_file, $output_file = false, $background = true, $ return $this; } - public function process($input_file, $output_file = false, $format = array("pdf"), $parameters = array(), $db_connection = array(), $background = true, $redirect_output = true) + public function process($input_file, $output_file = false, $format = array("pdf"), $parameters = array(), $db_connection = array(), $locale = false, $background = true, $redirect_output = true) { if(is_null($input_file) || empty($input_file)) throw new \Exception("No input file", 1); @@ -70,11 +70,13 @@ public function process($input_file, $output_file = false, $format = array("pdf" } } else { if( !in_array($format, $this->formats)) - throw new \Exception("Invalid format!", 1); + throw new \Exception("Invalid format!", 1); } $command = __DIR__ . $this->executable; + if(!empty($locale)) $command .= ' --locale ' . $locale . ' '; + $command .= " process "; $command .= $input_file; @@ -122,7 +124,7 @@ public function process($input_file, $output_file = false, $format = array("pdf" if( isset($db_connection['jdbc_url']) && !empty($db_connection['jdbc_url']) ) $command .= " --db-url " . $db_connection['jdbc_url']; - if ( isset($db_connection['jdbc_dir']) && !empty($db_connection['jdbc_dir']) ) + if ( isset($db_connection['jdbc_dir']) && !empty($db_connection['jdbc_dir']) ) $command .= ' --jdbc-dir ' . $db_connection['jdbc_dir']; if ( isset($db_connection['db_sid']) && !empty($db_connection['db_sid']) ) @@ -176,10 +178,10 @@ public function execute($run_as_user = false) if( $return_var != 0 && isset($output[0]) ) throw new \Exception($output[0], 1); - - elseif( $return_var != 0 ) + + elseif( $return_var != 0 ) 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); - + return $output; } } From 6e929e27a1d067b7e210fd61fd1e5a6b53b88d5a Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Thu, 24 Aug 2017 17:09:48 +0200 Subject: [PATCH 2/3] added support for overriding resource dir --- src/JasperPHP/JasperPHP.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/JasperPHP/JasperPHP.php b/src/JasperPHP/JasperPHP.php index 58d84ea..62e6ce3 100644 --- a/src/JasperPHP/JasperPHP.php +++ b/src/JasperPHP/JasperPHP.php @@ -56,7 +56,7 @@ public function compile($input_file, $output_file = false, $background = true, $ return $this; } - public function process($input_file, $output_file = false, $format = array("pdf"), $parameters = array(), $db_connection = array(), $locale = false, $background = true, $redirect_output = true) + public function process($input_file, $output_file = false, $format = array("pdf"), $parameters = array(), $db_connection = array(), $locale = false, $resourceDir = false, $background = true, $redirect_output = true) { if(is_null($input_file) || empty($input_file)) throw new \Exception("No input file", 1); @@ -90,7 +90,8 @@ public function process($input_file, $output_file = false, $format = array("pdf" $command .= " -f " . $format; // Resources dir - $command .= " -r " . $this->resource_directory; + if (empty($resourceDir)) $resourceDir = $this->resource_directory; + $command .= " -r " . $resourceDir; if( count($parameters) > 0 ) { From c4eedfd2d16bd99db45797098c080d5d96ad4ee3 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Thu, 24 Aug 2017 17:23:25 +0200 Subject: [PATCH 3/3] update package info for fork --- composer.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c4ca5c6..616f20a 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "cossou/jasperphp", + "name": "fazo96/jasperphp", "description": "Create Reports in PHP with JasperReports", "license": "MIT", "keywords": [ @@ -10,11 +10,15 @@ "pdf", "java" ], - "homepage": "https://github.com/cossou/JasperPHP", + "homepage": "https://github.com/fazo96/JasperPHP", "authors": [ { "name": "Hélder Duarte", "email": "cossou@gmail.com" + }, + { + "name": "Enrico Fasoli", + "email": "enrico.fasoli1996@gmail.com" } ], "autoload": {