Skip to content

Commit 55e54a7

Browse files
author
remi
committed
add doc blocks
git-svn-id: https://forge.glpi-project.org/svn/pdf/trunk@392 349b9182-4a13-0410-896f-e5e9767dd1b3
1 parent 3191dce commit 55e54a7

File tree

1 file changed

+66
-12
lines changed

1 file changed

+66
-12
lines changed

inc/simplepdf.class.php

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class PluginPdfSimplePDF {
4242
const CENTER = 'C';
4343
const RIGHT = 'R';
4444

45-
private $df;
45+
private $pdf;
4646

4747
// Page management
4848
private $width;
@@ -58,6 +58,8 @@ class PluginPdfSimplePDF {
5858

5959

6060
/**
61+
* Create a new PDF
62+
*
6163
* @param $format (default a4)
6264
* @param $orient (default portrait)
6365
**/
@@ -106,6 +108,8 @@ function __construct ($format='A4', $orient='') {
106108

107109

108110
/**
111+
* Set the title in each header
112+
*
109113
* @param $msg
110114
**/
111115
public function setHeader($msg) {
@@ -114,11 +118,20 @@ public function setHeader($msg) {
114118
$this->pdf->SetHeaderData('fd_logo.jpg', 15, $msg, '');
115119
}
116120

117-
121+
/**
122+
* Display the result in the browser
123+
**/
118124
public function render() {
119125
$this->pdf->Output('glpi.pdf', 'I');
120126
}
121127

128+
/**
129+
* Get/save the result in the browser
130+
*
131+
* @param $name String optional filename
132+
*
133+
* @return String with PDF content if filename not provided
134+
**/
122135
public function output($name=false) {
123136

124137
if (!$name) {
@@ -127,13 +140,20 @@ public function output($name=false) {
127140
$this->pdf->Output($name, 'F');
128141
}
129142

143+
/**
144+
* Start a new page
145+
**/
130146
public function newPage() {
131147

132148
$this->pdf->AddPage();
133149
}
134150

135151

136-
// Args is relative size of each column
152+
/**
153+
* Configure the width and number of colums
154+
*
155+
* @param list of size in % of the page width
156+
**/
137157
public function setColumnsSize() {
138158

139159
$this->cols = $tmp = func_get_args();
@@ -153,7 +173,11 @@ public function setColumnsSize() {
153173
}
154174

155175

156-
// Args are relative size of each column
176+
/**
177+
* Configure the width and number of colums
178+
*
179+
* @param list of alignment
180+
**/
157181
public function setColumnsAlign () {
158182

159183
$this->align = func_get_args();
@@ -169,14 +193,26 @@ public function setColumnsAlign () {
169193

170194

171195
/**
196+
* does nothing, just raise a warning in the php-errors.log
197+
*
198+
* @deprecated, no more used (should have be private)
199+
*
172200
* @param $gray
173201
**/
174202
public function displayBox($gray) {
175203

176204
Toolbox::displayBox("PluginPdfSimplePDF::displayBox() is deprecated");
177205
}
178206

179-
207+
/**
208+
* display a row
209+
*
210+
* @param $gray Integer gray level of the backkgroun of each cell
211+
* @param $padd Float cell padding (mm)
212+
* @param $defalign String default column alignment is not set (setColumnsAlign)
213+
* @param $miny Float minimum size of the row (mm)
214+
* @param $msgs Array of strings to display
215+
**/
180216
private function displayInternal($gray, $padd, $defalign, $miny, $msgs) {
181217

182218
$this->pdf->SetFillColor($gray, $gray, $gray);
@@ -244,18 +280,32 @@ private function displayInternal($gray, $padd, $defalign, $miny, $msgs) {
244280
$this->pdf->SetY($this->pdf->GetY() + 1);
245281
}
246282

283+
/**
284+
* display a Title row, centered with dark background
285+
*
286+
* @param list of strings, one string per column
287+
**/
247288
public function displayTitle() {
248289
$this->displayInternal(200, 1.0, self::CENTER, 1, func_get_args());
249290
}
250291

292+
/**
293+
* display a nomal row, default to left, with light background
294+
*
295+
* @param list of strings, one string per column
296+
**/
251297
public function displayLine() {
252298
$this->displayInternal(240, 0.5, self::LEFT, 1, func_get_args());
253299
}
254300

255301

256302
/**
257-
* @param $name
258-
* @param $URL
303+
* Display a single cell with a string
304+
*
305+
* @deprecated use displayLine with HTML
306+
*
307+
* @param $name String displayed text
308+
* @param $URL String link
259309
**/
260310
public function displayLink($name, $URL) {
261311

@@ -269,7 +319,7 @@ public function displayLink($name, $URL) {
269319
* @param $name string display on the left, before text
270320
* @param $content string of text display on right (multi-line)
271321
* @param $minline integer for minimum box size (default 3)
272-
* @param $maxline interger for maximum box size (1 page = 80 lines) (default 100)
322+
* @param $maxline interger for maximum box size (1 page = 80 lines) (default 100) (ignored)
273323
**/
274324
public function displayText($name, $content='', $minline=3, $maxline=100) {
275325

@@ -296,18 +346,22 @@ public function displayText($name, $content='', $minline=3, $maxline=100) {
296346

297347

298348
/**
349+
* Display space between row
350+
*
299351
* @param $nb (default 1)
300352
**/
301353
public function displaySpace($nb=1) {
302354

303-
$this->pdf->Ln(4);
355+
$this->pdf->Ln(4*$nb);
304356
}
305357

306358

307359
/**
308-
* @param $image
309-
* @param $dst_w
310-
* @param $dst_h
360+
* Display an image
361+
*
362+
* @param $image String path of the PNF file
363+
* @param $dst_w Intefer Width in Pixels
364+
* @param $dst_h Integer Height in Pixels
311365
**/
312366
public function addPngFromFile($image,$dst_w,$dst_h) {
313367

0 commit comments

Comments
 (0)