Subversion Repositories ALCASAR

Rev

Rev 2168 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2168 Rev 2225
Line 6... Line 6...
6
 * Use wkhtmltopdf to convert HTML to PDF.
6
 * Use wkhtmltopdf to convert HTML to PDF.
7
 *
7
 *
8
 * @author    Tom Houdayer
8
 * @author    Tom Houdayer
9
 * @copyright Copyright (C) ALCASAR (http://www.alcasar.net)
9
 * @copyright Copyright (C) ALCASAR (http://www.alcasar.net)
10
 * @license   GPL-3.0
10
 * @license   GPL-3.0
11
 * @version   $Id: TicketsGenerator.php 2168 2017-04-18 17:39:54Z tom.houdayer $
11
 * @version   $Id: TicketsGenerator.php 2225 2017-05-14 15:24:35Z tom.houdayer $
12
 */
12
 */
13
 
13
 
14
class TicketsGenerator
14
class TicketsGenerator
15
{
15
{
16
	/**
16
	/**
Line 32... Line 32...
32
	 * @var string HTML template filename.
32
	 * @var string HTML template filename.
33
	 */
33
	 */
34
	private $template = __DIR__ . '/' . 'tickets.template.php';
34
	private $template = __DIR__ . '/' . 'tickets.template.php';
35
 
35
 
36
	/**
36
	/**
37
	 * @var string|null HTML generated filename (null if not generated).
37
	 * @var bool Replace file if already exist.
38
	 */
38
	 */
39
	private $htmlGeneratedFilename;
39
	private $replace = true;
40
 
40
 
41
	/**
41
	/**
42
	 * Constructor.
42
	 * Constructor.
43
	 *
43
	 *
44
	 * @param array $options Options of the instance.
44
	 * @param array $options Options of the instance.
Line 52... Line 52...
52
			$this->language = $options['language'];
52
			$this->language = $options['language'];
53
		}
53
		}
54
		if (isset($options['template'])) {
54
		if (isset($options['template'])) {
55
			$this->template = $options['template'];
55
			$this->template = $options['template'];
56
		}
56
		}
-
 
57
		if (isset($options['replace'])) {
-
 
58
			$this->replace = $options['replace'];
-
 
59
		}
57
	}
60
	}
58
 
61
 
59
	/**
62
	/**
60
	 * Add a ticket.
63
	 * Add a ticket.
61
	 *
64
	 *
Line 93... Line 96...
93
	 *
96
	 *
94
	 * @return bool Result of the convertion (true if success).
97
	 * @return bool Result of the convertion (true if success).
95
	 */
98
	 */
96
	public function saveAs($filename)
99
	public function saveAs($filename)
97
	{
100
	{
98
		if (file_exists($filename)) {
101
		if ((!$this->replace) && (file_exists($filename))) {
99
			return false;
102
			return false;
100
		}
103
		}
101
 
104
 
102
		// TODO: Regex validation of $filename
105
		// TODO: Regex validation of $filename
103
 
106
 
Line 151... Line 154...
151
	 *
154
	 *
152
	 * @return bool Result of the generation (true if success).
155
	 * @return bool Result of the generation (true if success).
153
	 */
156
	 */
154
	private function generateHtml($output)
157
	private function generateHtml($output)
155
	{
158
	{
156
		if (file_exists($output)) {
159
		if ((!$this->replace) && (file_exists($output))) {
157
			return false;
160
			return false;
158
		}
161
		}
159
 
162
 
160
		if (!file_exists($this->template)) {
163
		if (!file_exists($this->template)) {
161
			return false;
164
			return false;