Completed
Push — 1.10.x ( 284d08...23ef56 )
by Angel Fernando Quiroz
50:25
created
main/inc/lib/phpdocx/pdf/include/page_frame_decorator.cls.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
    * @link http://www.w3.org/TR/CSS21/page.html#forced
172 172
    *
173 173
    * @param Frame $frame the frame to check
174
-   * @return bool true if a page break occured
174
+   * @return null|boolean true if a page break occured
175 175
    */
176 176
   function check_forced_page_break(Frame $frame) {
177 177
 
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
    * correct location.
427 427
    *
428 428
    * @param Frame $frame the frame to check
429
-   * @return Frame the frame following the page break
429
+   * @return boolean the frame following the page break
430 430
    */
431 431
   function check_page_break(Frame $frame) {
432 432
     // Do not split if we have already
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
    * @param float $h
118 118
    */
119 119
   function set_containing_block($x = null, $y = null, $w = null, $h = null) {
120
-    parent::set_containing_block($x,$y,$w,$h);
120
+    parent::set_containing_block($x, $y, $w, $h);
121 121
     $w = $this->get_containing_block("w");
122
-    if ( isset($h) )
122
+    if (isset($h))
123 123
       $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w);
124 124
   }
125 125
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
   function check_forced_page_break(Frame $frame) {
177 177
 
178 178
     // Skip check if page is already split
179
-    if ( $this->_page_full )
179
+    if ($this->_page_full)
180 180
       return;
181 181
 
182 182
     $block_types = array("block", "list-item", "table");
@@ -184,15 +184,15 @@  discard block
 block discarded – undo
184 184
 
185 185
     $style = $frame->get_style();
186 186
 
187
-    if ( !in_array($style->display, $block_types) )
187
+    if (!in_array($style->display, $block_types))
188 188
       return false;
189 189
 
190 190
     // Find the previous block-level sibling
191 191
     $prev = $frame->get_prev_sibling();
192
-    while ( $prev && !in_array($prev->get_style()->display, $block_types) )
192
+    while ($prev && !in_array($prev->get_style()->display, $block_types))
193 193
       $prev = $prev->get_prev_sibling();
194 194
 
195
-    if ( in_array($style->page_break_before, $page_breaks) ) {
195
+    if (in_array($style->page_break_before, $page_breaks)) {
196 196
 
197 197
       // Prevent cascading splits
198 198
       $frame->split();
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
       return true;
204 204
     }
205 205
 
206
-    if ( ($prev && in_array($prev->get_style()->page_break_after, $page_breaks)) ) {
206
+    if (($prev && in_array($prev->get_style()->page_break_after, $page_breaks))) {
207 207
       // Prevent cascading splits
208 208
       $frame->split();
209 209
       $prev->get_style()->page_break_after = "auto";
@@ -270,32 +270,32 @@  discard block
 block discarded – undo
270 270
      */
271 271
 
272 272
     $block_types = array("block", "list-item", "table");
273
-    dompdf_debug("page-break", "_page_break_allowed(" . $frame->get_node()->nodeName. ")");
273
+    dompdf_debug("page-break", "_page_break_allowed(".$frame->get_node()->nodeName.")");
274 274
     $display = $frame->get_style()->display;
275 275
 
276 276
     // Block Frames (1):
277
-    if ( in_array($display, $block_types) ) {
277
+    if (in_array($display, $block_types)) {
278 278
 
279 279
       // Avoid breaks within table-cells
280
-      if ( $this->_in_table ) {
281
-        dompdf_debug("page-break", "In table: " . $this->_in_table);
280
+      if ($this->_in_table) {
281
+        dompdf_debug("page-break", "In table: ".$this->_in_table);
282 282
         return false;
283 283
       }
284 284
 
285 285
       // Rules A & B
286 286
 
287
-      if ( $frame->get_style()->page_break_before === "avoid" ) {
287
+      if ($frame->get_style()->page_break_before === "avoid") {
288 288
         dompdf_debug("page-break", "before: avoid");
289 289
         return false;
290 290
       }
291 291
 
292 292
       // Find the preceeding block-level sibling
293 293
       $prev = $frame->get_prev_sibling();
294
-      while ( $prev && !in_array($prev->get_style()->display, $block_types) )
294
+      while ($prev && !in_array($prev->get_style()->display, $block_types))
295 295
         $prev = $prev->get_prev_sibling();
296 296
 
297 297
       // Does the previous element allow a page break after?
298
-      if ( $prev && $prev->get_style()->page_break_after === "avoid" ) {
298
+      if ($prev && $prev->get_style()->page_break_after === "avoid") {
299 299
         dompdf_debug("page-break", "after: avoid");
300 300
         return false;
301 301
       }
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
       // If both $prev & $frame have the same parent, check the parent's
304 304
       // page_break_inside property.
305 305
       $parent = $frame->get_parent();
306
-      if ( $prev && $parent && $parent->get_style()->page_break_inside === "avoid" ) {
306
+      if ($prev && $parent && $parent->get_style()->page_break_inside === "avoid") {
307 307
           dompdf_debug("page-break", "parent inside: avoid");
308 308
         return false;
309 309
       }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
       // To prevent cascading page breaks when a top-level element has
312 312
       // page-break-inside: avoid, ensure that at least one frame is
313 313
       // on the page before splitting.
314
-      if ( $parent->get_node()->nodeName === "body" && !$prev ) {
314
+      if ($parent->get_node()->nodeName === "body" && !$prev) {
315 315
         // We are the body's first child
316 316
           dompdf_debug("page-break", "Body's first child.");
317 317
         return false;
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 
320 320
       // If the frame is the first block-level frame, use the value from
321 321
       // $frame's parent instead.
322
-      if ( !$prev && $parent )
323
-        return $this->_page_break_allowed( $parent );
322
+      if (!$prev && $parent)
323
+        return $this->_page_break_allowed($parent);
324 324
 
325 325
       dompdf_debug("page-break", "block: break allowed");
326 326
       return true;
@@ -328,17 +328,17 @@  discard block
 block discarded – undo
328 328
     }
329 329
 
330 330
     // Inline frames (2):
331
-    else if ( in_array($display, Style::$INLINE_TYPES) ) {
331
+    else if (in_array($display, Style::$INLINE_TYPES)) {
332 332
 
333 333
       // Avoid breaks within table-cells
334
-      if ( $this->_in_table ) {
335
-          dompdf_debug("page-break", "In table: " . $this->_in_table);
334
+      if ($this->_in_table) {
335
+          dompdf_debug("page-break", "In table: ".$this->_in_table);
336 336
         return false;
337 337
       }
338 338
 
339 339
       // Rule C
340 340
       $block_parent = $frame->find_block_parent();
341
-      if ( count($block_parent->get_lines() ) < $frame->get_style()->orphans ) {
341
+      if (count($block_parent->get_lines()) < $frame->get_style()->orphans) {
342 342
           dompdf_debug("page-break", "orphans");
343 343
         return false;
344 344
       }
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
       // Rule D
350 350
       $p = $block_parent;
351 351
       while ($p) {
352
-        if ( $p->get_style()->page_break_inside === "avoid" ) {
352
+        if ($p->get_style()->page_break_inside === "avoid") {
353 353
           dompdf_debug("page-break", "parent->inside: avoid");
354 354
           return false;
355 355
         }
@@ -360,32 +360,32 @@  discard block
 block discarded – undo
360 360
       // page-break-inside: avoid, ensure that at least one frame with
361 361
       // some content is on the page before splitting.
362 362
       $prev = $frame->get_prev_sibling();
363
-      while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") )
363
+      while ($prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == ""))
364 364
         $prev = $prev->get_prev_sibling();
365 365
 
366
-      if ( $block_parent->get_node()->nodeName === "body" && !$prev ) {
366
+      if ($block_parent->get_node()->nodeName === "body" && !$prev) {
367 367
         // We are the body's first child
368 368
           dompdf_debug("page-break", "Body's first child.");
369 369
         return false;
370 370
       }
371 371
 
372 372
       // Skip breaks on empty text nodes
373
-      if ( $frame->get_node()->nodeName === "#text" &&
374
-           $frame->get_node()->nodeValue == "" )
373
+      if ($frame->get_node()->nodeName === "#text" &&
374
+           $frame->get_node()->nodeValue == "")
375 375
         return false;
376 376
 
377 377
       dompdf_debug("page-break", "inline: break allowed");
378 378
       return true;
379 379
 
380 380
     // Table-rows
381
-    } else if ( $display === "table-row" ) {
381
+    } else if ($display === "table-row") {
382 382
 
383 383
       // Simply check if the parent table's page_break_inside property is
384 384
       // not 'avoid'
385 385
       $p = Table_Frame_Decorator::find_parent_table($frame);
386 386
 
387 387
       while ($p) {
388
-        if ( $p->get_style()->page_break_inside === "avoid" ) {
388
+        if ($p->get_style()->page_break_inside === "avoid") {
389 389
           dompdf_debug("page-break", "parent->inside: avoid");
390 390
           return false;
391 391
         }
@@ -393,28 +393,28 @@  discard block
 block discarded – undo
393 393
       }
394 394
 
395 395
       // Avoid breaking after the first row of a table
396
-      if ( $p && $p->get_first_child() === $frame) {
396
+      if ($p && $p->get_first_child() === $frame) {
397 397
          dompdf_debug("page-break", "table: first-row");
398 398
         return false;
399 399
       }
400 400
 
401 401
       // If this is a nested table, prevent the page from breaking
402
-      if ( $this->_in_table > 1 ) {
402
+      if ($this->_in_table > 1) {
403 403
         dompdf_debug("page-break", "table: nested table");
404 404
         return false;
405 405
       }
406 406
 
407
-      dompdf_debug("page-break","table-row/row-groups: break allowed");
407
+      dompdf_debug("page-break", "table-row/row-groups: break allowed");
408 408
       return true;
409 409
 
410
-    } else if ( in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) {
410
+    } else if (in_array($display, Table_Frame_Decorator::$ROW_GROUPS)) {
411 411
 
412 412
       // Disallow breaks at row-groups: only split at row boundaries
413 413
       return false;
414 414
 
415 415
     } else {
416 416
 
417
-      dompdf_debug("page-break", "? " . $frame->get_style()->display . "");
417
+      dompdf_debug("page-break", "? ".$frame->get_style()->display."");
418 418
       return false;
419 419
     }
420 420
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
    */
431 431
   function check_page_break(Frame $frame) {
432 432
     // Do not split if we have already
433
-    if ( $this->_page_full )
433
+    if ($this->_page_full)
434 434
       return false;
435 435
 
436 436
     // Determine the frame's maximum y value
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
     // If a split is to occur here, then the bottom margins & paddings of all
440 440
     // parents of $frame must fit on the page as well:
441 441
     $p = $frame->get_parent();
442
-    while ( $p ) {
442
+    while ($p) {
443 443
       $style = $p->get_style();
444 444
       $max_y += $style->length_in_pt(array($style->margin_bottom,
445 445
                                            $style->padding_bottom,
@@ -449,12 +449,12 @@  discard block
 block discarded – undo
449 449
 
450 450
 
451 451
     // Check if $frame flows off the page
452
-    if ( $max_y <= $this->_bottom_page_margin )
452
+    if ($max_y <= $this->_bottom_page_margin)
453 453
       // no: do nothing
454 454
       return false;
455 455
 
456 456
     dompdf_debug("page-break", "check_page_break");
457
-    dompdf_debug("page-break", "in_table: " . $this->_in_table);
457
+    dompdf_debug("page-break", "in_table: ".$this->_in_table);
458 458
 
459 459
 
460 460
     // yes: determine page break location
@@ -463,42 +463,42 @@  discard block
 block discarded – undo
463 463
 
464 464
     $in_table = $this->_in_table;
465 465
 
466
-    dompdf_debug("page-break","Starting search");
467
-    while ( $iter ) {
466
+    dompdf_debug("page-break", "Starting search");
467
+    while ($iter) {
468 468
 //       echo "\nbacktrack: " .$iter->get_node()->nodeName ." ".spl_object_hash($iter->get_node()). "";
469
-      if ( $iter === $this ) {
469
+      if ($iter === $this) {
470 470
          dompdf_debug("page-break", "reached root.");
471 471
         // We've reached the root in our search.  Just split at $frame.
472 472
         break;
473 473
       }
474 474
 
475
-      if ( $this->_page_break_allowed($iter) ) {
476
-        dompdf_debug("page-break","break allowed, splitting.");
475
+      if ($this->_page_break_allowed($iter)) {
476
+        dompdf_debug("page-break", "break allowed, splitting.");
477 477
         $iter->split();
478 478
         $this->_page_full = true;
479 479
         $this->_in_table = $in_table;
480 480
         return true;
481 481
       }
482 482
 
483
-      if ( !$flg && $next = $iter->get_last_child() ) {
483
+      if (!$flg && $next = $iter->get_last_child()) {
484 484
          dompdf_debug("page-break", "following last child.");
485 485
 
486
-        if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) )
486
+        if (in_array($next->get_style()->display, Style::$TABLE_TYPES))
487 487
           $this->_in_table++;
488 488
 
489 489
         $iter = $next;
490 490
         continue;
491 491
       }
492 492
 
493
-      if ( $next = $iter->get_prev_sibling() ) {
493
+      if ($next = $iter->get_prev_sibling()) {
494 494
          dompdf_debug("page-break", "following prev sibling.");
495 495
 
496
-        if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) &&
497
-             !in_array($iter->get_style()->display, Style::$TABLE_TYPES) )
496
+        if (in_array($next->get_style()->display, Style::$TABLE_TYPES) &&
497
+             !in_array($iter->get_style()->display, Style::$TABLE_TYPES))
498 498
           $this->_in_table++;
499 499
 
500
-        else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) &&
501
-                  in_array($iter->get_style()->display, Style::$TABLE_TYPES) )
500
+        else if (!in_array($next->get_style()->display, Style::$TABLE_TYPES) &&
501
+                  in_array($iter->get_style()->display, Style::$TABLE_TYPES))
502 502
           $this->_in_table--;
503 503
 
504 504
         $iter = $next;
@@ -506,10 +506,10 @@  discard block
 block discarded – undo
506 506
         continue;
507 507
       }
508 508
 
509
-      if ( $next = $iter->get_parent() ) {
509
+      if ($next = $iter->get_parent()) {
510 510
          dompdf_debug("page-break", "following parent.");
511 511
 
512
-        if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) )
512
+        if (in_array($iter->get_style()->display, Style::$TABLE_TYPES))
513 513
           $this->_in_table--;
514 514
 
515 515
         $iter = $next;
@@ -527,17 +527,17 @@  discard block
 block discarded – undo
527 527
     dompdf_debug("page-break", "no valid break found, just splitting.");
528 528
 
529 529
     // If we are in a table, backtrack to the nearest top-level table row
530
-    if ( $this->_in_table ) {
530
+    if ($this->_in_table) {
531 531
       $num_tables = $this->_in_table - 1;
532 532
 
533 533
       $iter = $frame;
534
-      while ( $iter && $num_tables && $iter->get_style->display !== "table" ) {
534
+      while ($iter && $num_tables && $iter->get_style->display !== "table") {
535 535
         $iter = $iter->get_parent();
536 536
         $num_tables--;
537 537
       }
538 538
 
539 539
       $iter = $frame;
540
-      while ($iter && $iter->get_style()->display !== "table-row" )
540
+      while ($iter && $iter->get_style()->display !== "table-row")
541 541
         $iter = $iter->get_parent();
542 542
 
543 543
       $iter->split();
Please login to merge, or discard this patch.
Braces   +46 added lines, -32 removed lines patch added patch discarded remove patch
@@ -119,8 +119,10 @@  discard block
 block discarded – undo
119 119
   function set_containing_block($x = null, $y = null, $w = null, $h = null) {
120 120
     parent::set_containing_block($x,$y,$w,$h);
121 121
     $w = $this->get_containing_block("w");
122
-    if ( isset($h) )
123
-      $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w);
122
+    if ( isset($h) ) {
123
+          $this->_bottom_page_margin = $h;
124
+    }
125
+    // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w);
124 126
   }
125 127
 
126 128
   /**
@@ -176,21 +178,24 @@  discard block
 block discarded – undo
176 178
   function check_forced_page_break(Frame $frame) {
177 179
 
178 180
     // Skip check if page is already split
179
-    if ( $this->_page_full )
180
-      return;
181
+    if ( $this->_page_full ) {
182
+          return;
183
+    }
181 184
 
182 185
     $block_types = array("block", "list-item", "table");
183 186
     $page_breaks = array("always", "left", "right");
184 187
 
185 188
     $style = $frame->get_style();
186 189
 
187
-    if ( !in_array($style->display, $block_types) )
188
-      return false;
190
+    if ( !in_array($style->display, $block_types) ) {
191
+          return false;
192
+    }
189 193
 
190 194
     // Find the previous block-level sibling
191 195
     $prev = $frame->get_prev_sibling();
192
-    while ( $prev && !in_array($prev->get_style()->display, $block_types) )
193
-      $prev = $prev->get_prev_sibling();
196
+    while ( $prev && !in_array($prev->get_style()->display, $block_types) ) {
197
+          $prev = $prev->get_prev_sibling();
198
+    }
194 199
 
195 200
     if ( in_array($style->page_break_before, $page_breaks) ) {
196 201
 
@@ -291,8 +296,9 @@  discard block
 block discarded – undo
291 296
 
292 297
       // Find the preceeding block-level sibling
293 298
       $prev = $frame->get_prev_sibling();
294
-      while ( $prev && !in_array($prev->get_style()->display, $block_types) )
295
-        $prev = $prev->get_prev_sibling();
299
+      while ( $prev && !in_array($prev->get_style()->display, $block_types) ) {
300
+              $prev = $prev->get_prev_sibling();
301
+      }
296 302
 
297 303
       // Does the previous element allow a page break after?
298 304
       if ( $prev && $prev->get_style()->page_break_after === "avoid" ) {
@@ -319,8 +325,9 @@  discard block
 block discarded – undo
319 325
 
320 326
       // If the frame is the first block-level frame, use the value from
321 327
       // $frame's parent instead.
322
-      if ( !$prev && $parent )
323
-        return $this->_page_break_allowed( $parent );
328
+      if ( !$prev && $parent ) {
329
+              return $this->_page_break_allowed( $parent );
330
+      }
324 331
 
325 332
       dompdf_debug("page-break", "block: break allowed");
326 333
       return true;
@@ -360,8 +367,9 @@  discard block
 block discarded – undo
360 367
       // page-break-inside: avoid, ensure that at least one frame with
361 368
       // some content is on the page before splitting.
362 369
       $prev = $frame->get_prev_sibling();
363
-      while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") )
364
-        $prev = $prev->get_prev_sibling();
370
+      while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) {
371
+              $prev = $prev->get_prev_sibling();
372
+      }
365 373
 
366 374
       if ( $block_parent->get_node()->nodeName === "body" && !$prev ) {
367 375
         // We are the body's first child
@@ -371,8 +379,9 @@  discard block
 block discarded – undo
371 379
 
372 380
       // Skip breaks on empty text nodes
373 381
       if ( $frame->get_node()->nodeName === "#text" &&
374
-           $frame->get_node()->nodeValue == "" )
375
-        return false;
382
+           $frame->get_node()->nodeValue == "" ) {
383
+              return false;
384
+      }
376 385
 
377 386
       dompdf_debug("page-break", "inline: break allowed");
378 387
       return true;
@@ -430,8 +439,9 @@  discard block
 block discarded – undo
430 439
    */
431 440
   function check_page_break(Frame $frame) {
432 441
     // Do not split if we have already
433
-    if ( $this->_page_full )
434
-      return false;
442
+    if ( $this->_page_full ) {
443
+          return false;
444
+    }
435 445
 
436 446
     // Determine the frame's maximum y value
437 447
     $max_y = $frame->get_position("y") + $frame->get_margin_height();
@@ -449,9 +459,10 @@  discard block
 block discarded – undo
449 459
 
450 460
 
451 461
     // Check if $frame flows off the page
452
-    if ( $max_y <= $this->_bottom_page_margin )
453
-      // no: do nothing
462
+    if ( $max_y <= $this->_bottom_page_margin ) {
463
+          // no: do nothing
454 464
       return false;
465
+    }
455 466
 
456 467
     dompdf_debug("page-break", "check_page_break");
457 468
     dompdf_debug("page-break", "in_table: " . $this->_in_table);
@@ -483,8 +494,9 @@  discard block
 block discarded – undo
483 494
       if ( !$flg && $next = $iter->get_last_child() ) {
484 495
          dompdf_debug("page-break", "following last child.");
485 496
 
486
-        if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) )
487
-          $this->_in_table++;
497
+        if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) ) {
498
+                  $this->_in_table++;
499
+        }
488 500
 
489 501
         $iter = $next;
490 502
         continue;
@@ -494,12 +506,12 @@  discard block
 block discarded – undo
494 506
          dompdf_debug("page-break", "following prev sibling.");
495 507
 
496 508
         if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) &&
497
-             !in_array($iter->get_style()->display, Style::$TABLE_TYPES) )
498
-          $this->_in_table++;
499
-
500
-        else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) &&
501
-                  in_array($iter->get_style()->display, Style::$TABLE_TYPES) )
502
-          $this->_in_table--;
509
+             !in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) {
510
+                  $this->_in_table++;
511
+        } else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) &&
512
+                  in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) {
513
+                  $this->_in_table--;
514
+        }
503 515
 
504 516
         $iter = $next;
505 517
         $flg = false;
@@ -509,8 +521,9 @@  discard block
 block discarded – undo
509 521
       if ( $next = $iter->get_parent() ) {
510 522
          dompdf_debug("page-break", "following parent.");
511 523
 
512
-        if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) )
513
-          $this->_in_table--;
524
+        if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) {
525
+                  $this->_in_table--;
526
+        }
514 527
 
515 528
         $iter = $next;
516 529
         $flg = true;
@@ -537,8 +550,9 @@  discard block
 block discarded – undo
537 550
       }
538 551
 
539 552
       $iter = $frame;
540
-      while ($iter && $iter->get_style()->display !== "table-row" )
541
-        $iter = $iter->get_parent();
553
+      while ($iter && $iter->get_style()->display !== "table-row" ) {
554
+              $iter = $iter->get_parent();
555
+      }
542 556
 
543 557
       $iter->split();
544 558
       $this->_page_full = true;
Please login to merge, or discard this patch.
Indentation   +259 added lines, -260 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
34 34
  * @copyright 2004 Benj Carson
35 35
  * @author Benj Carson <[email protected]>
36 36
  * @package dompdf
37
-
38 37
  */
39 38
 
40 39
 /* $Id: page_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -47,137 +46,137 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class Page_Frame_Decorator extends Frame_Decorator {
49 48
 
50
-  /**
51
-   * y value of bottom page margin
52
-   *
53
-   * @var float
54
-   */
55
-  protected $_bottom_page_margin;
56
-
57
-  /**
58
-   * Flag indicating page is full.
59
-   *
60
-   * @var bool
61
-   */
62
-  protected $_page_full;
63
-
64
-  /**
65
-   * Number of tables currently being reflowed
66
-   *
67
-   * @var int
68
-   */
69
-  protected $_in_table;
70
-
71
-  /**
72
-   * The pdf renderer
73
-   *
74
-   * @var Renderer
75
-   */
76
-  protected $_renderer;
77
-
78
-  //........................................................................
79
-
80
-  /**
81
-   * Class constructor
82
-   *
83
-   * @param Frame $frame the frame to decorate
84
-   */
85
-  function __construct(Frame $frame, DOMPDF $dompdf) {
49
+    /**
50
+     * y value of bottom page margin
51
+     *
52
+     * @var float
53
+     */
54
+    protected $_bottom_page_margin;
55
+
56
+    /**
57
+     * Flag indicating page is full.
58
+     *
59
+     * @var bool
60
+     */
61
+    protected $_page_full;
62
+
63
+    /**
64
+     * Number of tables currently being reflowed
65
+     *
66
+     * @var int
67
+     */
68
+    protected $_in_table;
69
+
70
+    /**
71
+     * The pdf renderer
72
+     *
73
+     * @var Renderer
74
+     */
75
+    protected $_renderer;
76
+
77
+    //........................................................................
78
+
79
+    /**
80
+     * Class constructor
81
+     *
82
+     * @param Frame $frame the frame to decorate
83
+     */
84
+    function __construct(Frame $frame, DOMPDF $dompdf) {
86 85
     parent::__construct($frame, $dompdf);
87 86
     $this->_page_full = false;
88 87
     $this->_in_table = 0;
89 88
     $this->_bottom_page_margin = null;
90
-  }
89
+    }
91 90
 
92 91
 
93
-  /**
94
-   * Set the renderer used for this pdf
95
-   *
96
-   * @param Renderer $renderer the renderer to use
97
-   */
98
-  function set_renderer($renderer) {
92
+    /**
93
+     * Set the renderer used for this pdf
94
+     *
95
+     * @param Renderer $renderer the renderer to use
96
+     */
97
+    function set_renderer($renderer) {
99 98
     $this->_renderer = $renderer;
100
-  }
101
-
102
-  /**
103
-   * Return the renderer used for this pdf
104
-   *
105
-   * @return Renderer
106
-   */
107
-  function get_renderer() {
99
+    }
100
+
101
+    /**
102
+     * Return the renderer used for this pdf
103
+     *
104
+     * @return Renderer
105
+     */
106
+    function get_renderer() {
108 107
     return $this->_renderer;
109
-  }
110
-
111
-  /**
112
-   * Set the frame's containing block.  Overridden to set $this->_bottom_page_margin.
113
-   *
114
-   * @param float $x
115
-   * @param float $y
116
-   * @param float $w
117
-   * @param float $h
118
-   */
119
-  function set_containing_block($x = null, $y = null, $w = null, $h = null) {
108
+    }
109
+
110
+    /**
111
+     * Set the frame's containing block.  Overridden to set $this->_bottom_page_margin.
112
+     *
113
+     * @param float $x
114
+     * @param float $y
115
+     * @param float $w
116
+     * @param float $h
117
+     */
118
+    function set_containing_block($x = null, $y = null, $w = null, $h = null) {
120 119
     parent::set_containing_block($x,$y,$w,$h);
121 120
     $w = $this->get_containing_block("w");
122 121
     if ( isset($h) )
123
-      $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w);
124
-  }
125
-
126
-  /**
127
-   * Returns true if the page is full and is no longer accepting frames.
128
-   *
129
-   * @return bool
130
-   */
131
-  function is_full() {
122
+        $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w);
123
+    }
124
+
125
+    /**
126
+     * Returns true if the page is full and is no longer accepting frames.
127
+     *
128
+     * @return bool
129
+     */
130
+    function is_full() {
132 131
     return $this->_page_full;
133
-  }
132
+    }
134 133
 
135
-  /**
136
-   * Start a new page by resetting the full flag.
137
-   */
138
-  function next_page() {
134
+    /**
135
+     * Start a new page by resetting the full flag.
136
+     */
137
+    function next_page() {
139 138
     $this->_renderer->new_page();
140 139
     $this->_page_full = false;
141
-  }
140
+    }
142 141
 
143
-  /**
144
-   * Indicate to the page that a table is currently being reflowed.
145
-   */
146
-  function table_reflow_start() {
142
+    /**
143
+     * Indicate to the page that a table is currently being reflowed.
144
+     */
145
+    function table_reflow_start() {
147 146
     $this->_in_table++;
148
-  }
147
+    }
149 148
 
150
-  /**
151
-   * Indicate to the page that table reflow is finished.
152
-   */
153
-  function table_reflow_end() {
149
+    /**
150
+     * Indicate to the page that table reflow is finished.
151
+     */
152
+    function table_reflow_end() {
154 153
     $this->_in_table--;
155
-  }
156
-
157
-  /**
158
-   * Return whether we are currently in a nested table or not
159
-   *
160
-   * @return bool
161
-   */
162
-  function in_nested_table() {
154
+    }
155
+
156
+    /**
157
+     * Return whether we are currently in a nested table or not
158
+     *
159
+     * @return bool
160
+     */
161
+    function in_nested_table() {
163 162
     return $this->_in_table > 1;
164
-  }
163
+    }
165 164
   
166
-  /**
167
-   * Check if a forced page break is required before $frame.  This uses the
168
-   * frame's page_break_before property as well as the preceeding frame's
169
-   * page_break_after property.
170
-   *
171
-   * @link http://www.w3.org/TR/CSS21/page.html#forced
172
-   *
173
-   * @param Frame $frame the frame to check
174
-   * @return bool true if a page break occured
175
-   */
176
-  function check_forced_page_break(Frame $frame) {
165
+    /**
166
+     * Check if a forced page break is required before $frame.  This uses the
167
+     * frame's page_break_before property as well as the preceeding frame's
168
+     * page_break_after property.
169
+     *
170
+     * @link http://www.w3.org/TR/CSS21/page.html#forced
171
+     *
172
+     * @param Frame $frame the frame to check
173
+     * @return bool true if a page break occured
174
+     */
175
+    function check_forced_page_break(Frame $frame) {
177 176
 
178 177
     // Skip check if page is already split
179 178
     if ( $this->_page_full )
180
-      return;
179
+        return;
181 180
 
182 181
     $block_types = array("block", "list-item", "table");
183 182
     $page_breaks = array("always", "left", "right");
@@ -185,42 +184,42 @@  discard block
 block discarded – undo
185 184
     $style = $frame->get_style();
186 185
 
187 186
     if ( !in_array($style->display, $block_types) )
188
-      return false;
187
+        return false;
189 188
 
190 189
     // Find the previous block-level sibling
191 190
     $prev = $frame->get_prev_sibling();
192 191
     while ( $prev && !in_array($prev->get_style()->display, $block_types) )
193
-      $prev = $prev->get_prev_sibling();
192
+        $prev = $prev->get_prev_sibling();
194 193
 
195 194
     if ( in_array($style->page_break_before, $page_breaks) ) {
196 195
 
197
-      // Prevent cascading splits
198
-      $frame->split();
199
-      // We have to grab the style again here because split() resets
200
-      // $frame->style to the frame's orignal style.
201
-      $frame->get_style()->page_break_before = "auto";
202
-      $this->_page_full = true;
203
-      return true;
196
+        // Prevent cascading splits
197
+        $frame->split();
198
+        // We have to grab the style again here because split() resets
199
+        // $frame->style to the frame's orignal style.
200
+        $frame->get_style()->page_break_before = "auto";
201
+        $this->_page_full = true;
202
+        return true;
204 203
     }
205 204
 
206 205
     if ( ($prev && in_array($prev->get_style()->page_break_after, $page_breaks)) ) {
207
-      // Prevent cascading splits
208
-      $frame->split();
209
-      $prev->get_style()->page_break_after = "auto";
210
-      $this->_page_full = true;
211
-      return true;
206
+        // Prevent cascading splits
207
+        $frame->split();
208
+        $prev->get_style()->page_break_after = "auto";
209
+        $this->_page_full = true;
210
+        return true;
212 211
     }
213 212
 
214 213
     return false;
215
-  }
216
-
217
-  /**
218
-   * Determine if a page break is allowed before $frame
219
-   *
220
-   * @param Frame $frame the frame to check
221
-   * @return bool true if a break is allowed, false otherwise
222
-   */
223
-  protected function _page_break_allowed(Frame $frame) {
214
+    }
215
+
216
+    /**
217
+     * Determine if a page break is allowed before $frame
218
+     *
219
+     * @param Frame $frame the frame to check
220
+     * @return bool true if a break is allowed, false otherwise
221
+     */
222
+    protected function _page_break_allowed(Frame $frame) {
224 223
     /**
225 224
      *
226 225
      * http://www.w3.org/TR/CSS21/page.html#allowed-page-breaks
@@ -276,162 +275,162 @@  discard block
 block discarded – undo
276 275
     // Block Frames (1):
277 276
     if ( in_array($display, $block_types) ) {
278 277
 
279
-      // Avoid breaks within table-cells
280
-      if ( $this->_in_table ) {
278
+        // Avoid breaks within table-cells
279
+        if ( $this->_in_table ) {
281 280
         dompdf_debug("page-break", "In table: " . $this->_in_table);
282 281
         return false;
283
-      }
282
+        }
284 283
 
285
-      // Rules A & B
284
+        // Rules A & B
286 285
 
287
-      if ( $frame->get_style()->page_break_before === "avoid" ) {
286
+        if ( $frame->get_style()->page_break_before === "avoid" ) {
288 287
         dompdf_debug("page-break", "before: avoid");
289 288
         return false;
290
-      }
289
+        }
291 290
 
292
-      // Find the preceeding block-level sibling
293
-      $prev = $frame->get_prev_sibling();
294
-      while ( $prev && !in_array($prev->get_style()->display, $block_types) )
291
+        // Find the preceeding block-level sibling
292
+        $prev = $frame->get_prev_sibling();
293
+        while ( $prev && !in_array($prev->get_style()->display, $block_types) )
295 294
         $prev = $prev->get_prev_sibling();
296 295
 
297
-      // Does the previous element allow a page break after?
298
-      if ( $prev && $prev->get_style()->page_break_after === "avoid" ) {
296
+        // Does the previous element allow a page break after?
297
+        if ( $prev && $prev->get_style()->page_break_after === "avoid" ) {
299 298
         dompdf_debug("page-break", "after: avoid");
300 299
         return false;
301
-      }
300
+        }
302 301
 
303
-      // If both $prev & $frame have the same parent, check the parent's
304
-      // page_break_inside property.
305
-      $parent = $frame->get_parent();
306
-      if ( $prev && $parent && $parent->get_style()->page_break_inside === "avoid" ) {
307
-          dompdf_debug("page-break", "parent inside: avoid");
302
+        // If both $prev & $frame have the same parent, check the parent's
303
+        // page_break_inside property.
304
+        $parent = $frame->get_parent();
305
+        if ( $prev && $parent && $parent->get_style()->page_break_inside === "avoid" ) {
306
+            dompdf_debug("page-break", "parent inside: avoid");
308 307
         return false;
309
-      }
308
+        }
310 309
 
311
-      // To prevent cascading page breaks when a top-level element has
312
-      // page-break-inside: avoid, ensure that at least one frame is
313
-      // on the page before splitting.
314
-      if ( $parent->get_node()->nodeName === "body" && !$prev ) {
310
+        // To prevent cascading page breaks when a top-level element has
311
+        // page-break-inside: avoid, ensure that at least one frame is
312
+        // on the page before splitting.
313
+        if ( $parent->get_node()->nodeName === "body" && !$prev ) {
315 314
         // We are the body's first child
316
-          dompdf_debug("page-break", "Body's first child.");
315
+            dompdf_debug("page-break", "Body's first child.");
317 316
         return false;
318
-      }
317
+        }
319 318
 
320
-      // If the frame is the first block-level frame, use the value from
321
-      // $frame's parent instead.
322
-      if ( !$prev && $parent )
319
+        // If the frame is the first block-level frame, use the value from
320
+        // $frame's parent instead.
321
+        if ( !$prev && $parent )
323 322
         return $this->_page_break_allowed( $parent );
324 323
 
325
-      dompdf_debug("page-break", "block: break allowed");
326
-      return true;
324
+        dompdf_debug("page-break", "block: break allowed");
325
+        return true;
327 326
 
328 327
     }
329 328
 
330 329
     // Inline frames (2):
331 330
     else if ( in_array($display, Style::$INLINE_TYPES) ) {
332 331
 
333
-      // Avoid breaks within table-cells
334
-      if ( $this->_in_table ) {
335
-          dompdf_debug("page-break", "In table: " . $this->_in_table);
332
+        // Avoid breaks within table-cells
333
+        if ( $this->_in_table ) {
334
+            dompdf_debug("page-break", "In table: " . $this->_in_table);
336 335
         return false;
337
-      }
336
+        }
338 337
 
339
-      // Rule C
340
-      $block_parent = $frame->find_block_parent();
341
-      if ( count($block_parent->get_lines() ) < $frame->get_style()->orphans ) {
342
-          dompdf_debug("page-break", "orphans");
338
+        // Rule C
339
+        $block_parent = $frame->find_block_parent();
340
+        if ( count($block_parent->get_lines() ) < $frame->get_style()->orphans ) {
341
+            dompdf_debug("page-break", "orphans");
343 342
         return false;
344
-      }
343
+        }
345 344
 
346
-      // FIXME: Checking widows is tricky without having laid out the
347
-      // remaining line boxes.  Just ignore it for now...
345
+        // FIXME: Checking widows is tricky without having laid out the
346
+        // remaining line boxes.  Just ignore it for now...
348 347
 
349
-      // Rule D
350
-      $p = $block_parent;
351
-      while ($p) {
348
+        // Rule D
349
+        $p = $block_parent;
350
+        while ($p) {
352 351
         if ( $p->get_style()->page_break_inside === "avoid" ) {
353
-          dompdf_debug("page-break", "parent->inside: avoid");
354
-          return false;
352
+            dompdf_debug("page-break", "parent->inside: avoid");
353
+            return false;
355 354
         }
356 355
         $p = $p->find_block_parent();
357
-      }
356
+        }
358 357
 
359
-      // To prevent cascading page breaks when a top-level element has
360
-      // page-break-inside: avoid, ensure that at least one frame with
361
-      // some content is on the page before splitting.
362
-      $prev = $frame->get_prev_sibling();
363
-      while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") )
358
+        // To prevent cascading page breaks when a top-level element has
359
+        // page-break-inside: avoid, ensure that at least one frame with
360
+        // some content is on the page before splitting.
361
+        $prev = $frame->get_prev_sibling();
362
+        while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") )
364 363
         $prev = $prev->get_prev_sibling();
365 364
 
366
-      if ( $block_parent->get_node()->nodeName === "body" && !$prev ) {
365
+        if ( $block_parent->get_node()->nodeName === "body" && !$prev ) {
367 366
         // We are the body's first child
368
-          dompdf_debug("page-break", "Body's first child.");
367
+            dompdf_debug("page-break", "Body's first child.");
369 368
         return false;
370
-      }
369
+        }
371 370
 
372
-      // Skip breaks on empty text nodes
373
-      if ( $frame->get_node()->nodeName === "#text" &&
371
+        // Skip breaks on empty text nodes
372
+        if ( $frame->get_node()->nodeName === "#text" &&
374 373
            $frame->get_node()->nodeValue == "" )
375 374
         return false;
376 375
 
377
-      dompdf_debug("page-break", "inline: break allowed");
378
-      return true;
376
+        dompdf_debug("page-break", "inline: break allowed");
377
+        return true;
379 378
 
380 379
     // Table-rows
381 380
     } else if ( $display === "table-row" ) {
382 381
 
383
-      // Simply check if the parent table's page_break_inside property is
384
-      // not 'avoid'
385
-      $p = Table_Frame_Decorator::find_parent_table($frame);
382
+        // Simply check if the parent table's page_break_inside property is
383
+        // not 'avoid'
384
+        $p = Table_Frame_Decorator::find_parent_table($frame);
386 385
 
387
-      while ($p) {
386
+        while ($p) {
388 387
         if ( $p->get_style()->page_break_inside === "avoid" ) {
389
-          dompdf_debug("page-break", "parent->inside: avoid");
390
-          return false;
388
+            dompdf_debug("page-break", "parent->inside: avoid");
389
+            return false;
391 390
         }
392 391
         $p = $p->find_block_parent();
393
-      }
392
+        }
394 393
 
395
-      // Avoid breaking after the first row of a table
396
-      if ( $p && $p->get_first_child() === $frame) {
397
-         dompdf_debug("page-break", "table: first-row");
394
+        // Avoid breaking after the first row of a table
395
+        if ( $p && $p->get_first_child() === $frame) {
396
+            dompdf_debug("page-break", "table: first-row");
398 397
         return false;
399
-      }
398
+        }
400 399
 
401
-      // If this is a nested table, prevent the page from breaking
402
-      if ( $this->_in_table > 1 ) {
400
+        // If this is a nested table, prevent the page from breaking
401
+        if ( $this->_in_table > 1 ) {
403 402
         dompdf_debug("page-break", "table: nested table");
404 403
         return false;
405
-      }
404
+        }
406 405
 
407
-      dompdf_debug("page-break","table-row/row-groups: break allowed");
408
-      return true;
406
+        dompdf_debug("page-break","table-row/row-groups: break allowed");
407
+        return true;
409 408
 
410 409
     } else if ( in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) {
411 410
 
412
-      // Disallow breaks at row-groups: only split at row boundaries
413
-      return false;
411
+        // Disallow breaks at row-groups: only split at row boundaries
412
+        return false;
414 413
 
415 414
     } else {
416 415
 
417
-      dompdf_debug("page-break", "? " . $frame->get_style()->display . "");
418
-      return false;
416
+        dompdf_debug("page-break", "? " . $frame->get_style()->display . "");
417
+        return false;
419 418
     }
420 419
 
421
-  }
422
-
423
-  /**
424
-   * Check if $frame will fit on the page.  If the frame does not fit,
425
-   * the frame tree is modified so that a page break occurs in the
426
-   * correct location.
427
-   *
428
-   * @param Frame $frame the frame to check
429
-   * @return Frame the frame following the page break
430
-   */
431
-  function check_page_break(Frame $frame) {
420
+    }
421
+
422
+    /**
423
+     * Check if $frame will fit on the page.  If the frame does not fit,
424
+     * the frame tree is modified so that a page break occurs in the
425
+     * correct location.
426
+     *
427
+     * @param Frame $frame the frame to check
428
+     * @return Frame the frame following the page break
429
+     */
430
+    function check_page_break(Frame $frame) {
432 431
     // Do not split if we have already
433 432
     if ( $this->_page_full )
434
-      return false;
433
+        return false;
435 434
 
436 435
     // Determine the frame's maximum y value
437 436
     $max_y = $frame->get_position("y") + $frame->get_margin_height();
@@ -440,18 +439,18 @@  discard block
 block discarded – undo
440 439
     // parents of $frame must fit on the page as well:
441 440
     $p = $frame->get_parent();
442 441
     while ( $p ) {
443
-      $style = $p->get_style();
444
-      $max_y += $style->length_in_pt(array($style->margin_bottom,
445
-                                           $style->padding_bottom,
446
-                                           $style->border_bottom_width));
447
-      $p = $p->get_parent();
442
+        $style = $p->get_style();
443
+        $max_y += $style->length_in_pt(array($style->margin_bottom,
444
+                                            $style->padding_bottom,
445
+                                            $style->border_bottom_width));
446
+        $p = $p->get_parent();
448 447
     }
449 448
 
450 449
 
451 450
     // Check if $frame flows off the page
452 451
     if ( $max_y <= $this->_bottom_page_margin )
453
-      // no: do nothing
454
-      return false;
452
+        // no: do nothing
453
+        return false;
455 454
 
456 455
     dompdf_debug("page-break", "check_page_break");
457 456
     dompdf_debug("page-break", "in_table: " . $this->_in_table);
@@ -466,58 +465,58 @@  discard block
 block discarded – undo
466 465
     dompdf_debug("page-break","Starting search");
467 466
     while ( $iter ) {
468 467
 //       echo "\nbacktrack: " .$iter->get_node()->nodeName ." ".spl_object_hash($iter->get_node()). "";
469
-      if ( $iter === $this ) {
470
-         dompdf_debug("page-break", "reached root.");
468
+        if ( $iter === $this ) {
469
+            dompdf_debug("page-break", "reached root.");
471 470
         // We've reached the root in our search.  Just split at $frame.
472 471
         break;
473
-      }
472
+        }
474 473
 
475
-      if ( $this->_page_break_allowed($iter) ) {
474
+        if ( $this->_page_break_allowed($iter) ) {
476 475
         dompdf_debug("page-break","break allowed, splitting.");
477 476
         $iter->split();
478 477
         $this->_page_full = true;
479 478
         $this->_in_table = $in_table;
480 479
         return true;
481
-      }
480
+        }
482 481
 
483
-      if ( !$flg && $next = $iter->get_last_child() ) {
484
-         dompdf_debug("page-break", "following last child.");
482
+        if ( !$flg && $next = $iter->get_last_child() ) {
483
+            dompdf_debug("page-break", "following last child.");
485 484
 
486 485
         if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) )
487
-          $this->_in_table++;
486
+            $this->_in_table++;
488 487
 
489 488
         $iter = $next;
490 489
         continue;
491
-      }
490
+        }
492 491
 
493
-      if ( $next = $iter->get_prev_sibling() ) {
494
-         dompdf_debug("page-break", "following prev sibling.");
492
+        if ( $next = $iter->get_prev_sibling() ) {
493
+            dompdf_debug("page-break", "following prev sibling.");
495 494
 
496 495
         if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) &&
497 496
              !in_array($iter->get_style()->display, Style::$TABLE_TYPES) )
498
-          $this->_in_table++;
497
+            $this->_in_table++;
499 498
 
500 499
         else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) &&
501 500
                   in_array($iter->get_style()->display, Style::$TABLE_TYPES) )
502
-          $this->_in_table--;
501
+            $this->_in_table--;
503 502
 
504 503
         $iter = $next;
505 504
         $flg = false;
506 505
         continue;
507
-      }
506
+        }
508 507
 
509
-      if ( $next = $iter->get_parent() ) {
510
-         dompdf_debug("page-break", "following parent.");
508
+        if ( $next = $iter->get_parent() ) {
509
+            dompdf_debug("page-break", "following parent.");
511 510
 
512 511
         if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) )
513
-          $this->_in_table--;
512
+            $this->_in_table--;
514 513
 
515 514
         $iter = $next;
516 515
         $flg = true;
517 516
         continue;
518
-      }
517
+        }
519 518
 
520
-      break;
519
+        break;
521 520
 
522 521
     }
523 522
 
@@ -528,33 +527,33 @@  discard block
 block discarded – undo
528 527
 
529 528
     // If we are in a table, backtrack to the nearest top-level table row
530 529
     if ( $this->_in_table ) {
531
-      $num_tables = $this->_in_table - 1;
530
+        $num_tables = $this->_in_table - 1;
532 531
 
533
-      $iter = $frame;
534
-      while ( $iter && $num_tables && $iter->get_style->display !== "table" ) {
532
+        $iter = $frame;
533
+        while ( $iter && $num_tables && $iter->get_style->display !== "table" ) {
535 534
         $iter = $iter->get_parent();
536 535
         $num_tables--;
537
-      }
536
+        }
538 537
 
539
-      $iter = $frame;
540
-      while ($iter && $iter->get_style()->display !== "table-row" )
538
+        $iter = $frame;
539
+        while ($iter && $iter->get_style()->display !== "table-row" )
541 540
         $iter = $iter->get_parent();
542 541
 
543
-      $iter->split();
544
-      $this->_page_full = true;
545
-      return true;
542
+        $iter->split();
543
+        $this->_page_full = true;
544
+        return true;
546 545
     }
547 546
 
548 547
     $frame->split();
549 548
     $this->_page_full = true;
550 549
     return true;
551 550
 
552
-  }
551
+    }
553 552
 
554
-  //........................................................................
553
+    //........................................................................
555 554
 
556
-  function split($frame = null) {
555
+    function split($frame = null) {
557 556
     // Do nothing
558
-  }
557
+    }
559 558
 
560 559
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/pdflib_adapter.cls.php 5 patches
Doc Comments   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -442,6 +442,9 @@  discard block
 block discarded – undo
442 442
    * @param string corner
443 443
    * @param string join
444 444
    * @param array dash
445
+   * @param double $width
446
+   * @param string $cap
447
+   * @param string $join
445 448
    */
446 449
   protected function _set_line_style($width, $cap, $join, $dash) {
447 450
 
@@ -795,8 +798,8 @@  discard block
 block discarded – undo
795 798
    * @param string $font the font file to use
796 799
    * @param float $size the font size, in points
797 800
    * @param array $color
798
-   * @param float $adjust word spacing adjustment
799
-   * @param float $angle angle to write the text at, measured CW starting from the x-axis
801
+   * @param integer $adjust word spacing adjustment
802
+   * @param integer $angle angle to write the text at, measured CW starting from the x-axis
800 803
    */
801 804
   function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
802 805
                      $adjust = 0, $angle = 0,  $blend = "Normal", $opacity = 1.0) {
Please login to merge, or discard this patch.
Switch Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -454,37 +454,37 @@  discard block
 block discarded – undo
454 454
       $this->_pdf->setdash(0,0);
455 455
 
456 456
     switch ( $join ) {
457
-    case "miter":
458
-      $this->_pdf->setlinejoin(0);
459
-      break;
457
+        case "miter":
458
+          $this->_pdf->setlinejoin(0);
459
+          break;
460 460
 
461
-    case "round":
462
-      $this->_pdf->setlinejoin(1);
463
-      break;
461
+        case "round":
462
+          $this->_pdf->setlinejoin(1);
463
+          break;
464 464
 
465
-    case "bevel":
466
-      $this->_pdf->setlinejoin(2);
467
-      break;
465
+        case "bevel":
466
+          $this->_pdf->setlinejoin(2);
467
+          break;
468 468
 
469
-    default:
470
-      break;
469
+        default:
470
+          break;
471 471
     }
472 472
 
473 473
     switch ( $cap ) {
474
-    case "butt":
475
-      $this->_pdf->setlinecap(0);
476
-      break;
474
+        case "butt":
475
+          $this->_pdf->setlinecap(0);
476
+          break;
477 477
 
478
-    case "round":
479
-      $this->_pdf->setlinecap(1);
480
-      break;
478
+        case "round":
479
+          $this->_pdf->setlinecap(1);
480
+          break;
481 481
 
482
-    case "square":
483
-      $this->_pdf->setlinecap(2);
484
-      break;
482
+        case "square":
483
+          $this->_pdf->setlinecap(2);
484
+          break;
485 485
 
486
-    default:
487
-      break;
486
+        default:
487
+          break;
488 488
     }
489 489
 
490 490
     $this->_pdf->setlinewidth($width);
@@ -855,18 +855,18 @@  discard block
 block discarded – undo
855 855
 
856 856
         switch ($_t) {
857 857
 
858
-        case "text":
859
-          $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"),
860
-                              array($p, $this->_page_count), $text);
861
-          $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
862
-          break;
863
-
864
-        case "script":
865
-          if (!$eval) {
866
-            $eval = new PHP_Evaluator($this);
867
-          }
868
-          $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count));
869
-          break;
858
+            case "text":
859
+              $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"),
860
+                                  array($p, $this->_page_count), $text);
861
+              $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
862
+              break;
863
+
864
+            case "script":
865
+              if (!$eval) {
866
+                $eval = new PHP_Evaluator($this);
867
+              }
868
+              $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count));
869
+              break;
870 870
         }
871 871
       }
872 872
 
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -185,25 +185,25 @@  discard block
 block discarded – undo
185 185
    * @param string $orientation The orientation of the document (either 'landscape' or 'portrait')
186 186
    */
187 187
   function __construct($paper = "letter", $orientation = "portrait") {
188
-    if ( is_array($paper) )
188
+    if (is_array($paper))
189 189
       $size = $paper;
190
-    else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) )
190
+    else if (isset(self::$PAPER_SIZES[mb_strtolower($paper)]))
191 191
       $size = self::$PAPER_SIZES[mb_strtolower($paper)];
192 192
     else
193 193
       $size = self::$PAPER_SIZES["letter"];
194 194
 
195
-    if ( mb_strtolower($orientation) === "landscape" ) {
195
+    if (mb_strtolower($orientation) === "landscape") {
196 196
       $a = $size[3];
197 197
       $size[3] = $size[2];
198 198
       $size[2] = $a;
199 199
     }
200 200
     $this->_width = $size[2] - $size[0];
201
-    $this->_height= $size[3] - $size[1];
201
+    $this->_height = $size[3] - $size[1];
202 202
 
203 203
     $this->_pdf = new PDFLib();
204 204
 
205
-	if ( defined("DOMPDF_PDFLIB_LICENSE") )
206
-      $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE);
205
+	if (defined("DOMPDF_PDFLIB_LICENSE"))
206
+      $this->_pdf->set_parameter("license", DOMPDF_PDFLIB_LICENSE);
207 207
 
208 208
 	$this->_pdf->set_parameter("textformat", "utf8");
209 209
     $this->_pdf->set_parameter("fontwarning", "false");
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     $this->_pdf->set_info("Creator", "DOMPDF Converter");
212 212
 
213 213
     // Silence pedantic warnings about missing TZ settings
214
-    if ( function_exists("date_default_timezone_get") ) {
214
+    if (function_exists("date_default_timezone_get")) {
215 215
       $tz = @date_default_timezone_get();
216 216
       date_default_timezone_set("UTC");
217 217
       $this->_pdf->set_info("Date", date("Y-m-d"));
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
       $this->_pdf->set_info("Date", date("Y-m-d"));
221 221
     }
222 222
 
223
-    if ( self::$IN_MEMORY )
224
-      $this->_pdf->begin_document("","");
223
+    if (self::$IN_MEMORY)
224
+      $this->_pdf->begin_document("", "");
225 225
     else {
226 226
       $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf';
227
-      $this->_pdf->begin_document($this->_file,"");
227
+      $this->_pdf->begin_document($this->_file, "");
228 228
     }
229 229
 
230 230
     $this->_pdf->begin_page_ext($this->_width, $this->_height, "");
@@ -243,29 +243,29 @@  discard block
 block discarded – undo
243 243
         $face = basename($file);
244 244
 
245 245
         // Prefer ttfs to afms
246
-        if ( file_exists($file.".ttf") ) {
246
+        if (file_exists($file.".ttf")) {
247 247
           $outline = "$file.ttf";
248 248
           $afm = null;
249 249
 
250
-        } else if ( file_exists($file .".TTF") ) {
250
+        } else if (file_exists($file.".TTF")) {
251 251
           $outline = "$file.TTF";
252 252
           $afm = null;
253 253
 
254
-        } else if ( file_exists($file . ".pfb") ) {
254
+        } else if (file_exists($file.".pfb")) {
255 255
           $outline = "$file.pfb";
256 256
 
257
-          if ( file_exists($file . ".afm") )
257
+          if (file_exists($file.".afm"))
258 258
             $afm = "$file.afm";
259 259
 
260
-        } else if ( file_exists($file . ".PFB") ) {
260
+        } else if (file_exists($file.".PFB")) {
261 261
           $outline = "$file.PFB";
262
-          if ( file_exists($file . ".AFM") )
262
+          if (file_exists($file.".AFM"))
263 263
             $afm = "$file.AFM";
264 264
         } else
265 265
           continue;
266 266
 
267 267
         $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}");
268
-        if ( !is_null($afm) )
268
+        if (!is_null($afm))
269 269
           $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}");
270 270
       }
271 271
     }
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
    */
367 367
   function add_object($object, $where = 'all') {
368 368
 
369
-    if ( mb_strpos($where, "next") !== false ) {
369
+    if (mb_strpos($where, "next") !== false) {
370 370
       $this->_objs[$object]["start_page"]++;
371 371
       $where = str_replace("next", "", $where);
372
-      if ( $where == "" )
372
+      if ($where == "")
373 373
         $where = "add";
374 374
     }
375 375
 
@@ -386,18 +386,18 @@  discard block
 block discarded – undo
386 386
    */
387 387
   function stop_object($object) {
388 388
 
389
-    if ( !isset($this->_objs[$object]) )
389
+    if (!isset($this->_objs[$object]))
390 390
       return;
391 391
 
392 392
     $start = $this->_objs[$object]["start_page"];
393 393
     $where = $this->_objs[$object]["where"];
394 394
 
395 395
     // Place the object on this page if required
396
-    if ( $this->_page_number >= $start &&
396
+    if ($this->_page_number >= $start &&
397 397
          (($this->_page_number % 2 == 0 && $where === "even") ||
398 398
           ($this->_page_number % 2 == 1 && $where === "odd") ||
399
-          ($where === "all")) )
400
-      $this->_pdf->fit_image($object,0,0,"");
399
+          ($where === "all")))
400
+      $this->_pdf->fit_image($object, 0, 0, "");
401 401
 
402 402
     unset($this->_objs[$object]);
403 403
   }
@@ -407,16 +407,16 @@  discard block
 block discarded – undo
407 407
    */
408 408
   protected function _place_objects() {
409 409
 
410
-    foreach ( $this->_objs as $obj => $props ) {
410
+    foreach ($this->_objs as $obj => $props) {
411 411
       $start = $props["start_page"];
412 412
       $where = $props["where"];
413 413
 
414 414
       // Place the object on this page if required
415
-      if ( $this->_page_number >= $start &&
415
+      if ($this->_page_number >= $start &&
416 416
            (($this->_page_number % 2 == 0 && $where === "even") ||
417 417
             ($this->_page_number % 2 == 1 && $where === "odd") ||
418
-            ($where === "all")) ) {
419
-        $this->_pdf->fit_image($obj,0,0,"");
418
+            ($where === "all"))) {
419
+        $this->_pdf->fit_image($obj, 0, 0, "");
420 420
       }
421 421
     }
422 422
 
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
 
431 431
   function get_page_count() { return $this->_page_count; }
432 432
 
433
-  function set_page_number($num) { $this->_page_number = (int)$num; }
433
+  function set_page_number($num) { $this->_page_number = (int) $num; }
434 434
 
435
-  function set_page_count($count) { $this->_page_count = (int)$count; }
435
+  function set_page_count($count) { $this->_page_count = (int) $count; }
436 436
 
437 437
 
438 438
   /**
@@ -445,15 +445,15 @@  discard block
 block discarded – undo
445 445
    */
446 446
   protected function _set_line_style($width, $cap, $join, $dash) {
447 447
 
448
-    if ( count($dash) == 1 )
448
+    if (count($dash) == 1)
449 449
       $dash[] = $dash[0];
450 450
 
451
-    if ( count($dash) > 1 )
452
-      $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}");
451
+    if (count($dash) > 1)
452
+      $this->_pdf->setdashpattern("dasharray={".join(" ", $dash)."}");
453 453
     else
454
-      $this->_pdf->setdash(0,0);
454
+      $this->_pdf->setdash(0, 0);
455 455
 
456
-    switch ( $join ) {
456
+    switch ($join) {
457 457
     case "miter":
458 458
       $this->_pdf->setlinejoin(0);
459 459
       break;
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
       break;
471 471
     }
472 472
 
473
-    switch ( $cap ) {
473
+    switch ($cap) {
474 474
     case "butt":
475 475
       $this->_pdf->setlinecap(0);
476 476
       break;
@@ -497,12 +497,12 @@  discard block
 block discarded – undo
497 497
    * @param array $color array(r,g,b)
498 498
    */
499 499
   protected function _set_stroke_color($color) {
500
-    if($this->_last_stroke_color == $color)
500
+    if ($this->_last_stroke_color == $color)
501 501
     	return;
502 502
 
503 503
     $this->_last_stroke_color = $color;
504 504
 
505
-    list($r,$g,$b) = $color;
505
+    list($r, $g, $b) = $color;
506 506
     $this->_pdf->setcolor("stroke", "rgb", $r, $g, $b, 0);
507 507
   }
508 508
 
@@ -512,12 +512,12 @@  discard block
 block discarded – undo
512 512
    * @param array $color array(r,g,b)
513 513
    */
514 514
   protected function _set_fill_color($color) {
515
-    if($this->_last_fill_color == $color)
515
+    if ($this->_last_fill_color == $color)
516 516
     	return;
517 517
 
518 518
     $this->_last_fill_color = $color;
519 519
 
520
-    list($r,$g,$b) = $color;
520
+    list($r, $g, $b) = $color;
521 521
     $this->_pdf->setcolor("fill", "rgb", $r, $g, $b, 0);
522 522
   }
523 523
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
                           "symbol", "zapfdinbats");
538 538
 
539 539
     $test = strtolower(basename($font));
540
-    if ( in_array($test, $native_fonts) ) {
540
+    if (in_array($test, $native_fonts)) {
541 541
       $font = basename($font);
542 542
 
543 543
     } else {
@@ -545,20 +545,20 @@  discard block
 block discarded – undo
545 545
       $options .= " embedding=true";
546 546
     }
547 547
 
548
-    if ( is_null($encoding) ) {
548
+    if (is_null($encoding)) {
549 549
 
550 550
       // Unicode encoding is only available for the commerical
551 551
       // version of PDFlib and not PDFlib-Lite
552
-      if ( defined("DOMPDF_PDFLIB_LICENSE") )
552
+      if (defined("DOMPDF_PDFLIB_LICENSE"))
553 553
         $encoding = "unicode";
554 554
       else
555 555
         $encoding = "auto";
556 556
 
557 557
     }
558 558
 
559
-    $key = $font .":". $encoding .":". $options;
559
+    $key = $font.":".$encoding.":".$options;
560 560
 
561
-    if ( isset($this->_fonts[$key]) )
561
+    if (isset($this->_fonts[$key]))
562 562
       return $this->_fonts[$key];
563 563
 
564 564
     else {
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
     $y1 = $this->y($y1);
588 588
     $y2 = $this->y($y2);
589 589
 
590
-    $this->_pdf->moveto($x1,$y1);
590
+    $this->_pdf->moveto($x1, $y1);
591 591
     $this->_pdf->lineto($x2, $y2);
592 592
     $this->_pdf->stroke();
593 593
   }
@@ -622,20 +622,20 @@  discard block
 block discarded – undo
622 622
     $this->_set_fill_color($color);
623 623
     $this->_set_stroke_color($color);
624 624
 
625
-    if ( !$fill && isset($width) )
625
+    if (!$fill && isset($width))
626 626
       $this->_set_line_style($width, "square", "miter", $style);
627 627
 
628 628
     $y = $this->y(array_pop($points));
629 629
     $x = array_pop($points);
630
-    $this->_pdf->moveto($x,$y);
630
+    $this->_pdf->moveto($x, $y);
631 631
 
632 632
     while (count($points) > 1) {
633 633
       $y = $this->y(array_pop($points));
634 634
       $x = array_pop($points);
635
-      $this->_pdf->lineto($x,$y);
635
+      $this->_pdf->lineto($x, $y);
636 636
     }
637 637
 
638
-    if ( $fill )
638
+    if ($fill)
639 639
       $this->_pdf->fill();
640 640
     else
641 641
       $this->_pdf->closepath_stroke();
@@ -648,14 +648,14 @@  discard block
 block discarded – undo
648 648
     $this->_set_fill_color($color);
649 649
     $this->_set_stroke_color($color);
650 650
 
651
-    if ( !$fill && isset($width) )
651
+    if (!$fill && isset($width))
652 652
       $this->_set_line_style($width, "round", "round", $style);
653 653
 
654 654
     $y = $this->y($y);
655 655
 
656 656
     $this->_pdf->circle($x, $y, $r);
657 657
 
658
-    if ( $fill )
658
+    if ($fill)
659 659
       $this->_pdf->fill();
660 660
     else
661 661
       $this->_pdf->stroke();
@@ -665,15 +665,15 @@  discard block
 block discarded – undo
665 665
   //........................................................................
666 666
 
667 667
   function image($img_url, $img_type, $x, $y, $w, $h) {
668
-    $w = (int)$w;
669
-    $h = (int)$h;
668
+    $w = (int) $w;
669
+    $h = (int) $h;
670 670
 
671 671
     $img_type = strtolower($img_type);
672 672
 
673
-    if ( $img_type === "jpg" )
673
+    if ($img_type === "jpg")
674 674
       $img_type = "jpeg";
675 675
 
676
-    if ( isset($this->_imgs[$img_url]) )
676
+    if (isset($this->_imgs[$img_url]))
677 677
       $img = $this->_imgs[$img_url];
678 678
 
679 679
     else {
@@ -682,13 +682,13 @@  discard block
 block discarded – undo
682 682
     }
683 683
 
684 684
     $y = $this->y($y) - $h;
685
-    $this->_pdf->fit_image($img, $x, $y, 'boxsize={'. "$w $h" .'} fitmethod=entire');
685
+    $this->_pdf->fit_image($img, $x, $y, 'boxsize={'."$w $h".'} fitmethod=entire');
686 686
 
687 687
   }
688 688
 
689 689
   //........................................................................
690 690
 
691
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
691
+  function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0) {
692 692
     $fh = $this->_load_font($font);
693 693
 
694 694
     $this->_pdf->setfont($fh, $size);
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
 
697 697
     $y = $this->y($y) - Font_Metrics::get_font_height($font, $size);
698 698
 
699
-    $adjust = (float)$adjust;
700
-    $angle = -(float)$angle;
699
+    $adjust = (float) $adjust;
700
+    $angle = -(float) $angle;
701 701
 
702 702
     $this->_pdf->fit_textline($text, $x, $y, "rotate=$angle wordspacing=$adjust");
703 703
 
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
    * @param string $anchorname The name of the named destination
718 718
    */
719 719
   function add_named_dest($anchorname) {
720
-    $this->_pdf->add_nameddest($anchorname,"");
720
+    $this->_pdf->add_nameddest($anchorname, "");
721 721
   }
722 722
 
723 723
   //........................................................................
@@ -734,21 +734,21 @@  discard block
 block discarded – undo
734 734
   function add_link($url, $x, $y, $width, $height) {
735 735
 
736 736
     $y = $this->y($y) - $height;
737
-    if ( strpos($url, '#') === 0 ) {
737
+    if (strpos($url, '#') === 0) {
738 738
       // Local link
739
-      $name = substr($url,1);
740
-      if ( $name )
741
-        $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0");
739
+      $name = substr($url, 1);
740
+      if ($name)
741
+        $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=".substr($url, 1)." linewidth=0");
742 742
     } else {
743 743
 
744 744
       list($proto, $host, $path, $file) = explode_url($url);
745 745
 
746
-      if ( $proto == "" || $proto === "file://" )
746
+      if ($proto == "" || $proto === "file://")
747 747
         return; // Local links are not allowed
748 748
       $url = build_url($proto, $host, $path, $file);
749
-      $url = '{' . rawurldecode($url) . '}';
749
+      $url = '{'.rawurldecode($url).'}';
750 750
       
751
-      $action = $this->_pdf->create_action("URI", "url=" . $url);
751
+      $action = $this->_pdf->create_action("URI", "url=".$url);
752 752
       $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0");
753 753
     }
754 754
   }
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
     $fh = $this->_load_font($font);
760 760
 
761 761
     // Determine the additional width due to extra spacing
762
-    $num_spaces = mb_substr_count($text," ");
762
+    $num_spaces = mb_substr_count($text, " ");
763 763
     $delta = $spacing * $num_spaces;
764 764
     return $this->_pdf->stringwidth($text, $fh, $size) + $delta;
765 765
   }
@@ -798,8 +798,8 @@  discard block
 block discarded – undo
798 798
    * @param float $adjust word spacing adjustment
799 799
    * @param float $angle angle to write the text at, measured CW starting from the x-axis
800 800
    */
801
-  function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
802
-                     $adjust = 0, $angle = 0,  $blend = "Normal", $opacity = 1.0) {
801
+  function page_text($x, $y, $text, $font, $size, $color = array(0, 0, 0),
802
+                     $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) {
803 803
     $_t = "text";
804 804
     $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle");
805 805
   }
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
    */
843 843
   protected function _add_page_text() {
844 844
 
845
-    if ( !count($this->_page_text) )
845
+    if (!count($this->_page_text))
846 846
       return;
847 847
 
848 848
     $this->_pdf->suspend_page("");
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
         switch ($_t) {
857 857
 
858 858
         case "text":
859
-          $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"),
859
+          $text = str_replace(array("{PAGE_NUM}", "{PAGE_COUNT}"),
860 860
                               array($p, $this->_page_count), $text);
861 861
           $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
862 862
           break;
@@ -883,14 +883,14 @@  discard block
 block discarded – undo
883 883
     // Add page text
884 884
     $this->_add_page_text();
885 885
 
886
-    if ( isset($options["compress"]) && $options["compress"] != 1 )
886
+    if (isset($options["compress"]) && $options["compress"] != 1)
887 887
       $this->_pdf->set_value("compress", 0);
888 888
     else
889 889
       $this->_pdf->set_value("compress", 6);
890 890
 
891 891
     $this->_close();
892 892
 
893
-    if ( self::$IN_MEMORY ) {
893
+    if (self::$IN_MEMORY) {
894 894
       $data = $this->_pdf->get_buffer();
895 895
       $size = strlen($data);
896 896
 
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
       $size = filesize($this->_file);
899 899
 
900 900
 
901
-    $filename = str_replace(array("\n","'"),"", $filename);
901
+    $filename = str_replace(array("\n", "'"), "", $filename);
902 902
     $attach = (isset($options["Attachment"]) && $options["Attachment"]) ? "attachment" : "inline";
903 903
 
904 904
     header("Cache-Control: private");
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 
908 908
     //header("Content-length: " . $size);
909 909
 
910
-    if ( self::$IN_MEMORY )
910
+    if (self::$IN_MEMORY)
911 911
       echo $data;
912 912
 
913 913
     else {
@@ -915,11 +915,11 @@  discard block
 block discarded – undo
915 915
       // Chunked readfile()
916 916
       $chunk = (1 << 21); // 2 MB
917 917
       $fh = fopen($this->_file, "rb");
918
-      if ( !$fh )
919
-        throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file);
918
+      if (!$fh)
919
+        throw new DOMPDF_Exception("Unable to load temporary PDF file: ".$this->_file);
920 920
 
921
-      while ( !feof($fh) )
922
-        echo fread($fh,$chunk);
921
+      while (!feof($fh))
922
+        echo fread($fh, $chunk);
923 923
       fclose($fh);
924 924
 
925 925
       //debugpng
@@ -942,14 +942,14 @@  discard block
 block discarded – undo
942 942
     // Add page text
943 943
     $this->_add_page_text();
944 944
 
945
-    if ( isset($options["compress"]) && $options["compress"] != 1 )
945
+    if (isset($options["compress"]) && $options["compress"] != 1)
946 946
       $this->_pdf->set_value("compress", 0);
947 947
     else
948 948
       $this->_pdf->set_value("compress", 6);
949 949
 
950 950
     $this->_close();
951 951
 
952
-    if ( self::$IN_MEMORY )
952
+    if (self::$IN_MEMORY)
953 953
       $data = $this->_pdf->get_buffer();
954 954
 
955 955
     else {
Please login to merge, or discard this patch.
Braces   +125 added lines, -95 removed lines patch added patch discarded remove patch
@@ -185,12 +185,13 @@  discard block
 block discarded – undo
185 185
    * @param string $orientation The orientation of the document (either 'landscape' or 'portrait')
186 186
    */
187 187
   function __construct($paper = "letter", $orientation = "portrait") {
188
-    if ( is_array($paper) )
189
-      $size = $paper;
190
-    else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) )
191
-      $size = self::$PAPER_SIZES[mb_strtolower($paper)];
192
-    else
193
-      $size = self::$PAPER_SIZES["letter"];
188
+    if ( is_array($paper) ) {
189
+          $size = $paper;
190
+    } else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) {
191
+          $size = self::$PAPER_SIZES[mb_strtolower($paper)];
192
+    } else {
193
+          $size = self::$PAPER_SIZES["letter"];
194
+    }
194 195
 
195 196
     if ( mb_strtolower($orientation) === "landscape" ) {
196 197
       $a = $size[3];
@@ -202,8 +203,9 @@  discard block
 block discarded – undo
202 203
 
203 204
     $this->_pdf = new PDFLib();
204 205
 
205
-	if ( defined("DOMPDF_PDFLIB_LICENSE") )
206
-      $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE);
206
+	if ( defined("DOMPDF_PDFLIB_LICENSE") ) {
207
+	      $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE);
208
+	}
207 209
 
208 210
 	$this->_pdf->set_parameter("textformat", "utf8");
209 211
     $this->_pdf->set_parameter("fontwarning", "false");
@@ -220,9 +222,9 @@  discard block
 block discarded – undo
220 222
       $this->_pdf->set_info("Date", date("Y-m-d"));
221 223
     }
222 224
 
223
-    if ( self::$IN_MEMORY )
224
-      $this->_pdf->begin_document("","");
225
-    else {
225
+    if ( self::$IN_MEMORY ) {
226
+          $this->_pdf->begin_document("","");
227
+    } else {
226 228
       $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf';
227 229
       $this->_pdf->begin_document($this->_file,"");
228 230
     }
@@ -254,19 +256,23 @@  discard block
 block discarded – undo
254 256
         } else if ( file_exists($file . ".pfb") ) {
255 257
           $outline = "$file.pfb";
256 258
 
257
-          if ( file_exists($file . ".afm") )
258
-            $afm = "$file.afm";
259
+          if ( file_exists($file . ".afm") ) {
260
+                      $afm = "$file.afm";
261
+          }
259 262
 
260 263
         } else if ( file_exists($file . ".PFB") ) {
261 264
           $outline = "$file.PFB";
262
-          if ( file_exists($file . ".AFM") )
263
-            $afm = "$file.AFM";
264
-        } else
265
-          continue;
265
+          if ( file_exists($file . ".AFM") ) {
266
+                      $afm = "$file.AFM";
267
+          }
268
+        } else {
269
+                  continue;
270
+        }
266 271
 
267 272
         $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}");
268
-        if ( !is_null($afm) )
269
-          $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}");
273
+        if ( !is_null($afm) ) {
274
+                  $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}");
275
+        }
270 276
       }
271 277
     }
272 278
   }
@@ -369,8 +375,9 @@  discard block
 block discarded – undo
369 375
     if ( mb_strpos($where, "next") !== false ) {
370 376
       $this->_objs[$object]["start_page"]++;
371 377
       $where = str_replace("next", "", $where);
372
-      if ( $where == "" )
373
-        $where = "add";
378
+      if ( $where == "" ) {
379
+              $where = "add";
380
+      }
374 381
     }
375 382
 
376 383
     $this->_objs[$object]["where"] = $where;
@@ -386,8 +393,9 @@  discard block
 block discarded – undo
386 393
    */
387 394
   function stop_object($object) {
388 395
 
389
-    if ( !isset($this->_objs[$object]) )
390
-      return;
396
+    if ( !isset($this->_objs[$object]) ) {
397
+          return;
398
+    }
391 399
 
392 400
     $start = $this->_objs[$object]["start_page"];
393 401
     $where = $this->_objs[$object]["where"];
@@ -396,8 +404,9 @@  discard block
 block discarded – undo
396 404
     if ( $this->_page_number >= $start &&
397 405
          (($this->_page_number % 2 == 0 && $where === "even") ||
398 406
           ($this->_page_number % 2 == 1 && $where === "odd") ||
399
-          ($where === "all")) )
400
-      $this->_pdf->fit_image($object,0,0,"");
407
+          ($where === "all")) ) {
408
+          $this->_pdf->fit_image($object,0,0,"");
409
+    }
401 410
 
402 411
     unset($this->_objs[$object]);
403 412
   }
@@ -445,13 +454,15 @@  discard block
 block discarded – undo
445 454
    */
446 455
   protected function _set_line_style($width, $cap, $join, $dash) {
447 456
 
448
-    if ( count($dash) == 1 )
449
-      $dash[] = $dash[0];
457
+    if ( count($dash) == 1 ) {
458
+          $dash[] = $dash[0];
459
+    }
450 460
 
451
-    if ( count($dash) > 1 )
452
-      $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}");
453
-    else
454
-      $this->_pdf->setdash(0,0);
461
+    if ( count($dash) > 1 ) {
462
+          $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}");
463
+    } else {
464
+          $this->_pdf->setdash(0,0);
465
+    }
455 466
 
456 467
     switch ( $join ) {
457 468
     case "miter":
@@ -497,8 +508,9 @@  discard block
 block discarded – undo
497 508
    * @param array $color array(r,g,b)
498 509
    */
499 510
   protected function _set_stroke_color($color) {
500
-    if($this->_last_stroke_color == $color)
501
-    	return;
511
+    if($this->_last_stroke_color == $color) {
512
+        	return;
513
+    }
502 514
 
503 515
     $this->_last_stroke_color = $color;
504 516
 
@@ -512,8 +524,9 @@  discard block
 block discarded – undo
512 524
    * @param array $color array(r,g,b)
513 525
    */
514 526
   protected function _set_fill_color($color) {
515
-    if($this->_last_fill_color == $color)
516
-    	return;
527
+    if($this->_last_fill_color == $color) {
528
+        	return;
529
+    }
517 530
 
518 531
     $this->_last_fill_color = $color;
519 532
 
@@ -549,19 +562,19 @@  discard block
 block discarded – undo
549 562
 
550 563
       // Unicode encoding is only available for the commerical
551 564
       // version of PDFlib and not PDFlib-Lite
552
-      if ( defined("DOMPDF_PDFLIB_LICENSE") )
553
-        $encoding = "unicode";
554
-      else
555
-        $encoding = "auto";
565
+      if ( defined("DOMPDF_PDFLIB_LICENSE") ) {
566
+              $encoding = "unicode";
567
+      } else {
568
+              $encoding = "auto";
569
+      }
556 570
 
557 571
     }
558 572
 
559 573
     $key = $font .":". $encoding .":". $options;
560 574
 
561
-    if ( isset($this->_fonts[$key]) )
562
-      return $this->_fonts[$key];
563
-
564
-    else {
575
+    if ( isset($this->_fonts[$key]) ) {
576
+          return $this->_fonts[$key];
577
+    } else {
565 578
 
566 579
       $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options);
567 580
       return $this->_fonts[$key];
@@ -622,8 +635,9 @@  discard block
 block discarded – undo
622 635
     $this->_set_fill_color($color);
623 636
     $this->_set_stroke_color($color);
624 637
 
625
-    if ( !$fill && isset($width) )
626
-      $this->_set_line_style($width, "square", "miter", $style);
638
+    if ( !$fill && isset($width) ) {
639
+          $this->_set_line_style($width, "square", "miter", $style);
640
+    }
627 641
 
628 642
     $y = $this->y(array_pop($points));
629 643
     $x = array_pop($points);
@@ -635,10 +649,11 @@  discard block
 block discarded – undo
635 649
       $this->_pdf->lineto($x,$y);
636 650
     }
637 651
 
638
-    if ( $fill )
639
-      $this->_pdf->fill();
640
-    else
641
-      $this->_pdf->closepath_stroke();
652
+    if ( $fill ) {
653
+          $this->_pdf->fill();
654
+    } else {
655
+          $this->_pdf->closepath_stroke();
656
+    }
642 657
   }
643 658
 
644 659
   //........................................................................
@@ -648,17 +663,19 @@  discard block
 block discarded – undo
648 663
     $this->_set_fill_color($color);
649 664
     $this->_set_stroke_color($color);
650 665
 
651
-    if ( !$fill && isset($width) )
652
-      $this->_set_line_style($width, "round", "round", $style);
666
+    if ( !$fill && isset($width) ) {
667
+          $this->_set_line_style($width, "round", "round", $style);
668
+    }
653 669
 
654 670
     $y = $this->y($y);
655 671
 
656 672
     $this->_pdf->circle($x, $y, $r);
657 673
 
658
-    if ( $fill )
659
-      $this->_pdf->fill();
660
-    else
661
-      $this->_pdf->stroke();
674
+    if ( $fill ) {
675
+          $this->_pdf->fill();
676
+    } else {
677
+          $this->_pdf->stroke();
678
+    }
662 679
 
663 680
   }
664 681
 
@@ -670,13 +687,13 @@  discard block
 block discarded – undo
670 687
 
671 688
     $img_type = strtolower($img_type);
672 689
 
673
-    if ( $img_type === "jpg" )
674
-      $img_type = "jpeg";
675
-
676
-    if ( isset($this->_imgs[$img_url]) )
677
-      $img = $this->_imgs[$img_url];
690
+    if ( $img_type === "jpg" ) {
691
+          $img_type = "jpeg";
692
+    }
678 693
 
679
-    else {
694
+    if ( isset($this->_imgs[$img_url]) ) {
695
+          $img = $this->_imgs[$img_url];
696
+    } else {
680 697
 
681 698
       $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, "");
682 699
     }
@@ -737,14 +754,17 @@  discard block
 block discarded – undo
737 754
     if ( strpos($url, '#') === 0 ) {
738 755
       // Local link
739 756
       $name = substr($url,1);
740
-      if ( $name )
741
-        $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0");
757
+      if ( $name ) {
758
+              $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0");
759
+      }
742 760
     } else {
743 761
 
744 762
       list($proto, $host, $path, $file) = explode_url($url);
745 763
 
746
-      if ( $proto == "" || $proto === "file://" )
747
-        return; // Local links are not allowed
764
+      if ( $proto == "" || $proto === "file://" ) {
765
+              return;
766
+      }
767
+      // Local links are not allowed
748 768
       $url = build_url($proto, $host, $path, $file);
749 769
       $url = '{' . rawurldecode($url) . '}';
750 770
       
@@ -842,8 +862,9 @@  discard block
 block discarded – undo
842 862
    */
843 863
   protected function _add_page_text() {
844 864
 
845
-    if ( !count($this->_page_text) )
846
-      return;
865
+    if ( !count($this->_page_text) ) {
866
+          return;
867
+    }
847 868
 
848 869
     $this->_pdf->suspend_page("");
849 870
 
@@ -883,10 +904,11 @@  discard block
 block discarded – undo
883 904
     // Add page text
884 905
     $this->_add_page_text();
885 906
 
886
-    if ( isset($options["compress"]) && $options["compress"] != 1 )
887
-      $this->_pdf->set_value("compress", 0);
888
-    else
889
-      $this->_pdf->set_value("compress", 6);
907
+    if ( isset($options["compress"]) && $options["compress"] != 1 ) {
908
+          $this->_pdf->set_value("compress", 0);
909
+    } else {
910
+          $this->_pdf->set_value("compress", 6);
911
+    }
890 912
 
891 913
     $this->_close();
892 914
 
@@ -894,8 +916,9 @@  discard block
 block discarded – undo
894 916
       $data = $this->_pdf->get_buffer();
895 917
       $size = strlen($data);
896 918
 
897
-    } else
898
-      $size = filesize($this->_file);
919
+    } else {
920
+          $size = filesize($this->_file);
921
+    }
899 922
 
900 923
 
901 924
     $filename = str_replace(array("\n","'"),"", $filename);
@@ -907,26 +930,30 @@  discard block
 block discarded – undo
907 930
 
908 931
     //header("Content-length: " . $size);
909 932
 
910
-    if ( self::$IN_MEMORY )
911
-      echo $data;
912
-
913
-    else {
933
+    if ( self::$IN_MEMORY ) {
934
+          echo $data;
935
+    } else {
914 936
 
915 937
       // Chunked readfile()
916 938
       $chunk = (1 << 21); // 2 MB
917 939
       $fh = fopen($this->_file, "rb");
918
-      if ( !$fh )
919
-        throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file);
940
+      if ( !$fh ) {
941
+              throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file);
942
+      }
920 943
 
921
-      while ( !feof($fh) )
922
-        echo fread($fh,$chunk);
944
+      while ( !feof($fh) ) {
945
+              echo fread($fh,$chunk);
946
+      }
923 947
       fclose($fh);
924 948
 
925 949
       //debugpng
926
-      if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']';
927
-      if (!DEBUGKEEPTEMP)
928
-
950
+      if (DEBUGPNG) {
951
+          print '[pdflib stream unlink '.$this->_file.']';
952
+      }
953
+      if (!DEBUGKEEPTEMP) {
954
+      
929 955
       unlink($this->_file);
956
+      }
930 957
       $this->_file = null;
931 958
     }
932 959
 
@@ -942,24 +969,27 @@  discard block
 block discarded – undo
942 969
     // Add page text
943 970
     $this->_add_page_text();
944 971
 
945
-    if ( isset($options["compress"]) && $options["compress"] != 1 )
946
-      $this->_pdf->set_value("compress", 0);
947
-    else
948
-      $this->_pdf->set_value("compress", 6);
972
+    if ( isset($options["compress"]) && $options["compress"] != 1 ) {
973
+          $this->_pdf->set_value("compress", 0);
974
+    } else {
975
+          $this->_pdf->set_value("compress", 6);
976
+    }
949 977
 
950 978
     $this->_close();
951 979
 
952
-    if ( self::$IN_MEMORY )
953
-      $data = $this->_pdf->get_buffer();
954
-
955
-    else {
980
+    if ( self::$IN_MEMORY ) {
981
+          $data = $this->_pdf->get_buffer();
982
+    } else {
956 983
       $data = file_get_contents($this->_file);
957 984
 
958 985
       //debugpng
959
-      if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']';
960
-      if (!DEBUGKEEPTEMP)
961
-
986
+      if (DEBUGPNG) {
987
+          print '[pdflib output unlink '.$this->_file.']';
988
+      }
989
+      if (!DEBUGKEEPTEMP) {
990
+      
962 991
       unlink($this->_file);
992
+      }
963 993
       $this->_file = null;
964 994
     }
965 995
 
Please login to merge, or discard this patch.
Indentation   +486 added lines, -486 removed lines patch added patch discarded remove patch
@@ -61,170 +61,170 @@  discard block
 block discarded – undo
61 61
  */
62 62
 class PDFLib_Adapter implements Canvas {
63 63
 
64
-  /**
65
-   * Dimensions of paper sizes in points
66
-   *
67
-   * @var array;
68
-   */
69
-  static public $PAPER_SIZES = array(); // Set to
64
+    /**
65
+     * Dimensions of paper sizes in points
66
+     *
67
+     * @var array;
68
+     */
69
+    static public $PAPER_SIZES = array(); // Set to
70 70
                                         // CPDF_Adapter::$PAPER_SIZES below.
71 71
 
72
-  /**
73
-   * Fudge factor to adjust reported font heights
74
-   *
75
-   * CPDF reports larger font heights than PDFLib.  This factor
76
-   * adjusts the height reported by get_font_height().
77
-   *
78
-   * @var float
79
-   */
80
-  const FONT_HEIGHT_SCALE = 1.2;
81
-
82
-  /**
83
-   * Whether to create PDFs in memory or on disk
84
-   *
85
-   * @var bool
86
-   */
87
-  static $IN_MEMORY = true;
88
-
89
-  /**
90
-   * Instance of PDFLib class
91
-   *
92
-   * @var PDFlib
93
-   */
94
-  private $_pdf;
95
-
96
-  /**
97
-   * Name of temporary file used for PDFs created on disk
98
-   *
99
-   * @var string
100
-   */
101
-  private $_file;
102
-
103
-  /**
104
-   * PDF width, in points
105
-   *
106
-   * @var float
107
-   */
108
-  private $_width;
109
-
110
-  /**
111
-   * PDF height, in points
112
-   *
113
-   * @var height
114
-   */
115
-  private $_height;
116
-
117
-  /**
118
-   * Last fill colour used
119
-   *
120
-   * @var array
121
-   */
122
-  private $_last_fill_color;
123
-
124
-  /**
125
-   * Last stroke colour used
126
-   *
127
-   * @var array
128
-   */
129
-  private $_last_stroke_color;
130
-
131
-  /**
132
-   * Cache of image handles
133
-   *
134
-   * @var array
135
-   */
136
-  private $_imgs;
137
-
138
-  /**
139
-   * Cache of font handles
140
-   *
141
-   * @var array
142
-   */
143
-  private $_fonts;
144
-
145
-  /**
146
-   * List of objects (templates) to add to multiple pages
147
-   *
148
-   * @var array
149
-   */
150
-  private $_objs;
151
-
152
-  /**
153
-   * Current page number
154
-   *
155
-   * @var int
156
-   */
157
-  private $_page_number;
158
-
159
-  /**
160
-   * Total number of pages
161
-   *
162
-   * @var int
163
-   */
164
-  private $_page_count;
165
-
166
-  /**
167
-   * Text to display on every page
168
-   *
169
-   * @var array
170
-   */
171
-  private $_page_text;
172
-
173
-  /**
174
-   * Array of pages for accesing after rendering is initially complete
175
-   *
176
-   * @var array
177
-   */
178
-  private $_pages;
179
-
180
-  /**
181
-   * Class constructor
182
-   *
183
-   * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or
184
-   *                     an array(xmin,ymin,xmax,ymax)
185
-   * @param string $orientation The orientation of the document (either 'landscape' or 'portrait')
186
-   */
187
-  function __construct($paper = "letter", $orientation = "portrait") {
72
+    /**
73
+     * Fudge factor to adjust reported font heights
74
+     *
75
+     * CPDF reports larger font heights than PDFLib.  This factor
76
+     * adjusts the height reported by get_font_height().
77
+     *
78
+     * @var float
79
+     */
80
+    const FONT_HEIGHT_SCALE = 1.2;
81
+
82
+    /**
83
+     * Whether to create PDFs in memory or on disk
84
+     *
85
+     * @var bool
86
+     */
87
+    static $IN_MEMORY = true;
88
+
89
+    /**
90
+     * Instance of PDFLib class
91
+     *
92
+     * @var PDFlib
93
+     */
94
+    private $_pdf;
95
+
96
+    /**
97
+     * Name of temporary file used for PDFs created on disk
98
+     *
99
+     * @var string
100
+     */
101
+    private $_file;
102
+
103
+    /**
104
+     * PDF width, in points
105
+     *
106
+     * @var float
107
+     */
108
+    private $_width;
109
+
110
+    /**
111
+     * PDF height, in points
112
+     *
113
+     * @var height
114
+     */
115
+    private $_height;
116
+
117
+    /**
118
+     * Last fill colour used
119
+     *
120
+     * @var array
121
+     */
122
+    private $_last_fill_color;
123
+
124
+    /**
125
+     * Last stroke colour used
126
+     *
127
+     * @var array
128
+     */
129
+    private $_last_stroke_color;
130
+
131
+    /**
132
+     * Cache of image handles
133
+     *
134
+     * @var array
135
+     */
136
+    private $_imgs;
137
+
138
+    /**
139
+     * Cache of font handles
140
+     *
141
+     * @var array
142
+     */
143
+    private $_fonts;
144
+
145
+    /**
146
+     * List of objects (templates) to add to multiple pages
147
+     *
148
+     * @var array
149
+     */
150
+    private $_objs;
151
+
152
+    /**
153
+     * Current page number
154
+     *
155
+     * @var int
156
+     */
157
+    private $_page_number;
158
+
159
+    /**
160
+     * Total number of pages
161
+     *
162
+     * @var int
163
+     */
164
+    private $_page_count;
165
+
166
+    /**
167
+     * Text to display on every page
168
+     *
169
+     * @var array
170
+     */
171
+    private $_page_text;
172
+
173
+    /**
174
+     * Array of pages for accesing after rendering is initially complete
175
+     *
176
+     * @var array
177
+     */
178
+    private $_pages;
179
+
180
+    /**
181
+     * Class constructor
182
+     *
183
+     * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or
184
+     *                     an array(xmin,ymin,xmax,ymax)
185
+     * @param string $orientation The orientation of the document (either 'landscape' or 'portrait')
186
+     */
187
+    function __construct($paper = "letter", $orientation = "portrait") {
188 188
     if ( is_array($paper) )
189
-      $size = $paper;
189
+        $size = $paper;
190 190
     else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) )
191
-      $size = self::$PAPER_SIZES[mb_strtolower($paper)];
191
+        $size = self::$PAPER_SIZES[mb_strtolower($paper)];
192 192
     else
193
-      $size = self::$PAPER_SIZES["letter"];
193
+        $size = self::$PAPER_SIZES["letter"];
194 194
 
195 195
     if ( mb_strtolower($orientation) === "landscape" ) {
196
-      $a = $size[3];
197
-      $size[3] = $size[2];
198
-      $size[2] = $a;
196
+        $a = $size[3];
197
+        $size[3] = $size[2];
198
+        $size[2] = $a;
199 199
     }
200 200
     $this->_width = $size[2] - $size[0];
201 201
     $this->_height= $size[3] - $size[1];
202 202
 
203 203
     $this->_pdf = new PDFLib();
204 204
 
205
-	if ( defined("DOMPDF_PDFLIB_LICENSE") )
206
-      $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE);
205
+    if ( defined("DOMPDF_PDFLIB_LICENSE") )
206
+        $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE);
207 207
 
208
-	$this->_pdf->set_parameter("textformat", "utf8");
208
+    $this->_pdf->set_parameter("textformat", "utf8");
209 209
     $this->_pdf->set_parameter("fontwarning", "false");
210 210
 
211 211
     $this->_pdf->set_info("Creator", "DOMPDF Converter");
212 212
 
213 213
     // Silence pedantic warnings about missing TZ settings
214 214
     if ( function_exists("date_default_timezone_get") ) {
215
-      $tz = @date_default_timezone_get();
216
-      date_default_timezone_set("UTC");
217
-      $this->_pdf->set_info("Date", date("Y-m-d"));
218
-      date_default_timezone_set($tz);
215
+        $tz = @date_default_timezone_get();
216
+        date_default_timezone_set("UTC");
217
+        $this->_pdf->set_info("Date", date("Y-m-d"));
218
+        date_default_timezone_set($tz);
219 219
     } else {
220
-      $this->_pdf->set_info("Date", date("Y-m-d"));
220
+        $this->_pdf->set_info("Date", date("Y-m-d"));
221 221
     }
222 222
 
223 223
     if ( self::$IN_MEMORY )
224
-      $this->_pdf->begin_document("","");
224
+        $this->_pdf->begin_document("","");
225 225
     else {
226
-      $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf';
227
-      $this->_pdf->begin_document($this->_file,"");
226
+        $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf';
227
+        $this->_pdf->begin_document($this->_file,"");
228 228
     }
229 229
 
230 230
     $this->_pdf->begin_page_ext($this->_width, $this->_height, "");
@@ -239,155 +239,155 @@  discard block
 block discarded – undo
239 239
     // Set up font paths
240 240
     $families = Font_Metrics::get_font_families();
241 241
     foreach ($families as $family => $files) {
242
-      foreach ($files as $style => $file) {
242
+        foreach ($files as $style => $file) {
243 243
         $face = basename($file);
244 244
 
245 245
         // Prefer ttfs to afms
246 246
         if ( file_exists($file.".ttf") ) {
247
-          $outline = "$file.ttf";
248
-          $afm = null;
247
+            $outline = "$file.ttf";
248
+            $afm = null;
249 249
 
250 250
         } else if ( file_exists($file .".TTF") ) {
251
-          $outline = "$file.TTF";
252
-          $afm = null;
251
+            $outline = "$file.TTF";
252
+            $afm = null;
253 253
 
254 254
         } else if ( file_exists($file . ".pfb") ) {
255
-          $outline = "$file.pfb";
255
+            $outline = "$file.pfb";
256 256
 
257
-          if ( file_exists($file . ".afm") )
257
+            if ( file_exists($file . ".afm") )
258 258
             $afm = "$file.afm";
259 259
 
260 260
         } else if ( file_exists($file . ".PFB") ) {
261
-          $outline = "$file.PFB";
262
-          if ( file_exists($file . ".AFM") )
261
+            $outline = "$file.PFB";
262
+            if ( file_exists($file . ".AFM") )
263 263
             $afm = "$file.AFM";
264 264
         } else
265
-          continue;
265
+            continue;
266 266
 
267 267
         $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}");
268 268
         if ( !is_null($afm) )
269
-          $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}");
270
-      }
269
+            $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}");
270
+        }
271
+    }
271 272
     }
272
-  }
273 273
 
274
-  /**
275
-   * Close the pdf
276
-   */
277
-  protected function _close() {
274
+    /**
275
+     * Close the pdf
276
+     */
277
+    protected function _close() {
278 278
     $this->_place_objects();
279 279
 
280 280
     // Close all pages
281 281
     $this->_pdf->suspend_page("");
282 282
     for ($p = 1; $p <= $this->_page_count; $p++) {
283
-      $this->_pdf->resume_page("pagenumber=$p");
284
-      $this->_pdf->end_page_ext("");
283
+        $this->_pdf->resume_page("pagenumber=$p");
284
+        $this->_pdf->end_page_ext("");
285 285
     }
286 286
 
287 287
     $this->_pdf->end_document("");
288
-  }
289
-
290
-
291
-  /**
292
-   * Returns the PDFLib instance
293
-   *
294
-   * @return PDFLib
295
-   */
296
-  function get_pdflib() { return $this->_pdf; }
297
-
298
-  /**
299
-   * Add meta information to the PDF
300
-   *
301
-   * @param string $label  label of the value (Creator, Producter, etc.)
302
-   * @param string $value  the text to set
303
-   */
304
-  function add_info($label, $value) {
288
+    }
289
+
290
+
291
+    /**
292
+     * Returns the PDFLib instance
293
+     *
294
+     * @return PDFLib
295
+     */
296
+    function get_pdflib() { return $this->_pdf; }
297
+
298
+    /**
299
+     * Add meta information to the PDF
300
+     *
301
+     * @param string $label  label of the value (Creator, Producter, etc.)
302
+     * @param string $value  the text to set
303
+     */
304
+    function add_info($label, $value) {
305 305
     $this->_pdf->set_info($label, $value);
306
-  }
306
+    }
307 307
   
308
-  /**
309
-   * Opens a new 'object' (template in PDFLib-speak)
310
-   *
311
-   * While an object is open, all drawing actions are recorded to the
312
-   * object instead of being drawn on the current page.  Objects can
313
-   * be added later to a specific page or to several pages.
314
-   *
315
-   * The return value is an integer ID for the new object.
316
-   *
317
-   * @see PDFLib_Adapter::close_object()
318
-   * @see PDFLib_Adapter::add_object()
319
-   *
320
-   * @return int
321
-   */
322
-  function open_object() {
308
+    /**
309
+     * Opens a new 'object' (template in PDFLib-speak)
310
+     *
311
+     * While an object is open, all drawing actions are recorded to the
312
+     * object instead of being drawn on the current page.  Objects can
313
+     * be added later to a specific page or to several pages.
314
+     *
315
+     * The return value is an integer ID for the new object.
316
+     *
317
+     * @see PDFLib_Adapter::close_object()
318
+     * @see PDFLib_Adapter::add_object()
319
+     *
320
+     * @return int
321
+     */
322
+    function open_object() {
323 323
     $this->_pdf->suspend_page("");
324 324
     $ret = $this->_pdf->begin_template($this->_width, $this->_height);
325 325
     $this->_pdf->save();
326 326
     $this->_objs[$ret] = array("start_page" => $this->_page_number);
327 327
     return $ret;
328
-  }
329
-
330
-  /**
331
-   * Reopen an existing object (NOT IMPLEMENTED)
332
-   *
333
-   * PDFLib does not seem to support reopening templates.
334
-   *
335
-   * @param int $object the ID of a previously opened object
336
-   */
337
-  function reopen_object($object) {
328
+    }
329
+
330
+    /**
331
+     * Reopen an existing object (NOT IMPLEMENTED)
332
+     *
333
+     * PDFLib does not seem to support reopening templates.
334
+     *
335
+     * @param int $object the ID of a previously opened object
336
+     */
337
+    function reopen_object($object) {
338 338
     throw new DOMPDF_Exception("PDFLib does not support reopening objects.");
339
-  }
340
-
341
-  /**
342
-   * Close the current template
343
-   *
344
-   * @see PDFLib_Adapter::open_object()
345
-   */
346
-  function close_object() {
339
+    }
340
+
341
+    /**
342
+     * Close the current template
343
+     *
344
+     * @see PDFLib_Adapter::open_object()
345
+     */
346
+    function close_object() {
347 347
     $this->_pdf->restore();
348 348
     $this->_pdf->end_template();
349 349
     $this->_pdf->resume_page("pagenumber=".$this->_page_number);
350
-  }
351
-
352
-  /**
353
-   * Adds the specified object to the document
354
-   *
355
-   * $where can be one of:
356
-   * - 'add' add to current page only
357
-   * - 'all' add to every page from the current one onwards
358
-   * - 'odd' add to all odd numbered pages from now on
359
-   * - 'even' add to all even numbered pages from now on
360
-   * - 'next' add the object to the next page only
361
-   * - 'nextodd' add to all odd numbered pages from the next one
362
-   * - 'nexteven' add to all even numbered pages from the next one
363
-   *
364
-   * @param int $object the object handle returned by open_object()
365
-   * @param string $where
366
-   */
367
-  function add_object($object, $where = 'all') {
350
+    }
351
+
352
+    /**
353
+     * Adds the specified object to the document
354
+     *
355
+     * $where can be one of:
356
+     * - 'add' add to current page only
357
+     * - 'all' add to every page from the current one onwards
358
+     * - 'odd' add to all odd numbered pages from now on
359
+     * - 'even' add to all even numbered pages from now on
360
+     * - 'next' add the object to the next page only
361
+     * - 'nextodd' add to all odd numbered pages from the next one
362
+     * - 'nexteven' add to all even numbered pages from the next one
363
+     *
364
+     * @param int $object the object handle returned by open_object()
365
+     * @param string $where
366
+     */
367
+    function add_object($object, $where = 'all') {
368 368
 
369 369
     if ( mb_strpos($where, "next") !== false ) {
370
-      $this->_objs[$object]["start_page"]++;
371
-      $where = str_replace("next", "", $where);
372
-      if ( $where == "" )
370
+        $this->_objs[$object]["start_page"]++;
371
+        $where = str_replace("next", "", $where);
372
+        if ( $where == "" )
373 373
         $where = "add";
374 374
     }
375 375
 
376 376
     $this->_objs[$object]["where"] = $where;
377
-  }
378
-
379
-  /**
380
-   * Stops the specified template from appearing in the document.
381
-   *
382
-   * The object will stop being displayed on the page following the
383
-   * current one.
384
-   *
385
-   * @param int $object
386
-   */
387
-  function stop_object($object) {
377
+    }
378
+
379
+    /**
380
+     * Stops the specified template from appearing in the document.
381
+     *
382
+     * The object will stop being displayed on the page following the
383
+     * current one.
384
+     *
385
+     * @param int $object
386
+     */
387
+    function stop_object($object) {
388 388
 
389 389
     if ( !isset($this->_objs[$object]) )
390
-      return;
390
+        return;
391 391
 
392 392
     $start = $this->_objs[$object]["start_page"];
393 393
     $where = $this->_objs[$object]["where"];
@@ -397,74 +397,74 @@  discard block
 block discarded – undo
397 397
          (($this->_page_number % 2 == 0 && $where === "even") ||
398 398
           ($this->_page_number % 2 == 1 && $where === "odd") ||
399 399
           ($where === "all")) )
400
-      $this->_pdf->fit_image($object,0,0,"");
400
+        $this->_pdf->fit_image($object,0,0,"");
401 401
 
402 402
     unset($this->_objs[$object]);
403
-  }
403
+    }
404 404
 
405
-  /**
406
-   * Add all active objects to the current page
407
-   */
408
-  protected function _place_objects() {
405
+    /**
406
+     * Add all active objects to the current page
407
+     */
408
+    protected function _place_objects() {
409 409
 
410 410
     foreach ( $this->_objs as $obj => $props ) {
411
-      $start = $props["start_page"];
412
-      $where = $props["where"];
411
+        $start = $props["start_page"];
412
+        $where = $props["where"];
413 413
 
414
-      // Place the object on this page if required
415
-      if ( $this->_page_number >= $start &&
414
+        // Place the object on this page if required
415
+        if ( $this->_page_number >= $start &&
416 416
            (($this->_page_number % 2 == 0 && $where === "even") ||
417 417
             ($this->_page_number % 2 == 1 && $where === "odd") ||
418 418
             ($where === "all")) ) {
419 419
         $this->_pdf->fit_image($obj,0,0,"");
420
-      }
420
+        }
421 421
     }
422 422
 
423
-  }
423
+    }
424 424
 
425
-  function get_width() { return $this->_width; }
425
+    function get_width() { return $this->_width; }
426 426
 
427
-  function get_height() { return $this->_height; }
427
+    function get_height() { return $this->_height; }
428 428
 
429
-  function get_page_number() { return $this->_page_number; }
429
+    function get_page_number() { return $this->_page_number; }
430 430
 
431
-  function get_page_count() { return $this->_page_count; }
431
+    function get_page_count() { return $this->_page_count; }
432 432
 
433
-  function set_page_number($num) { $this->_page_number = (int)$num; }
433
+    function set_page_number($num) { $this->_page_number = (int)$num; }
434 434
 
435
-  function set_page_count($count) { $this->_page_count = (int)$count; }
435
+    function set_page_count($count) { $this->_page_count = (int)$count; }
436 436
 
437 437
 
438
-  /**
439
-   * Sets the line style
440
-   *
441
-   * @param float width
442
-   * @param string corner
443
-   * @param string join
444
-   * @param array dash
445
-   */
446
-  protected function _set_line_style($width, $cap, $join, $dash) {
438
+    /**
439
+     * Sets the line style
440
+     *
441
+     * @param float width
442
+     * @param string corner
443
+     * @param string join
444
+     * @param array dash
445
+     */
446
+    protected function _set_line_style($width, $cap, $join, $dash) {
447 447
 
448 448
     if ( count($dash) == 1 )
449
-      $dash[] = $dash[0];
449
+        $dash[] = $dash[0];
450 450
 
451 451
     if ( count($dash) > 1 )
452
-      $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}");
452
+        $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}");
453 453
     else
454
-      $this->_pdf->setdash(0,0);
454
+        $this->_pdf->setdash(0,0);
455 455
 
456 456
     switch ( $join ) {
457 457
     case "miter":
458 458
       $this->_pdf->setlinejoin(0);
459
-      break;
459
+        break;
460 460
 
461 461
     case "round":
462 462
       $this->_pdf->setlinejoin(1);
463
-      break;
463
+        break;
464 464
 
465 465
     case "bevel":
466 466
       $this->_pdf->setlinejoin(2);
467
-      break;
467
+        break;
468 468
 
469 469
     default:
470 470
       break;
@@ -473,15 +473,15 @@  discard block
 block discarded – undo
473 473
     switch ( $cap ) {
474 474
     case "butt":
475 475
       $this->_pdf->setlinecap(0);
476
-      break;
476
+        break;
477 477
 
478 478
     case "round":
479 479
       $this->_pdf->setlinecap(1);
480
-      break;
480
+        break;
481 481
 
482 482
     case "square":
483 483
       $this->_pdf->setlinecap(2);
484
-      break;
484
+        break;
485 485
 
486 486
     default:
487 487
       break;
@@ -489,69 +489,69 @@  discard block
 block discarded – undo
489 489
 
490 490
     $this->_pdf->setlinewidth($width);
491 491
 
492
-  }
492
+    }
493 493
 
494
-  /**
495
-   * Sets the line color
496
-   *
497
-   * @param array $color array(r,g,b)
498
-   */
499
-  protected function _set_stroke_color($color) {
494
+    /**
495
+     * Sets the line color
496
+     *
497
+     * @param array $color array(r,g,b)
498
+     */
499
+    protected function _set_stroke_color($color) {
500 500
     if($this->_last_stroke_color == $color)
501
-    	return;
501
+        return;
502 502
 
503 503
     $this->_last_stroke_color = $color;
504 504
 
505 505
     list($r,$g,$b) = $color;
506 506
     $this->_pdf->setcolor("stroke", "rgb", $r, $g, $b, 0);
507
-  }
508
-
509
-  /**
510
-   * Sets the fill color
511
-   *
512
-   * @param array $color array(r,g,b)
513
-   */
514
-  protected function _set_fill_color($color) {
507
+    }
508
+
509
+    /**
510
+     * Sets the fill color
511
+     *
512
+     * @param array $color array(r,g,b)
513
+     */
514
+    protected function _set_fill_color($color) {
515 515
     if($this->_last_fill_color == $color)
516
-    	return;
516
+        return;
517 517
 
518 518
     $this->_last_fill_color = $color;
519 519
 
520 520
     list($r,$g,$b) = $color;
521 521
     $this->_pdf->setcolor("fill", "rgb", $r, $g, $b, 0);
522
-  }
522
+    }
523 523
 
524
-  /**
525
-   * Loads a specific font and stores the corresponding descriptor.
526
-   *
527
-   * @param string $font
528
-   * @return int the font descriptor for the font
529
-   */
530
-  protected function _load_font($font, $encoding = null, $options = "") {
524
+    /**
525
+     * Loads a specific font and stores the corresponding descriptor.
526
+     *
527
+     * @param string $font
528
+     * @return int the font descriptor for the font
529
+     */
530
+    protected function _load_font($font, $encoding = null, $options = "") {
531 531
 
532 532
     // Check if the font is a native PDF font
533 533
     // Embed non-native fonts
534 534
     $native_fonts = array("courier", "courier-bold", "courier-oblique", "courier-boldoblique",
535
-                          "helvetica", "helvetica-bold", "helvetica-oblique", "helvetica-boldoblique",
536
-                          "times-roman", "times-bold", "times-italic", "times-bolditalic",
537
-                          "symbol", "zapfdinbats");
535
+                            "helvetica", "helvetica-bold", "helvetica-oblique", "helvetica-boldoblique",
536
+                            "times-roman", "times-bold", "times-italic", "times-bolditalic",
537
+                            "symbol", "zapfdinbats");
538 538
 
539 539
     $test = strtolower(basename($font));
540 540
     if ( in_array($test, $native_fonts) ) {
541
-      $font = basename($font);
541
+        $font = basename($font);
542 542
 
543 543
     } else {
544
-      // Embed non-native fonts
545
-      $options .= " embedding=true";
544
+        // Embed non-native fonts
545
+        $options .= " embedding=true";
546 546
     }
547 547
 
548 548
     if ( is_null($encoding) ) {
549 549
 
550
-      // Unicode encoding is only available for the commerical
551
-      // version of PDFlib and not PDFlib-Lite
552
-      if ( defined("DOMPDF_PDFLIB_LICENSE") )
550
+        // Unicode encoding is only available for the commerical
551
+        // version of PDFlib and not PDFlib-Lite
552
+        if ( defined("DOMPDF_PDFLIB_LICENSE") )
553 553
         $encoding = "unicode";
554
-      else
554
+        else
555 555
         $encoding = "auto";
556 556
 
557 557
     }
@@ -559,28 +559,28 @@  discard block
 block discarded – undo
559 559
     $key = $font .":". $encoding .":". $options;
560 560
 
561 561
     if ( isset($this->_fonts[$key]) )
562
-      return $this->_fonts[$key];
562
+        return $this->_fonts[$key];
563 563
 
564 564
     else {
565 565
 
566
-      $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options);
567
-      return $this->_fonts[$key];
566
+        $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options);
567
+        return $this->_fonts[$key];
568 568
 
569 569
     }
570 570
 
571
-  }
571
+    }
572 572
 
573
-  /**
574
-   * Remaps y coords from 4th to 1st quadrant
575
-   *
576
-   * @param float $y
577
-   * @return float
578
-   */
579
-  protected function y($y) { return $this->_height - $y; }
573
+    /**
574
+     * Remaps y coords from 4th to 1st quadrant
575
+     *
576
+     * @param float $y
577
+     * @return float
578
+     */
579
+    protected function y($y) { return $this->_height - $y; }
580 580
 
581
-  //........................................................................
581
+    //........................................................................
582 582
 
583
-  function line($x1, $y1, $x2, $y2, $color, $width, $style = null) {
583
+    function line($x1, $y1, $x2, $y2, $color, $width, $style = null) {
584 584
     $this->_set_line_style($width, "butt", "", $style);
585 585
     $this->_set_stroke_color($color);
586 586
 
@@ -590,11 +590,11 @@  discard block
 block discarded – undo
590 590
     $this->_pdf->moveto($x1,$y1);
591 591
     $this->_pdf->lineto($x2, $y2);
592 592
     $this->_pdf->stroke();
593
-  }
593
+    }
594 594
 
595
-  //........................................................................
595
+    //........................................................................
596 596
 
597
-  function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) {
597
+    function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) {
598 598
     $this->_set_stroke_color($color);
599 599
     $this->_set_line_style($width, "square", "miter", $style);
600 600
 
@@ -602,93 +602,93 @@  discard block
 block discarded – undo
602 602
 
603 603
     $this->_pdf->rect($x1, $y1, $w, $h);
604 604
     $this->_pdf->stroke();
605
-  }
605
+    }
606 606
 
607
-  //........................................................................
607
+    //........................................................................
608 608
 
609
-  function filled_rectangle($x1, $y1, $w, $h, $color) {
609
+    function filled_rectangle($x1, $y1, $w, $h, $color) {
610 610
     $this->_set_fill_color($color);
611 611
 
612 612
     $y1 = $this->y($y1) - $h;
613 613
 
614 614
     $this->_pdf->rect($x1, $y1, $w, $h);
615 615
     $this->_pdf->fill();
616
-  }
616
+    }
617 617
 
618
-  //........................................................................
618
+    //........................................................................
619 619
 
620
-  function polygon($points, $color, $width = null, $style = null, $fill = false) {
620
+    function polygon($points, $color, $width = null, $style = null, $fill = false) {
621 621
 
622 622
     $this->_set_fill_color($color);
623 623
     $this->_set_stroke_color($color);
624 624
 
625 625
     if ( !$fill && isset($width) )
626
-      $this->_set_line_style($width, "square", "miter", $style);
626
+        $this->_set_line_style($width, "square", "miter", $style);
627 627
 
628 628
     $y = $this->y(array_pop($points));
629 629
     $x = array_pop($points);
630 630
     $this->_pdf->moveto($x,$y);
631 631
 
632 632
     while (count($points) > 1) {
633
-      $y = $this->y(array_pop($points));
634
-      $x = array_pop($points);
635
-      $this->_pdf->lineto($x,$y);
633
+        $y = $this->y(array_pop($points));
634
+        $x = array_pop($points);
635
+        $this->_pdf->lineto($x,$y);
636 636
     }
637 637
 
638 638
     if ( $fill )
639
-      $this->_pdf->fill();
639
+        $this->_pdf->fill();
640 640
     else
641
-      $this->_pdf->closepath_stroke();
642
-  }
641
+        $this->_pdf->closepath_stroke();
642
+    }
643 643
 
644
-  //........................................................................
644
+    //........................................................................
645 645
 
646
-  function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) {
646
+    function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) {
647 647
 
648 648
     $this->_set_fill_color($color);
649 649
     $this->_set_stroke_color($color);
650 650
 
651 651
     if ( !$fill && isset($width) )
652
-      $this->_set_line_style($width, "round", "round", $style);
652
+        $this->_set_line_style($width, "round", "round", $style);
653 653
 
654 654
     $y = $this->y($y);
655 655
 
656 656
     $this->_pdf->circle($x, $y, $r);
657 657
 
658 658
     if ( $fill )
659
-      $this->_pdf->fill();
659
+        $this->_pdf->fill();
660 660
     else
661
-      $this->_pdf->stroke();
661
+        $this->_pdf->stroke();
662 662
 
663
-  }
663
+    }
664 664
 
665
-  //........................................................................
665
+    //........................................................................
666 666
 
667
-  function image($img_url, $img_type, $x, $y, $w, $h) {
667
+    function image($img_url, $img_type, $x, $y, $w, $h) {
668 668
     $w = (int)$w;
669 669
     $h = (int)$h;
670 670
 
671 671
     $img_type = strtolower($img_type);
672 672
 
673 673
     if ( $img_type === "jpg" )
674
-      $img_type = "jpeg";
674
+        $img_type = "jpeg";
675 675
 
676 676
     if ( isset($this->_imgs[$img_url]) )
677
-      $img = $this->_imgs[$img_url];
677
+        $img = $this->_imgs[$img_url];
678 678
 
679 679
     else {
680 680
 
681
-      $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, "");
681
+        $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, "");
682 682
     }
683 683
 
684 684
     $y = $this->y($y) - $h;
685 685
     $this->_pdf->fit_image($img, $x, $y, 'boxsize={'. "$w $h" .'} fitmethod=entire');
686 686
 
687
-  }
687
+    }
688 688
 
689
-  //........................................................................
689
+    //........................................................................
690 690
 
691
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
691
+    function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
692 692
     $fh = $this->_load_font($font);
693 693
 
694 694
     $this->_pdf->setfont($fh, $size);
@@ -701,72 +701,72 @@  discard block
 block discarded – undo
701 701
 
702 702
     $this->_pdf->fit_textline($text, $x, $y, "rotate=$angle wordspacing=$adjust");
703 703
 
704
-  }
704
+    }
705 705
 
706
-  //........................................................................
706
+    //........................................................................
707 707
   
708
-  function javascript($code) {
708
+    function javascript($code) {
709 709
     // Not implemented
710
-  }
710
+    }
711 711
 
712
-  //........................................................................
712
+    //........................................................................
713 713
 
714
-  /**
715
-   * Add a named destination (similar to <a name="foo">...</a> in html)
716
-   *
717
-   * @param string $anchorname The name of the named destination
718
-   */
719
-  function add_named_dest($anchorname) {
714
+    /**
715
+     * Add a named destination (similar to <a name="foo">...</a> in html)
716
+     *
717
+     * @param string $anchorname The name of the named destination
718
+     */
719
+    function add_named_dest($anchorname) {
720 720
     $this->_pdf->add_nameddest($anchorname,"");
721
-  }
721
+    }
722 722
 
723
-  //........................................................................
723
+    //........................................................................
724 724
 
725
-  /**
726
-   * Add a link to the pdf
727
-   *
728
-   * @param string $url The url to link to
729
-   * @param float  $x   The x position of the link
730
-   * @param float  $y   The y position of the link
731
-   * @param float  $width   The width of the link
732
-   * @param float  $height   The height of the link
733
-   */
734
-  function add_link($url, $x, $y, $width, $height) {
725
+    /**
726
+     * Add a link to the pdf
727
+     *
728
+     * @param string $url The url to link to
729
+     * @param float  $x   The x position of the link
730
+     * @param float  $y   The y position of the link
731
+     * @param float  $width   The width of the link
732
+     * @param float  $height   The height of the link
733
+     */
734
+    function add_link($url, $x, $y, $width, $height) {
735 735
 
736 736
     $y = $this->y($y) - $height;
737 737
     if ( strpos($url, '#') === 0 ) {
738
-      // Local link
739
-      $name = substr($url,1);
740
-      if ( $name )
738
+        // Local link
739
+        $name = substr($url,1);
740
+        if ( $name )
741 741
         $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0");
742 742
     } else {
743 743
 
744
-      list($proto, $host, $path, $file) = explode_url($url);
744
+        list($proto, $host, $path, $file) = explode_url($url);
745 745
 
746
-      if ( $proto == "" || $proto === "file://" )
746
+        if ( $proto == "" || $proto === "file://" )
747 747
         return; // Local links are not allowed
748
-      $url = build_url($proto, $host, $path, $file);
749
-      $url = '{' . rawurldecode($url) . '}';
748
+        $url = build_url($proto, $host, $path, $file);
749
+        $url = '{' . rawurldecode($url) . '}';
750 750
       
751
-      $action = $this->_pdf->create_action("URI", "url=" . $url);
752
-      $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0");
751
+        $action = $this->_pdf->create_action("URI", "url=" . $url);
752
+        $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0");
753
+    }
753 754
     }
754
-  }
755 755
 
756
-  //........................................................................
756
+    //........................................................................
757 757
 
758
-  function get_text_width($text, $font, $size, $spacing = 0) {
758
+    function get_text_width($text, $font, $size, $spacing = 0) {
759 759
     $fh = $this->_load_font($font);
760 760
 
761 761
     // Determine the additional width due to extra spacing
762 762
     $num_spaces = mb_substr_count($text," ");
763 763
     $delta = $spacing * $num_spaces;
764 764
     return $this->_pdf->stringwidth($text, $fh, $size) + $delta;
765
-  }
765
+    }
766 766
 
767
-  //........................................................................
767
+    //........................................................................
768 768
 
769
-  function get_font_height($font, $size) {
769
+    function get_font_height($font, $size) {
770 770
 
771 771
     $fh = $this->_load_font($font);
772 772
 
@@ -777,54 +777,54 @@  discard block
 block discarded – undo
777 777
 
778 778
     // $desc is usually < 0,
779 779
     return self::FONT_HEIGHT_SCALE * $size * ($asc - $desc);
780
-  }
781
-
782
-  //........................................................................
783
-
784
-  /**
785
-   * Writes text at the specified x and y coordinates on every page
786
-   *
787
-   * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced
788
-   * with their current values.
789
-   *
790
-   * See {@link Style::munge_colour()} for the format of the colour array.
791
-   *
792
-   * @param float $x
793
-   * @param float $y
794
-   * @param string $text the text to write
795
-   * @param string $font the font file to use
796
-   * @param float $size the font size, in points
797
-   * @param array $color
798
-   * @param float $adjust word spacing adjustment
799
-   * @param float $angle angle to write the text at, measured CW starting from the x-axis
800
-   */
801
-  function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
802
-                     $adjust = 0, $angle = 0,  $blend = "Normal", $opacity = 1.0) {
780
+    }
781
+
782
+    //........................................................................
783
+
784
+    /**
785
+     * Writes text at the specified x and y coordinates on every page
786
+     *
787
+     * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced
788
+     * with their current values.
789
+     *
790
+     * See {@link Style::munge_colour()} for the format of the colour array.
791
+     *
792
+     * @param float $x
793
+     * @param float $y
794
+     * @param string $text the text to write
795
+     * @param string $font the font file to use
796
+     * @param float $size the font size, in points
797
+     * @param array $color
798
+     * @param float $adjust word spacing adjustment
799
+     * @param float $angle angle to write the text at, measured CW starting from the x-axis
800
+     */
801
+    function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
802
+                        $adjust = 0, $angle = 0,  $blend = "Normal", $opacity = 1.0) {
803 803
     $_t = "text";
804 804
     $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle");
805
-  }
806
-
807
-  //........................................................................
808
-
809
-  /**
810
-   * Processes a script on every page
811
-   *
812
-   * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available.
813
-   *
814
-   * This function can be used to add page numbers to all pages
815
-   * after the first one, for example.
816
-   *
817
-   * @param string $code the script code
818
-   * @param string $type the language type for script
819
-   */
820
-  function page_script($code, $type = "text/php") {
805
+    }
806
+
807
+    //........................................................................
808
+
809
+    /**
810
+     * Processes a script on every page
811
+     *
812
+     * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available.
813
+     *
814
+     * This function can be used to add page numbers to all pages
815
+     * after the first one, for example.
816
+     *
817
+     * @param string $code the script code
818
+     * @param string $type the language type for script
819
+     */
820
+    function page_script($code, $type = "text/php") {
821 821
     $_t = "script";
822 822
     $this->_page_text[] = compact("_t", "code", "type");
823
-  }
823
+    }
824 824
 
825
-  //........................................................................
825
+    //........................................................................
826 826
 
827
-  function new_page() {
827
+    function new_page() {
828 828
 
829 829
     // Add objects to the current page
830 830
     $this->_place_objects();
@@ -833,69 +833,69 @@  discard block
 block discarded – undo
833 833
     $this->_pdf->begin_page_ext($this->_width, $this->_height, "");
834 834
     $this->_page_number = ++$this->_page_count;
835 835
 
836
-  }
836
+    }
837 837
 
838
-  //........................................................................
838
+    //........................................................................
839 839
 
840
-  /**
841
-   * Add text to each page after rendering is complete
842
-   */
843
-  protected function _add_page_text() {
840
+    /**
841
+     * Add text to each page after rendering is complete
842
+     */
843
+    protected function _add_page_text() {
844 844
 
845 845
     if ( !count($this->_page_text) )
846
-      return;
846
+        return;
847 847
 
848 848
     $this->_pdf->suspend_page("");
849 849
 
850 850
     for ($p = 1; $p <= $this->_page_count; $p++) {
851
-      $this->_pdf->resume_page("pagenumber=$p");
851
+        $this->_pdf->resume_page("pagenumber=$p");
852 852
 
853
-      foreach ($this->_page_text as $pt) {
853
+        foreach ($this->_page_text as $pt) {
854 854
         extract($pt);
855 855
 
856 856
         switch ($_t) {
857 857
 
858 858
         case "text":
859 859
           $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"),
860
-                              array($p, $this->_page_count), $text);
861
-          $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
862
-          break;
860
+                                array($p, $this->_page_count), $text);
861
+            $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
862
+            break;
863 863
 
864 864
         case "script":
865 865
           if (!$eval) {
866 866
             $eval = new PHP_Evaluator($this);
867
-          }
868
-          $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count));
869
-          break;
867
+            }
868
+            $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count));
869
+            break;
870
+        }
870 871
         }
871
-      }
872 872
 
873
-      $this->_pdf->suspend_page("");
873
+        $this->_pdf->suspend_page("");
874 874
     }
875 875
 
876 876
     $this->_pdf->resume_page("pagenumber=".$this->_page_number);
877
-  }
877
+    }
878 878
 
879
-  //........................................................................
879
+    //........................................................................
880 880
 
881
-  function stream($filename, $options = null) {
881
+    function stream($filename, $options = null) {
882 882
 
883 883
     // Add page text
884 884
     $this->_add_page_text();
885 885
 
886 886
     if ( isset($options["compress"]) && $options["compress"] != 1 )
887
-      $this->_pdf->set_value("compress", 0);
887
+        $this->_pdf->set_value("compress", 0);
888 888
     else
889
-      $this->_pdf->set_value("compress", 6);
889
+        $this->_pdf->set_value("compress", 6);
890 890
 
891 891
     $this->_close();
892 892
 
893 893
     if ( self::$IN_MEMORY ) {
894
-      $data = $this->_pdf->get_buffer();
895
-      $size = strlen($data);
894
+        $data = $this->_pdf->get_buffer();
895
+        $size = strlen($data);
896 896
 
897 897
     } else
898
-      $size = filesize($this->_file);
898
+        $size = filesize($this->_file);
899 899
 
900 900
 
901 901
     $filename = str_replace(array("\n","'"),"", $filename);
@@ -908,63 +908,63 @@  discard block
 block discarded – undo
908 908
     //header("Content-length: " . $size);
909 909
 
910 910
     if ( self::$IN_MEMORY )
911
-      echo $data;
911
+        echo $data;
912 912
 
913 913
     else {
914 914
 
915
-      // Chunked readfile()
916
-      $chunk = (1 << 21); // 2 MB
917
-      $fh = fopen($this->_file, "rb");
918
-      if ( !$fh )
915
+        // Chunked readfile()
916
+        $chunk = (1 << 21); // 2 MB
917
+        $fh = fopen($this->_file, "rb");
918
+        if ( !$fh )
919 919
         throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file);
920 920
 
921
-      while ( !feof($fh) )
921
+        while ( !feof($fh) )
922 922
         echo fread($fh,$chunk);
923
-      fclose($fh);
923
+        fclose($fh);
924 924
 
925
-      //debugpng
926
-      if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']';
927
-      if (!DEBUGKEEPTEMP)
925
+        //debugpng
926
+        if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']';
927
+        if (!DEBUGKEEPTEMP)
928 928
 
929
-      unlink($this->_file);
930
-      $this->_file = null;
929
+        unlink($this->_file);
930
+        $this->_file = null;
931 931
     }
932 932
 
933 933
     flush();
934 934
 
935 935
 
936
-  }
936
+    }
937 937
 
938
-  //........................................................................
938
+    //........................................................................
939 939
 
940
-  function output($options = null) {
940
+    function output($options = null) {
941 941
 
942 942
     // Add page text
943 943
     $this->_add_page_text();
944 944
 
945 945
     if ( isset($options["compress"]) && $options["compress"] != 1 )
946
-      $this->_pdf->set_value("compress", 0);
946
+        $this->_pdf->set_value("compress", 0);
947 947
     else
948
-      $this->_pdf->set_value("compress", 6);
948
+        $this->_pdf->set_value("compress", 6);
949 949
 
950 950
     $this->_close();
951 951
 
952 952
     if ( self::$IN_MEMORY )
953
-      $data = $this->_pdf->get_buffer();
953
+        $data = $this->_pdf->get_buffer();
954 954
 
955 955
     else {
956
-      $data = file_get_contents($this->_file);
956
+        $data = file_get_contents($this->_file);
957 957
 
958
-      //debugpng
959
-      if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']';
960
-      if (!DEBUGKEEPTEMP)
958
+        //debugpng
959
+        if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']';
960
+        if (!DEBUGKEEPTEMP)
961 961
 
962
-      unlink($this->_file);
963
-      $this->_file = null;
962
+        unlink($this->_file);
963
+        $this->_file = null;
964 964
     }
965 965
 
966 966
     return $data;
967
-  }
967
+    }
968 968
 }
969 969
 
970 970
 // Workaround for idiotic limitation on statics...
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/style.cls.php 5 patches
Doc Comments   +27 added lines, -2 removed lines patch added patch discarded remove patch
@@ -742,6 +742,10 @@  discard block
 block discarded – undo
742 742
    * Assume that __set will be also called when this is called, so do not check validity again.
743 743
    * Only created, if !important exists -> always set true.
744 744
    */
745
+
746
+  /**
747
+   * @param string $prop
748
+   */
745 749
   function important_set($prop) {
746 750
       $prop = str_replace("-", "_", $prop);
747 751
       $this->_important_props[$prop] = true;
@@ -1276,7 +1280,8 @@  discard block
 block discarded – undo
1276 1280
   /**
1277 1281
    * Return a single border property
1278 1282
    *
1279
-   * @return mixed
1283
+   * @param string $side
1284
+   * @return string
1280 1285
    */
1281 1286
   protected function _get_border($side) {
1282 1287
     $color = $this->__get("border_" . $side . "_color");
@@ -1363,6 +1368,10 @@  discard block
 block discarded – undo
1363 1368
    * Applicable for background, border, padding, margin, font, list_style
1364 1369
    * Note: $type has a leading underscore (or is empty), the others not.
1365 1370
    */
1371
+
1372
+  /**
1373
+   * @param string $side
1374
+   */
1366 1375
   protected function _set_style_side_type($style,$side,$type,$val,$important) {
1367 1376
     if ( !isset($this->_important_props[$style.'_'.$side.$type]) || $important) {
1368 1377
       //see __set and __get, on all assignments clear cache!
@@ -1381,6 +1390,9 @@  discard block
 block discarded – undo
1381 1390
       $this->_set_style_side_type($style,'left',$type,$left,$important);
1382 1391
   }
1383 1392
 
1393
+  /**
1394
+   * @param boolean $important
1395
+   */
1384 1396
   protected function _set_style_type($style,$type,$val,$important) {
1385 1397
     $arr = explode(" ", $val);
1386 1398
     switch (count($arr)) {
@@ -1404,6 +1416,10 @@  discard block
 block discarded – undo
1404 1416
     $this->_props[$style.$type] = $val;
1405 1417
   }
1406 1418
 
1419
+  /**
1420
+   * @param string $style
1421
+   * @param string $type
1422
+   */
1407 1423
   protected function _set_style_type_important($style,$type,$val) {
1408 1424
     $this->_set_style_type($style,$type,$val,isset($this->_important_props[$style.$type]));
1409 1425
   }
@@ -1411,12 +1427,21 @@  discard block
 block discarded – undo
1411 1427
   /* Anyway only called if _important matches and is assigned
1412 1428
    * E.g. _set_style_side_type($style,$side,'',str_replace("none", "0px", $val),isset($this->_important_props[$style.'_'.$side]));
1413 1429
    */
1430
+
1431
+  /**
1432
+   * @param string $style
1433
+   * @param string $side
1434
+   */
1414 1435
   protected function _set_style_side_width_important($style,$side,$val) {
1415 1436
     //see __set and __get, on all assignments clear cache!
1416 1437
     $this->_prop_cache[$style.'_'.$side] = null;
1417 1438
     $this->_props[$style.'_'.$side] = str_replace("none", "0px", $val);
1418 1439
   }
1419 1440
 
1441
+  /**
1442
+   * @param string $style
1443
+   * @param boolean $important
1444
+   */
1420 1445
   protected function _set_style($style,$val,$important) {
1421 1446
     if ( !isset($this->_important_props[$style]) || $important) {
1422 1447
       if ($important) {
@@ -1505,7 +1530,6 @@  discard block
 block discarded – undo
1505 1530
    * Set the background image url
1506 1531
    *
1507 1532
    * @link http://www.w3.org/TR/CSS21/colors.html#background-properties
1508
-   * @param string $url
1509 1533
    */
1510 1534
   function set_background_image($val) {
1511 1535
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
@@ -1769,6 +1793,7 @@  discard block
 block discarded – undo
1769 1793
    *
1770 1794
    * @param string $side
1771 1795
    * @param string $border_spec  ([width] [style] [color])
1796
+   * @param boolean $important
1772 1797
    */
1773 1798
   protected function _set_border($side, $border_spec, $important) {
1774 1799
     $border_spec = str_replace(",", " ", $border_spec);
Please login to merge, or discard this patch.
Switch Indentation   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -592,130 +592,130 @@  discard block
 block discarded – undo
592 592
     // Handle colour names
593 593
     switch ($colour) {
594 594
 
595
-    case "maroon":
596
-      $r = 0x80;
597
-      break;
598
-
599
-    case "red":
600
-      $r = 0xff;
601
-      break;
602
-
603
-    case "orange":
604
-      $r = 0xff;
605
-      $g = 0xa5;
606
-      break;
607
-
608
-    case "yellow":
609
-      $r = 0xff;
610
-      $g = 0xff;
611
-      break;
612
-
613
-    case "olive":
614
-      $r = 0x80;
615
-      $g = 0x80;
616
-      break;
617
-
618
-    case "purple":
619
-      $r = 0x80;
620
-      $b = 0x80;
621
-      break;
622
-
623
-    case "fuchsia":
624
-      $r = 0xff;
625
-      $b = 0xff;
626
-      break;
627
-
628
-    case "white":
629
-      $r = $g = $b = 0xff;
630
-      break;
631
-
632
-    case "lime":
633
-      $g = 0xff;
634
-      break;
635
-
636
-    case "green":
637
-      $g = 0x80;
638
-      break;
639
-
640
-    case "navy":
641
-      $b = 0x80;
642
-      break;
643
-
644
-    case "blue":
645
-      $b = 0xff;
646
-      break;
647
-
648
-    case "aqua":
649
-      $g = 0xff;
650
-      $b = 0xff;
651
-      break;
652
-
653
-    case "teal":
654
-      $g = 0x80;
655
-      $b = 0x80;
656
-      break;
657
-
658
-    case "black":
659
-      break;
660
-
661
-    case "sliver":
662
-      $r = $g = $b = 0xc0;
663
-      break;
664
-
665
-    case "gray":
666
-    case "grey":
667
-      $r = $g = $b = 0x80;
668
-      break;
669
-
670
-    case "transparent":
671
-      return "transparent";
595
+        case "maroon":
596
+          $r = 0x80;
597
+          break;
598
+
599
+        case "red":
600
+          $r = 0xff;
601
+          break;
602
+
603
+        case "orange":
604
+          $r = 0xff;
605
+          $g = 0xa5;
606
+          break;
607
+
608
+        case "yellow":
609
+          $r = 0xff;
610
+          $g = 0xff;
611
+          break;
612
+
613
+        case "olive":
614
+          $r = 0x80;
615
+          $g = 0x80;
616
+          break;
617
+
618
+        case "purple":
619
+          $r = 0x80;
620
+          $b = 0x80;
621
+          break;
622
+
623
+        case "fuchsia":
624
+          $r = 0xff;
625
+          $b = 0xff;
626
+          break;
627
+
628
+        case "white":
629
+          $r = $g = $b = 0xff;
630
+          break;
631
+
632
+        case "lime":
633
+          $g = 0xff;
634
+          break;
635
+
636
+        case "green":
637
+          $g = 0x80;
638
+          break;
639
+
640
+        case "navy":
641
+          $b = 0x80;
642
+          break;
643
+
644
+        case "blue":
645
+          $b = 0xff;
646
+          break;
647
+
648
+        case "aqua":
649
+          $g = 0xff;
650
+          $b = 0xff;
651
+          break;
652
+
653
+        case "teal":
654
+          $g = 0x80;
655
+          $b = 0x80;
656
+          break;
657
+
658
+        case "black":
659
+          break;
660
+
661
+        case "sliver":
662
+          $r = $g = $b = 0xc0;
663
+          break;
664
+
665
+        case "gray":
666
+        case "grey":
667
+          $r = $g = $b = 0x80;
668
+          break;
669
+
670
+        case "transparent":
671
+          return "transparent";
672 672
       
673
-    default:
674
-      if ( mb_strlen($colour) == 4 && $colour[0] === "#" ) {
675
-        // #rgb format
676
-        $r = hexdec($colour[1] . $colour[1]);
677
-        $g = hexdec($colour[2] . $colour[2]);
678
-        $b = hexdec($colour[3] . $colour[3]);
679
-
680
-      } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) {
681
-        // #rrggbb format
682
-        $r = hexdec(mb_substr($colour, 1, 2));
683
-        $g = hexdec(mb_substr($colour, 3, 2));
684
-        $b = hexdec(mb_substr($colour, 5, 2));
685
-
686
-      } else if ( mb_strpos($colour, "rgb") !== false ) {
687
-        // rgb( r,g,b ) format
688
-        $i = mb_strpos($colour, "(");
689
-        $j = mb_strpos($colour, ")");
673
+        default:
674
+          if ( mb_strlen($colour) == 4 && $colour[0] === "#" ) {
675
+            // #rgb format
676
+            $r = hexdec($colour[1] . $colour[1]);
677
+            $g = hexdec($colour[2] . $colour[2]);
678
+            $b = hexdec($colour[3] . $colour[3]);
679
+
680
+          } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) {
681
+            // #rrggbb format
682
+            $r = hexdec(mb_substr($colour, 1, 2));
683
+            $g = hexdec(mb_substr($colour, 3, 2));
684
+            $b = hexdec(mb_substr($colour, 5, 2));
685
+
686
+          } else if ( mb_strpos($colour, "rgb") !== false ) {
687
+            // rgb( r,g,b ) format
688
+            $i = mb_strpos($colour, "(");
689
+            $j = mb_strpos($colour, ")");
690 690
         
691
-        // Bad colour value
692
-        if ($i === false || $j === false)
693
-          return null;
691
+            // Bad colour value
692
+            if ($i === false || $j === false)
693
+              return null;
694 694
 
695
-        $triplet = explode(",", mb_substr($colour, $i+1, $j-$i-1));
695
+            $triplet = explode(",", mb_substr($colour, $i+1, $j-$i-1));
696 696
 
697
-        if (count($triplet) != 3)
698
-          return null;
697
+            if (count($triplet) != 3)
698
+              return null;
699 699
         
700
-        foreach (array_keys($triplet) as $c) {
701
-          $triplet[$c] = trim($triplet[$c]);
700
+            foreach (array_keys($triplet) as $c) {
701
+              $triplet[$c] = trim($triplet[$c]);
702 702
           
703
-          if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" )
704
-            $triplet[$c] = round($triplet[$c] * 0.255);
705
-        }
703
+              if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" )
704
+                $triplet[$c] = round($triplet[$c] * 0.255);
705
+            }
706 706
 
707
-        list($r, $g, $b) = $triplet;
707
+            list($r, $g, $b) = $triplet;
708 708
 
709
-      } else {
710
-        // Who knows?
711
-        return null;
712
-      }
709
+          } else {
710
+            // Who knows?
711
+            return null;
712
+          }
713 713
       
714
-      // Clip to 0 - 1
715
-      $r = $r < 0 ? 0 : ($r > 255 ? 255 : $r);
716
-      $g = $g < 0 ? 0 : ($g > 255 ? 255 : $g);
717
-      $b = $b < 0 ? 0 : ($b > 255 ? 255 : $b);
718
-      break;
714
+          // Clip to 0 - 1
715
+          $r = $r < 0 ? 0 : ($r > 255 ? 255 : $r);
716
+          $g = $g < 0 ? 0 : ($g > 255 ? 255 : $g);
717
+          $b = $b < 0 ? 0 : ($b > 255 ? 255 : $b);
718
+          break;
719 719
       
720 720
     }
721 721
     
@@ -941,38 +941,38 @@  discard block
 block discarded – undo
941 941
     
942 942
     switch ($fs) {
943 943
       
944
-    case "xx-small":
945
-      $fs = 3/5 * $this->_parent_font_size;
946
-      break;
947
-
948
-    case "x-small":
949
-      $fs = 3/4 * $this->_parent_font_size;
950
-      break;
951
-
952
-    case "smaller":
953
-    case "small":
954
-      $fs = 8/9 * $this->_parent_font_size;
955
-      break;
956
-
957
-    case "medium":
958
-      $fs = $this->_parent_font_size;
959
-      break;
960
-
961
-    case "larger":
962
-    case "large":
963
-      $fs = 6/5 * $this->_parent_font_size;
964
-      break;
965
-
966
-    case "x-large":
967
-      $fs = 3/2 * $this->_parent_font_size;
968
-      break;
969
-
970
-    case "xx-large":
971
-      $fs = 2/1 * $this->_parent_font_size;
972
-      break;
973
-
974
-    default:
975
-      break;
944
+        case "xx-small":
945
+          $fs = 3/5 * $this->_parent_font_size;
946
+          break;
947
+
948
+        case "x-small":
949
+          $fs = 3/4 * $this->_parent_font_size;
950
+          break;
951
+
952
+        case "smaller":
953
+        case "small":
954
+          $fs = 8/9 * $this->_parent_font_size;
955
+          break;
956
+
957
+        case "medium":
958
+          $fs = $this->_parent_font_size;
959
+          break;
960
+
961
+        case "larger":
962
+        case "large":
963
+          $fs = 6/5 * $this->_parent_font_size;
964
+          break;
965
+
966
+        case "x-large":
967
+          $fs = 3/2 * $this->_parent_font_size;
968
+          break;
969
+
970
+        case "xx-large":
971
+          $fs = 2/1 * $this->_parent_font_size;
972
+          break;
973
+
974
+        default:
975
+          break;
976 976
     }
977 977
 
978 978
     // Ensure relative sizes resolve to something
@@ -1058,61 +1058,61 @@  discard block
 block discarded – undo
1058 1058
 
1059 1059
     switch ($tmp[0]) {
1060 1060
 
1061
-    case "left":
1062
-      $x = "0%";
1063
-      break;
1061
+        case "left":
1062
+          $x = "0%";
1063
+          break;
1064 1064
 
1065
-    case "right":
1066
-      $x = "100%";
1067
-      break;
1065
+        case "right":
1066
+          $x = "100%";
1067
+          break;
1068 1068
 
1069
-    case "top":
1070
-      $y = "0%";
1071
-      break;
1069
+        case "top":
1070
+          $y = "0%";
1071
+          break;
1072 1072
 
1073
-    case "bottom":
1074
-      $y = "100%";
1075
-      break;
1073
+        case "bottom":
1074
+          $y = "100%";
1075
+          break;
1076 1076
 
1077
-    case "center":
1078
-      $x = "50%";
1079
-      $y = "50%";
1080
-      break;
1077
+        case "center":
1078
+          $x = "50%";
1079
+          $y = "50%";
1080
+          break;
1081 1081
 
1082
-    default:
1083
-      $x = $tmp[0];
1084
-      break;
1082
+        default:
1083
+          $x = $tmp[0];
1084
+          break;
1085 1085
     }
1086 1086
 
1087 1087
     if ( isset($tmp[1]) ) {
1088 1088
 
1089 1089
       switch ($tmp[1]) {
1090
-      case "left":
1091
-        $x = "0%";
1092
-        break;
1090
+          case "left":
1091
+            $x = "0%";
1092
+            break;
1093 1093
         
1094
-      case "right":
1095
-        $x = "100%";
1096
-        break;
1094
+          case "right":
1095
+            $x = "100%";
1096
+            break;
1097 1097
         
1098
-      case "top":
1099
-        $y = "0%";
1100
-        break;
1098
+          case "top":
1099
+            $y = "0%";
1100
+            break;
1101 1101
         
1102
-      case "bottom":
1103
-        $y = "100%";
1104
-        break;
1102
+          case "bottom":
1103
+            $y = "100%";
1104
+            break;
1105 1105
         
1106
-      case "center":
1107
-        if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" )
1108
-          $y = "50%";
1109
-        else
1110
-          $x = "50%";
1111
-        break;
1106
+          case "center":
1107
+            if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" )
1108
+              $y = "50%";
1109
+            else
1110
+              $x = "50%";
1111
+            break;
1112 1112
         
1113
-      default:
1114
-        $y = $tmp[1];
1115
-        break;
1113
+          default:
1114
+            $y = $tmp[1];
1115
+            break;
1116 1116
       }
1117 1117
 
1118 1118
     } else {
@@ -1384,20 +1384,20 @@  discard block
 block discarded – undo
1384 1384
   protected function _set_style_type($style,$type,$val,$important) {
1385 1385
     $arr = explode(" ", $val);
1386 1386
     switch (count($arr)) {
1387
-    case 1:
1388
-      $this->_set_style_sides_type($style,$arr[0],$arr[0],$arr[0],$arr[0],$type,$important);
1389
-      break;
1390
-    case 2:
1391
-      $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[0],$arr[1],$type,$important);
1392
-      break;
1393
-    case 3:
1394
-      $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[1],$arr[2],$type,$important);
1395
-      break;
1396
-    case 4:
1397
-      $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[2],$arr[3],$type,$important);
1398
-      break;
1399
-    default:
1400
-      break;
1387
+        case 1:
1388
+          $this->_set_style_sides_type($style,$arr[0],$arr[0],$arr[0],$arr[0],$type,$important);
1389
+          break;
1390
+        case 2:
1391
+          $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[0],$arr[1],$type,$important);
1392
+          break;
1393
+        case 3:
1394
+          $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[1],$arr[2],$type,$important);
1395
+          break;
1396
+        case 4:
1397
+          $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[2],$arr[3],$type,$important);
1398
+          break;
1399
+        default:
1400
+          break;
1401 1401
     }
1402 1402
     //see __set and __get, on all assignments clear cache!
1403 1403
 	$this->_prop_cache[$style.$type] = null;
Please login to merge, or discard this patch.
Spacing   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
    *
112 112
    * @var array
113 113
    */
114
-  static $BLOCK_TYPES = array("block","inline-block", "table-cell", "list-item");
114
+  static $BLOCK_TYPES = array("block", "inline-block", "table-cell", "list-item");
115 115
 
116 116
   /**
117 117
    * List of all table types.  Should really be a constant.
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
     $this->_parent_font_size = null;
200 200
     $this->__font_size_calculated = false;
201 201
     
202
-    if ( !isset(self::$_defaults) ) {
202
+    if (!isset(self::$_defaults)) {
203 203
     
204 204
       // Shorthand
205
-      $d =& self::$_defaults;
205
+      $d = & self::$_defaults;
206 206
     
207 207
       // All CSS 2.1 properties, and their default values
208 208
       $d["azimuth"] = "center";
@@ -398,90 +398,90 @@  discard block
 block discarded – undo
398 398
    */
399 399
   function length_in_pt($length, $ref_size = null) {
400 400
 
401
-    if ( !is_array($length) )
401
+    if (!is_array($length))
402 402
       $length = array($length);
403 403
 
404
-    if ( !isset($ref_size) )
404
+    if (!isset($ref_size))
405 405
       $ref_size = self::$default_font_size;
406 406
 
407 407
     $ret = 0;
408 408
     foreach ($length as $l) {
409 409
 
410
-      if ( $l === "auto" )
410
+      if ($l === "auto")
411 411
         return "auto";
412 412
       
413
-      if ( $l === "none" )
413
+      if ($l === "none")
414 414
         return "none";
415 415
 
416 416
       // Assume numeric values are already in points
417
-      if ( is_numeric($l) ) {
417
+      if (is_numeric($l)) {
418 418
         $ret += $l;
419 419
         continue;
420 420
       }
421 421
         
422
-      if ( $l === "normal" ) {
422
+      if ($l === "normal") {
423 423
         $ret += $ref_size;
424 424
         continue;
425 425
       }
426 426
 
427 427
       // Border lengths
428
-      if ( $l === "thin" ) {
428
+      if ($l === "thin") {
429 429
         $ret += 0.5;
430 430
         continue;
431 431
       }
432 432
       
433
-      if ( $l === "medium" ) {
433
+      if ($l === "medium") {
434 434
         $ret += 1.5;
435 435
         continue;
436 436
       }
437 437
     
438
-      if ( $l === "thick" ) {
438
+      if ($l === "thick") {
439 439
         $ret += 2.5;
440 440
         continue;
441 441
       }
442 442
       
443
-      if ( ($i = mb_strpos($l, "pt"))  !== false ) {
443
+      if (($i = mb_strpos($l, "pt")) !== false) {
444 444
         $ret += mb_substr($l, 0, $i);
445 445
         continue;
446 446
       }
447 447
 
448
-      if ( ($i = mb_strpos($l, "px"))  !== false ) {
449
-        $ret += ( mb_substr($l, 0, $i)  * 72 ) / DOMPDF_DPI;
448
+      if (($i = mb_strpos($l, "px")) !== false) {
449
+        $ret += (mb_substr($l, 0, $i) * 72) / DOMPDF_DPI;
450 450
         continue;
451 451
       }
452 452
 
453
-      if ( ($i = mb_strpos($l, "em"))  !== false ) {
453
+      if (($i = mb_strpos($l, "em")) !== false) {
454 454
         $ret += mb_substr($l, 0, $i) * $this->__get("font_size");
455 455
         continue;
456 456
       }
457 457
       
458 458
       // FIXME: em:ex ratio?
459
-      if ( ($i = mb_strpos($l, "ex"))  !== false ) {
459
+      if (($i = mb_strpos($l, "ex")) !== false) {
460 460
         $ret += mb_substr($l, 0, $i) * $this->__get("font_size");
461 461
         continue;
462 462
       }
463 463
       
464
-      if ( ($i = mb_strpos($l, "%"))  !== false ) {
465
-        $ret += mb_substr($l, 0, $i)/100 * $ref_size;
464
+      if (($i = mb_strpos($l, "%")) !== false) {
465
+        $ret += mb_substr($l, 0, $i) / 100 * $ref_size;
466 466
         continue;
467 467
       }
468 468
       
469
-      if ( ($i = mb_strpos($l, "in")) !== false ) {
469
+      if (($i = mb_strpos($l, "in")) !== false) {
470 470
         $ret += mb_substr($l, 0, $i) * 72;
471 471
         continue;
472 472
       }
473 473
           
474
-      if ( ($i = mb_strpos($l, "cm")) !== false ) {
474
+      if (($i = mb_strpos($l, "cm")) !== false) {
475 475
         $ret += mb_substr($l, 0, $i) * 72 / 2.54;
476 476
         continue;
477 477
       }
478 478
 
479
-      if ( ($i = mb_strpos($l, "mm")) !== false ) {
479
+      if (($i = mb_strpos($l, "mm")) !== false) {
480 480
         $ret += mb_substr($l, 0, $i) * 72 / 25.4;
481 481
         continue;
482 482
       }
483 483
           
484
-      if ( ($i = mb_strpos($l, "pc")) !== false ) {
484
+      if (($i = mb_strpos($l, "pc")) !== false) {
485 485
         $ret += mb_substr($l, 0, $i) / 12;
486 486
         continue;
487 487
       }
@@ -507,12 +507,12 @@  discard block
 block discarded – undo
507 507
     foreach (self::$_inherited as $prop) {
508 508
       //inherit the !important property also.
509 509
       //if local property is also !important, don't inherit.
510
-      if ( isset($parent->_props[$prop]) &&
511
-           ( !isset($this->_props[$prop]) ||
512
-             ( isset($parent->_important_props[$prop]) && !isset($this->_important_props[$prop]) )
510
+      if (isset($parent->_props[$prop]) &&
511
+           (!isset($this->_props[$prop]) ||
512
+             (isset($parent->_important_props[$prop]) && !isset($this->_important_props[$prop]))
513 513
            )
514 514
          ) {
515
-        if ( isset($parent->_important_props[$prop]) ) {
515
+        if (isset($parent->_important_props[$prop])) {
516 516
           $this->_important_props[$prop] = true;
517 517
         }
518 518
         //see __set and __get, on all assignments clear cache!
@@ -522,8 +522,8 @@  discard block
 block discarded – undo
522 522
     }
523 523
       
524 524
     foreach (array_keys($this->_props) as $prop) {
525
-      if ( $this->_props[$prop] === "inherit" ) {
526
-        if ( isset($parent->_important_props[$prop]) ) {
525
+      if ($this->_props[$prop] === "inherit") {
526
+        if (isset($parent->_important_props[$prop])) {
527 527
           $this->_important_props[$prop] = true;
528 528
         }
529 529
         //do not assign direct, but
@@ -554,20 +554,20 @@  discard block
 block discarded – undo
554 554
     //treat the !important attribute
555 555
     //if old rule has !important attribute, override with new rule only if
556 556
     //the new rule is also !important
557
-    foreach($style->_props as $prop => $val ) {
557
+    foreach ($style->_props as $prop => $val) {
558 558
       if (isset($style->_important_props[$prop])) {
559 559
  	    $this->_important_props[$prop] = true;
560 560
         //see __set and __get, on all assignments clear cache!
561 561
 		$this->_prop_cache[$prop] = null;
562 562
  	    $this->_props[$prop] = $val;
563
- 	  } else if ( !isset($this->_important_props[$prop]) ) {
563
+ 	  } else if (!isset($this->_important_props[$prop])) {
564 564
         //see __set and __get, on all assignments clear cache!
565 565
 		$this->_prop_cache[$prop] = null;
566 566
  	    $this->_props[$prop] = $val;
567 567
  	  }
568 568
  	}
569 569
 
570
-    if ( isset($style->_props["font_size"]) )
570
+    if (isset($style->_props["font_size"]))
571 571
       $this->__font_size_calculated = false;
572 572
   }
573 573
 
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
    * @return array
581 581
    */
582 582
   function munge_colour($colour) {
583
-    if ( is_array($colour) )
583
+    if (is_array($colour))
584 584
       // Assume the array has the right format...
585 585
       // FIXME: should/could verify this.
586 586
       return $colour;
@@ -671,19 +671,19 @@  discard block
 block discarded – undo
671 671
       return "transparent";
672 672
       
673 673
     default:
674
-      if ( mb_strlen($colour) == 4 && $colour[0] === "#" ) {
674
+      if (mb_strlen($colour) == 4 && $colour[0] === "#") {
675 675
         // #rgb format
676
-        $r = hexdec($colour[1] . $colour[1]);
677
-        $g = hexdec($colour[2] . $colour[2]);
678
-        $b = hexdec($colour[3] . $colour[3]);
676
+        $r = hexdec($colour[1].$colour[1]);
677
+        $g = hexdec($colour[2].$colour[2]);
678
+        $b = hexdec($colour[3].$colour[3]);
679 679
 
680
-      } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) {
680
+      } else if (mb_strlen($colour) == 7 && $colour[0] === "#") {
681 681
         // #rrggbb format
682 682
         $r = hexdec(mb_substr($colour, 1, 2));
683 683
         $g = hexdec(mb_substr($colour, 3, 2));
684 684
         $b = hexdec(mb_substr($colour, 5, 2));
685 685
 
686
-      } else if ( mb_strpos($colour, "rgb") !== false ) {
686
+      } else if (mb_strpos($colour, "rgb") !== false) {
687 687
         // rgb( r,g,b ) format
688 688
         $i = mb_strpos($colour, "(");
689 689
         $j = mb_strpos($colour, ")");
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
         if ($i === false || $j === false)
693 693
           return null;
694 694
 
695
-        $triplet = explode(",", mb_substr($colour, $i+1, $j-$i-1));
695
+        $triplet = explode(",", mb_substr($colour, $i + 1, $j - $i - 1));
696 696
 
697 697
         if (count($triplet) != 3)
698 698
           return null;
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
         foreach (array_keys($triplet) as $c) {
701 701
           $triplet[$c] = trim($triplet[$c]);
702 702
           
703
-          if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" )
703
+          if ($triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%")
704 704
             $triplet[$c] = round($triplet[$c] * 0.255);
705 705
         }
706 706
 
@@ -784,19 +784,19 @@  discard block
 block discarded – undo
784 784
     $prop = str_replace("-", "_", $prop);
785 785
     $this->_prop_cache[$prop] = null;
786 786
     
787
-    if ( !isset(self::$_defaults[$prop]) ) {
787
+    if (!isset(self::$_defaults[$prop])) {
788 788
       $_dompdf_warnings[] = "'$prop' is not a valid CSS2 property.";
789 789
       return;
790 790
     }
791 791
     
792
-    if ( $prop !== "content" && is_string($val) && mb_strpos($val, "url") === false ) {
792
+    if ($prop !== "content" && is_string($val) && mb_strpos($val, "url") === false) {
793 793
       $val = mb_strtolower(trim(str_replace(array("\n", "\t"), array(" "), $val)));
794 794
       $val = preg_replace("/([0-9]+) (pt|px|pc|em|ex|in|cm|mm|%)/S", "\\1\\2", $val);
795 795
     }
796 796
     
797 797
     $method = "set_$prop";
798 798
 
799
-    if ( method_exists($this, $method) )
799
+    if (method_exists($this, $method))
800 800
       $this->$method($val);
801 801
     else
802 802
       $this->_props[$prop] = $val;
@@ -818,19 +818,19 @@  discard block
 block discarded – undo
818 818
    */
819 819
   function __get($prop) {
820 820
     
821
-    if ( !isset(self::$_defaults[$prop]) )
821
+    if (!isset(self::$_defaults[$prop]))
822 822
       throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property.");
823 823
 
824
-    if ( isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null)
824
+    if (isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null)
825 825
       return $this->_prop_cache[$prop];
826 826
     
827 827
     $method = "get_$prop";
828 828
 
829 829
     // Fall back on defaults if property is not set
830
-    if ( !isset($this->_props[$prop]) )
830
+    if (!isset($this->_props[$prop]))
831 831
       $this->_props[$prop] = self::$_defaults[$prop];
832 832
 
833
-    if ( method_exists($this, $method) )
833
+    if (method_exists($this, $method))
834 834
       return $this->_prop_cache[$prop] = $this->$method();
835 835
 
836 836
 
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
    */
850 850
   function get_font_family() {
851 851
   
852
-    $DEBUGCSS=DEBUGCSS; //=DEBUGCSS; Allow override of global setting for ad hoc debug
852
+    $DEBUGCSS = DEBUGCSS; //=DEBUGCSS; Allow override of global setting for ad hoc debug
853 853
 	
854 854
     // Select the appropriate font.  First determine the subtype, then check
855 855
     // the specified font-families for a candidate.
@@ -857,14 +857,14 @@  discard block
 block discarded – undo
857 857
     // Resolve font-weight
858 858
     $weight = $this->__get("font_weight");
859 859
     
860
-    if ( is_numeric($weight) ) {
860
+    if (is_numeric($weight)) {
861 861
 
862
-      if ( $weight < 600 )
862
+      if ($weight < 600)
863 863
         $weight = "normal";
864 864
       else
865 865
         $weight = "bold";
866 866
 
867
-    } else if ( $weight === "bold" || $weight === "bolder" ) {
867
+    } else if ($weight === "bold" || $weight === "bolder") {
868 868
       $weight = "bold";
869 869
 
870 870
     } else {
@@ -875,11 +875,11 @@  discard block
 block discarded – undo
875 875
     // Resolve font-style
876 876
     $font_style = $this->__get("font_style");
877 877
 
878
-    if ( $weight === "bold" && ($font_style === "italic" || $font_style === "oblique") )
878
+    if ($weight === "bold" && ($font_style === "italic" || $font_style === "oblique"))
879 879
       $subtype = "bold_italic";
880
-    else if ( $weight === "bold" && $font_style !== "italic" && $font_style !== "oblique" )
880
+    else if ($weight === "bold" && $font_style !== "italic" && $font_style !== "oblique")
881 881
       $subtype = "bold";
882
-    else if ( $weight !== "bold" && ($font_style === "italic" || $font_style === "oblique") )
882
+    else if ($weight !== "bold" && ($font_style === "italic" || $font_style === "oblique"))
883 883
       $subtype = "italic";
884 884
     else
885 885
       $subtype = "normal";
@@ -890,19 +890,19 @@  discard block
 block discarded – undo
890 890
       print '('.$this->_props["font_family"].'.'.$font_style.'.'.$this->__get("font_weight").'.'.$weight.'.'.$subtype.')';
891 891
     }
892 892
     $families = explode(",", $this->_props["font_family"]);
893
-    $families = array_map('trim',$families);
893
+    $families = array_map('trim', $families);
894 894
     reset($families);
895 895
 
896 896
     $font = null;
897
-    while ( current($families) ) {
897
+    while (current($families)) {
898 898
       list(,$family) = each($families);
899 899
       //remove leading and trailing string delimiters, e.g. on font names with spaces;
900 900
       //remove leading and trailing whitespace
901
-      $family=trim($family," \t\n\r\x0B\"'");
901
+      $family = trim($family, " \t\n\r\x0B\"'");
902 902
       if ($DEBUGCSS) print '('.$family.')';
903 903
       $font = Font_Metrics::get_font($family, $subtype);
904 904
 
905
-      if ( $font ) {
905
+      if ($font) {
906 906
         if ($DEBUGCSS)  print '('.$font.")get_font_family]\n</pre>";
907 907
         return $font;
908 908
       }
@@ -912,11 +912,11 @@  discard block
 block discarded – undo
912 912
     if ($DEBUGCSS)  print '(default)';
913 913
     $font = Font_Metrics::get_font($family, $subtype);
914 914
 
915
-    if ( $font ) {
915
+    if ($font) {
916 916
       if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>";
917 917
       return $font;
918 918
     }
919
-    throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '" . $this->_props["font_family"] ."'");
919
+    throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '".$this->_props["font_family"]."'");
920 920
     
921 921
   }
922 922
 
@@ -928,30 +928,30 @@  discard block
 block discarded – undo
928 928
    */
929 929
   function get_font_size() {
930 930
 
931
-    if ( $this->__font_size_calculated )
931
+    if ($this->__font_size_calculated)
932 932
       return $this->_props["font_size"];
933 933
     
934
-    if ( !isset($this->_props["font_size"]) )
934
+    if (!isset($this->_props["font_size"]))
935 935
       $fs = self::$_defaults["font_size"];
936 936
     else
937 937
       $fs = $this->_props["font_size"];
938 938
     
939
-    if ( !isset($this->_parent_font_size) )
939
+    if (!isset($this->_parent_font_size))
940 940
       $this->_parent_font_size = self::$default_font_size;
941 941
     
942 942
     switch ($fs) {
943 943
       
944 944
     case "xx-small":
945
-      $fs = 3/5 * $this->_parent_font_size;
945
+      $fs = 3 / 5 * $this->_parent_font_size;
946 946
       break;
947 947
 
948 948
     case "x-small":
949
-      $fs = 3/4 * $this->_parent_font_size;
949
+      $fs = 3 / 4 * $this->_parent_font_size;
950 950
       break;
951 951
 
952 952
     case "smaller":
953 953
     case "small":
954
-      $fs = 8/9 * $this->_parent_font_size;
954
+      $fs = 8 / 9 * $this->_parent_font_size;
955 955
       break;
956 956
 
957 957
     case "medium":
@@ -960,15 +960,15 @@  discard block
 block discarded – undo
960 960
 
961 961
     case "larger":
962 962
     case "large":
963
-      $fs = 6/5 * $this->_parent_font_size;
963
+      $fs = 6 / 5 * $this->_parent_font_size;
964 964
       break;
965 965
 
966 966
     case "x-large":
967
-      $fs = 3/2 * $this->_parent_font_size;
967
+      $fs = 3 / 2 * $this->_parent_font_size;
968 968
       break;
969 969
 
970 970
     case "xx-large":
971
-      $fs = 2/1 * $this->_parent_font_size;
971
+      $fs = 2 / 1 * $this->_parent_font_size;
972 972
       break;
973 973
 
974 974
     default:
@@ -976,10 +976,10 @@  discard block
 block discarded – undo
976 976
     }
977 977
 
978 978
     // Ensure relative sizes resolve to something
979
-    if ( ($i = mb_strpos($fs, "em")) !== false )
979
+    if (($i = mb_strpos($fs, "em")) !== false)
980 980
       $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size;
981 981
 
982
-    else if ( ($i = mb_strpos($fs, "ex")) !== false )
982
+    else if (($i = mb_strpos($fs, "ex")) !== false)
983 983
       $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size;
984 984
 
985 985
     else
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
    * @return float
999 999
    */
1000 1000
   function get_word_spacing() {
1001
-    if ( $this->_props["word_spacing"] === "normal" )
1001
+    if ($this->_props["word_spacing"] === "normal")
1002 1002
       return 0;
1003 1003
 
1004 1004
     return $this->_props["word_spacing"];
@@ -1009,13 +1009,13 @@  discard block
 block discarded – undo
1009 1009
    * @return float
1010 1010
    */
1011 1011
   function get_line_height() {
1012
-    if ( $this->_props["line_height"] === "normal" )
1012
+    if ($this->_props["line_height"] === "normal")
1013 1013
       return self::$default_line_height * $this->get_font_size();
1014 1014
 
1015
-    if ( is_numeric($this->_props["line_height"]) )
1016
-      return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size());
1015
+    if (is_numeric($this->_props["line_height"]))
1016
+      return $this->length_in_pt($this->_props["line_height"]."%", $this->get_font_size());
1017 1017
     
1018
-    return $this->length_in_pt( $this->_props["line_height"], $this->get_font_size() );
1018
+    return $this->length_in_pt($this->_props["line_height"], $this->get_font_size());
1019 1019
   }
1020 1020
 
1021 1021
   /**
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
    * @return array
1029 1029
    */
1030 1030
   function get_color() {
1031
-    return $this->munge_color( $this->_props["color"] );
1031
+    return $this->munge_color($this->_props["color"]);
1032 1032
   }
1033 1033
 
1034 1034
   /**
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
    * @return array
1041 1041
    */
1042 1042
   function get_background_color() {
1043
-    return $this->munge_color( $this->_props["background_color"] );
1043
+    return $this->munge_color($this->_props["background_color"]);
1044 1044
   }
1045 1045
   
1046 1046
   /**
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
       break;
1085 1085
     }
1086 1086
 
1087
-    if ( isset($tmp[1]) ) {
1087
+    if (isset($tmp[1])) {
1088 1088
 
1089 1089
       switch ($tmp[1]) {
1090 1090
       case "left":
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
         break;
1105 1105
         
1106 1106
       case "center":
1107
-        if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" )
1107
+        if ($tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center")
1108 1108
           $y = "50%";
1109 1109
         else
1110 1110
           $x = "50%";
@@ -1119,14 +1119,14 @@  discard block
 block discarded – undo
1119 1119
       $y = "50%";
1120 1120
     }
1121 1121
 
1122
-    if ( !isset($x) )
1122
+    if (!isset($x))
1123 1123
       $x = "0%";
1124 1124
 
1125
-    if ( !isset($y) )
1125
+    if (!isset($y))
1126 1126
       $y = "0%";
1127 1127
 
1128
-    return array( 0 => $x, "x" => $x,
1129
-                  1 => $y, "y" => $y );
1128
+    return array(0 => $x, "x" => $x,
1129
+                  1 => $y, "y" => $y);
1130 1130
   }
1131 1131
 
1132 1132
 
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
    * @return array
1182 1182
    */
1183 1183
   function get_border_top_color() {
1184
-    if ( $this->_props["border_top_color"] === "" ) {
1184
+    if ($this->_props["border_top_color"] === "") {
1185 1185
       //see __set and __get, on all assignments clear cache!
1186 1186
       $this->_prop_cache["border_top_color"] = null;
1187 1187
       $this->_props["border_top_color"] = $this->__get("color");
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
   }
1191 1191
 
1192 1192
   function get_border_right_color() {
1193
-    if ( $this->_props["border_right_color"] === "" ) {
1193
+    if ($this->_props["border_right_color"] === "") {
1194 1194
       //see __set and __get, on all assignments clear cache!
1195 1195
       $this->_prop_cache["border_right_color"] = null;
1196 1196
       $this->_props["border_right_color"] = $this->__get("color");
@@ -1199,16 +1199,16 @@  discard block
 block discarded – undo
1199 1199
   }
1200 1200
 
1201 1201
   function get_border_bottom_color() {
1202
-    if ( $this->_props["border_bottom_color"] === "" ) {
1202
+    if ($this->_props["border_bottom_color"] === "") {
1203 1203
       //see __set and __get, on all assignments clear cache!
1204 1204
       $this->_prop_cache["border_bottom_color"] = null;
1205 1205
       $this->_props["border_bottom_color"] = $this->__get("color");
1206 1206
     }
1207
-    return $this->munge_color($this->_props["border_bottom_color"]);;
1207
+    return $this->munge_color($this->_props["border_bottom_color"]); ;
1208 1208
   }
1209 1209
 
1210 1210
   function get_border_left_color() {
1211
-    if ( $this->_props["border_left_color"] === "" ) {
1211
+    if ($this->_props["border_left_color"] === "") {
1212 1212
       //see __set and __get, on all assignments clear cache!
1213 1213
       $this->_prop_cache["border_left_color"] = null;
1214 1214
       $this->_props["border_left_color"] = $this->__get("color");
@@ -1279,10 +1279,10 @@  discard block
 block discarded – undo
1279 1279
    * @return mixed
1280 1280
    */
1281 1281
   protected function _get_border($side) {
1282
-    $color = $this->__get("border_" . $side . "_color");
1282
+    $color = $this->__get("border_".$side."_color");
1283 1283
     
1284
-    return $this->__get("border_" . $side . "_width") . " " .
1285
-      $this->__get("border_" . $side . "_style") . " " . $color["hex"];
1284
+    return $this->__get("border_".$side."_width")." ".
1285
+      $this->__get("border_".$side."_style")." ".$color["hex"];
1286 1286
   }
1287 1287
 
1288 1288
   /**#@+
@@ -1363,8 +1363,8 @@  discard block
 block discarded – undo
1363 1363
    * Applicable for background, border, padding, margin, font, list_style
1364 1364
    * Note: $type has a leading underscore (or is empty), the others not.
1365 1365
    */
1366
-  protected function _set_style_side_type($style,$side,$type,$val,$important) {
1367
-    if ( !isset($this->_important_props[$style.'_'.$side.$type]) || $important) {
1366
+  protected function _set_style_side_type($style, $side, $type, $val, $important) {
1367
+    if (!isset($this->_important_props[$style.'_'.$side.$type]) || $important) {
1368 1368
       //see __set and __get, on all assignments clear cache!
1369 1369
       $this->_prop_cache[$style.'_'.$side.$type] = null;
1370 1370
       if ($important) {
@@ -1374,27 +1374,27 @@  discard block
 block discarded – undo
1374 1374
     }
1375 1375
   }
1376 1376
 
1377
-  protected function _set_style_sides_type($style,$top,$right,$bottom,$left,$type,$important) {
1378
-      $this->_set_style_side_type($style,'top',$type,$top,$important);
1379
-      $this->_set_style_side_type($style,'right',$type,$right,$important);
1380
-      $this->_set_style_side_type($style,'bottom',$type,$bottom,$important);
1381
-      $this->_set_style_side_type($style,'left',$type,$left,$important);
1377
+  protected function _set_style_sides_type($style, $top, $right, $bottom, $left, $type, $important) {
1378
+      $this->_set_style_side_type($style, 'top', $type, $top, $important);
1379
+      $this->_set_style_side_type($style, 'right', $type, $right, $important);
1380
+      $this->_set_style_side_type($style, 'bottom', $type, $bottom, $important);
1381
+      $this->_set_style_side_type($style, 'left', $type, $left, $important);
1382 1382
   }
1383 1383
 
1384
-  protected function _set_style_type($style,$type,$val,$important) {
1384
+  protected function _set_style_type($style, $type, $val, $important) {
1385 1385
     $arr = explode(" ", $val);
1386 1386
     switch (count($arr)) {
1387 1387
     case 1:
1388
-      $this->_set_style_sides_type($style,$arr[0],$arr[0],$arr[0],$arr[0],$type,$important);
1388
+      $this->_set_style_sides_type($style, $arr[0], $arr[0], $arr[0], $arr[0], $type, $important);
1389 1389
       break;
1390 1390
     case 2:
1391
-      $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[0],$arr[1],$type,$important);
1391
+      $this->_set_style_sides_type($style, $arr[0], $arr[1], $arr[0], $arr[1], $type, $important);
1392 1392
       break;
1393 1393
     case 3:
1394
-      $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[1],$arr[2],$type,$important);
1394
+      $this->_set_style_sides_type($style, $arr[0], $arr[1], $arr[1], $arr[2], $type, $important);
1395 1395
       break;
1396 1396
     case 4:
1397
-      $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[2],$arr[3],$type,$important);
1397
+      $this->_set_style_sides_type($style, $arr[0], $arr[1], $arr[2], $arr[3], $type, $important);
1398 1398
       break;
1399 1399
     default:
1400 1400
       break;
@@ -1404,21 +1404,21 @@  discard block
 block discarded – undo
1404 1404
     $this->_props[$style.$type] = $val;
1405 1405
   }
1406 1406
 
1407
-  protected function _set_style_type_important($style,$type,$val) {
1408
-    $this->_set_style_type($style,$type,$val,isset($this->_important_props[$style.$type]));
1407
+  protected function _set_style_type_important($style, $type, $val) {
1408
+    $this->_set_style_type($style, $type, $val, isset($this->_important_props[$style.$type]));
1409 1409
   }
1410 1410
 
1411 1411
   /* Anyway only called if _important matches and is assigned
1412 1412
    * E.g. _set_style_side_type($style,$side,'',str_replace("none", "0px", $val),isset($this->_important_props[$style.'_'.$side]));
1413 1413
    */
1414
-  protected function _set_style_side_width_important($style,$side,$val) {
1414
+  protected function _set_style_side_width_important($style, $side, $val) {
1415 1415
     //see __set and __get, on all assignments clear cache!
1416 1416
     $this->_prop_cache[$style.'_'.$side] = null;
1417 1417
     $this->_props[$style.'_'.$side] = str_replace("none", "0px", $val);
1418 1418
   }
1419 1419
 
1420
-  protected function _set_style($style,$val,$important) {
1421
-    if ( !isset($this->_important_props[$style]) || $important) {
1420
+  protected function _set_style($style, $val, $important) {
1421
+    if (!isset($this->_important_props[$style]) || $important) {
1422 1422
       if ($important) {
1423 1423
         $this->_important_props[$style] = true;
1424 1424
       }
@@ -1429,22 +1429,22 @@  discard block
 block discarded – undo
1429 1429
   }
1430 1430
 
1431 1431
   protected function _image($val) {
1432
-    $DEBUGCSS=DEBUGCSS;
1432
+    $DEBUGCSS = DEBUGCSS;
1433 1433
     
1434
-    if ( mb_strpos($val, "url") === false ) {
1434
+    if (mb_strpos($val, "url") === false) {
1435 1435
       $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none
1436 1436
     } else {
1437
-      $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val));
1437
+      $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/", "\\1", trim($val));
1438 1438
 
1439 1439
       // Resolve the url now in the context of the current stylesheet
1440 1440
       $parsed_url = explode_url($val);
1441
-      if ( $parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "" ) {
1442
-        if ($parsed_url["path"]{0} === '/' || $parsed_url["path"]{0} === '\\' ) {
1441
+      if ($parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "") {
1442
+        if ($parsed_url["path"]{0} === '/' || $parsed_url["path"]{0} === '\\') {
1443 1443
           $path = $_SERVER["DOCUMENT_ROOT"].'/';
1444 1444
         } else {
1445 1445
           $path = $this->_stylesheet->get_base_path();
1446 1446
         }
1447
-        $path .= $parsed_url["path"] . $parsed_url["file"];
1447
+        $path .= $parsed_url["path"].$parsed_url["file"];
1448 1448
         $path = realpath($path);
1449 1449
         // If realpath returns FALSE then specifically state that there is no background image
1450 1450
         if (!$path) { $path = 'none'; }
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
       print "<pre>[_image\n";
1460 1460
       print_r($parsed_url);
1461 1461
       print $this->_stylesheet->get_protocol()."\n".$this->_stylesheet->get_base_path()."\n".$path."\n";
1462
-      print "_image]</pre>";;
1462
+      print "_image]</pre>"; ;
1463 1463
     }
1464 1464
     return $path;
1465 1465
   }
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
   function set_color($colour) {
1478 1478
     $col = $this->munge_colour($colour);
1479 1479
 
1480
-    if ( is_null($col) )
1480
+    if (is_null($col))
1481 1481
       $col = self::$_defaults["color"];
1482 1482
 
1483 1483
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
@@ -1493,7 +1493,7 @@  discard block
 block discarded – undo
1493 1493
    */
1494 1494
   function set_background_color($colour) {
1495 1495
     $col = $this->munge_colour($colour);
1496
-    if ( is_null($col) )
1496
+    if (is_null($col))
1497 1497
       $col = self::$_defaults["background_color"];
1498 1498
 
1499 1499
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
    * @param string $val
1521 1521
    */
1522 1522
   function set_background_repeat($val) {
1523
-    if ( is_null($val) )
1523
+    if (is_null($val))
1524 1524
       $val = self::$_defaults["background_repeat"];
1525 1525
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1526 1526
     $this->_prop_cache["background_repeat"] = null;
@@ -1534,7 +1534,7 @@  discard block
 block discarded – undo
1534 1534
    * @param string $val
1535 1535
    */
1536 1536
   function set_background_attachment($val) {
1537
-    if ( is_null($val) )
1537
+    if (is_null($val))
1538 1538
       $val = self::$_defaults["background_attachment"];
1539 1539
 
1540 1540
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
@@ -1549,7 +1549,7 @@  discard block
 block discarded – undo
1549 1549
    * @param string $val
1550 1550
    */
1551 1551
   function set_background_position($val) {
1552
-    if ( is_null($val) )
1552
+    if (is_null($val))
1553 1553
       $val = self::$_defaults["background_position"];
1554 1554
 
1555 1555
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
@@ -1568,21 +1568,21 @@  discard block
 block discarded – undo
1568 1568
     $pos = array();
1569 1569
     $tmp = explode(" ", $val);
1570 1570
     $important = isset($this->_important_props["background"]);
1571
-    foreach($tmp as $attr) {
1571
+    foreach ($tmp as $attr) {
1572 1572
 	  if (mb_substr($attr, 0, 3) === "url" || $attr === "none") {
1573 1573
    	    $this->_set_style("background_image", $this->_image($attr), $important);
1574 1574
   	  } else if ($attr === "fixed" || $attr === "scroll") {
1575 1575
    	    $this->_set_style("background_attachment", $attr, $important);
1576 1576
   	  } else if ($attr === "repeat" || $attr === "repeat-x" || $attr === "repeat-y" || $attr === "no-repeat") {
1577 1577
    	    $this->_set_style("background_repeat", $attr, $important);
1578
-      } else if (($col = $this->munge_color($attr)) != null ) {
1578
+      } else if (($col = $this->munge_color($attr)) != null) {
1579 1579
    	    $this->_set_style("background_color", is_array($col) ? $col["hex"] : $col, $important);
1580 1580
       } else {
1581 1581
  		$pos[] = $attr;
1582 1582
  	  }
1583 1583
  	}
1584 1584
  	if (count($pos)) {
1585
- 	  $this->_set_style("background_position",implode(' ',$pos), $important);
1585
+ 	  $this->_set_style("background_position", implode(' ', $pos), $important);
1586 1586
  	}
1587 1587
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1588 1588
 	$this->_prop_cache["background"] = null;
@@ -1636,14 +1636,14 @@  discard block
 block discarded – undo
1636 1636
 
1637 1637
     $important = isset($this->_important_props["font"]);
1638 1638
 
1639
-	if ( preg_match("/^(italic|oblique|normal)\s*(.*)$/i",$val,$match) ) {
1639
+	if (preg_match("/^(italic|oblique|normal)\s*(.*)$/i", $val, $match)) {
1640 1640
 		$this->_set_style("font_style", $match[1], $important);
1641 1641
 		$val = $match[2];
1642 1642
 	} else {
1643 1643
 		$this->_set_style("font_style", self::$_defaults["font_style"], $important);
1644 1644
 	}
1645 1645
 
1646
-	if ( preg_match("/^(small-caps|normal)\s*(.*)$/i",$val,$match) ) {
1646
+	if (preg_match("/^(small-caps|normal)\s*(.*)$/i", $val, $match)) {
1647 1647
 		$this->_set_style("font_variant", $match[1], $important);
1648 1648
 		$val = $match[2];
1649 1649
 	} else {
@@ -1651,8 +1651,8 @@  discard block
 block discarded – undo
1651 1651
 	}
1652 1652
 
1653 1653
     //matching numeric value followed by unit -> this is indeed a subsequent font size. Skip!
1654
-	if ( preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i",$val,$match) &&
1655
-         !preg_match("/^(?:pt|px|pc|em|ex|in|cm|mm|%)/",$match[2])
1654
+	if (preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i", $val, $match) &&
1655
+         !preg_match("/^(?:pt|px|pc|em|ex|in|cm|mm|%)/", $match[2])
1656 1656
 	   ) {
1657 1657
 		$this->_set_style("font_weight", $match[1], $important);
1658 1658
 		$val = $match[2];
@@ -1660,10 +1660,10 @@  discard block
 block discarded – undo
1660 1660
 		$this->_set_style("font_weight", self::$_defaults["font_weight"], $important);
1661 1661
 	}
1662 1662
 
1663
-	if ( preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) {
1663
+	if (preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i", $val, $match)) {
1664 1664
 		$this->_set_style("font_size", $match[1], $important);
1665 1665
 		$val = $match[2];
1666
-        if (preg_match("/^\/\s*(\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) {
1666
+        if (preg_match("/^\/\s*(\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i", $val, $match)) {
1667 1667
 			$this->_set_style("line_height", $match[1], $important);
1668 1668
 			$val = $match[2];
1669 1669
         } else {
@@ -1674,7 +1674,7 @@  discard block
 block discarded – undo
1674 1674
 		$this->_set_style("line_height", self::$_defaults["line_height"], $important);
1675 1675
 	}
1676 1676
 
1677
-	if(strlen($val) != 0) {
1677
+	if (strlen($val) != 0) {
1678 1678
 	  $this->_set_style("font_family", $val, $important);
1679 1679
 	} else {
1680 1680
 	  $this->_set_style("font_family", self::$_defaults["font_family"], $important);
@@ -1715,24 +1715,24 @@  discard block
 block discarded – undo
1715 1715
    * @param $val
1716 1716
    */
1717 1717
   function set_margin_top($val) {
1718
-    $this->_set_style_side_width_important('margin','top',$val);
1718
+    $this->_set_style_side_width_important('margin', 'top', $val);
1719 1719
   }
1720 1720
 
1721 1721
   function set_margin_right($val) {
1722
-    $this->_set_style_side_width_important('margin','right',$val);
1722
+    $this->_set_style_side_width_important('margin', 'right', $val);
1723 1723
   }
1724 1724
 
1725 1725
   function set_margin_bottom($val) {
1726
-    $this->_set_style_side_width_important('margin','bottom',$val);
1726
+    $this->_set_style_side_width_important('margin', 'bottom', $val);
1727 1727
   }
1728 1728
 
1729 1729
   function set_margin_left($val) {
1730
-    $this->_set_style_side_width_important('margin','left',$val);
1730
+    $this->_set_style_side_width_important('margin', 'left', $val);
1731 1731
   }
1732 1732
   
1733 1733
   function set_margin($val) {
1734 1734
     $val = str_replace("none", "0px", $val);
1735
-    $this->_set_style_type_important('margin','',$val);
1735
+    $this->_set_style_type_important('margin', '', $val);
1736 1736
   }
1737 1737
   /**#@-*/
1738 1738
 
@@ -1743,24 +1743,24 @@  discard block
 block discarded – undo
1743 1743
    * @param $val
1744 1744
    */
1745 1745
   function set_padding_top($val) {
1746
-    $this->_set_style_side_width_important('padding','top',$val);
1746
+    $this->_set_style_side_width_important('padding', 'top', $val);
1747 1747
   }
1748 1748
 
1749 1749
   function set_padding_right($val) {
1750
-    $this->_set_style_side_width_important('padding','right',$val);
1750
+    $this->_set_style_side_width_important('padding', 'right', $val);
1751 1751
   }
1752 1752
 
1753 1753
   function set_padding_bottom($val) {
1754
-    $this->_set_style_side_width_important('padding','bottom',$val);
1754
+    $this->_set_style_side_width_important('padding', 'bottom', $val);
1755 1755
   }
1756 1756
 
1757 1757
   function set_padding_left($val) {
1758
-    $this->_set_style_side_width_important('padding','left',$val);
1758
+    $this->_set_style_side_width_important('padding', 'left', $val);
1759 1759
   }
1760 1760
 
1761 1761
   function set_padding($val) {
1762 1762
     $val = str_replace("none", "0px", $val);
1763
-    $this->_set_style_type_important('padding','',$val);
1763
+    $this->_set_style_type_important('padding', '', $val);
1764 1764
   }
1765 1765
   /**#@-*/
1766 1766
 
@@ -1778,21 +1778,21 @@  discard block
 block discarded – undo
1778 1778
  
1779 1779
     //For consistency of individal and combined properties, and with ie8 and firefox3
1780 1780
     //reset all attributes, even if only partially given
1781
-    $this->_set_style_side_type('border',$side,'_style',self::$_defaults['border_'.$side.'_style'],$important);
1782
-    $this->_set_style_side_type('border',$side,'_width',self::$_defaults['border_'.$side.'_width'],$important);
1783
-    $this->_set_style_side_type('border',$side,'_color',self::$_defaults['border_'.$side.'_color'],$important);
1781
+    $this->_set_style_side_type('border', $side, '_style', self::$_defaults['border_'.$side.'_style'], $important);
1782
+    $this->_set_style_side_type('border', $side, '_width', self::$_defaults['border_'.$side.'_width'], $important);
1783
+    $this->_set_style_side_type('border', $side, '_color', self::$_defaults['border_'.$side.'_color'], $important);
1784 1784
 
1785 1785
     foreach ($arr as $value) {
1786 1786
       $value = trim($value);
1787
-      if ( in_array($value, self::$BORDER_STYLES) ) {
1788
-        $this->_set_style_side_type('border',$side,'_style',$value,$important);
1787
+      if (in_array($value, self::$BORDER_STYLES)) {
1788
+        $this->_set_style_side_type('border', $side, '_style', $value, $important);
1789 1789
 
1790
-      } else if ( preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value ) ) {
1791
-        $this->_set_style_side_type('border',$side,'_width',$value,$important);
1790
+      } else if (preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value)) {
1791
+        $this->_set_style_side_type('border', $side, '_width', $value, $important);
1792 1792
 
1793 1793
       } else {
1794 1794
         // must be colour
1795
-        $this->_set_style_side_type('border',$side,'_color',$value,$important);
1795
+        $this->_set_style_side_type('border', $side, '_color', $value, $important);
1796 1796
       }
1797 1797
     }
1798 1798
 
@@ -1824,15 +1824,15 @@  discard block
 block discarded – undo
1824 1824
   }
1825 1825
 
1826 1826
   function set_border_width($val) {
1827
-    $this->_set_style_type_important('border','_width',$val);
1827
+    $this->_set_style_type_important('border', '_width', $val);
1828 1828
   }
1829 1829
 
1830 1830
   function set_border_color($val) {
1831
-    $this->_set_style_type_important('border','_color',$val);
1831
+    $this->_set_style_type_important('border', '_color', $val);
1832 1832
   }
1833 1833
 
1834 1834
   function set_border_style($val) {
1835
-    $this->_set_style_type_important('border','_style',$val);
1835
+    $this->_set_style_type_important('border', '_style', $val);
1836 1836
   }
1837 1837
   /**#@-*/
1838 1838
 
@@ -1847,12 +1847,12 @@  discard block
 block discarded – undo
1847 1847
 
1848 1848
     $arr = explode(" ", $val);
1849 1849
 
1850
-    if ( count($arr) == 1 )
1850
+    if (count($arr) == 1)
1851 1851
       $arr[1] = $arr[0];
1852 1852
 
1853 1853
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1854 1854
 	$this->_prop_cache["border_spacing"] = null;
1855
-    $this->_props["border_spacing"] = $arr[0] . " " . $arr[1];
1855
+    $this->_props["border_spacing"] = $arr[0]." ".$arr[1];
1856 1856
   }
1857 1857
 
1858 1858
   /**
@@ -1907,9 +1907,9 @@  discard block
 block discarded – undo
1907 1907
         continue;
1908 1908
       }
1909 1909
 
1910
-      if ( in_array($value, $types) ) {
1910
+      if (in_array($value, $types)) {
1911 1911
    	    $this->_set_style("list_style_type", $value, $important);
1912
-      } else if ( in_array($value, $positions) ) {
1912
+      } else if (in_array($value, $positions)) {
1913 1913
    	    $this->_set_style("list_style_position", $value, $important);
1914 1914
       }
1915 1915
     }
@@ -1935,8 +1935,8 @@  discard block
 block discarded – undo
1935 1935
 
1936 1936
 /*DEBUGCSS*/  function debug_print()
1937 1937
 /*DEBUGCSS*/  {
1938
-/*DEBUGCSS*/    print "parent_font_size:".$this->_parent_font_size . ";\n";
1939
-/*DEBUGCSS*/    foreach($this->_props as $prop => $val ) {
1938
+/*DEBUGCSS*/    print "parent_font_size:".$this->_parent_font_size.";\n";
1939
+/*DEBUGCSS*/    foreach ($this->_props as $prop => $val) {
1940 1940
 /*DEBUGCSS*/      print $prop.':'.$val;
1941 1941
 /*DEBUGCSS*/      if (isset($this->_important_props[$prop])) {
1942 1942
 /*DEBUGCSS*/      	print '!important';
Please login to merge, or discard this patch.
Braces   +132 added lines, -92 removed lines patch added patch discarded remove patch
@@ -398,20 +398,24 @@  discard block
 block discarded – undo
398 398
    */
399 399
   function length_in_pt($length, $ref_size = null) {
400 400
 
401
-    if ( !is_array($length) )
402
-      $length = array($length);
401
+    if ( !is_array($length) ) {
402
+          $length = array($length);
403
+    }
403 404
 
404
-    if ( !isset($ref_size) )
405
-      $ref_size = self::$default_font_size;
405
+    if ( !isset($ref_size) ) {
406
+          $ref_size = self::$default_font_size;
407
+    }
406 408
 
407 409
     $ret = 0;
408 410
     foreach ($length as $l) {
409 411
 
410
-      if ( $l === "auto" )
411
-        return "auto";
412
+      if ( $l === "auto" ) {
413
+              return "auto";
414
+      }
412 415
       
413
-      if ( $l === "none" )
414
-        return "none";
416
+      if ( $l === "none" ) {
417
+              return "none";
418
+      }
415 419
 
416 420
       // Assume numeric values are already in points
417 421
       if ( is_numeric($l) ) {
@@ -567,8 +571,9 @@  discard block
 block discarded – undo
567 571
  	  }
568 572
  	}
569 573
 
570
-    if ( isset($style->_props["font_size"]) )
571
-      $this->__font_size_calculated = false;
574
+    if ( isset($style->_props["font_size"]) ) {
575
+          $this->__font_size_calculated = false;
576
+    }
572 577
   }
573 578
 
574 579
   
@@ -580,10 +585,11 @@  discard block
 block discarded – undo
580 585
    * @return array
581 586
    */
582 587
   function munge_colour($colour) {
583
-    if ( is_array($colour) )
584
-      // Assume the array has the right format...
588
+    if ( is_array($colour) ) {
589
+          // Assume the array has the right format...
585 590
       // FIXME: should/could verify this.
586 591
       return $colour;
592
+    }
587 593
     
588 594
     $r = 0;
589 595
     $g = 0;
@@ -689,19 +695,22 @@  discard block
 block discarded – undo
689 695
         $j = mb_strpos($colour, ")");
690 696
         
691 697
         // Bad colour value
692
-        if ($i === false || $j === false)
693
-          return null;
698
+        if ($i === false || $j === false) {
699
+                  return null;
700
+        }
694 701
 
695 702
         $triplet = explode(",", mb_substr($colour, $i+1, $j-$i-1));
696 703
 
697
-        if (count($triplet) != 3)
698
-          return null;
704
+        if (count($triplet) != 3) {
705
+                  return null;
706
+        }
699 707
         
700 708
         foreach (array_keys($triplet) as $c) {
701 709
           $triplet[$c] = trim($triplet[$c]);
702 710
           
703
-          if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" )
704
-            $triplet[$c] = round($triplet[$c] * 0.255);
711
+          if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" ) {
712
+                      $triplet[$c] = round($triplet[$c] * 0.255);
713
+          }
705 714
         }
706 715
 
707 716
         list($r, $g, $b) = $triplet;
@@ -796,10 +805,11 @@  discard block
 block discarded – undo
796 805
     
797 806
     $method = "set_$prop";
798 807
 
799
-    if ( method_exists($this, $method) )
800
-      $this->$method($val);
801
-    else
802
-      $this->_props[$prop] = $val;
808
+    if ( method_exists($this, $method) ) {
809
+          $this->$method($val);
810
+    } else {
811
+          $this->_props[$prop] = $val;
812
+    }
803 813
     
804 814
   }
805 815
 
@@ -818,20 +828,24 @@  discard block
 block discarded – undo
818 828
    */
819 829
   function __get($prop) {
820 830
     
821
-    if ( !isset(self::$_defaults[$prop]) )
822
-      throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property.");
831
+    if ( !isset(self::$_defaults[$prop]) ) {
832
+          throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property.");
833
+    }
823 834
 
824
-    if ( isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null)
825
-      return $this->_prop_cache[$prop];
835
+    if ( isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null) {
836
+          return $this->_prop_cache[$prop];
837
+    }
826 838
     
827 839
     $method = "get_$prop";
828 840
 
829 841
     // Fall back on defaults if property is not set
830
-    if ( !isset($this->_props[$prop]) )
831
-      $this->_props[$prop] = self::$_defaults[$prop];
842
+    if ( !isset($this->_props[$prop]) ) {
843
+          $this->_props[$prop] = self::$_defaults[$prop];
844
+    }
832 845
 
833
-    if ( method_exists($this, $method) )
834
-      return $this->_prop_cache[$prop] = $this->$method();
846
+    if ( method_exists($this, $method) ) {
847
+          return $this->_prop_cache[$prop] = $this->$method();
848
+    }
835 849
 
836 850
 
837 851
     return $this->_prop_cache[$prop] = $this->_props[$prop];
@@ -859,10 +873,11 @@  discard block
 block discarded – undo
859 873
     
860 874
     if ( is_numeric($weight) ) {
861 875
 
862
-      if ( $weight < 600 )
863
-        $weight = "normal";
864
-      else
865
-        $weight = "bold";
876
+      if ( $weight < 600 ) {
877
+              $weight = "normal";
878
+      } else {
879
+              $weight = "bold";
880
+      }
866 881
 
867 882
     } else if ( $weight === "bold" || $weight === "bolder" ) {
868 883
       $weight = "bold";
@@ -875,14 +890,15 @@  discard block
 block discarded – undo
875 890
     // Resolve font-style
876 891
     $font_style = $this->__get("font_style");
877 892
 
878
-    if ( $weight === "bold" && ($font_style === "italic" || $font_style === "oblique") )
879
-      $subtype = "bold_italic";
880
-    else if ( $weight === "bold" && $font_style !== "italic" && $font_style !== "oblique" )
881
-      $subtype = "bold";
882
-    else if ( $weight !== "bold" && ($font_style === "italic" || $font_style === "oblique") )
883
-      $subtype = "italic";
884
-    else
885
-      $subtype = "normal";
893
+    if ( $weight === "bold" && ($font_style === "italic" || $font_style === "oblique") ) {
894
+          $subtype = "bold_italic";
895
+    } else if ( $weight === "bold" && $font_style !== "italic" && $font_style !== "oblique" ) {
896
+          $subtype = "bold";
897
+    } else if ( $weight !== "bold" && ($font_style === "italic" || $font_style === "oblique") ) {
898
+          $subtype = "italic";
899
+    } else {
900
+          $subtype = "normal";
901
+    }
886 902
     
887 903
     // Resolve the font family
888 904
     if ($DEBUGCSS) {
@@ -899,21 +915,29 @@  discard block
 block discarded – undo
899 915
       //remove leading and trailing string delimiters, e.g. on font names with spaces;
900 916
       //remove leading and trailing whitespace
901 917
       $family=trim($family," \t\n\r\x0B\"'");
902
-      if ($DEBUGCSS) print '('.$family.')';
918
+      if ($DEBUGCSS) {
919
+          print '('.$family.')';
920
+      }
903 921
       $font = Font_Metrics::get_font($family, $subtype);
904 922
 
905 923
       if ( $font ) {
906
-        if ($DEBUGCSS)  print '('.$font.")get_font_family]\n</pre>";
924
+        if ($DEBUGCSS) {
925
+            print '('.$font.")get_font_family]\n</pre>";
926
+        }
907 927
         return $font;
908 928
       }
909 929
     }
910 930
 
911 931
     $family = null;
912
-    if ($DEBUGCSS)  print '(default)';
932
+    if ($DEBUGCSS) {
933
+        print '(default)';
934
+    }
913 935
     $font = Font_Metrics::get_font($family, $subtype);
914 936
 
915 937
     if ( $font ) {
916
-      if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>";
938
+      if ($DEBUGCSS) {
939
+          print '('.$font.")get_font_family]\n</pre>";
940
+      }
917 941
       return $font;
918 942
     }
919 943
     throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '" . $this->_props["font_family"] ."'");
@@ -928,16 +952,19 @@  discard block
 block discarded – undo
928 952
    */
929 953
   function get_font_size() {
930 954
 
931
-    if ( $this->__font_size_calculated )
932
-      return $this->_props["font_size"];
955
+    if ( $this->__font_size_calculated ) {
956
+          return $this->_props["font_size"];
957
+    }
933 958
     
934
-    if ( !isset($this->_props["font_size"]) )
935
-      $fs = self::$_defaults["font_size"];
936
-    else
937
-      $fs = $this->_props["font_size"];
959
+    if ( !isset($this->_props["font_size"]) ) {
960
+          $fs = self::$_defaults["font_size"];
961
+    } else {
962
+          $fs = $this->_props["font_size"];
963
+    }
938 964
     
939
-    if ( !isset($this->_parent_font_size) )
940
-      $this->_parent_font_size = self::$default_font_size;
965
+    if ( !isset($this->_parent_font_size) ) {
966
+          $this->_parent_font_size = self::$default_font_size;
967
+    }
941 968
     
942 969
     switch ($fs) {
943 970
       
@@ -976,14 +1003,13 @@  discard block
 block discarded – undo
976 1003
     }
977 1004
 
978 1005
     // Ensure relative sizes resolve to something
979
-    if ( ($i = mb_strpos($fs, "em")) !== false )
980
-      $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size;
981
-
982
-    else if ( ($i = mb_strpos($fs, "ex")) !== false )
983
-      $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size;
984
-
985
-    else
986
-      $fs = $this->length_in_pt($fs);
1006
+    if ( ($i = mb_strpos($fs, "em")) !== false ) {
1007
+          $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size;
1008
+    } else if ( ($i = mb_strpos($fs, "ex")) !== false ) {
1009
+          $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size;
1010
+    } else {
1011
+          $fs = $this->length_in_pt($fs);
1012
+    }
987 1013
 
988 1014
     //see __set and __get, on all assignments clear cache!
989 1015
 	$this->_prop_cache["font_size"] = null;
@@ -998,8 +1024,9 @@  discard block
 block discarded – undo
998 1024
    * @return float
999 1025
    */
1000 1026
   function get_word_spacing() {
1001
-    if ( $this->_props["word_spacing"] === "normal" )
1002
-      return 0;
1027
+    if ( $this->_props["word_spacing"] === "normal" ) {
1028
+          return 0;
1029
+    }
1003 1030
 
1004 1031
     return $this->_props["word_spacing"];
1005 1032
   }
@@ -1009,11 +1036,13 @@  discard block
 block discarded – undo
1009 1036
    * @return float
1010 1037
    */
1011 1038
   function get_line_height() {
1012
-    if ( $this->_props["line_height"] === "normal" )
1013
-      return self::$default_line_height * $this->get_font_size();
1039
+    if ( $this->_props["line_height"] === "normal" ) {
1040
+          return self::$default_line_height * $this->get_font_size();
1041
+    }
1014 1042
 
1015
-    if ( is_numeric($this->_props["line_height"]) )
1016
-      return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size());
1043
+    if ( is_numeric($this->_props["line_height"]) ) {
1044
+          return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size());
1045
+    }
1017 1046
     
1018 1047
     return $this->length_in_pt( $this->_props["line_height"], $this->get_font_size() );
1019 1048
   }
@@ -1104,10 +1133,11 @@  discard block
 block discarded – undo
1104 1133
         break;
1105 1134
         
1106 1135
       case "center":
1107
-        if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" )
1108
-          $y = "50%";
1109
-        else
1110
-          $x = "50%";
1136
+        if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" ) {
1137
+                  $y = "50%";
1138
+        } else {
1139
+                  $x = "50%";
1140
+        }
1111 1141
         break;
1112 1142
         
1113 1143
       default:
@@ -1119,11 +1149,13 @@  discard block
 block discarded – undo
1119 1149
       $y = "50%";
1120 1150
     }
1121 1151
 
1122
-    if ( !isset($x) )
1123
-      $x = "0%";
1152
+    if ( !isset($x) ) {
1153
+          $x = "0%";
1154
+    }
1124 1155
 
1125
-    if ( !isset($y) )
1126
-      $y = "0%";
1156
+    if ( !isset($y) ) {
1157
+          $y = "0%";
1158
+    }
1127 1159
 
1128 1160
     return array( 0 => $x, "x" => $x,
1129 1161
                   1 => $y, "y" => $y );
@@ -1477,8 +1509,9 @@  discard block
 block discarded – undo
1477 1509
   function set_color($colour) {
1478 1510
     $col = $this->munge_colour($colour);
1479 1511
 
1480
-    if ( is_null($col) )
1481
-      $col = self::$_defaults["color"];
1512
+    if ( is_null($col) ) {
1513
+          $col = self::$_defaults["color"];
1514
+    }
1482 1515
 
1483 1516
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1484 1517
 	$this->_prop_cache["color"] = null;
@@ -1493,8 +1526,9 @@  discard block
 block discarded – undo
1493 1526
    */
1494 1527
   function set_background_color($colour) {
1495 1528
     $col = $this->munge_colour($colour);
1496
-    if ( is_null($col) )
1497
-      $col = self::$_defaults["background_color"];
1529
+    if ( is_null($col) ) {
1530
+          $col = self::$_defaults["background_color"];
1531
+    }
1498 1532
 
1499 1533
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1500 1534
 	$this->_prop_cache["background_color"] = null;
@@ -1520,8 +1554,9 @@  discard block
 block discarded – undo
1520 1554
    * @param string $val
1521 1555
    */
1522 1556
   function set_background_repeat($val) {
1523
-    if ( is_null($val) )
1524
-      $val = self::$_defaults["background_repeat"];
1557
+    if ( is_null($val) ) {
1558
+          $val = self::$_defaults["background_repeat"];
1559
+    }
1525 1560
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1526 1561
     $this->_prop_cache["background_repeat"] = null;
1527 1562
     $this->_props["background_repeat"] = $val;
@@ -1534,8 +1569,9 @@  discard block
 block discarded – undo
1534 1569
    * @param string $val
1535 1570
    */
1536 1571
   function set_background_attachment($val) {
1537
-    if ( is_null($val) )
1538
-      $val = self::$_defaults["background_attachment"];
1572
+    if ( is_null($val) ) {
1573
+          $val = self::$_defaults["background_attachment"];
1574
+    }
1539 1575
 
1540 1576
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1541 1577
 	$this->_prop_cache["background_attachment"] = null;
@@ -1549,8 +1585,9 @@  discard block
 block discarded – undo
1549 1585
    * @param string $val
1550 1586
    */
1551 1587
   function set_background_position($val) {
1552
-    if ( is_null($val) )
1553
-      $val = self::$_defaults["background_position"];
1588
+    if ( is_null($val) ) {
1589
+          $val = self::$_defaults["background_position"];
1590
+    }
1554 1591
 
1555 1592
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1556 1593
 	$this->_prop_cache["background_position"] = null;
@@ -1688,8 +1725,9 @@  discard block
 block discarded – undo
1688 1725
    * @param string $break
1689 1726
    */
1690 1727
   function set_page_break_before($break) {
1691
-    if ($break === "left" || $break === "right")
1692
-      $break = "always";
1728
+    if ($break === "left" || $break === "right") {
1729
+          $break = "always";
1730
+    }
1693 1731
 
1694 1732
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1695 1733
 	$this->_prop_cache["page_break_before"] = null;
@@ -1697,8 +1735,9 @@  discard block
 block discarded – undo
1697 1735
   }
1698 1736
 
1699 1737
   function set_page_break_after($break) {
1700
-    if ($break === "left" || $break === "right")
1701
-      $break = "always";
1738
+    if ($break === "left" || $break === "right") {
1739
+          $break = "always";
1740
+    }
1702 1741
 
1703 1742
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1704 1743
 	$this->_prop_cache["page_break_after"] = null;
@@ -1847,8 +1886,9 @@  discard block
 block discarded – undo
1847 1886
 
1848 1887
     $arr = explode(" ", $val);
1849 1888
 
1850
-    if ( count($arr) == 1 )
1851
-      $arr[1] = $arr[0];
1889
+    if ( count($arr) == 1 ) {
1890
+          $arr[1] = $arr[0];
1891
+    }
1852 1892
 
1853 1893
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1854 1894
 	$this->_prop_cache["border_spacing"] = null;
Please login to merge, or discard this patch.
Indentation   +1073 added lines, -1073 removed lines patch added patch discarded remove patch
@@ -85,114 +85,114 @@  discard block
 block discarded – undo
85 85
  */
86 86
 class Style {
87 87
 
88
-  /**
89
-   * Default font size, in points.
90
-   *
91
-   * @var float
92
-   */
93
-  static $default_font_size = 12;
94
-
95
-  /**
96
-   * Default line height, as a fraction of the font size.
97
-   *
98
-   * @var float
99
-   */
100
-  static $default_line_height = 1.2;
101
-
102
-  /**
103
-   * List of all inline types.  Should really be a constant.
104
-   *
105
-   * @var array
106
-   */
107
-  static $INLINE_TYPES = array("inline");
108
-
109
-  /**
110
-   * List of all block types.  Should really be a constant.
111
-   *
112
-   * @var array
113
-   */
114
-  static $BLOCK_TYPES = array("block","inline-block", "table-cell", "list-item");
115
-
116
-  /**
117
-   * List of all table types.  Should really be a constant.
118
-   *
119
-   * @var array;
120
-   */
121
-  static $TABLE_TYPES = array("table", "inline-table");
122
-
123
-  /**
124
-   * List of valid border styles.  Should also really be a constant.
125
-   *
126
-   * @var array
127
-   */
128
-  static $BORDER_STYLES = array("none", "hidden", "dotted", "dashed", "solid",
88
+    /**
89
+     * Default font size, in points.
90
+     *
91
+     * @var float
92
+     */
93
+    static $default_font_size = 12;
94
+
95
+    /**
96
+     * Default line height, as a fraction of the font size.
97
+     *
98
+     * @var float
99
+     */
100
+    static $default_line_height = 1.2;
101
+
102
+    /**
103
+     * List of all inline types.  Should really be a constant.
104
+     *
105
+     * @var array
106
+     */
107
+    static $INLINE_TYPES = array("inline");
108
+
109
+    /**
110
+     * List of all block types.  Should really be a constant.
111
+     *
112
+     * @var array
113
+     */
114
+    static $BLOCK_TYPES = array("block","inline-block", "table-cell", "list-item");
115
+
116
+    /**
117
+     * List of all table types.  Should really be a constant.
118
+     *
119
+     * @var array;
120
+     */
121
+    static $TABLE_TYPES = array("table", "inline-table");
122
+
123
+    /**
124
+     * List of valid border styles.  Should also really be a constant.
125
+     *
126
+     * @var array
127
+     */
128
+    static $BORDER_STYLES = array("none", "hidden", "dotted", "dashed", "solid",
129 129
                                 "double", "groove", "ridge", "inset", "outset");
130 130
 
131
-  /**
132
-   * Default style values.
133
-   *
134
-   * @link http://www.w3.org/TR/CSS21/propidx.html
135
-   *
136
-   * @var array
137
-   */
138
-  static protected $_defaults = null;
139
-
140
-  /**
141
-   * List of inherited properties
142
-   *
143
-   * @link http://www.w3.org/TR/CSS21/propidx.html
144
-   *
145
-   * @var array
146
-   */
147
-  static protected $_inherited = null;
148
-
149
-  /**
150
-   * The stylesheet this style belongs to
151
-   *
152
-   * @see Stylesheet
153
-   * @var Stylesheet
154
-   */
155
-  protected $_stylesheet; // stylesheet this style is attached to
156
-
157
-  /**
158
-   * Main array of all CSS properties & values
159
-   *
160
-   * @var array
161
-   */
162
-  protected $_props;
163
-
164
-  /* var instead of protected would allow access outside of class */
165
-  protected $_important_props;
166
-
167
-  /**
168
-   * Cached property values
169
-   *
170
-   * @var array
171
-   */
172
-  protected $_prop_cache;
131
+    /**
132
+     * Default style values.
133
+     *
134
+     * @link http://www.w3.org/TR/CSS21/propidx.html
135
+     *
136
+     * @var array
137
+     */
138
+    static protected $_defaults = null;
139
+
140
+    /**
141
+     * List of inherited properties
142
+     *
143
+     * @link http://www.w3.org/TR/CSS21/propidx.html
144
+     *
145
+     * @var array
146
+     */
147
+    static protected $_inherited = null;
148
+
149
+    /**
150
+     * The stylesheet this style belongs to
151
+     *
152
+     * @see Stylesheet
153
+     * @var Stylesheet
154
+     */
155
+    protected $_stylesheet; // stylesheet this style is attached to
156
+
157
+    /**
158
+     * Main array of all CSS properties & values
159
+     *
160
+     * @var array
161
+     */
162
+    protected $_props;
163
+
164
+    /* var instead of protected would allow access outside of class */
165
+    protected $_important_props;
166
+
167
+    /**
168
+     * Cached property values
169
+     *
170
+     * @var array
171
+     */
172
+    protected $_prop_cache;
173 173
   
174
-  /**
175
-   * Font size of parent element in document tree.  Used for relative font
176
-   * size resolution.
177
-   *
178
-   * @var float
179
-   */
180
-  protected $_parent_font_size; // Font size of parent element
174
+    /**
175
+     * Font size of parent element in document tree.  Used for relative font
176
+     * size resolution.
177
+     *
178
+     * @var float
179
+     */
180
+    protected $_parent_font_size; // Font size of parent element
181 181
   
182
-  // private members
183
-  /**
184
-   * True once the font size is resolved absolutely
185
-   *
186
-   * @var bool
187
-   */
188
-  private $__font_size_calculated; // Cache flag
182
+    // private members
183
+    /**
184
+     * True once the font size is resolved absolutely
185
+     *
186
+     * @var bool
187
+     */
188
+    private $__font_size_calculated; // Cache flag
189 189
   
190
-  /**
191
-   * Class constructor
192
-   *
193
-   * @param Stylesheet $stylesheet the stylesheet this Style is associated with.
194
-   */
195
-  function __construct(Stylesheet $stylesheet) {
190
+    /**
191
+     * Class constructor
192
+     *
193
+     * @param Stylesheet $stylesheet the stylesheet this Style is associated with.
194
+     */
195
+    function __construct(Stylesheet $stylesheet) {
196 196
     $this->_props = array();
197 197
     $this->_important_props = array();
198 198
     $this->_stylesheet = $stylesheet;
@@ -201,330 +201,330 @@  discard block
 block discarded – undo
201 201
     
202 202
     if ( !isset(self::$_defaults) ) {
203 203
     
204
-      // Shorthand
205
-      $d =& self::$_defaults;
204
+        // Shorthand
205
+        $d =& self::$_defaults;
206 206
     
207
-      // All CSS 2.1 properties, and their default values
208
-      $d["azimuth"] = "center";
209
-      $d["background_attachment"] = "scroll";
210
-      $d["background_color"] = "transparent";
211
-      $d["background_image"] = "none";
212
-      $d["background_position"] = "0% 0%";
213
-      $d["background_repeat"] = "repeat";
214
-      $d["background"] = "";
215
-      $d["border_collapse"] = "separate";
216
-      $d["border_color"] = "";
217
-      $d["border_spacing"] = "0";
218
-      $d["border_style"] = "";
219
-      $d["border_top"] = "";
220
-      $d["border_right"] = "";
221
-      $d["border_bottom"] = "";
222
-      $d["border_left"] = "";
223
-      $d["border_top_color"] = "";
224
-      $d["border_right_color"] = "";
225
-      $d["border_bottom_color"] = "";
226
-      $d["border_left_color"] = "";
227
-      $d["border_top_style"] = "none";
228
-      $d["border_right_style"] = "none";
229
-      $d["border_bottom_style"] = "none";
230
-      $d["border_left_style"] = "none";
231
-      $d["border_top_width"] = "medium";
232
-      $d["border_right_width"] = "medium";
233
-      $d["border_bottom_width"] = "medium";
234
-      $d["border_left_width"] = "medium";
235
-      $d["border_width"] = "medium";
236
-      $d["border"] = "";
237
-      $d["bottom"] = "auto";
238
-      $d["caption_side"] = "top";
239
-      $d["clear"] = "none";
240
-      $d["clip"] = "auto";
241
-      $d["color"] = "#000000";
242
-      $d["content"] = "normal";
243
-      $d["counter_increment"] = "none";
244
-      $d["counter_reset"] = "none";
245
-      $d["cue_after"] = "none";
246
-      $d["cue_before"] = "none";
247
-      $d["cue"] = "";
248
-      $d["cursor"] = "auto";
249
-      $d["direction"] = "ltr";
250
-      $d["display"] = "inline";
251
-      $d["elevation"] = "level";
252
-      $d["empty_cells"] = "show";
253
-      $d["float"] = "none";
254
-      $d["font_family"] = "serif";
255
-      $d["font_size"] = "medium";
256
-      $d["font_style"] = "normal";
257
-      $d["font_variant"] = "normal";
258
-      $d["font_weight"] = "normal";
259
-      $d["font"] = "";
260
-      $d["height"] = "auto";
261
-      $d["left"] = "auto";
262
-      $d["letter_spacing"] = "normal";
263
-      $d["line_height"] = "normal";
264
-      $d["list_style_image"] = "none";
265
-      $d["list_style_position"] = "outside";
266
-      $d["list_style_type"] = "disc";
267
-      $d["list_style"] = "";
268
-      $d["margin_right"] = "0";
269
-      $d["margin_left"] = "0";
270
-      $d["margin_top"] = "0";
271
-      $d["margin_bottom"] = "0";
272
-      $d["margin"] = "";
273
-      $d["max_height"] = "none";
274
-      $d["max_width"] = "none";
275
-      $d["min_height"] = "0";
276
-      $d["min_width"] = "0";
277
-      $d["orphans"] = "2";
278
-      $d["outline_color"] = "invert";
279
-      $d["outline_style"] = "none";
280
-      $d["outline_width"] = "medium";
281
-      $d["outline"] = "";
282
-      $d["overflow"] = "visible";
283
-      $d["padding_top"] = "0";
284
-      $d["padding_right"] = "0";
285
-      $d["padding_bottom"] = "0";
286
-      $d["padding_left"] = "0";
287
-      $d["padding"] = "";
288
-      $d["page_break_after"] = "auto";
289
-      $d["page_break_before"] = "auto";
290
-      $d["page_break_inside"] = "auto";
291
-      $d["pause_after"] = "0";
292
-      $d["pause_before"] = "0";
293
-      $d["pause"] = "";
294
-      $d["pitch_range"] = "50";
295
-      $d["pitch"] = "medium";
296
-      $d["play_during"] = "auto";
297
-      $d["position"] = "static";
298
-      $d["quotes"] = "";
299
-      $d["richness"] = "50";
300
-      $d["right"] = "auto";
301
-      $d["speak_header"] = "once";
302
-      $d["speak_numeral"] = "continuous";
303
-      $d["speak_punctuation"] = "none";
304
-      $d["speak"] = "normal";
305
-      $d["speech_rate"] = "medium";
306
-      $d["stress"] = "50";
307
-      $d["table_layout"] = "auto";
308
-      $d["text_align"] = "left";
309
-      $d["text_decoration"] = "none";
310
-      $d["text_indent"] = "0";
311
-      $d["text_transform"] = "none";
312
-      $d["top"] = "auto";
313
-      $d["unicode_bidi"] = "normal";
314
-      $d["vertical_align"] = "baseline";
315
-      $d["visibility"] = "visible";
316
-      $d["voice_family"] = "";
317
-      $d["volume"] = "medium";
318
-      $d["white_space"] = "normal";
319
-      $d["widows"] = "2";
320
-      $d["width"] = "auto";
321
-      $d["word_spacing"] = "normal";
322
-      $d["z_index"] = "auto";
323
-
324
-      // Properties that inherit by default
325
-      self::$_inherited = array("azimuth",
326
-                                 "border_collapse",
327
-                                 "border_spacing",
328
-                                 "caption_side",
329
-                                 "color",
330
-                                 "cursor",
331
-                                 "direction",
332
-                                 "elevation",
333
-                                 "empty_cells",
334
-                                 "font_family",
335
-                                 "font_size",
336
-                                 "font_style",
337
-                                 "font_variant",
338
-                                 "font_weight",
339
-                                 "font",
340
-                                 "letter_spacing",
341
-                                 "line_height",
342
-                                 "list_style_image",
343
-                                 "list_style_position",
344
-                                 "list_style_type",
345
-                                 "list_style",
346
-                                 "orphans",
347
-                                 "page_break_inside",
348
-                                 "pitch_range",
349
-                                 "pitch",
350
-                                 "quotes",
351
-                                 "richness",
352
-                                 "speak_header",
353
-                                 "speak_numeral",
354
-                                 "speak_punctuation",
355
-                                 "speak",
356
-                                 "speech_rate",
357
-                                 "stress",
358
-                                 "text_align",
359
-                                 "text_indent",
360
-                                 "text_transform",
361
-                                 "visibility",
362
-                                 "voice_family",
363
-                                 "volume",
364
-                                 "white_space",
365
-                                 "widows",
366
-                                 "word_spacing");
367
-    }
368
-
369
-  }
370
-
371
-  /**
372
-   * "Destructor": forcibly free all references held by this object
373
-   */
374
-  function dispose() {
207
+        // All CSS 2.1 properties, and their default values
208
+        $d["azimuth"] = "center";
209
+        $d["background_attachment"] = "scroll";
210
+        $d["background_color"] = "transparent";
211
+        $d["background_image"] = "none";
212
+        $d["background_position"] = "0% 0%";
213
+        $d["background_repeat"] = "repeat";
214
+        $d["background"] = "";
215
+        $d["border_collapse"] = "separate";
216
+        $d["border_color"] = "";
217
+        $d["border_spacing"] = "0";
218
+        $d["border_style"] = "";
219
+        $d["border_top"] = "";
220
+        $d["border_right"] = "";
221
+        $d["border_bottom"] = "";
222
+        $d["border_left"] = "";
223
+        $d["border_top_color"] = "";
224
+        $d["border_right_color"] = "";
225
+        $d["border_bottom_color"] = "";
226
+        $d["border_left_color"] = "";
227
+        $d["border_top_style"] = "none";
228
+        $d["border_right_style"] = "none";
229
+        $d["border_bottom_style"] = "none";
230
+        $d["border_left_style"] = "none";
231
+        $d["border_top_width"] = "medium";
232
+        $d["border_right_width"] = "medium";
233
+        $d["border_bottom_width"] = "medium";
234
+        $d["border_left_width"] = "medium";
235
+        $d["border_width"] = "medium";
236
+        $d["border"] = "";
237
+        $d["bottom"] = "auto";
238
+        $d["caption_side"] = "top";
239
+        $d["clear"] = "none";
240
+        $d["clip"] = "auto";
241
+        $d["color"] = "#000000";
242
+        $d["content"] = "normal";
243
+        $d["counter_increment"] = "none";
244
+        $d["counter_reset"] = "none";
245
+        $d["cue_after"] = "none";
246
+        $d["cue_before"] = "none";
247
+        $d["cue"] = "";
248
+        $d["cursor"] = "auto";
249
+        $d["direction"] = "ltr";
250
+        $d["display"] = "inline";
251
+        $d["elevation"] = "level";
252
+        $d["empty_cells"] = "show";
253
+        $d["float"] = "none";
254
+        $d["font_family"] = "serif";
255
+        $d["font_size"] = "medium";
256
+        $d["font_style"] = "normal";
257
+        $d["font_variant"] = "normal";
258
+        $d["font_weight"] = "normal";
259
+        $d["font"] = "";
260
+        $d["height"] = "auto";
261
+        $d["left"] = "auto";
262
+        $d["letter_spacing"] = "normal";
263
+        $d["line_height"] = "normal";
264
+        $d["list_style_image"] = "none";
265
+        $d["list_style_position"] = "outside";
266
+        $d["list_style_type"] = "disc";
267
+        $d["list_style"] = "";
268
+        $d["margin_right"] = "0";
269
+        $d["margin_left"] = "0";
270
+        $d["margin_top"] = "0";
271
+        $d["margin_bottom"] = "0";
272
+        $d["margin"] = "";
273
+        $d["max_height"] = "none";
274
+        $d["max_width"] = "none";
275
+        $d["min_height"] = "0";
276
+        $d["min_width"] = "0";
277
+        $d["orphans"] = "2";
278
+        $d["outline_color"] = "invert";
279
+        $d["outline_style"] = "none";
280
+        $d["outline_width"] = "medium";
281
+        $d["outline"] = "";
282
+        $d["overflow"] = "visible";
283
+        $d["padding_top"] = "0";
284
+        $d["padding_right"] = "0";
285
+        $d["padding_bottom"] = "0";
286
+        $d["padding_left"] = "0";
287
+        $d["padding"] = "";
288
+        $d["page_break_after"] = "auto";
289
+        $d["page_break_before"] = "auto";
290
+        $d["page_break_inside"] = "auto";
291
+        $d["pause_after"] = "0";
292
+        $d["pause_before"] = "0";
293
+        $d["pause"] = "";
294
+        $d["pitch_range"] = "50";
295
+        $d["pitch"] = "medium";
296
+        $d["play_during"] = "auto";
297
+        $d["position"] = "static";
298
+        $d["quotes"] = "";
299
+        $d["richness"] = "50";
300
+        $d["right"] = "auto";
301
+        $d["speak_header"] = "once";
302
+        $d["speak_numeral"] = "continuous";
303
+        $d["speak_punctuation"] = "none";
304
+        $d["speak"] = "normal";
305
+        $d["speech_rate"] = "medium";
306
+        $d["stress"] = "50";
307
+        $d["table_layout"] = "auto";
308
+        $d["text_align"] = "left";
309
+        $d["text_decoration"] = "none";
310
+        $d["text_indent"] = "0";
311
+        $d["text_transform"] = "none";
312
+        $d["top"] = "auto";
313
+        $d["unicode_bidi"] = "normal";
314
+        $d["vertical_align"] = "baseline";
315
+        $d["visibility"] = "visible";
316
+        $d["voice_family"] = "";
317
+        $d["volume"] = "medium";
318
+        $d["white_space"] = "normal";
319
+        $d["widows"] = "2";
320
+        $d["width"] = "auto";
321
+        $d["word_spacing"] = "normal";
322
+        $d["z_index"] = "auto";
323
+
324
+        // Properties that inherit by default
325
+        self::$_inherited = array("azimuth",
326
+                                    "border_collapse",
327
+                                    "border_spacing",
328
+                                    "caption_side",
329
+                                    "color",
330
+                                    "cursor",
331
+                                    "direction",
332
+                                    "elevation",
333
+                                    "empty_cells",
334
+                                    "font_family",
335
+                                    "font_size",
336
+                                    "font_style",
337
+                                    "font_variant",
338
+                                    "font_weight",
339
+                                    "font",
340
+                                    "letter_spacing",
341
+                                    "line_height",
342
+                                    "list_style_image",
343
+                                    "list_style_position",
344
+                                    "list_style_type",
345
+                                    "list_style",
346
+                                    "orphans",
347
+                                    "page_break_inside",
348
+                                    "pitch_range",
349
+                                    "pitch",
350
+                                    "quotes",
351
+                                    "richness",
352
+                                    "speak_header",
353
+                                    "speak_numeral",
354
+                                    "speak_punctuation",
355
+                                    "speak",
356
+                                    "speech_rate",
357
+                                    "stress",
358
+                                    "text_align",
359
+                                    "text_indent",
360
+                                    "text_transform",
361
+                                    "visibility",
362
+                                    "voice_family",
363
+                                    "volume",
364
+                                    "white_space",
365
+                                    "widows",
366
+                                    "word_spacing");
367
+    }
368
+
369
+    }
370
+
371
+    /**
372
+     * "Destructor": forcibly free all references held by this object
373
+     */
374
+    function dispose() {
375 375
     unset($this->_stylesheet);
376
-  }
376
+    }
377 377
   
378
-  /**
379
-   * returns the {@link Stylesheet} this Style is associated with.
380
-   *
381
-   * @return Stylesheet
382
-   */
383
-  function get_stylesheet() { return $this->_stylesheet; }
378
+    /**
379
+     * returns the {@link Stylesheet} this Style is associated with.
380
+     *
381
+     * @return Stylesheet
382
+     */
383
+    function get_stylesheet() { return $this->_stylesheet; }
384 384
   
385
-  /**
386
-   * Converts any CSS length value into an absolute length in points.
387
-   *
388
-   * length_in_pt() takes a single length (e.g. '1em') or an array of
389
-   * lengths and returns an absolute length.  If an array is passed, then
390
-   * the return value is the sum of all elements.
391
-   *
392
-   * If a reference size is not provided, the default font size is used
393
-   * ({@link Style::$default_font_size}).
394
-   *
395
-   * @param float|array $length   the length or array of lengths to resolve
396
-   * @param float       $ref_size  an absolute reference size to resolve percentage lengths
397
-   * @return float
398
-   */
399
-  function length_in_pt($length, $ref_size = null) {
385
+    /**
386
+     * Converts any CSS length value into an absolute length in points.
387
+     *
388
+     * length_in_pt() takes a single length (e.g. '1em') or an array of
389
+     * lengths and returns an absolute length.  If an array is passed, then
390
+     * the return value is the sum of all elements.
391
+     *
392
+     * If a reference size is not provided, the default font size is used
393
+     * ({@link Style::$default_font_size}).
394
+     *
395
+     * @param float|array $length   the length or array of lengths to resolve
396
+     * @param float       $ref_size  an absolute reference size to resolve percentage lengths
397
+     * @return float
398
+     */
399
+    function length_in_pt($length, $ref_size = null) {
400 400
 
401 401
     if ( !is_array($length) )
402
-      $length = array($length);
402
+        $length = array($length);
403 403
 
404 404
     if ( !isset($ref_size) )
405
-      $ref_size = self::$default_font_size;
405
+        $ref_size = self::$default_font_size;
406 406
 
407 407
     $ret = 0;
408 408
     foreach ($length as $l) {
409 409
 
410
-      if ( $l === "auto" )
410
+        if ( $l === "auto" )
411 411
         return "auto";
412 412
       
413
-      if ( $l === "none" )
413
+        if ( $l === "none" )
414 414
         return "none";
415 415
 
416
-      // Assume numeric values are already in points
417
-      if ( is_numeric($l) ) {
416
+        // Assume numeric values are already in points
417
+        if ( is_numeric($l) ) {
418 418
         $ret += $l;
419 419
         continue;
420
-      }
420
+        }
421 421
         
422
-      if ( $l === "normal" ) {
422
+        if ( $l === "normal" ) {
423 423
         $ret += $ref_size;
424 424
         continue;
425
-      }
425
+        }
426 426
 
427
-      // Border lengths
428
-      if ( $l === "thin" ) {
427
+        // Border lengths
428
+        if ( $l === "thin" ) {
429 429
         $ret += 0.5;
430 430
         continue;
431
-      }
431
+        }
432 432
       
433
-      if ( $l === "medium" ) {
433
+        if ( $l === "medium" ) {
434 434
         $ret += 1.5;
435 435
         continue;
436
-      }
436
+        }
437 437
     
438
-      if ( $l === "thick" ) {
438
+        if ( $l === "thick" ) {
439 439
         $ret += 2.5;
440 440
         continue;
441
-      }
441
+        }
442 442
       
443
-      if ( ($i = mb_strpos($l, "pt"))  !== false ) {
443
+        if ( ($i = mb_strpos($l, "pt"))  !== false ) {
444 444
         $ret += mb_substr($l, 0, $i);
445 445
         continue;
446
-      }
446
+        }
447 447
 
448
-      if ( ($i = mb_strpos($l, "px"))  !== false ) {
448
+        if ( ($i = mb_strpos($l, "px"))  !== false ) {
449 449
         $ret += ( mb_substr($l, 0, $i)  * 72 ) / DOMPDF_DPI;
450 450
         continue;
451
-      }
451
+        }
452 452
 
453
-      if ( ($i = mb_strpos($l, "em"))  !== false ) {
453
+        if ( ($i = mb_strpos($l, "em"))  !== false ) {
454 454
         $ret += mb_substr($l, 0, $i) * $this->__get("font_size");
455 455
         continue;
456
-      }
456
+        }
457 457
       
458
-      // FIXME: em:ex ratio?
459
-      if ( ($i = mb_strpos($l, "ex"))  !== false ) {
458
+        // FIXME: em:ex ratio?
459
+        if ( ($i = mb_strpos($l, "ex"))  !== false ) {
460 460
         $ret += mb_substr($l, 0, $i) * $this->__get("font_size");
461 461
         continue;
462
-      }
462
+        }
463 463
       
464
-      if ( ($i = mb_strpos($l, "%"))  !== false ) {
464
+        if ( ($i = mb_strpos($l, "%"))  !== false ) {
465 465
         $ret += mb_substr($l, 0, $i)/100 * $ref_size;
466 466
         continue;
467
-      }
467
+        }
468 468
       
469
-      if ( ($i = mb_strpos($l, "in")) !== false ) {
469
+        if ( ($i = mb_strpos($l, "in")) !== false ) {
470 470
         $ret += mb_substr($l, 0, $i) * 72;
471 471
         continue;
472
-      }
472
+        }
473 473
           
474
-      if ( ($i = mb_strpos($l, "cm")) !== false ) {
474
+        if ( ($i = mb_strpos($l, "cm")) !== false ) {
475 475
         $ret += mb_substr($l, 0, $i) * 72 / 2.54;
476 476
         continue;
477
-      }
477
+        }
478 478
 
479
-      if ( ($i = mb_strpos($l, "mm")) !== false ) {
479
+        if ( ($i = mb_strpos($l, "mm")) !== false ) {
480 480
         $ret += mb_substr($l, 0, $i) * 72 / 25.4;
481 481
         continue;
482
-      }
482
+        }
483 483
           
484
-      if ( ($i = mb_strpos($l, "pc")) !== false ) {
484
+        if ( ($i = mb_strpos($l, "pc")) !== false ) {
485 485
         $ret += mb_substr($l, 0, $i) / 12;
486 486
         continue;
487
-      }
487
+        }
488 488
           
489
-      // Bogus value
490
-      $ret += $ref_size;
489
+        // Bogus value
490
+        $ret += $ref_size;
491 491
     }
492 492
 
493 493
     return $ret;
494
-  }
494
+    }
495 495
 
496 496
   
497
-  /**
498
-   * Set inherited properties in this style using values in $parent
499
-   *
500
-   * @param Style $parent
501
-   */
502
-  function inherit(Style $parent) {
497
+    /**
498
+     * Set inherited properties in this style using values in $parent
499
+     *
500
+     * @param Style $parent
501
+     */
502
+    function inherit(Style $parent) {
503 503
 
504 504
     // Set parent font size
505 505
     $this->_parent_font_size = $parent->get_font_size();
506 506
     
507 507
     foreach (self::$_inherited as $prop) {
508
-      //inherit the !important property also.
509
-      //if local property is also !important, don't inherit.
510
-      if ( isset($parent->_props[$prop]) &&
508
+        //inherit the !important property also.
509
+        //if local property is also !important, don't inherit.
510
+        if ( isset($parent->_props[$prop]) &&
511 511
            ( !isset($this->_props[$prop]) ||
512 512
              ( isset($parent->_important_props[$prop]) && !isset($this->_important_props[$prop]) )
513
-           )
514
-         ) {
513
+            )
514
+            ) {
515 515
         if ( isset($parent->_important_props[$prop]) ) {
516
-          $this->_important_props[$prop] = true;
516
+            $this->_important_props[$prop] = true;
517 517
         }
518 518
         //see __set and __get, on all assignments clear cache!
519
-		$this->_prop_cache[$prop] = null;
520
-		$this->_props[$prop] = $parent->_props[$prop];
521
-      }
519
+        $this->_prop_cache[$prop] = null;
520
+        $this->_props[$prop] = $parent->_props[$prop];
521
+        }
522 522
     }
523 523
       
524 524
     foreach (array_keys($this->_props) as $prop) {
525
-      if ( $this->_props[$prop] === "inherit" ) {
525
+        if ( $this->_props[$prop] === "inherit" ) {
526 526
         if ( isset($parent->_important_props[$prop]) ) {
527
-          $this->_important_props[$prop] = true;
527
+            $this->_important_props[$prop] = true;
528 528
         }
529 529
         //do not assign direct, but
530 530
         //implicite assignment through __set, redirect to specialized, get value with __get
@@ -532,58 +532,58 @@  discard block
 block discarded – undo
532 532
         //Therefore do not directly assign the value without __set
533 533
         //set _important_props before that to be able to propagate.
534 534
         //see __set and __get, on all assignments clear cache!
535
-		//$this->_prop_cache[$prop] = null;
536
-		//$this->_props[$prop] = $parent->_props[$prop];
535
+        //$this->_prop_cache[$prop] = null;
536
+        //$this->_props[$prop] = $parent->_props[$prop];
537 537
         //props_set for more obvious explicite assignment not implemented, because
538 538
         //too many implicite uses.
539 539
         // $this->props_set($prop, $parent->$prop);
540 540
         $this->$prop = $parent->$prop;
541
-      }
541
+        }
542 542
     }
543 543
           
544 544
     return $this;
545
-  }
545
+    }
546 546
 
547 547
   
548
-  /**
549
-   * Override properties in this style with those in $style
550
-   *
551
-   * @param Style $style
552
-   */
553
-  function merge(Style $style) {
548
+    /**
549
+     * Override properties in this style with those in $style
550
+     *
551
+     * @param Style $style
552
+     */
553
+    function merge(Style $style) {
554 554
     //treat the !important attribute
555 555
     //if old rule has !important attribute, override with new rule only if
556 556
     //the new rule is also !important
557 557
     foreach($style->_props as $prop => $val ) {
558
-      if (isset($style->_important_props[$prop])) {
559
- 	    $this->_important_props[$prop] = true;
558
+        if (isset($style->_important_props[$prop])) {
559
+            $this->_important_props[$prop] = true;
560 560
         //see __set and __get, on all assignments clear cache!
561
-		$this->_prop_cache[$prop] = null;
562
- 	    $this->_props[$prop] = $val;
563
- 	  } else if ( !isset($this->_important_props[$prop]) ) {
561
+        $this->_prop_cache[$prop] = null;
562
+            $this->_props[$prop] = $val;
563
+        } else if ( !isset($this->_important_props[$prop]) ) {
564 564
         //see __set and __get, on all assignments clear cache!
565
-		$this->_prop_cache[$prop] = null;
566
- 	    $this->_props[$prop] = $val;
567
- 	  }
568
- 	}
565
+        $this->_prop_cache[$prop] = null;
566
+            $this->_props[$prop] = $val;
567
+        }
568
+        }
569 569
 
570 570
     if ( isset($style->_props["font_size"]) )
571
-      $this->__font_size_calculated = false;
572
-  }
571
+        $this->__font_size_calculated = false;
572
+    }
573 573
 
574 574
   
575
-  /**
576
-   * Returns an array(r, g, b, "r"=> r, "g"=>g, "b"=>b, "hex"=>"#rrggbb")
577
-   * based on the provided CSS colour value.
578
-   *
579
-   * @param string $colour
580
-   * @return array
581
-   */
582
-  function munge_colour($colour) {
575
+    /**
576
+     * Returns an array(r, g, b, "r"=> r, "g"=>g, "b"=>b, "hex"=>"#rrggbb")
577
+     * based on the provided CSS colour value.
578
+     *
579
+     * @param string $colour
580
+     * @return array
581
+     */
582
+    function munge_colour($colour) {
583 583
     if ( is_array($colour) )
584
-      // Assume the array has the right format...
585
-      // FIXME: should/could verify this.
586
-      return $colour;
584
+        // Assume the array has the right format...
585
+        // FIXME: should/could verify this.
586
+        return $colour;
587 587
     
588 588
     $r = 0;
589 589
     $g = 0;
@@ -594,78 +594,78 @@  discard block
 block discarded – undo
594 594
 
595 595
     case "maroon":
596 596
       $r = 0x80;
597
-      break;
597
+        break;
598 598
 
599 599
     case "red":
600 600
       $r = 0xff;
601
-      break;
601
+        break;
602 602
 
603 603
     case "orange":
604 604
       $r = 0xff;
605
-      $g = 0xa5;
606
-      break;
605
+        $g = 0xa5;
606
+        break;
607 607
 
608 608
     case "yellow":
609 609
       $r = 0xff;
610
-      $g = 0xff;
611
-      break;
610
+        $g = 0xff;
611
+        break;
612 612
 
613 613
     case "olive":
614 614
       $r = 0x80;
615
-      $g = 0x80;
616
-      break;
615
+        $g = 0x80;
616
+        break;
617 617
 
618 618
     case "purple":
619 619
       $r = 0x80;
620
-      $b = 0x80;
621
-      break;
620
+        $b = 0x80;
621
+        break;
622 622
 
623 623
     case "fuchsia":
624 624
       $r = 0xff;
625
-      $b = 0xff;
626
-      break;
625
+        $b = 0xff;
626
+        break;
627 627
 
628 628
     case "white":
629 629
       $r = $g = $b = 0xff;
630
-      break;
630
+        break;
631 631
 
632 632
     case "lime":
633 633
       $g = 0xff;
634
-      break;
634
+        break;
635 635
 
636 636
     case "green":
637 637
       $g = 0x80;
638
-      break;
638
+        break;
639 639
 
640 640
     case "navy":
641 641
       $b = 0x80;
642
-      break;
642
+        break;
643 643
 
644 644
     case "blue":
645 645
       $b = 0xff;
646
-      break;
646
+        break;
647 647
 
648 648
     case "aqua":
649 649
       $g = 0xff;
650
-      $b = 0xff;
651
-      break;
650
+        $b = 0xff;
651
+        break;
652 652
 
653 653
     case "teal":
654 654
       $g = 0x80;
655
-      $b = 0x80;
656
-      break;
655
+        $b = 0x80;
656
+        break;
657 657
 
658 658
     case "black":
659 659
       break;
660 660
 
661 661
     case "sliver":
662 662
       $r = $g = $b = 0xc0;
663
-      break;
663
+        break;
664 664
 
665 665
     case "gray":
666 666
     case "grey":
667 667
       $r = $g = $b = 0x80;
668
-      break;
668
+        break;
669 669
 
670 670
     case "transparent":
671 671
       return "transparent";
@@ -677,177 +677,177 @@  discard block
 block discarded – undo
677 677
         $g = hexdec($colour[2] . $colour[2]);
678 678
         $b = hexdec($colour[3] . $colour[3]);
679 679
 
680
-      } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) {
680
+        } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) {
681 681
         // #rrggbb format
682 682
         $r = hexdec(mb_substr($colour, 1, 2));
683 683
         $g = hexdec(mb_substr($colour, 3, 2));
684 684
         $b = hexdec(mb_substr($colour, 5, 2));
685 685
 
686
-      } else if ( mb_strpos($colour, "rgb") !== false ) {
686
+        } else if ( mb_strpos($colour, "rgb") !== false ) {
687 687
         // rgb( r,g,b ) format
688 688
         $i = mb_strpos($colour, "(");
689 689
         $j = mb_strpos($colour, ")");
690 690
         
691 691
         // Bad colour value
692 692
         if ($i === false || $j === false)
693
-          return null;
693
+            return null;
694 694
 
695 695
         $triplet = explode(",", mb_substr($colour, $i+1, $j-$i-1));
696 696
 
697 697
         if (count($triplet) != 3)
698
-          return null;
698
+            return null;
699 699
         
700 700
         foreach (array_keys($triplet) as $c) {
701
-          $triplet[$c] = trim($triplet[$c]);
701
+            $triplet[$c] = trim($triplet[$c]);
702 702
           
703
-          if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" )
703
+            if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" )
704 704
             $triplet[$c] = round($triplet[$c] * 0.255);
705 705
         }
706 706
 
707 707
         list($r, $g, $b) = $triplet;
708 708
 
709
-      } else {
709
+        } else {
710 710
         // Who knows?
711 711
         return null;
712
-      }
712
+        }
713 713
       
714
-      // Clip to 0 - 1
715
-      $r = $r < 0 ? 0 : ($r > 255 ? 255 : $r);
716
-      $g = $g < 0 ? 0 : ($g > 255 ? 255 : $g);
717
-      $b = $b < 0 ? 0 : ($b > 255 ? 255 : $b);
718
-      break;
714
+        // Clip to 0 - 1
715
+        $r = $r < 0 ? 0 : ($r > 255 ? 255 : $r);
716
+        $g = $g < 0 ? 0 : ($g > 255 ? 255 : $g);
717
+        $b = $b < 0 ? 0 : ($b > 255 ? 255 : $b);
718
+        break;
719 719
       
720 720
     }
721 721
     
722 722
     // Form array
723 723
     $arr = array(0 => $r / 0xff, 1 => $g / 0xff, 2 => $b / 0xff,
724
-                 "r"=>$r / 0xff, "g"=>$g / 0xff, "b"=>$b / 0xff,
725
-                 "hex" => sprintf("#%02X%02X%02X", $r, $g, $b));
724
+                    "r"=>$r / 0xff, "g"=>$g / 0xff, "b"=>$b / 0xff,
725
+                    "hex" => sprintf("#%02X%02X%02X", $r, $g, $b));
726 726
     return $arr;
727 727
       
728
-  }
728
+    }
729 729
 
730 730
   
731
-  /**
732
-   * Alias for {@link Style::munge_colour()}
733
-   *
734
-   * @param string $color
735
-   * @return array
736
-   */
737
-  function munge_color($color) { return CSS_Color::parse($color); }
738
-
739
-  /* direct access to _important_props array from outside would work only when declared as
731
+    /**
732
+     * Alias for {@link Style::munge_colour()}
733
+     *
734
+     * @param string $color
735
+     * @return array
736
+     */
737
+    function munge_color($color) { return CSS_Color::parse($color); }
738
+
739
+    /* direct access to _important_props array from outside would work only when declared as
740 740
    * 'var $_important_props;' instead of 'protected $_important_props;'
741 741
    * Don't call _set/__get on missing attribute. Therefore need a special access.
742 742
    * Assume that __set will be also called when this is called, so do not check validity again.
743 743
    * Only created, if !important exists -> always set true.
744 744
    */
745
-  function important_set($prop) {
746
-      $prop = str_replace("-", "_", $prop);
747
-      $this->_important_props[$prop] = true;
748
-  }
745
+    function important_set($prop) {
746
+        $prop = str_replace("-", "_", $prop);
747
+        $this->_important_props[$prop] = true;
748
+    }
749 749
 
750
-  function important_get($prop) {
751
-      isset($this->_important_props[$prop]);
752
-  }
750
+    function important_get($prop) {
751
+        isset($this->_important_props[$prop]);
752
+    }
753 753
 
754
-  /**
755
-   * PHP5 overloaded setter
756
-   *
757
-   * This function along with {@link Style::__get()} permit a user of the
758
-   * Style class to access any (CSS) property using the following syntax:
759
-   * <code>
760
-   *  Style->margin_top = "1em";
761
-   *  echo (Style->margin_top);
762
-   * </code>
763
-   *
764
-   * __set() automatically calls the provided set function, if one exists,
765
-   * otherwise it sets the property directly.  Typically, __set() is not
766
-   * called directly from outside of this class.
767
-   *
768
-   * On each modification clear cache to return accurate setting.
769
-   * Also affects direct settings not using __set
770
-   * For easier finding all assignments, attempted to allowing only explicite assignment:
771
-   * Very many uses, e.g. frame_reflower.cls.php -> for now leave as it is
772
-   * function __set($prop, $val) {
773
-   *   throw new DOMPDF_Exception("Implicite replacement of assignment by __set.  Not good.");
774
-   * }
775
-   * function props_set($prop, $val) { ... }
776
-   *
777
-   * @param string $prop  the property to set
778
-   * @param mixed  $val   the value of the property
779
-   *
780
-   */
781
-  function __set($prop, $val) {
754
+    /**
755
+     * PHP5 overloaded setter
756
+     *
757
+     * This function along with {@link Style::__get()} permit a user of the
758
+     * Style class to access any (CSS) property using the following syntax:
759
+     * <code>
760
+     *  Style->margin_top = "1em";
761
+     *  echo (Style->margin_top);
762
+     * </code>
763
+     *
764
+     * __set() automatically calls the provided set function, if one exists,
765
+     * otherwise it sets the property directly.  Typically, __set() is not
766
+     * called directly from outside of this class.
767
+     *
768
+     * On each modification clear cache to return accurate setting.
769
+     * Also affects direct settings not using __set
770
+     * For easier finding all assignments, attempted to allowing only explicite assignment:
771
+     * Very many uses, e.g. frame_reflower.cls.php -> for now leave as it is
772
+     * function __set($prop, $val) {
773
+     *   throw new DOMPDF_Exception("Implicite replacement of assignment by __set.  Not good.");
774
+     * }
775
+     * function props_set($prop, $val) { ... }
776
+     *
777
+     * @param string $prop  the property to set
778
+     * @param mixed  $val   the value of the property
779
+     *
780
+     */
781
+    function __set($prop, $val) {
782 782
     global $_dompdf_warnings;
783 783
 
784 784
     $prop = str_replace("-", "_", $prop);
785 785
     $this->_prop_cache[$prop] = null;
786 786
     
787 787
     if ( !isset(self::$_defaults[$prop]) ) {
788
-      $_dompdf_warnings[] = "'$prop' is not a valid CSS2 property.";
789
-      return;
788
+        $_dompdf_warnings[] = "'$prop' is not a valid CSS2 property.";
789
+        return;
790 790
     }
791 791
     
792 792
     if ( $prop !== "content" && is_string($val) && mb_strpos($val, "url") === false ) {
793
-      $val = mb_strtolower(trim(str_replace(array("\n", "\t"), array(" "), $val)));
794
-      $val = preg_replace("/([0-9]+) (pt|px|pc|em|ex|in|cm|mm|%)/S", "\\1\\2", $val);
793
+        $val = mb_strtolower(trim(str_replace(array("\n", "\t"), array(" "), $val)));
794
+        $val = preg_replace("/([0-9]+) (pt|px|pc|em|ex|in|cm|mm|%)/S", "\\1\\2", $val);
795 795
     }
796 796
     
797 797
     $method = "set_$prop";
798 798
 
799 799
     if ( method_exists($this, $method) )
800
-      $this->$method($val);
800
+        $this->$method($val);
801 801
     else
802
-      $this->_props[$prop] = $val;
802
+        $this->_props[$prop] = $val;
803 803
     
804
-  }
804
+    }
805 805
 
806
-  /**
807
-   * PHP5 overloaded getter
808
-   *
809
-   * Along with {@link Style::__set()} __get() provides access to all CSS
810
-   * properties directly.  Typically __get() is not called directly outside
811
-   * of this class.
812
-   *
813
-   * On each modification clear cache to return accurate setting.
814
-   * Also affects direct settings not using __set
815
-   *
816
-   * @param string $prop
817
-   * @return mixed
818
-   */
819
-  function __get($prop) {
806
+    /**
807
+     * PHP5 overloaded getter
808
+     *
809
+     * Along with {@link Style::__set()} __get() provides access to all CSS
810
+     * properties directly.  Typically __get() is not called directly outside
811
+     * of this class.
812
+     *
813
+     * On each modification clear cache to return accurate setting.
814
+     * Also affects direct settings not using __set
815
+     *
816
+     * @param string $prop
817
+     * @return mixed
818
+     */
819
+    function __get($prop) {
820 820
     
821 821
     if ( !isset(self::$_defaults[$prop]) )
822
-      throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property.");
822
+        throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property.");
823 823
 
824 824
     if ( isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null)
825
-      return $this->_prop_cache[$prop];
825
+        return $this->_prop_cache[$prop];
826 826
     
827 827
     $method = "get_$prop";
828 828
 
829 829
     // Fall back on defaults if property is not set
830 830
     if ( !isset($this->_props[$prop]) )
831
-      $this->_props[$prop] = self::$_defaults[$prop];
831
+        $this->_props[$prop] = self::$_defaults[$prop];
832 832
 
833 833
     if ( method_exists($this, $method) )
834
-      return $this->_prop_cache[$prop] = $this->$method();
834
+        return $this->_prop_cache[$prop] = $this->$method();
835 835
 
836 836
 
837 837
     return $this->_prop_cache[$prop] = $this->_props[$prop];
838
-  }
838
+    }
839 839
 
840 840
 
841
-  /**
842
-   * Getter for the 'font-family' CSS property.
843
-   *
844
-   * Uses the {@link Font_Metrics} class to resolve the font family into an
845
-   * actual font file.
846
-   *
847
-   * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-family
848
-   * @return string
849
-   */
850
-  function get_font_family() {
841
+    /**
842
+     * Getter for the 'font-family' CSS property.
843
+     *
844
+     * Uses the {@link Font_Metrics} class to resolve the font family into an
845
+     * actual font file.
846
+     *
847
+     * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-family
848
+     * @return string
849
+     */
850
+    function get_font_family() {
851 851
   
852 852
     $DEBUGCSS=DEBUGCSS; //=DEBUGCSS; Allow override of global setting for ad hoc debug
853 853
 	
@@ -859,16 +859,16 @@  discard block
 block discarded – undo
859 859
     
860 860
     if ( is_numeric($weight) ) {
861 861
 
862
-      if ( $weight < 600 )
862
+        if ( $weight < 600 )
863 863
         $weight = "normal";
864
-      else
864
+        else
865 865
         $weight = "bold";
866 866
 
867 867
     } else if ( $weight === "bold" || $weight === "bolder" ) {
868
-      $weight = "bold";
868
+        $weight = "bold";
869 869
 
870 870
     } else {
871
-      $weight = "normal";
871
+        $weight = "normal";
872 872
 
873 873
     }
874 874
 
@@ -876,18 +876,18 @@  discard block
 block discarded – undo
876 876
     $font_style = $this->__get("font_style");
877 877
 
878 878
     if ( $weight === "bold" && ($font_style === "italic" || $font_style === "oblique") )
879
-      $subtype = "bold_italic";
879
+        $subtype = "bold_italic";
880 880
     else if ( $weight === "bold" && $font_style !== "italic" && $font_style !== "oblique" )
881
-      $subtype = "bold";
881
+        $subtype = "bold";
882 882
     else if ( $weight !== "bold" && ($font_style === "italic" || $font_style === "oblique") )
883
-      $subtype = "italic";
883
+        $subtype = "italic";
884 884
     else
885
-      $subtype = "normal";
885
+        $subtype = "normal";
886 886
     
887 887
     // Resolve the font family
888 888
     if ($DEBUGCSS) {
889
-      print "<pre>[get_font_family:";
890
-      print '('.$this->_props["font_family"].'.'.$font_style.'.'.$this->__get("font_weight").'.'.$weight.'.'.$subtype.')';
889
+        print "<pre>[get_font_family:";
890
+        print '('.$this->_props["font_family"].'.'.$font_style.'.'.$this->__get("font_weight").'.'.$weight.'.'.$subtype.')';
891 891
     }
892 892
     $families = explode(",", $this->_props["font_family"]);
893 893
     $families = array_map('trim',$families);
@@ -895,17 +895,17 @@  discard block
 block discarded – undo
895 895
 
896 896
     $font = null;
897 897
     while ( current($families) ) {
898
-      list(,$family) = each($families);
899
-      //remove leading and trailing string delimiters, e.g. on font names with spaces;
900
-      //remove leading and trailing whitespace
901
-      $family=trim($family," \t\n\r\x0B\"'");
902
-      if ($DEBUGCSS) print '('.$family.')';
903
-      $font = Font_Metrics::get_font($family, $subtype);
904
-
905
-      if ( $font ) {
898
+        list(,$family) = each($families);
899
+        //remove leading and trailing string delimiters, e.g. on font names with spaces;
900
+        //remove leading and trailing whitespace
901
+        $family=trim($family," \t\n\r\x0B\"'");
902
+        if ($DEBUGCSS) print '('.$family.')';
903
+        $font = Font_Metrics::get_font($family, $subtype);
904
+
905
+        if ( $font ) {
906 906
         if ($DEBUGCSS)  print '('.$font.")get_font_family]\n</pre>";
907 907
         return $font;
908
-      }
908
+        }
909 909
     }
910 910
 
911 911
     $family = null;
@@ -913,63 +913,63 @@  discard block
 block discarded – undo
913 913
     $font = Font_Metrics::get_font($family, $subtype);
914 914
 
915 915
     if ( $font ) {
916
-      if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>";
917
-      return $font;
916
+        if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>";
917
+        return $font;
918 918
     }
919 919
     throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '" . $this->_props["font_family"] ."'");
920 920
     
921
-  }
921
+    }
922 922
 
923
-  /**
924
-   * Returns the resolved font size, in points
925
-   *
926
-   * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size
927
-   * @return float
928
-   */
929
-  function get_font_size() {
923
+    /**
924
+     * Returns the resolved font size, in points
925
+     *
926
+     * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size
927
+     * @return float
928
+     */
929
+    function get_font_size() {
930 930
 
931 931
     if ( $this->__font_size_calculated )
932
-      return $this->_props["font_size"];
932
+        return $this->_props["font_size"];
933 933
     
934 934
     if ( !isset($this->_props["font_size"]) )
935
-      $fs = self::$_defaults["font_size"];
935
+        $fs = self::$_defaults["font_size"];
936 936
     else
937
-      $fs = $this->_props["font_size"];
937
+        $fs = $this->_props["font_size"];
938 938
     
939 939
     if ( !isset($this->_parent_font_size) )
940
-      $this->_parent_font_size = self::$default_font_size;
940
+        $this->_parent_font_size = self::$default_font_size;
941 941
     
942 942
     switch ($fs) {
943 943
       
944 944
     case "xx-small":
945 945
       $fs = 3/5 * $this->_parent_font_size;
946
-      break;
946
+        break;
947 947
 
948 948
     case "x-small":
949 949
       $fs = 3/4 * $this->_parent_font_size;
950
-      break;
950
+        break;
951 951
 
952 952
     case "smaller":
953 953
     case "small":
954 954
       $fs = 8/9 * $this->_parent_font_size;
955
-      break;
955
+        break;
956 956
 
957 957
     case "medium":
958 958
       $fs = $this->_parent_font_size;
959
-      break;
959
+        break;
960 960
 
961 961
     case "larger":
962 962
     case "large":
963 963
       $fs = 6/5 * $this->_parent_font_size;
964
-      break;
964
+        break;
965 965
 
966 966
     case "x-large":
967 967
       $fs = 3/2 * $this->_parent_font_size;
968
-      break;
968
+        break;
969 969
 
970 970
     case "xx-large":
971 971
       $fs = 2/1 * $this->_parent_font_size;
972
-      break;
972
+        break;
973 973
 
974 974
     default:
975 975
       break;
@@ -977,82 +977,82 @@  discard block
 block discarded – undo
977 977
 
978 978
     // Ensure relative sizes resolve to something
979 979
     if ( ($i = mb_strpos($fs, "em")) !== false )
980
-      $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size;
980
+        $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size;
981 981
 
982 982
     else if ( ($i = mb_strpos($fs, "ex")) !== false )
983
-      $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size;
983
+        $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size;
984 984
 
985 985
     else
986
-      $fs = $this->length_in_pt($fs);
986
+        $fs = $this->length_in_pt($fs);
987 987
 
988 988
     //see __set and __get, on all assignments clear cache!
989
-	$this->_prop_cache["font_size"] = null;
989
+    $this->_prop_cache["font_size"] = null;
990 990
     $this->_props["font_size"] = $fs;
991 991
     $this->__font_size_calculated = true;
992 992
     return $this->_props["font_size"];
993 993
 
994
-  }
994
+    }
995 995
 
996
-  /**
997
-   * @link http://www.w3.org/TR/CSS21/text.html#propdef-word-spacing
998
-   * @return float
999
-   */
1000
-  function get_word_spacing() {
996
+    /**
997
+     * @link http://www.w3.org/TR/CSS21/text.html#propdef-word-spacing
998
+     * @return float
999
+     */
1000
+    function get_word_spacing() {
1001 1001
     if ( $this->_props["word_spacing"] === "normal" )
1002
-      return 0;
1002
+        return 0;
1003 1003
 
1004 1004
     return $this->_props["word_spacing"];
1005
-  }
1005
+    }
1006 1006
 
1007
-  /**
1008
-   * @link http://www.w3.org/TR/CSS21/visudet.html#propdef-line-height
1009
-   * @return float
1010
-   */
1011
-  function get_line_height() {
1007
+    /**
1008
+     * @link http://www.w3.org/TR/CSS21/visudet.html#propdef-line-height
1009
+     * @return float
1010
+     */
1011
+    function get_line_height() {
1012 1012
     if ( $this->_props["line_height"] === "normal" )
1013
-      return self::$default_line_height * $this->get_font_size();
1013
+        return self::$default_line_height * $this->get_font_size();
1014 1014
 
1015 1015
     if ( is_numeric($this->_props["line_height"]) )
1016
-      return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size());
1016
+        return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size());
1017 1017
     
1018 1018
     return $this->length_in_pt( $this->_props["line_height"], $this->get_font_size() );
1019
-  }
1019
+    }
1020 1020
 
1021
-  /**
1022
-   * Returns the colour as an array
1023
-   *
1024
-   * The array has the following format:
1025
-   * <code>array(r,g,b, "r" => r, "g" => g, "b" => b, "hex" => "#rrggbb")</code>
1026
-   *
1027
-   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-color
1028
-   * @return array
1029
-   */
1030
-  function get_color() {
1021
+    /**
1022
+     * Returns the colour as an array
1023
+     *
1024
+     * The array has the following format:
1025
+     * <code>array(r,g,b, "r" => r, "g" => g, "b" => b, "hex" => "#rrggbb")</code>
1026
+     *
1027
+     * @link http://www.w3.org/TR/CSS21/colors.html#propdef-color
1028
+     * @return array
1029
+     */
1030
+    function get_color() {
1031 1031
     return $this->munge_color( $this->_props["color"] );
1032
-  }
1032
+    }
1033 1033
 
1034
-  /**
1035
-   * Returns the background colour as an array
1036
-   *
1037
-   * The returned array has the same format as {@link Style::get_color()}
1038
-   *
1039
-   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-color
1040
-   * @return array
1041
-   */
1042
-  function get_background_color() {
1034
+    /**
1035
+     * Returns the background colour as an array
1036
+     *
1037
+     * The returned array has the same format as {@link Style::get_color()}
1038
+     *
1039
+     * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-color
1040
+     * @return array
1041
+     */
1042
+    function get_background_color() {
1043 1043
     return $this->munge_color( $this->_props["background_color"] );
1044
-  }
1044
+    }
1045 1045
   
1046
-  /**
1047
-   * Returns the background position as an array
1048
-   *
1049
-   * The returned array has the following format:
1050
-   * <code>array(x,y, "x" => x, "y" => y)</code>
1051
-   *
1052
-   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position
1053
-   * @return array
1054
-   */
1055
-  function get_background_position() {
1046
+    /**
1047
+     * Returns the background position as an array
1048
+     *
1049
+     * The returned array has the following format:
1050
+     * <code>array(x,y, "x" => x, "y" => y)</code>
1051
+     *
1052
+     * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position
1053
+     * @return array
1054
+     */
1055
+    function get_background_position() {
1056 1056
     
1057 1057
     $tmp = explode(" ", $this->_props["background_position"]);
1058 1058
 
@@ -1060,119 +1060,119 @@  discard block
 block discarded – undo
1060 1060
 
1061 1061
     case "left":
1062 1062
       $x = "0%";
1063
-      break;
1063
+        break;
1064 1064
 
1065 1065
     case "right":
1066 1066
       $x = "100%";
1067
-      break;
1067
+        break;
1068 1068
 
1069 1069
     case "top":
1070 1070
       $y = "0%";
1071
-      break;
1071
+        break;
1072 1072
 
1073 1073
     case "bottom":
1074 1074
       $y = "100%";
1075
-      break;
1075
+        break;
1076 1076
 
1077 1077
     case "center":
1078 1078
       $x = "50%";
1079
-      $y = "50%";
1080
-      break;
1079
+        $y = "50%";
1080
+        break;
1081 1081
 
1082 1082
     default:
1083 1083
       $x = $tmp[0];
1084
-      break;
1084
+        break;
1085 1085
     }
1086 1086
 
1087 1087
     if ( isset($tmp[1]) ) {
1088 1088
 
1089
-      switch ($tmp[1]) {
1090
-      case "left":
1089
+        switch ($tmp[1]) {
1090
+        case "left":
1091 1091
         $x = "0%";
1092 1092
         break;
1093 1093
         
1094
-      case "right":
1094
+        case "right":
1095 1095
         $x = "100%";
1096 1096
         break;
1097 1097
         
1098
-      case "top":
1098
+        case "top":
1099 1099
         $y = "0%";
1100 1100
         break;
1101 1101
         
1102
-      case "bottom":
1102
+        case "bottom":
1103 1103
         $y = "100%";
1104 1104
         break;
1105 1105
         
1106
-      case "center":
1106
+        case "center":
1107 1107
         if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" )
1108
-          $y = "50%";
1108
+            $y = "50%";
1109 1109
         else
1110
-          $x = "50%";
1110
+            $x = "50%";
1111 1111
         break;
1112 1112
         
1113
-      default:
1113
+        default:
1114 1114
         $y = $tmp[1];
1115 1115
         break;
1116
-      }
1116
+        }
1117 1117
 
1118 1118
     } else {
1119
-      $y = "50%";
1119
+        $y = "50%";
1120 1120
     }
1121 1121
 
1122 1122
     if ( !isset($x) )
1123
-      $x = "0%";
1123
+        $x = "0%";
1124 1124
 
1125 1125
     if ( !isset($y) )
1126
-      $y = "0%";
1126
+        $y = "0%";
1127 1127
 
1128 1128
     return array( 0 => $x, "x" => $x,
1129
-                  1 => $y, "y" => $y );
1130
-  }
1129
+                    1 => $y, "y" => $y );
1130
+    }
1131 1131
 
1132 1132
 
1133
-  /**
1134
-   * Returns the background as it is currently stored
1135
-   *
1136
-   * (currently anyway only for completeness.
1137
-   * not used for further processing)
1138
-   *
1139
-   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment
1140
-   * @return string
1141
-   */
1142
-  function get_background_attachment() {
1133
+    /**
1134
+     * Returns the background as it is currently stored
1135
+     *
1136
+     * (currently anyway only for completeness.
1137
+     * not used for further processing)
1138
+     *
1139
+     * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment
1140
+     * @return string
1141
+     */
1142
+    function get_background_attachment() {
1143 1143
     return $this->_props["background_attachment"];
1144
-  }
1144
+    }
1145 1145
 
1146 1146
 
1147
-  /**
1148
-   * Returns the background_repeat as it is currently stored
1149
-   *
1150
-   * (currently anyway only for completeness.
1151
-   * not used for further processing)
1152
-   *
1153
-   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat
1154
-   * @return string
1155
-   */
1156
-  function get_background_repeat() {
1147
+    /**
1148
+     * Returns the background_repeat as it is currently stored
1149
+     *
1150
+     * (currently anyway only for completeness.
1151
+     * not used for further processing)
1152
+     *
1153
+     * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat
1154
+     * @return string
1155
+     */
1156
+    function get_background_repeat() {
1157 1157
     return $this->_props["background_repeat"];
1158
-  }
1158
+    }
1159 1159
 
1160 1160
 
1161
-  /**
1162
-   * Returns the background as it is currently stored
1163
-   *
1164
-   * (currently anyway only for completeness.
1165
-   * not used for further processing, but the individual get_background_xxx)
1166
-   *
1167
-   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background
1168
-   * @return string
1169
-   */
1170
-  function get_background() {
1161
+    /**
1162
+     * Returns the background as it is currently stored
1163
+     *
1164
+     * (currently anyway only for completeness.
1165
+     * not used for further processing, but the individual get_background_xxx)
1166
+     *
1167
+     * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background
1168
+     * @return string
1169
+     */
1170
+    function get_background() {
1171 1171
     return $this->_props["background"];
1172
-  }
1172
+    }
1173 1173
 
1174 1174
 
1175
-  /**#@+
1175
+    /**#@+
1176 1176
    * Returns the border colour as an array
1177 1177
    *
1178 1178
    * See {@link Style::get_color()}
@@ -1180,112 +1180,112 @@  discard block
 block discarded – undo
1180 1180
    * @link http://www.w3.org/TR/CSS21/box.html#border-color-properties
1181 1181
    * @return array
1182 1182
    */
1183
-  function get_border_top_color() {
1183
+    function get_border_top_color() {
1184 1184
     if ( $this->_props["border_top_color"] === "" ) {
1185
-      //see __set and __get, on all assignments clear cache!
1186
-      $this->_prop_cache["border_top_color"] = null;
1187
-      $this->_props["border_top_color"] = $this->__get("color");
1185
+        //see __set and __get, on all assignments clear cache!
1186
+        $this->_prop_cache["border_top_color"] = null;
1187
+        $this->_props["border_top_color"] = $this->__get("color");
1188 1188
     }
1189 1189
     return $this->munge_color($this->_props["border_top_color"]);
1190
-  }
1190
+    }
1191 1191
 
1192
-  function get_border_right_color() {
1192
+    function get_border_right_color() {
1193 1193
     if ( $this->_props["border_right_color"] === "" ) {
1194
-      //see __set and __get, on all assignments clear cache!
1195
-      $this->_prop_cache["border_right_color"] = null;
1196
-      $this->_props["border_right_color"] = $this->__get("color");
1194
+        //see __set and __get, on all assignments clear cache!
1195
+        $this->_prop_cache["border_right_color"] = null;
1196
+        $this->_props["border_right_color"] = $this->__get("color");
1197 1197
     }
1198 1198
     return $this->munge_color($this->_props["border_right_color"]);
1199
-  }
1199
+    }
1200 1200
 
1201
-  function get_border_bottom_color() {
1201
+    function get_border_bottom_color() {
1202 1202
     if ( $this->_props["border_bottom_color"] === "" ) {
1203
-      //see __set and __get, on all assignments clear cache!
1204
-      $this->_prop_cache["border_bottom_color"] = null;
1205
-      $this->_props["border_bottom_color"] = $this->__get("color");
1203
+        //see __set and __get, on all assignments clear cache!
1204
+        $this->_prop_cache["border_bottom_color"] = null;
1205
+        $this->_props["border_bottom_color"] = $this->__get("color");
1206 1206
     }
1207 1207
     return $this->munge_color($this->_props["border_bottom_color"]);;
1208
-  }
1208
+    }
1209 1209
 
1210
-  function get_border_left_color() {
1210
+    function get_border_left_color() {
1211 1211
     if ( $this->_props["border_left_color"] === "" ) {
1212
-      //see __set and __get, on all assignments clear cache!
1213
-      $this->_prop_cache["border_left_color"] = null;
1214
-      $this->_props["border_left_color"] = $this->__get("color");
1212
+        //see __set and __get, on all assignments clear cache!
1213
+        $this->_prop_cache["border_left_color"] = null;
1214
+        $this->_props["border_left_color"] = $this->__get("color");
1215 1215
     }
1216 1216
     return $this->munge_color($this->_props["border_left_color"]);
1217
-  }
1217
+    }
1218 1218
   
1219
-  /**#@-*/
1219
+    /**#@-*/
1220 1220
 
1221
- /**#@+
1221
+    /**#@+
1222 1222
    * Returns the border width, as it is currently stored
1223 1223
    *
1224 1224
    * @link http://www.w3.org/TR/CSS21/box.html#border-width-properties
1225 1225
    * @return float|string
1226 1226
    */
1227
-  function get_border_top_width() {
1227
+    function get_border_top_width() {
1228 1228
     $style = $this->__get("border_top_style");
1229 1229
     return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_top_width"]) : 0;
1230
-  }
1230
+    }
1231 1231
   
1232
-  function get_border_right_width() {
1232
+    function get_border_right_width() {
1233 1233
     $style = $this->__get("border_right_style");
1234 1234
     return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_right_width"]) : 0;
1235
-  }
1235
+    }
1236 1236
 
1237
-  function get_border_bottom_width() {
1237
+    function get_border_bottom_width() {
1238 1238
     $style = $this->__get("border_bottom_style");
1239 1239
     return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_bottom_width"]) : 0;
1240
-  }
1240
+    }
1241 1241
 
1242
-  function get_border_left_width() {
1242
+    function get_border_left_width() {
1243 1243
     $style = $this->__get("border_left_style");
1244 1244
     return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_left_width"]) : 0;
1245
-  }
1246
-  /**#@-*/
1247
-
1248
-  /**
1249
-   * Return an array of all border properties.
1250
-   *
1251
-   * The returned array has the following structure:
1252
-   * <code>
1253
-   * array("top" => array("width" => [border-width],
1254
-   *                      "style" => [border-style],
1255
-   *                      "color" => [border-color (array)]),
1256
-   *       "bottom" ... )
1257
-   * </code>
1258
-   *
1259
-   * @return array
1260
-   */
1261
-  function get_border_properties() {
1245
+    }
1246
+    /**#@-*/
1247
+
1248
+    /**
1249
+     * Return an array of all border properties.
1250
+     *
1251
+     * The returned array has the following structure:
1252
+     * <code>
1253
+     * array("top" => array("width" => [border-width],
1254
+     *                      "style" => [border-style],
1255
+     *                      "color" => [border-color (array)]),
1256
+     *       "bottom" ... )
1257
+     * </code>
1258
+     *
1259
+     * @return array
1260
+     */
1261
+    function get_border_properties() {
1262 1262
     return array("top" => array("width" => $this->__get("border_top_width"),
1263 1263
                                 "style" => $this->__get("border_top_style"),
1264 1264
                                 "color" => $this->__get("border_top_color")),
1265
-                 "bottom" => array("width" => $this->__get("border_bottom_width"),
1266
-                                   "style" => $this->__get("border_bottom_style"),
1267
-                                   "color" => $this->__get("border_bottom_color")),
1268
-                 "right" => array("width" => $this->__get("border_right_width"),
1269
-                                  "style" => $this->__get("border_right_style"),
1270
-                                  "color" => $this->__get("border_right_color")),
1271
-                 "left" => array("width" => $this->__get("border_left_width"),
1272
-                                 "style" => $this->__get("border_left_style"),
1273
-                                 "color" => $this->__get("border_left_color")));
1274
-  }
1275
-
1276
-  /**
1277
-   * Return a single border property
1278
-   *
1279
-   * @return mixed
1280
-   */
1281
-  protected function _get_border($side) {
1265
+                    "bottom" => array("width" => $this->__get("border_bottom_width"),
1266
+                                    "style" => $this->__get("border_bottom_style"),
1267
+                                    "color" => $this->__get("border_bottom_color")),
1268
+                    "right" => array("width" => $this->__get("border_right_width"),
1269
+                                    "style" => $this->__get("border_right_style"),
1270
+                                    "color" => $this->__get("border_right_color")),
1271
+                    "left" => array("width" => $this->__get("border_left_width"),
1272
+                                    "style" => $this->__get("border_left_style"),
1273
+                                    "color" => $this->__get("border_left_color")));
1274
+    }
1275
+
1276
+    /**
1277
+     * Return a single border property
1278
+     *
1279
+     * @return mixed
1280
+     */
1281
+    protected function _get_border($side) {
1282 1282
     $color = $this->__get("border_" . $side . "_color");
1283 1283
     
1284 1284
     return $this->__get("border_" . $side . "_width") . " " .
1285
-      $this->__get("border_" . $side . "_style") . " " . $color["hex"];
1286
-  }
1285
+        $this->__get("border_" . $side . "_style") . " " . $color["hex"];
1286
+    }
1287 1287
 
1288
-  /**#@+
1288
+    /**#@+
1289 1289
    * Return full border properties as a string
1290 1290
    *
1291 1291
    * Border properties are returned just as specified in CSS:
@@ -1295,28 +1295,28 @@  discard block
 block discarded – undo
1295 1295
    * @link http://www.w3.org/TR/CSS21/box.html#border-shorthand-properties
1296 1296
    * @return string
1297 1297
    */
1298
-  function get_border_top() { return $this->_get_border("top"); }
1299
-  function get_border_right() { return $this->_get_border("right"); }
1300
-  function get_border_bottom() { return $this->_get_border("bottom"); }
1301
-  function get_border_left() { return $this->_get_border("left"); }
1302
-  /**#@-*/
1303
-
1304
-
1305
-  /**
1306
-   * Returns border spacing as an array
1307
-   *
1308
-   * The array has the format (h_space,v_space)
1309
-   *
1310
-   * @link http://www.w3.org/TR/CSS21/tables.html#propdef-border-spacing
1311
-   * @return array
1312
-   */
1313
-  function get_border_spacing() {
1298
+    function get_border_top() { return $this->_get_border("top"); }
1299
+    function get_border_right() { return $this->_get_border("right"); }
1300
+    function get_border_bottom() { return $this->_get_border("bottom"); }
1301
+    function get_border_left() { return $this->_get_border("left"); }
1302
+    /**#@-*/
1303
+
1304
+
1305
+    /**
1306
+     * Returns border spacing as an array
1307
+     *
1308
+     * The array has the format (h_space,v_space)
1309
+     *
1310
+     * @link http://www.w3.org/TR/CSS21/tables.html#propdef-border-spacing
1311
+     * @return array
1312
+     */
1313
+    function get_border_spacing() {
1314 1314
     return explode(" ", $this->_props["border_spacing"]);
1315
-  }
1315
+    }
1316 1316
 
1317 1317
 /*==============================*/
1318 1318
 
1319
-  /*
1319
+    /*
1320 1320
    !important attribute
1321 1321
    For basic functionality of the !important attribute with overloading
1322 1322
    of several styles of an element, changes in inherit(), merge() and _parse_properties()
@@ -1358,419 +1358,419 @@  discard block
 block discarded – undo
1358 1358
    Related functionality for background, padding, margin, font, list_style
1359 1359
   */
1360 1360
 
1361
-  /* Generalized set function for individual attribute of combined style.
1361
+    /* Generalized set function for individual attribute of combined style.
1362 1362
    * With check for !important
1363 1363
    * Applicable for background, border, padding, margin, font, list_style
1364 1364
    * Note: $type has a leading underscore (or is empty), the others not.
1365 1365
    */
1366
-  protected function _set_style_side_type($style,$side,$type,$val,$important) {
1366
+    protected function _set_style_side_type($style,$side,$type,$val,$important) {
1367 1367
     if ( !isset($this->_important_props[$style.'_'.$side.$type]) || $important) {
1368
-      //see __set and __get, on all assignments clear cache!
1369
-      $this->_prop_cache[$style.'_'.$side.$type] = null;
1370
-      if ($important) {
1368
+        //see __set and __get, on all assignments clear cache!
1369
+        $this->_prop_cache[$style.'_'.$side.$type] = null;
1370
+        if ($important) {
1371 1371
         $this->_important_props[$style.'_'.$side.$type] = true;
1372
-      }
1373
-      $this->_props[$style.'_'.$side.$type] = $val;
1372
+        }
1373
+        $this->_props[$style.'_'.$side.$type] = $val;
1374
+    }
1374 1375
     }
1375
-  }
1376 1376
 
1377
-  protected function _set_style_sides_type($style,$top,$right,$bottom,$left,$type,$important) {
1378
-      $this->_set_style_side_type($style,'top',$type,$top,$important);
1379
-      $this->_set_style_side_type($style,'right',$type,$right,$important);
1380
-      $this->_set_style_side_type($style,'bottom',$type,$bottom,$important);
1381
-      $this->_set_style_side_type($style,'left',$type,$left,$important);
1382
-  }
1377
+    protected function _set_style_sides_type($style,$top,$right,$bottom,$left,$type,$important) {
1378
+        $this->_set_style_side_type($style,'top',$type,$top,$important);
1379
+        $this->_set_style_side_type($style,'right',$type,$right,$important);
1380
+        $this->_set_style_side_type($style,'bottom',$type,$bottom,$important);
1381
+        $this->_set_style_side_type($style,'left',$type,$left,$important);
1382
+    }
1383 1383
 
1384
-  protected function _set_style_type($style,$type,$val,$important) {
1384
+    protected function _set_style_type($style,$type,$val,$important) {
1385 1385
     $arr = explode(" ", $val);
1386 1386
     switch (count($arr)) {
1387 1387
     case 1:
1388 1388
       $this->_set_style_sides_type($style,$arr[0],$arr[0],$arr[0],$arr[0],$type,$important);
1389
-      break;
1389
+        break;
1390 1390
     case 2:
1391 1391
       $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[0],$arr[1],$type,$important);
1392
-      break;
1392
+        break;
1393 1393
     case 3:
1394 1394
       $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[1],$arr[2],$type,$important);
1395
-      break;
1395
+        break;
1396 1396
     case 4:
1397 1397
       $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[2],$arr[3],$type,$important);
1398
-      break;
1398
+        break;
1399 1399
     default:
1400 1400
       break;
1401 1401
     }
1402 1402
     //see __set and __get, on all assignments clear cache!
1403
-	$this->_prop_cache[$style.$type] = null;
1403
+    $this->_prop_cache[$style.$type] = null;
1404 1404
     $this->_props[$style.$type] = $val;
1405
-  }
1405
+    }
1406 1406
 
1407
-  protected function _set_style_type_important($style,$type,$val) {
1407
+    protected function _set_style_type_important($style,$type,$val) {
1408 1408
     $this->_set_style_type($style,$type,$val,isset($this->_important_props[$style.$type]));
1409
-  }
1409
+    }
1410 1410
 
1411
-  /* Anyway only called if _important matches and is assigned
1411
+    /* Anyway only called if _important matches and is assigned
1412 1412
    * E.g. _set_style_side_type($style,$side,'',str_replace("none", "0px", $val),isset($this->_important_props[$style.'_'.$side]));
1413 1413
    */
1414
-  protected function _set_style_side_width_important($style,$side,$val) {
1414
+    protected function _set_style_side_width_important($style,$side,$val) {
1415 1415
     //see __set and __get, on all assignments clear cache!
1416 1416
     $this->_prop_cache[$style.'_'.$side] = null;
1417 1417
     $this->_props[$style.'_'.$side] = str_replace("none", "0px", $val);
1418
-  }
1418
+    }
1419 1419
 
1420
-  protected function _set_style($style,$val,$important) {
1420
+    protected function _set_style($style,$val,$important) {
1421 1421
     if ( !isset($this->_important_props[$style]) || $important) {
1422
-      if ($important) {
1422
+        if ($important) {
1423 1423
         $this->_important_props[$style] = true;
1424
-      }
1425
-      //see __set and __get, on all assignments clear cache!
1426
-	  $this->_prop_cache[$style] = null;
1427
-      $this->_props[$style] = $val;
1424
+        }
1425
+        //see __set and __get, on all assignments clear cache!
1426
+        $this->_prop_cache[$style] = null;
1427
+        $this->_props[$style] = $val;
1428
+    }
1428 1429
     }
1429
-  }
1430 1430
 
1431
-  protected function _image($val) {
1431
+    protected function _image($val) {
1432 1432
     $DEBUGCSS=DEBUGCSS;
1433 1433
     
1434 1434
     if ( mb_strpos($val, "url") === false ) {
1435
-      $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none
1435
+        $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none
1436 1436
     } else {
1437
-      $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val));
1437
+        $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val));
1438 1438
 
1439
-      // Resolve the url now in the context of the current stylesheet
1440
-      $parsed_url = explode_url($val);
1441
-      if ( $parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "" ) {
1439
+        // Resolve the url now in the context of the current stylesheet
1440
+        $parsed_url = explode_url($val);
1441
+        if ( $parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "" ) {
1442 1442
         if ($parsed_url["path"]{0} === '/' || $parsed_url["path"]{0} === '\\' ) {
1443
-          $path = $_SERVER["DOCUMENT_ROOT"].'/';
1443
+            $path = $_SERVER["DOCUMENT_ROOT"].'/';
1444 1444
         } else {
1445
-          $path = $this->_stylesheet->get_base_path();
1445
+            $path = $this->_stylesheet->get_base_path();
1446 1446
         }
1447 1447
         $path .= $parsed_url["path"] . $parsed_url["file"];
1448 1448
         $path = realpath($path);
1449 1449
         // If realpath returns FALSE then specifically state that there is no background image
1450 1450
         if (!$path) { $path = 'none'; }
1451
-      } else {
1451
+        } else {
1452 1452
         $path = build_url($this->_stylesheet->get_protocol(),
1453
-                          $this->_stylesheet->get_host(),
1454
-                          $this->_stylesheet->get_base_path(),
1455
-                          $val);
1456
-      }
1453
+                            $this->_stylesheet->get_host(),
1454
+                            $this->_stylesheet->get_base_path(),
1455
+                            $val);
1456
+        }
1457 1457
     }
1458 1458
     if ($DEBUGCSS) {
1459
-      print "<pre>[_image\n";
1460
-      print_r($parsed_url);
1461
-      print $this->_stylesheet->get_protocol()."\n".$this->_stylesheet->get_base_path()."\n".$path."\n";
1462
-      print "_image]</pre>";;
1459
+        print "<pre>[_image\n";
1460
+        print_r($parsed_url);
1461
+        print $this->_stylesheet->get_protocol()."\n".$this->_stylesheet->get_base_path()."\n".$path."\n";
1462
+        print "_image]</pre>";;
1463 1463
     }
1464 1464
     return $path;
1465
-  }
1465
+    }
1466 1466
 
1467 1467
 /*======================*/
1468 1468
 
1469
-  /**
1470
-   * Sets colour
1471
-   *
1472
-   * The colour parameter can be any valid CSS colour value
1473
-   *
1474
-   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-color
1475
-   * @param string $colour
1476
-   */
1477
-  function set_color($colour) {
1469
+    /**
1470
+     * Sets colour
1471
+     *
1472
+     * The colour parameter can be any valid CSS colour value
1473
+     *
1474
+     * @link http://www.w3.org/TR/CSS21/colors.html#propdef-color
1475
+     * @param string $colour
1476
+     */
1477
+    function set_color($colour) {
1478 1478
     $col = $this->munge_colour($colour);
1479 1479
 
1480 1480
     if ( is_null($col) )
1481
-      $col = self::$_defaults["color"];
1481
+        $col = self::$_defaults["color"];
1482 1482
 
1483 1483
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1484
-	$this->_prop_cache["color"] = null;
1484
+    $this->_prop_cache["color"] = null;
1485 1485
     $this->_props["color"] = $col["hex"];
1486
-  }
1486
+    }
1487 1487
 
1488
-  /**
1489
-   * Sets the background colour
1490
-   *
1491
-   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-color
1492
-   * @param string $colour
1493
-   */
1494
-  function set_background_color($colour) {
1488
+    /**
1489
+     * Sets the background colour
1490
+     *
1491
+     * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-color
1492
+     * @param string $colour
1493
+     */
1494
+    function set_background_color($colour) {
1495 1495
     $col = $this->munge_colour($colour);
1496 1496
     if ( is_null($col) )
1497
-      $col = self::$_defaults["background_color"];
1497
+        $col = self::$_defaults["background_color"];
1498 1498
 
1499 1499
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1500
-	$this->_prop_cache["background_color"] = null;
1500
+    $this->_prop_cache["background_color"] = null;
1501 1501
     $this->_props["background_color"] = is_array($col) ? $col["hex"] : $col;
1502
-  }
1502
+    }
1503 1503
 
1504
-  /**
1505
-   * Set the background image url
1506
-   *
1507
-   * @link http://www.w3.org/TR/CSS21/colors.html#background-properties
1508
-   * @param string $url
1509
-   */
1510
-  function set_background_image($val) {
1504
+    /**
1505
+     * Set the background image url
1506
+     *
1507
+     * @link http://www.w3.org/TR/CSS21/colors.html#background-properties
1508
+     * @param string $url
1509
+     */
1510
+    function set_background_image($val) {
1511 1511
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1512
-	$this->_prop_cache["background_image"] = null;
1512
+    $this->_prop_cache["background_image"] = null;
1513 1513
     $this->_props["background_image"] = $this->_image($val);
1514
-  }
1514
+    }
1515 1515
 
1516
-  /**
1517
-   * Sets the background repeat
1518
-   *
1519
-   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat
1520
-   * @param string $val
1521
-   */
1522
-  function set_background_repeat($val) {
1516
+    /**
1517
+     * Sets the background repeat
1518
+     *
1519
+     * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat
1520
+     * @param string $val
1521
+     */
1522
+    function set_background_repeat($val) {
1523 1523
     if ( is_null($val) )
1524
-      $val = self::$_defaults["background_repeat"];
1524
+        $val = self::$_defaults["background_repeat"];
1525 1525
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1526 1526
     $this->_prop_cache["background_repeat"] = null;
1527 1527
     $this->_props["background_repeat"] = $val;
1528
-  }
1528
+    }
1529 1529
 
1530
-  /**
1531
-   * Sets the background attachment
1532
-   *
1533
-   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment
1534
-   * @param string $val
1535
-   */
1536
-  function set_background_attachment($val) {
1530
+    /**
1531
+     * Sets the background attachment
1532
+     *
1533
+     * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment
1534
+     * @param string $val
1535
+     */
1536
+    function set_background_attachment($val) {
1537 1537
     if ( is_null($val) )
1538
-      $val = self::$_defaults["background_attachment"];
1538
+        $val = self::$_defaults["background_attachment"];
1539 1539
 
1540 1540
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1541
-	$this->_prop_cache["background_attachment"] = null;
1541
+    $this->_prop_cache["background_attachment"] = null;
1542 1542
     $this->_props["background_attachment"] = $val;
1543
-  }
1543
+    }
1544 1544
 
1545
-  /**
1546
-   * Sets the background position
1547
-   *
1548
-   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position
1549
-   * @param string $val
1550
-   */
1551
-  function set_background_position($val) {
1545
+    /**
1546
+     * Sets the background position
1547
+     *
1548
+     * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position
1549
+     * @param string $val
1550
+     */
1551
+    function set_background_position($val) {
1552 1552
     if ( is_null($val) )
1553
-      $val = self::$_defaults["background_position"];
1553
+        $val = self::$_defaults["background_position"];
1554 1554
 
1555 1555
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1556
-	$this->_prop_cache["background_position"] = null;
1556
+    $this->_prop_cache["background_position"] = null;
1557 1557
     $this->_props["background_position"] = $val;
1558
-  }
1558
+    }
1559 1559
 
1560
-  /**
1561
-   * Sets the background - combined options
1562
-   *
1563
-   * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background
1564
-   * @param string $val
1565
-   */
1566
-  function set_background($val) {
1560
+    /**
1561
+     * Sets the background - combined options
1562
+     *
1563
+     * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background
1564
+     * @param string $val
1565
+     */
1566
+    function set_background($val) {
1567 1567
     $col = null;
1568 1568
     $pos = array();
1569 1569
     $tmp = explode(" ", $val);
1570 1570
     $important = isset($this->_important_props["background"]);
1571 1571
     foreach($tmp as $attr) {
1572
-	  if (mb_substr($attr, 0, 3) === "url" || $attr === "none") {
1573
-   	    $this->_set_style("background_image", $this->_image($attr), $important);
1574
-  	  } else if ($attr === "fixed" || $attr === "scroll") {
1575
-   	    $this->_set_style("background_attachment", $attr, $important);
1576
-  	  } else if ($attr === "repeat" || $attr === "repeat-x" || $attr === "repeat-y" || $attr === "no-repeat") {
1577
-   	    $this->_set_style("background_repeat", $attr, $important);
1578
-      } else if (($col = $this->munge_color($attr)) != null ) {
1579
-   	    $this->_set_style("background_color", is_array($col) ? $col["hex"] : $col, $important);
1580
-      } else {
1581
- 		$pos[] = $attr;
1582
- 	  }
1583
- 	}
1584
- 	if (count($pos)) {
1585
- 	  $this->_set_style("background_position",implode(' ',$pos), $important);
1586
- 	}
1572
+        if (mb_substr($attr, 0, 3) === "url" || $attr === "none") {
1573
+            $this->_set_style("background_image", $this->_image($attr), $important);
1574
+        } else if ($attr === "fixed" || $attr === "scroll") {
1575
+            $this->_set_style("background_attachment", $attr, $important);
1576
+        } else if ($attr === "repeat" || $attr === "repeat-x" || $attr === "repeat-y" || $attr === "no-repeat") {
1577
+            $this->_set_style("background_repeat", $attr, $important);
1578
+        } else if (($col = $this->munge_color($attr)) != null ) {
1579
+            $this->_set_style("background_color", is_array($col) ? $col["hex"] : $col, $important);
1580
+        } else {
1581
+            $pos[] = $attr;
1582
+        }
1583
+        }
1584
+        if (count($pos)) {
1585
+        $this->_set_style("background_position",implode(' ',$pos), $important);
1586
+        }
1587 1587
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1588
-	$this->_prop_cache["background"] = null;
1589
- 	$this->_props["background"] = $val;
1590
-  }
1588
+    $this->_prop_cache["background"] = null;
1589
+        $this->_props["background"] = $val;
1590
+    }
1591 1591
 
1592
-  /**
1593
-   * Sets the font size
1594
-   *
1595
-   * $size can be any acceptable CSS size
1596
-   *
1597
-   * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size
1598
-   * @param string|float $size
1599
-   */
1600
-  function set_font_size($size) {
1592
+    /**
1593
+     * Sets the font size
1594
+     *
1595
+     * $size can be any acceptable CSS size
1596
+     *
1597
+     * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size
1598
+     * @param string|float $size
1599
+     */
1600
+    function set_font_size($size) {
1601 1601
     $this->__font_size_calculated = false;
1602 1602
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1603
-	$this->_prop_cache["font_size"] = null;
1603
+    $this->_prop_cache["font_size"] = null;
1604 1604
     $this->_props["font_size"] = $size;
1605
-  }
1605
+    }
1606 1606
 
1607
-  /**
1608
-   * Sets the font style
1609
-   *
1610
-   * combined attributes
1611
-   * set individual attributes also, respecting !important mark
1612
-   * exactly this order, separate by space. Multiple fonts separated by comma:
1613
-   * font-style, font-variant, font-weight, font-size, line-height, font-family
1614
-   *
1615
-   * Other than with border and list, existing partial attributes should
1616
-   * reset when starting here, even when not mentioned.
1617
-   * If individual attribute is !important and explicite or implicite replacement is not,
1618
-   * keep individual attribute
1619
-   *
1620
-   * require whitespace as delimiters for single value attributes
1621
-   * On delimiter "/" treat first as font height, second as line height
1622
-   * treat all remaining at the end of line as font
1623
-   * font-style, font-variant, font-weight, font-size, line-height, font-family
1624
-   *
1625
-   * missing font-size and font-family might be not allowed, but accept it here and
1626
-   * use default (medium size, enpty font name)
1627
-   *
1628
-   * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style
1629
-   * @param $val
1630
-   */
1631
-  function set_font($val) {
1607
+    /**
1608
+     * Sets the font style
1609
+     *
1610
+     * combined attributes
1611
+     * set individual attributes also, respecting !important mark
1612
+     * exactly this order, separate by space. Multiple fonts separated by comma:
1613
+     * font-style, font-variant, font-weight, font-size, line-height, font-family
1614
+     *
1615
+     * Other than with border and list, existing partial attributes should
1616
+     * reset when starting here, even when not mentioned.
1617
+     * If individual attribute is !important and explicite or implicite replacement is not,
1618
+     * keep individual attribute
1619
+     *
1620
+     * require whitespace as delimiters for single value attributes
1621
+     * On delimiter "/" treat first as font height, second as line height
1622
+     * treat all remaining at the end of line as font
1623
+     * font-style, font-variant, font-weight, font-size, line-height, font-family
1624
+     *
1625
+     * missing font-size and font-family might be not allowed, but accept it here and
1626
+     * use default (medium size, enpty font name)
1627
+     *
1628
+     * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style
1629
+     * @param $val
1630
+     */
1631
+    function set_font($val) {
1632 1632
     $this->__font_size_calculated = false;
1633 1633
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1634
-	$this->_prop_cache["font"] = null;
1635
- 	$this->_props["font"] = $val;
1634
+    $this->_prop_cache["font"] = null;
1635
+        $this->_props["font"] = $val;
1636 1636
 
1637 1637
     $important = isset($this->_important_props["font"]);
1638 1638
 
1639
-	if ( preg_match("/^(italic|oblique|normal)\s*(.*)$/i",$val,$match) ) {
1640
-		$this->_set_style("font_style", $match[1], $important);
1641
-		$val = $match[2];
1642
-	} else {
1643
-		$this->_set_style("font_style", self::$_defaults["font_style"], $important);
1644
-	}
1639
+    if ( preg_match("/^(italic|oblique|normal)\s*(.*)$/i",$val,$match) ) {
1640
+        $this->_set_style("font_style", $match[1], $important);
1641
+        $val = $match[2];
1642
+    } else {
1643
+        $this->_set_style("font_style", self::$_defaults["font_style"], $important);
1644
+    }
1645 1645
 
1646
-	if ( preg_match("/^(small-caps|normal)\s*(.*)$/i",$val,$match) ) {
1647
-		$this->_set_style("font_variant", $match[1], $important);
1648
-		$val = $match[2];
1649
-	} else {
1650
-		$this->_set_style("font_variant", self::$_defaults["font_variant"], $important);
1651
-	}
1646
+    if ( preg_match("/^(small-caps|normal)\s*(.*)$/i",$val,$match) ) {
1647
+        $this->_set_style("font_variant", $match[1], $important);
1648
+        $val = $match[2];
1649
+    } else {
1650
+        $this->_set_style("font_variant", self::$_defaults["font_variant"], $important);
1651
+    }
1652 1652
 
1653 1653
     //matching numeric value followed by unit -> this is indeed a subsequent font size. Skip!
1654
-	if ( preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i",$val,$match) &&
1654
+    if ( preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i",$val,$match) &&
1655 1655
          !preg_match("/^(?:pt|px|pc|em|ex|in|cm|mm|%)/",$match[2])
1656
-	   ) {
1657
-		$this->_set_style("font_weight", $match[1], $important);
1658
-		$val = $match[2];
1659
-	} else {
1660
-		$this->_set_style("font_weight", self::$_defaults["font_weight"], $important);
1661
-	}
1662
-
1663
-	if ( preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) {
1664
-		$this->_set_style("font_size", $match[1], $important);
1665
-		$val = $match[2];
1656
+        ) {
1657
+        $this->_set_style("font_weight", $match[1], $important);
1658
+        $val = $match[2];
1659
+    } else {
1660
+        $this->_set_style("font_weight", self::$_defaults["font_weight"], $important);
1661
+    }
1662
+
1663
+    if ( preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) {
1664
+        $this->_set_style("font_size", $match[1], $important);
1665
+        $val = $match[2];
1666 1666
         if (preg_match("/^\/\s*(\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) {
1667
-			$this->_set_style("line_height", $match[1], $important);
1668
-			$val = $match[2];
1667
+            $this->_set_style("line_height", $match[1], $important);
1668
+            $val = $match[2];
1669 1669
         } else {
1670
-			$this->_set_style("line_height", self::$_defaults["line_height"], $important);
1670
+            $this->_set_style("line_height", self::$_defaults["line_height"], $important);
1671 1671
         }
1672
-	} else {
1673
- 		$this->_set_style("font_size", self::$_defaults["font_size"], $important);
1674
-		$this->_set_style("line_height", self::$_defaults["line_height"], $important);
1675
-	}
1676
-
1677
-	if(strlen($val) != 0) {
1678
-	  $this->_set_style("font_family", $val, $important);
1679
-	} else {
1680
-	  $this->_set_style("font_family", self::$_defaults["font_family"], $important);
1681
-	}
1682
-  }
1683
-
1684
-  /**#@+
1672
+    } else {
1673
+            $this->_set_style("font_size", self::$_defaults["font_size"], $important);
1674
+        $this->_set_style("line_height", self::$_defaults["line_height"], $important);
1675
+    }
1676
+
1677
+    if(strlen($val) != 0) {
1678
+        $this->_set_style("font_family", $val, $important);
1679
+    } else {
1680
+        $this->_set_style("font_family", self::$_defaults["font_family"], $important);
1681
+    }
1682
+    }
1683
+
1684
+    /**#@+
1685 1685
    * Sets page break properties
1686 1686
    *
1687 1687
    * @link http://www.w3.org/TR/CSS21/page.html#page-breaks
1688 1688
    * @param string $break
1689 1689
    */
1690
-  function set_page_break_before($break) {
1690
+    function set_page_break_before($break) {
1691 1691
     if ($break === "left" || $break === "right")
1692
-      $break = "always";
1692
+        $break = "always";
1693 1693
 
1694 1694
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1695
-	$this->_prop_cache["page_break_before"] = null;
1695
+    $this->_prop_cache["page_break_before"] = null;
1696 1696
     $this->_props["page_break_before"] = $break;
1697
-  }
1697
+    }
1698 1698
 
1699
-  function set_page_break_after($break) {
1699
+    function set_page_break_after($break) {
1700 1700
     if ($break === "left" || $break === "right")
1701
-      $break = "always";
1701
+        $break = "always";
1702 1702
 
1703 1703
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1704
-	$this->_prop_cache["page_break_after"] = null;
1704
+    $this->_prop_cache["page_break_after"] = null;
1705 1705
     $this->_props["page_break_after"] = $break;
1706
-  }
1707
-  /**#@-*/
1706
+    }
1707
+    /**#@-*/
1708 1708
     
1709
-  //........................................................................
1709
+    //........................................................................
1710 1710
 
1711
-  /**#@+
1711
+    /**#@+
1712 1712
    * Sets the margin size
1713 1713
    *
1714 1714
    * @link http://www.w3.org/TR/CSS21/box.html#margin-properties
1715 1715
    * @param $val
1716 1716
    */
1717
-  function set_margin_top($val) {
1717
+    function set_margin_top($val) {
1718 1718
     $this->_set_style_side_width_important('margin','top',$val);
1719
-  }
1719
+    }
1720 1720
 
1721
-  function set_margin_right($val) {
1721
+    function set_margin_right($val) {
1722 1722
     $this->_set_style_side_width_important('margin','right',$val);
1723
-  }
1723
+    }
1724 1724
 
1725
-  function set_margin_bottom($val) {
1725
+    function set_margin_bottom($val) {
1726 1726
     $this->_set_style_side_width_important('margin','bottom',$val);
1727
-  }
1727
+    }
1728 1728
 
1729
-  function set_margin_left($val) {
1729
+    function set_margin_left($val) {
1730 1730
     $this->_set_style_side_width_important('margin','left',$val);
1731
-  }
1731
+    }
1732 1732
   
1733
-  function set_margin($val) {
1733
+    function set_margin($val) {
1734 1734
     $val = str_replace("none", "0px", $val);
1735 1735
     $this->_set_style_type_important('margin','',$val);
1736
-  }
1737
-  /**#@-*/
1736
+    }
1737
+    /**#@-*/
1738 1738
 
1739
-  /**#@+
1739
+    /**#@+
1740 1740
    * Sets the padding size
1741 1741
    *
1742 1742
    * @link http://www.w3.org/TR/CSS21/box.html#padding-properties
1743 1743
    * @param $val
1744 1744
    */
1745
-  function set_padding_top($val) {
1745
+    function set_padding_top($val) {
1746 1746
     $this->_set_style_side_width_important('padding','top',$val);
1747
-  }
1747
+    }
1748 1748
 
1749
-  function set_padding_right($val) {
1749
+    function set_padding_right($val) {
1750 1750
     $this->_set_style_side_width_important('padding','right',$val);
1751
-  }
1751
+    }
1752 1752
 
1753
-  function set_padding_bottom($val) {
1753
+    function set_padding_bottom($val) {
1754 1754
     $this->_set_style_side_width_important('padding','bottom',$val);
1755
-  }
1755
+    }
1756 1756
 
1757
-  function set_padding_left($val) {
1757
+    function set_padding_left($val) {
1758 1758
     $this->_set_style_side_width_important('padding','left',$val);
1759
-  }
1759
+    }
1760 1760
 
1761
-  function set_padding($val) {
1761
+    function set_padding($val) {
1762 1762
     $val = str_replace("none", "0px", $val);
1763 1763
     $this->_set_style_type_important('padding','',$val);
1764
-  }
1765
-  /**#@-*/
1766
-
1767
-  /**
1768
-   * Sets a single border
1769
-   *
1770
-   * @param string $side
1771
-   * @param string $border_spec  ([width] [style] [color])
1772
-   */
1773
-  protected function _set_border($side, $border_spec, $important) {
1764
+    }
1765
+    /**#@-*/
1766
+
1767
+    /**
1768
+     * Sets a single border
1769
+     *
1770
+     * @param string $side
1771
+     * @param string $border_spec  ([width] [style] [color])
1772
+     */
1773
+    protected function _set_border($side, $border_spec, $important) {
1774 1774
     $border_spec = str_replace(",", " ", $border_spec);
1775 1775
     $arr = explode(" ", $border_spec);
1776 1776
 
@@ -1783,155 +1783,155 @@  discard block
 block discarded – undo
1783 1783
     $this->_set_style_side_type('border',$side,'_color',self::$_defaults['border_'.$side.'_color'],$important);
1784 1784
 
1785 1785
     foreach ($arr as $value) {
1786
-      $value = trim($value);
1787
-      if ( in_array($value, self::$BORDER_STYLES) ) {
1786
+        $value = trim($value);
1787
+        if ( in_array($value, self::$BORDER_STYLES) ) {
1788 1788
         $this->_set_style_side_type('border',$side,'_style',$value,$important);
1789 1789
 
1790
-      } else if ( preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value ) ) {
1790
+        } else if ( preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value ) ) {
1791 1791
         $this->_set_style_side_type('border',$side,'_width',$value,$important);
1792 1792
 
1793
-      } else {
1793
+        } else {
1794 1794
         // must be colour
1795 1795
         $this->_set_style_side_type('border',$side,'_color',$value,$important);
1796
-      }
1796
+        }
1797 1797
     }
1798 1798
 
1799 1799
     //see __set and __get, on all assignments clear cache!
1800
-	$this->_prop_cache['border_'.$side] = null;
1800
+    $this->_prop_cache['border_'.$side] = null;
1801 1801
     $this->_props['border_'.$side] = $border_spec;
1802
-  }
1802
+    }
1803 1803
 
1804
-  /**#@+
1804
+    /**#@+
1805 1805
    * Sets the border styles
1806 1806
    *
1807 1807
    * @link http://www.w3.org/TR/CSS21/box.html#border-properties
1808 1808
    * @param string $val
1809 1809
    */
1810
-  function set_border_top($val) { $this->_set_border("top", $val, isset($this->_important_props['border_top'])); }
1811
-  function set_border_right($val) { $this->_set_border("right", $val, isset($this->_important_props['border_right'])); }
1812
-  function set_border_bottom($val) { $this->_set_border("bottom", $val, isset($this->_important_props['border_bottom'])); }
1813
-  function set_border_left($val) { $this->_set_border("left", $val, isset($this->_important_props['border_left'])); }
1810
+    function set_border_top($val) { $this->_set_border("top", $val, isset($this->_important_props['border_top'])); }
1811
+    function set_border_right($val) { $this->_set_border("right", $val, isset($this->_important_props['border_right'])); }
1812
+    function set_border_bottom($val) { $this->_set_border("bottom", $val, isset($this->_important_props['border_bottom'])); }
1813
+    function set_border_left($val) { $this->_set_border("left", $val, isset($this->_important_props['border_left'])); }
1814 1814
 
1815
-  function set_border($val) {
1815
+    function set_border($val) {
1816 1816
     $important = isset($this->_important_props["border"]);
1817 1817
     $this->_set_border("top", $val, $important);
1818 1818
     $this->_set_border("right", $val, $important);
1819 1819
     $this->_set_border("bottom", $val, $important);
1820 1820
     $this->_set_border("left", $val, $important);
1821 1821
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1822
-	$this->_prop_cache["border"] = null;
1822
+    $this->_prop_cache["border"] = null;
1823 1823
     $this->_props["border"] = $val;
1824
-  }
1824
+    }
1825 1825
 
1826
-  function set_border_width($val) {
1826
+    function set_border_width($val) {
1827 1827
     $this->_set_style_type_important('border','_width',$val);
1828
-  }
1828
+    }
1829 1829
 
1830
-  function set_border_color($val) {
1830
+    function set_border_color($val) {
1831 1831
     $this->_set_style_type_important('border','_color',$val);
1832
-  }
1832
+    }
1833 1833
 
1834
-  function set_border_style($val) {
1834
+    function set_border_style($val) {
1835 1835
     $this->_set_style_type_important('border','_style',$val);
1836
-  }
1837
-  /**#@-*/
1836
+    }
1837
+    /**#@-*/
1838 1838
 
1839 1839
 
1840
-  /**
1841
-   * Sets the border spacing
1842
-   *
1843
-   * @link http://www.w3.org/TR/CSS21/box.html#border-properties
1844
-   * @param float $val
1845
-   */
1846
-  function set_border_spacing($val) {
1840
+    /**
1841
+     * Sets the border spacing
1842
+     *
1843
+     * @link http://www.w3.org/TR/CSS21/box.html#border-properties
1844
+     * @param float $val
1845
+     */
1846
+    function set_border_spacing($val) {
1847 1847
 
1848 1848
     $arr = explode(" ", $val);
1849 1849
 
1850 1850
     if ( count($arr) == 1 )
1851
-      $arr[1] = $arr[0];
1851
+        $arr[1] = $arr[0];
1852 1852
 
1853 1853
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1854
-	$this->_prop_cache["border_spacing"] = null;
1854
+    $this->_prop_cache["border_spacing"] = null;
1855 1855
     $this->_props["border_spacing"] = $arr[0] . " " . $arr[1];
1856
-  }
1856
+    }
1857 1857
 
1858
-  /**
1859
-   * Sets the list style image
1860
-   *
1861
-   * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style-image
1862
-   * @param $val
1863
-   */
1864
-  function set_list_style_image($val) {
1858
+    /**
1859
+     * Sets the list style image
1860
+     *
1861
+     * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style-image
1862
+     * @param $val
1863
+     */
1864
+    function set_list_style_image($val) {
1865 1865
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1866
-	$this->_prop_cache["list_style_image"] = null;
1866
+    $this->_prop_cache["list_style_image"] = null;
1867 1867
     $this->_props["list_style_image"] = $this->_image($val);
1868
-  }
1868
+    }
1869 1869
 
1870
-  /**
1871
-   * Sets the list style
1872
-   *
1873
-   * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style
1874
-   * @param $val
1875
-   */
1876
-  function set_list_style($val) {
1870
+    /**
1871
+     * Sets the list style
1872
+     *
1873
+     * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style
1874
+     * @param $val
1875
+     */
1876
+    function set_list_style($val) {
1877 1877
     $important = isset($this->_important_props["list_style"]);
1878 1878
     $arr = explode(" ", str_replace(",", " ", $val));
1879 1879
 
1880 1880
     static $types = array("disc", "circle", "square", "decimal",
1881
-                   "decimal-leading-zero", "lower-roman",
1882
-                   "upper-roman", "lower-greek", "lower-latin",
1883
-                   "upper-latin", "armenian", "georgian",
1884
-                   "lower-alpha", "upper-alpha", "hebrew",
1885
-                   "cjk-ideographic", "hiragana", "katakana",
1886
-                   "hiragana-iroha", "katakana-iroha", "none");
1881
+                    "decimal-leading-zero", "lower-roman",
1882
+                    "upper-roman", "lower-greek", "lower-latin",
1883
+                    "upper-latin", "armenian", "georgian",
1884
+                    "lower-alpha", "upper-alpha", "hebrew",
1885
+                    "cjk-ideographic", "hiragana", "katakana",
1886
+                    "hiragana-iroha", "katakana-iroha", "none");
1887 1887
 
1888 1888
     static $positions = array("inside", "outside");
1889 1889
 
1890 1890
     foreach ($arr as $value) {
1891
-      /* http://www.w3.org/TR/CSS21/generate.html#list-style
1891
+        /* http://www.w3.org/TR/CSS21/generate.html#list-style
1892 1892
        * A value of 'none' for the 'list-style' property sets both 'list-style-type' and 'list-style-image' to 'none'
1893 1893
        */
1894
-      if ($value === "none") {
1895
-   	    $this->_set_style("list_style_type", $value, $important);
1896
-   	    $this->_set_style("list_style_image", $value, $important);
1894
+        if ($value === "none") {
1895
+            $this->_set_style("list_style_type", $value, $important);
1896
+            $this->_set_style("list_style_image", $value, $important);
1897 1897
         continue;
1898
-      }
1898
+        }
1899 1899
 
1900
-      //On setting or merging or inheriting list_style_image as well as list_style_type,
1901
-      //and url exists, then url has precedence, otherwise fall back to list_style_type
1902
-      //Firefox is wrong here (list_style_image gets overwritten on explicite list_style_type)
1903
-      //Internet Explorer 7/8 and dompdf is right.
1900
+        //On setting or merging or inheriting list_style_image as well as list_style_type,
1901
+        //and url exists, then url has precedence, otherwise fall back to list_style_type
1902
+        //Firefox is wrong here (list_style_image gets overwritten on explicite list_style_type)
1903
+        //Internet Explorer 7/8 and dompdf is right.
1904 1904
        
1905
-	  if (mb_substr($value, 0, 3) === "url") {
1906
-   	    $this->_set_style("list_style_image", $this->_image($value), $important);
1905
+        if (mb_substr($value, 0, 3) === "url") {
1906
+            $this->_set_style("list_style_image", $this->_image($value), $important);
1907 1907
         continue;
1908
-      }
1908
+        }
1909 1909
 
1910
-      if ( in_array($value, $types) ) {
1911
-   	    $this->_set_style("list_style_type", $value, $important);
1912
-      } else if ( in_array($value, $positions) ) {
1913
-   	    $this->_set_style("list_style_position", $value, $important);
1914
-      }
1910
+        if ( in_array($value, $types) ) {
1911
+            $this->_set_style("list_style_type", $value, $important);
1912
+        } else if ( in_array($value, $positions) ) {
1913
+            $this->_set_style("list_style_position", $value, $important);
1914
+        }
1915 1915
     }
1916 1916
 
1917 1917
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1918
-	$this->_prop_cache["list_style"] = null;
1919
- 	$this->_props["list_style"] = $val;
1920
-  }
1918
+    $this->_prop_cache["list_style"] = null;
1919
+        $this->_props["list_style"] = $val;
1920
+    }
1921 1921
 
1922
-  /**
1923
-   * Generate a string representation of the Style
1924
-   *
1925
-   * This dumps the entire property array into a string via print_r.  Useful
1926
-   * for debugging.
1927
-   *
1928
-   * @return string
1929
-   */
1930
- /*DEBUGCSS print: see below additional debugging util*/
1931
-  function __toString() {
1922
+    /**
1923
+     * Generate a string representation of the Style
1924
+     *
1925
+     * This dumps the entire property array into a string via print_r.  Useful
1926
+     * for debugging.
1927
+     *
1928
+     * @return string
1929
+     */
1930
+    /*DEBUGCSS print: see below additional debugging util*/
1931
+    function __toString() {
1932 1932
     return print_r(array_merge(array("parent_font_size" => $this->_parent_font_size),
1933
-                               $this->_props), true);
1934
-  }
1933
+                                $this->_props), true);
1934
+    }
1935 1935
 
1936 1936
 /*DEBUGCSS*/  function debug_print()
1937 1937
 /*DEBUGCSS*/  {
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/table_frame_decorator.cls.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -129,7 +129,6 @@
 block discarded – undo
129 129
    * added to the clone.  This method is overidden in order to remove
130 130
    * frames from the cellmap properly.
131 131
    *
132
-   * @param Frame $row
133 132
    */
134 133
   function split($child = null) {
135 134
 
Please login to merge, or discard this patch.
Indentation   +188 added lines, -189 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
34 34
  * @copyright 2004 Benj Carson
35 35
  * @author Benj Carson <[email protected]>
36 36
  * @package dompdf
37
-
38 37
  */
39 38
 
40 39
 /* $Id: table_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -46,73 +45,73 @@  discard block
 block discarded – undo
46 45
  * @package dompdf
47 46
  */
48 47
 class Table_Frame_Decorator extends Frame_Decorator {
49
-  static $VALID_CHILDREN = array("table-row-group",
50
-                                 "table-row",
51
-                                 "table-header-group",
52
-                                 "table-footer-group",
53
-                                 "table-column",
54
-                                 "table-column-group",
55
-                                 "table-caption",
56
-                                 "table-cell");
57
-
58
-  static $ROW_GROUPS = array('table-row-group',
59
-                             'table-header-group',
60
-                             'table-footer-group');
61
-
62
-  /**
63
-   * The Cellmap object for this table.  The cellmap maps table cells
64
-   * to rows and columns, and aids in calculating column widths.
65
-   *
66
-   * @var Cellmap
67
-   */
68
-  protected $_cellmap;
69
-
70
-  /**
71
-   * The minimum width of the table, in pt
72
-   *
73
-   * @var float
74
-   */
75
-  protected $_min_width;
76
-
77
-  /**
78
-   * The maximum width of the table, in pt
79
-   *
80
-   * @var float
81
-   */
82
-  protected $_max_width;
83
-
84
-  /**
85
-   * Table header rows.  Each table header is duplicated when a table
86
-   * spans pages.
87
-   *
88
-   * @var array
89
-   */
90
-  protected $_headers;
91
-
92
-  /**
93
-   * Table footer rows.  Each table footer is duplicated when a table
94
-   * spans pages.
95
-   *
96
-   * @var array
97
-   */
98
-  protected $_footers;
99
-
100
-  /**
101
-   * Class constructor
102
-   *
103
-   * @param Frame $frame the frame to decorate
104
-   */
105
-  function __construct(Frame $frame, DOMPDF $dompdf) {
48
+    static $VALID_CHILDREN = array("table-row-group",
49
+                                    "table-row",
50
+                                    "table-header-group",
51
+                                    "table-footer-group",
52
+                                    "table-column",
53
+                                    "table-column-group",
54
+                                    "table-caption",
55
+                                    "table-cell");
56
+
57
+    static $ROW_GROUPS = array('table-row-group',
58
+                                'table-header-group',
59
+                                'table-footer-group');
60
+
61
+    /**
62
+     * The Cellmap object for this table.  The cellmap maps table cells
63
+     * to rows and columns, and aids in calculating column widths.
64
+     *
65
+     * @var Cellmap
66
+     */
67
+    protected $_cellmap;
68
+
69
+    /**
70
+     * The minimum width of the table, in pt
71
+     *
72
+     * @var float
73
+     */
74
+    protected $_min_width;
75
+
76
+    /**
77
+     * The maximum width of the table, in pt
78
+     *
79
+     * @var float
80
+     */
81
+    protected $_max_width;
82
+
83
+    /**
84
+     * Table header rows.  Each table header is duplicated when a table
85
+     * spans pages.
86
+     *
87
+     * @var array
88
+     */
89
+    protected $_headers;
90
+
91
+    /**
92
+     * Table footer rows.  Each table footer is duplicated when a table
93
+     * spans pages.
94
+     *
95
+     * @var array
96
+     */
97
+    protected $_footers;
98
+
99
+    /**
100
+     * Class constructor
101
+     *
102
+     * @param Frame $frame the frame to decorate
103
+     */
104
+    function __construct(Frame $frame, DOMPDF $dompdf) {
106 105
     parent::__construct($frame, $dompdf);
107 106
     $this->_cellmap = new Cellmap($this);
108 107
     $this->_min_width = null;
109 108
     $this->_max_width = null;
110 109
     $this->_headers = array();
111 110
     $this->_footers = array();
112
-  }
111
+    }
113 112
 
114 113
 
115
-  function reset() {
114
+    function reset() {
116 115
     parent::reset();
117 116
     $this->_cellmap->reset();
118 117
     $this->_min_width = null;
@@ -120,22 +119,22 @@  discard block
 block discarded – undo
120 119
     $this->_headers = array();
121 120
     $this->_footers = array();
122 121
     $this->_reflower->reset();
123
-  }
122
+    }
124 123
 
125
-  //........................................................................
124
+    //........................................................................
126 125
 
127
-  /**
128
-   * split the table at $row.  $row and all subsequent rows will be
129
-   * added to the clone.  This method is overidden in order to remove
130
-   * frames from the cellmap properly.
131
-   *
132
-   * @param Frame $row
133
-   */
134
-  function split($child = null) {
126
+    /**
127
+     * split the table at $row.  $row and all subsequent rows will be
128
+     * added to the clone.  This method is overidden in order to remove
129
+     * frames from the cellmap properly.
130
+     *
131
+     * @param Frame $row
132
+     */
133
+    function split($child = null) {
135 134
 
136 135
     if ( is_null($child) ) {
137
-      parent::split();
138
-      return;
136
+        parent::split();
137
+        return;
139 138
     }
140 139
 
141 140
     // If $child is a header or if it is the first non-header row, do
@@ -143,200 +142,200 @@  discard block
 block discarded – undo
143 142
     if ( count($this->_headers) && !in_array($child, $this->_headers, true) &&
144 143
          !in_array($child->get_prev_sibling(), $this->_headers, true) ) {
145 144
 
146
-      $first_header = null;
145
+        $first_header = null;
147 146
 
148
-      // Insert copies of the table headers before $child
149
-      foreach ($this->_headers as $header) {
147
+        // Insert copies of the table headers before $child
148
+        foreach ($this->_headers as $header) {
150 149
 
151 150
         $new_header = $header->deep_copy();
152 151
 
153 152
         if ( is_null($first_header) )
154
-          $first_header = $new_header;
153
+            $first_header = $new_header;
155 154
 
156 155
         $this->insert_child_before($new_header, $child);
157
-      }
156
+        }
158 157
 
159
-      parent::split($first_header);
158
+        parent::split($first_header);
160 159
 
161 160
     } else if ( in_array($child->get_style()->display, self::$ROW_GROUPS) ) {
162 161
 
163
-      // Individual rows should have already been handled
164
-      parent::split($child);
162
+        // Individual rows should have already been handled
163
+        parent::split($child);
165 164
 
166 165
     } else {
167 166
 
168
-      $iter = $child;
167
+        $iter = $child;
169 168
 
170
-      while ($iter) {
169
+        while ($iter) {
171 170
         $this->_cellmap->remove_row($iter);
172 171
         $iter = $iter->get_next_sibling();
173
-      }
172
+        }
174 173
 
175
-      parent::split($child);
174
+        parent::split($child);
175
+    }
176 176
     }
177
-  }
178 177
 
179
-  /**
180
-   * Static function to locate the parent table of a frame
181
-   *
182
-   * @param Frame $frame
183
-   * @return Frame the table that is an ancestor of $frame
184
-   */
185
-  static function find_parent_table(Frame $frame) {
178
+    /**
179
+     * Static function to locate the parent table of a frame
180
+     *
181
+     * @param Frame $frame
182
+     * @return Frame the table that is an ancestor of $frame
183
+     */
184
+    static function find_parent_table(Frame $frame) {
186 185
 
187 186
     while ( $frame = $frame->get_parent() )
188
-      if ( in_array($frame->get_style()->display, Style::$TABLE_TYPES) )
187
+        if ( in_array($frame->get_style()->display, Style::$TABLE_TYPES) )
189 188
         break;
190 189
 
191 190
     return $frame;
192
-  }
193
-
194
-  /**
195
-   * Return this table's Cellmap
196
-   *
197
-   * @return Cellmap
198
-   */
199
-  function get_cellmap() { return $this->_cellmap; }
200
-
201
-  /**
202
-   * Return the minimum width of this table
203
-   *
204
-   * @return float
205
-   */
206
-  function get_min_width() { return $this->_min_width; }
207
-
208
-  /**
209
-   * Return the maximum width of this table
210
-   *
211
-   * @return float
212
-   */
213
-  function get_max_width() { return $this->_max_width; }
214
-
215
-  /**
216
-   * Set the minimum width of the table
217
-   *
218
-   * @param float $width the new minimum width
219
-   */
220
-  function set_min_width($width) { $this->_min_width = $width; }
221
-
222
-  /**
223
-   * Set the maximum width of the table
224
-   *
225
-   * @param float $width the new maximum width
226
-   */
227
-  function set_max_width($width) { $this->_max_width = $width; }
228
-
229
-  /**
230
-   * Restructure tree so that the table has the correct structure.
231
-   * Invalid children (i.e. all non-table-rows) are moved below the
232
-   * table.
233
-   */
234
-  function normalise() {
191
+    }
192
+
193
+    /**
194
+     * Return this table's Cellmap
195
+     *
196
+     * @return Cellmap
197
+     */
198
+    function get_cellmap() { return $this->_cellmap; }
199
+
200
+    /**
201
+     * Return the minimum width of this table
202
+     *
203
+     * @return float
204
+     */
205
+    function get_min_width() { return $this->_min_width; }
206
+
207
+    /**
208
+     * Return the maximum width of this table
209
+     *
210
+     * @return float
211
+     */
212
+    function get_max_width() { return $this->_max_width; }
213
+
214
+    /**
215
+     * Set the minimum width of the table
216
+     *
217
+     * @param float $width the new minimum width
218
+     */
219
+    function set_min_width($width) { $this->_min_width = $width; }
220
+
221
+    /**
222
+     * Set the maximum width of the table
223
+     *
224
+     * @param float $width the new maximum width
225
+     */
226
+    function set_max_width($width) { $this->_max_width = $width; }
227
+
228
+    /**
229
+     * Restructure tree so that the table has the correct structure.
230
+     * Invalid children (i.e. all non-table-rows) are moved below the
231
+     * table.
232
+     */
233
+    function normalise() {
235 234
 
236 235
     // Store frames generated by invalid tags and move them outside the table
237 236
     $erroneous_frames = array();
238 237
     $anon_row = false;
239 238
     $iter = $this->get_first_child();
240 239
     while ( $iter ) {
241
-      $child = $iter;
242
-      $iter = $iter->get_next_sibling();
240
+        $child = $iter;
241
+        $iter = $iter->get_next_sibling();
243 242
 
244
-      $display = $child->get_style()->display;
243
+        $display = $child->get_style()->display;
245 244
 
246
-      if ( $anon_row ) {
245
+        if ( $anon_row ) {
247 246
 
248 247
         if ( $display === "table-row" ) {
249
-          // Add the previous anonymous row
250
-          $this->insert_child_before($table_row, $child);
248
+            // Add the previous anonymous row
249
+            $this->insert_child_before($table_row, $child);
251 250
 
252
-          $table_row->normalise();
253
-          $child->normalise();
254
-          $anon_row = false;
255
-          continue;
251
+            $table_row->normalise();
252
+            $child->normalise();
253
+            $anon_row = false;
254
+            continue;
256 255
         }
257 256
 
258 257
         // add the child to the anonymous row
259 258
         $table_row->append_child($child);
260 259
         continue;
261 260
 
262
-      } else {
261
+        } else {
263 262
 
264 263
         if ( $display === "table-row" ) {
265
-          $child->normalise();
266
-          continue;
264
+            $child->normalise();
265
+            continue;
267 266
         }
268 267
 
269 268
         if ( $display === "table-cell") {
270
-          // Create an anonymous table row
271
-          $tr = $this->get_node()->ownerDocument->createElement("tr");
269
+            // Create an anonymous table row
270
+            $tr = $this->get_node()->ownerDocument->createElement("tr");
272 271
 
273
-          $frame = new Frame($tr);
272
+            $frame = new Frame($tr);
274 273
 
275
-          $css = $this->get_style()->get_stylesheet();
276
-          $style = $css->create_style();
277
-          $style->inherit($this->get_style());
274
+            $css = $this->get_style()->get_stylesheet();
275
+            $style = $css->create_style();
276
+            $style->inherit($this->get_style());
278 277
 
279
-          // Lookup styles for tr tags.  If the user wants styles to work
280
-          // better, they should make the tr explicit... I'm not going to
281
-          // try to guess what they intended.
282
-          if ( $tr_style = $css->lookup("tr") )
278
+            // Lookup styles for tr tags.  If the user wants styles to work
279
+            // better, they should make the tr explicit... I'm not going to
280
+            // try to guess what they intended.
281
+            if ( $tr_style = $css->lookup("tr") )
283 282
             $style->merge($tr_style);
284 283
 
285
-          // Okay, I have absolutely no idea why I need this clone here, but
286
-          // if it's omitted, php (as of 2004-07-28) segfaults.
287
-          $frame->set_style(clone $style);
288
-          $table_row = Frame_Factory::decorate_frame($frame, $this->_dompdf);
289
-          $table_row->set_root($this->_root);
284
+            // Okay, I have absolutely no idea why I need this clone here, but
285
+            // if it's omitted, php (as of 2004-07-28) segfaults.
286
+            $frame->set_style(clone $style);
287
+            $table_row = Frame_Factory::decorate_frame($frame, $this->_dompdf);
288
+            $table_row->set_root($this->_root);
290 289
 
291
-          // Add the cell to the row
292
-          $table_row->append_child($child);
290
+            // Add the cell to the row
291
+            $table_row->append_child($child);
293 292
 
294
-          $anon_row = true;
295
-          continue;
293
+            $anon_row = true;
294
+            continue;
296 295
         }
297 296
 
298 297
         if ( !in_array($display, self::$VALID_CHILDREN) ) {
299
-          $erroneous_frames[] = $child;
300
-          continue;
298
+            $erroneous_frames[] = $child;
299
+            continue;
301 300
         }
302 301
 
303 302
         // Normalise other table parts (i.e. row groups)
304 303
         foreach ($child->get_children() as $grandchild) {
305
-          if ( $grandchild->get_style()->display === "table-row" )
304
+            if ( $grandchild->get_style()->display === "table-row" )
306 305
             $grandchild->normalise();
307 306
         }
308 307
 
309 308
         // Add headers and footers
310 309
         if ( $display === "table-header-group" )
311
-          $this->_headers[] = $child;
310
+            $this->_headers[] = $child;
312 311
 
313 312
         else if ( $display === "table-footer-group" )
314
-          $this->_footers[] = $child;
315
-      }
313
+            $this->_footers[] = $child;
314
+        }
316 315
     }
317 316
 
318 317
     if ( $anon_row ) {
319
-      // Add the row to the table
320
-      $this->_frame->append_child($table_row);
321
-      $table_row->normalise();
322
-      $this->_cellmap->add_row();
318
+        // Add the row to the table
319
+        $this->_frame->append_child($table_row);
320
+        $table_row->normalise();
321
+        $this->_cellmap->add_row();
323 322
     }
324 323
 
325 324
     foreach ($erroneous_frames as $frame)
326
-      $this->move_after($frame);
325
+        $this->move_after($frame);
327 326
 
328
-  }
327
+    }
329 328
 
330
-  //........................................................................
329
+    //........................................................................
331 330
 
332
-  /**
333
-   * Moves the specified frame and it's corresponding node outside of
334
-   * the table.
335
-   *
336
-   * @param Frame $frame the frame to move
337
-   */
338
-  function move_after(Frame $frame) {
331
+    /**
332
+     * Moves the specified frame and it's corresponding node outside of
333
+     * the table.
334
+     *
335
+     * @param Frame $frame the frame to move
336
+     */
337
+    function move_after(Frame $frame) {
339 338
     $this->get_parent()->insert_child_after($frame, $this);
340
-  }
339
+    }
341 340
 
342 341
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
    */
134 134
   function split($child = null) {
135 135
 
136
-    if ( is_null($child) ) {
136
+    if (is_null($child)) {
137 137
       parent::split();
138 138
       return;
139 139
     }
140 140
 
141 141
     // If $child is a header or if it is the first non-header row, do
142 142
     // not duplicate headers, simply move the table to the next page.
143
-    if ( count($this->_headers) && !in_array($child, $this->_headers, true) &&
144
-         !in_array($child->get_prev_sibling(), $this->_headers, true) ) {
143
+    if (count($this->_headers) && !in_array($child, $this->_headers, true) &&
144
+         !in_array($child->get_prev_sibling(), $this->_headers, true)) {
145 145
 
146 146
       $first_header = null;
147 147
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
         $new_header = $header->deep_copy();
152 152
 
153
-        if ( is_null($first_header) )
153
+        if (is_null($first_header))
154 154
           $first_header = $new_header;
155 155
 
156 156
         $this->insert_child_before($new_header, $child);
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
       parent::split($first_header);
160 160
 
161
-    } else if ( in_array($child->get_style()->display, self::$ROW_GROUPS) ) {
161
+    } else if (in_array($child->get_style()->display, self::$ROW_GROUPS)) {
162 162
 
163 163
       // Individual rows should have already been handled
164 164
       parent::split($child);
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
    */
185 185
   static function find_parent_table(Frame $frame) {
186 186
 
187
-    while ( $frame = $frame->get_parent() )
188
-      if ( in_array($frame->get_style()->display, Style::$TABLE_TYPES) )
187
+    while ($frame = $frame->get_parent())
188
+      if (in_array($frame->get_style()->display, Style::$TABLE_TYPES))
189 189
         break;
190 190
 
191 191
     return $frame;
@@ -237,15 +237,15 @@  discard block
 block discarded – undo
237 237
     $erroneous_frames = array();
238 238
     $anon_row = false;
239 239
     $iter = $this->get_first_child();
240
-    while ( $iter ) {
240
+    while ($iter) {
241 241
       $child = $iter;
242 242
       $iter = $iter->get_next_sibling();
243 243
 
244 244
       $display = $child->get_style()->display;
245 245
 
246
-      if ( $anon_row ) {
246
+      if ($anon_row) {
247 247
 
248
-        if ( $display === "table-row" ) {
248
+        if ($display === "table-row") {
249 249
           // Add the previous anonymous row
250 250
           $this->insert_child_before($table_row, $child);
251 251
 
@@ -261,12 +261,12 @@  discard block
 block discarded – undo
261 261
 
262 262
       } else {
263 263
 
264
-        if ( $display === "table-row" ) {
264
+        if ($display === "table-row") {
265 265
           $child->normalise();
266 266
           continue;
267 267
         }
268 268
 
269
-        if ( $display === "table-cell") {
269
+        if ($display === "table-cell") {
270 270
           // Create an anonymous table row
271 271
           $tr = $this->get_node()->ownerDocument->createElement("tr");
272 272
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
           // Lookup styles for tr tags.  If the user wants styles to work
280 280
           // better, they should make the tr explicit... I'm not going to
281 281
           // try to guess what they intended.
282
-          if ( $tr_style = $css->lookup("tr") )
282
+          if ($tr_style = $css->lookup("tr"))
283 283
             $style->merge($tr_style);
284 284
 
285 285
           // Okay, I have absolutely no idea why I need this clone here, but
@@ -295,27 +295,27 @@  discard block
 block discarded – undo
295 295
           continue;
296 296
         }
297 297
 
298
-        if ( !in_array($display, self::$VALID_CHILDREN) ) {
298
+        if (!in_array($display, self::$VALID_CHILDREN)) {
299 299
           $erroneous_frames[] = $child;
300 300
           continue;
301 301
         }
302 302
 
303 303
         // Normalise other table parts (i.e. row groups)
304 304
         foreach ($child->get_children() as $grandchild) {
305
-          if ( $grandchild->get_style()->display === "table-row" )
305
+          if ($grandchild->get_style()->display === "table-row")
306 306
             $grandchild->normalise();
307 307
         }
308 308
 
309 309
         // Add headers and footers
310
-        if ( $display === "table-header-group" )
310
+        if ($display === "table-header-group")
311 311
           $this->_headers[] = $child;
312 312
 
313
-        else if ( $display === "table-footer-group" )
313
+        else if ($display === "table-footer-group")
314 314
           $this->_footers[] = $child;
315 315
       }
316 316
     }
317 317
 
318
-    if ( $anon_row ) {
318
+    if ($anon_row) {
319 319
       // Add the row to the table
320 320
       $this->_frame->append_child($table_row);
321 321
       $table_row->normalise();
Please login to merge, or discard this patch.
Braces   +20 added lines, -15 removed lines patch added patch discarded remove patch
@@ -150,8 +150,9 @@  discard block
 block discarded – undo
150 150
 
151 151
         $new_header = $header->deep_copy();
152 152
 
153
-        if ( is_null($first_header) )
154
-          $first_header = $new_header;
153
+        if ( is_null($first_header) ) {
154
+                  $first_header = $new_header;
155
+        }
155 156
 
156 157
         $this->insert_child_before($new_header, $child);
157 158
       }
@@ -184,9 +185,10 @@  discard block
 block discarded – undo
184 185
    */
185 186
   static function find_parent_table(Frame $frame) {
186 187
 
187
-    while ( $frame = $frame->get_parent() )
188
-      if ( in_array($frame->get_style()->display, Style::$TABLE_TYPES) )
188
+    while ( $frame = $frame->get_parent() ) {
189
+          if ( in_array($frame->get_style()->display, Style::$TABLE_TYPES) )
189 190
         break;
191
+    }
190 192
 
191 193
     return $frame;
192 194
   }
@@ -279,8 +281,9 @@  discard block
 block discarded – undo
279 281
           // Lookup styles for tr tags.  If the user wants styles to work
280 282
           // better, they should make the tr explicit... I'm not going to
281 283
           // try to guess what they intended.
282
-          if ( $tr_style = $css->lookup("tr") )
283
-            $style->merge($tr_style);
284
+          if ( $tr_style = $css->lookup("tr") ) {
285
+                      $style->merge($tr_style);
286
+          }
284 287
 
285 288
           // Okay, I have absolutely no idea why I need this clone here, but
286 289
           // if it's omitted, php (as of 2004-07-28) segfaults.
@@ -302,16 +305,17 @@  discard block
 block discarded – undo
302 305
 
303 306
         // Normalise other table parts (i.e. row groups)
304 307
         foreach ($child->get_children() as $grandchild) {
305
-          if ( $grandchild->get_style()->display === "table-row" )
306
-            $grandchild->normalise();
308
+          if ( $grandchild->get_style()->display === "table-row" ) {
309
+                      $grandchild->normalise();
310
+          }
307 311
         }
308 312
 
309 313
         // Add headers and footers
310
-        if ( $display === "table-header-group" )
311
-          $this->_headers[] = $child;
312
-
313
-        else if ( $display === "table-footer-group" )
314
-          $this->_footers[] = $child;
314
+        if ( $display === "table-header-group" ) {
315
+                  $this->_headers[] = $child;
316
+        } else if ( $display === "table-footer-group" ) {
317
+                  $this->_footers[] = $child;
318
+        }
315 319
       }
316 320
     }
317 321
 
@@ -322,8 +326,9 @@  discard block
 block discarded – undo
322 326
       $this->_cellmap->add_row();
323 327
     }
324 328
 
325
-    foreach ($erroneous_frames as $frame)
326
-      $this->move_after($frame);
329
+    foreach ($erroneous_frames as $frame) {
330
+          $this->move_after($frame);
331
+    }
327 332
 
328 333
   }
329 334
 
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/tcpdf_adapter.cls.php 4 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
   /**
180 180
    * Sets the stroke colour
181 181
    *
182
-   * @param array $color
182
+   * @param array $colour
183 183
    */
184 184
   protected function _set_stroke_colour($colour) {
185 185
     $colour[0] = round(255 * $colour[0]);
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
   /**
197 197
    * Sets the fill colour
198 198
    *
199
-   * @param array $color
199
+   * @param array $colour
200 200
    */
201 201
   protected function _set_fill_colour($colour) {
202 202
     $colour[0] = round(255 * $colour[0]);
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
    * @param string $font the font file to use
392 392
    * @param float $size the font size, in points
393 393
    * @param array $color
394
-   * @param float $adjust word spacing adjustment
394
+   * @param integer $adjust word spacing adjustment
395 395
    */
396 396
   function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0){}
397 397
 
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
    * @param string $text the text to be sized
422 422
    * @param string $font the desired font
423 423
    * @param float  $size the desired font size
424
-   * @param float  $spacing word spacing, if any
424
+   * @param integer  $spacing word spacing, if any
425 425
    * @return float
426 426
    */
427 427
   function get_text_width($text, $font, $size, $spacing = 0){}
Please login to merge, or discard this patch.
Indentation   +328 added lines, -329 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
34 34
  * @copyright 2004 Benj Carson
35 35
  * @author Benj Carson <[email protected]>
36 36
  * @package dompdf
37
-
38 37
  */
39 38
 
40 39
 /* $Id: tcpdf_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */
@@ -57,98 +56,98 @@  discard block
 block discarded – undo
57 56
  */
58 57
 class TCPDF_Adapter implements Canvas {
59 58
 
60
-  /**
61
-   * Dimensions of paper sizes in points
62
-   *
63
-   * @var array;
64
-   */
65
-  static public $PAPER_SIZES = array(); // Set to
59
+    /**
60
+     * Dimensions of paper sizes in points
61
+     *
62
+     * @var array;
63
+     */
64
+    static public $PAPER_SIZES = array(); // Set to
66 65
                                         // CPDF_Adapter::$PAPER_SIZES below.
67 66
 
68 67
 
69
-  /**
70
-   * Instance of the TCPDF class
71
-   *
72
-   * @var TCPDF
73
-   */
74
-  private $_pdf;
75
-
76
-  /**
77
-   * PDF width in points
78
-   *
79
-   * @var float
80
-   */
81
-  private $_width;
82
-
83
-  /**
84
-   * PDF height in points
85
-   *
86
-   * @var float
87
-   */
88
-  private $_height;
89
-
90
-  /**
91
-   * Last fill colour used
92
-   *
93
-   * @var array
94
-   */
95
-  private $_last_fill_color;
96
-
97
-  /**
98
-   * Last stroke colour used
99
-   *
100
-   * @var array
101
-   */
102
-  private $_last_stroke_color;
103
-
104
-  /**
105
-   * Last line width used
106
-   *
107
-   * @var float
108
-   */
109
-  private $_last_line_width;
68
+    /**
69
+     * Instance of the TCPDF class
70
+     *
71
+     * @var TCPDF
72
+     */
73
+    private $_pdf;
74
+
75
+    /**
76
+     * PDF width in points
77
+     *
78
+     * @var float
79
+     */
80
+    private $_width;
81
+
82
+    /**
83
+     * PDF height in points
84
+     *
85
+     * @var float
86
+     */
87
+    private $_height;
88
+
89
+    /**
90
+     * Last fill colour used
91
+     *
92
+     * @var array
93
+     */
94
+    private $_last_fill_color;
95
+
96
+    /**
97
+     * Last stroke colour used
98
+     *
99
+     * @var array
100
+     */
101
+    private $_last_stroke_color;
102
+
103
+    /**
104
+     * Last line width used
105
+     *
106
+     * @var float
107
+     */
108
+    private $_last_line_width;
110 109
   
111
-  /**
112
-   * Total number of pages
113
-   *
114
-   * @var int
115
-   */
116
-  private $_page_count;
117
-
118
-  /**
119
-   * Text to display on every page
120
-   *
121
-   * @var array
122
-   */
123
-  private $_page_text;
124
-
125
-  /**
126
-   * Array of pages for accessing after initial rendering is complete
127
-   *
128
-   * @var array
129
-   */
130
-  private $_pages;
131
-
132
-  /**
133
-   * Class constructor
134
-   *
135
-   * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or
136
-   *                     an array(xmin,ymin,xmax,ymax)
137
-   * @param string $orientation The orientation of the document (either 'landscape' or 'portrait')
138
-   */
139
-  function __construct($paper = "letter", $orientation = "portrait") {
110
+    /**
111
+     * Total number of pages
112
+     *
113
+     * @var int
114
+     */
115
+    private $_page_count;
116
+
117
+    /**
118
+     * Text to display on every page
119
+     *
120
+     * @var array
121
+     */
122
+    private $_page_text;
123
+
124
+    /**
125
+     * Array of pages for accessing after initial rendering is complete
126
+     *
127
+     * @var array
128
+     */
129
+    private $_pages;
130
+
131
+    /**
132
+     * Class constructor
133
+     *
134
+     * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or
135
+     *                     an array(xmin,ymin,xmax,ymax)
136
+     * @param string $orientation The orientation of the document (either 'landscape' or 'portrait')
137
+     */
138
+    function __construct($paper = "letter", $orientation = "portrait") {
140 139
    
141 140
     if ( is_array($paper) )
142
-      $size = $paper;
141
+        $size = $paper;
143 142
     else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) )
144
-      $size = self::$PAPER_SIZE[$paper];
143
+        $size = self::$PAPER_SIZE[$paper];
145 144
     else
146
-      $size = self::$PAPER_SIZE["letter"];
145
+        $size = self::$PAPER_SIZE["letter"];
147 146
 
148 147
     if ( mb_strtolower($orientation) === "landscape" ) {
149
-      $a = $size[3];
150
-      $size[3] = $size[2];
151
-      $size[2] = $a;
148
+        $a = $size[3];
149
+        $size[3] = $size[2];
150
+        $size[2] = $a;
152 151
     }
153 152
 
154 153
     $this->_width = $size[2] - $size[0];
@@ -163,135 +162,135 @@  discard block
 block discarded – undo
163 162
     $this->_page_text = array();
164 163
 
165 164
     $this->_last_fill_color     =
166
-      $this->_last_stroke_color =
167
-      $this->_last_line_width   = null;
165
+        $this->_last_stroke_color =
166
+        $this->_last_line_width   = null;
168 167
 
169
-  }  
168
+    }  
170 169
   
171
-  /**
172
-   * Remaps y coords from 4th to 1st quadrant
173
-   *
174
-   * @param float $y
175
-   * @return float
176
-   */
177
-  protected function y($y) { return $this->_height - $y; }
178
-
179
-  /**
180
-   * Sets the stroke colour
181
-   *
182
-   * @param array $color
183
-   */
184
-  protected function _set_stroke_colour($colour) {
170
+    /**
171
+     * Remaps y coords from 4th to 1st quadrant
172
+     *
173
+     * @param float $y
174
+     * @return float
175
+     */
176
+    protected function y($y) { return $this->_height - $y; }
177
+
178
+    /**
179
+     * Sets the stroke colour
180
+     *
181
+     * @param array $color
182
+     */
183
+    protected function _set_stroke_colour($colour) {
185 184
     $colour[0] = round(255 * $colour[0]);
186 185
     $colour[1] = round(255 * $colour[1]);
187 186
     $colour[2] = round(255 * $colour[2]);
188 187
 
189 188
     if ( is_null($this->_last_stroke_color) || $color != $this->_last_stroke_color ) {
190
-      $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]);
191
-      $this->_last_stroke_color = $color;
189
+        $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]);
190
+        $this->_last_stroke_color = $color;
192 191
     }
193 192
 
194
-  }
193
+    }
195 194
 
196
-  /**
197
-   * Sets the fill colour
198
-   *
199
-   * @param array $color
200
-   */
201
-  protected function _set_fill_colour($colour) {
195
+    /**
196
+     * Sets the fill colour
197
+     *
198
+     * @param array $color
199
+     */
200
+    protected function _set_fill_colour($colour) {
202 201
     $colour[0] = round(255 * $colour[0]);
203 202
     $colour[1] = round(255 * $colour[1]);
204 203
     $colour[2] = round(255 * $colour[2]);
205 204
 
206 205
     if ( is_null($this->_last_fill_color) || $color != $this->_last_fill_color ) {
207
-      $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]);
208
-      $this->_last_fill_color = $color;
206
+        $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]);
207
+        $this->_last_fill_color = $color;
209 208
     }
210 209
 
211
-  }
210
+    }
212 211
 
213
-  /**
214
-   * Return the TCPDF instance
215
-   *
216
-   * @return TCPDF
217
-   */
218
-  function get_tcpdf() { return $this->_pdf; }
212
+    /**
213
+     * Return the TCPDF instance
214
+     *
215
+     * @return TCPDF
216
+     */
217
+    function get_tcpdf() { return $this->_pdf; }
219 218
   
220
-  /**
221
-   * Returns the current page number
222
-   *
223
-   * @return int
224
-   */
225
-  function get_page_number() {
219
+    /**
220
+     * Returns the current page number
221
+     *
222
+     * @return int
223
+     */
224
+    function get_page_number() {
226 225
     return $this->_page_number;
227
-  }
228
-
229
-  /**
230
-   * Returns the total number of pages
231
-   *
232
-   * @return int
233
-   */
234
-  function get_page_count() {
226
+    }
227
+
228
+    /**
229
+     * Returns the total number of pages
230
+     *
231
+     * @return int
232
+     */
233
+    function get_page_count() {
235 234
     return $this->_page_count;
236
-  }
237
-
238
-  /**
239
-   * Sets the total number of pages
240
-   *
241
-   * @param int $count
242
-   */
243
-  function set_page_count($count) {
235
+    }
236
+
237
+    /**
238
+     * Sets the total number of pages
239
+     *
240
+     * @param int $count
241
+     */
242
+    function set_page_count($count) {
244 243
     $this->_page_count = (int)$count;
245
-  }
246
-
247
-  /**
248
-   * Draws a line from x1,y1 to x2,y2
249
-   *
250
-   * See {@link Style::munge_colour()} for the format of the colour array.
251
-   * See {@link Cpdf::setLineStyle()} for a description of the format of the
252
-   * $style parameter (aka dash).
253
-   *
254
-   * @param float $x1
255
-   * @param float $y1
256
-   * @param float $x2
257
-   * @param float $y2
258
-   * @param array $color
259
-   * @param float $width
260
-   * @param array $style
261
-   */
262
-  function line($x1, $y1, $x2, $y2, $color, $width, $style = null) {
244
+    }
245
+
246
+    /**
247
+     * Draws a line from x1,y1 to x2,y2
248
+     *
249
+     * See {@link Style::munge_colour()} for the format of the colour array.
250
+     * See {@link Cpdf::setLineStyle()} for a description of the format of the
251
+     * $style parameter (aka dash).
252
+     *
253
+     * @param float $x1
254
+     * @param float $y1
255
+     * @param float $x2
256
+     * @param float $y2
257
+     * @param array $color
258
+     * @param float $width
259
+     * @param array $style
260
+     */
261
+    function line($x1, $y1, $x2, $y2, $color, $width, $style = null) {
263 262
 
264 263
     if ( is_null($this->_last_line_width) || $width != $this->_last_line_width ) {
265
-      $this->_pdf->SetLineWidth($width);
266
-      $this->_last_line_width = $width;
264
+        $this->_pdf->SetLineWidth($width);
265
+        $this->_last_line_width = $width;
267 266
     }
268 267
 
269 268
     $this->_set_stroke_colour($color);
270 269
 
271 270
     // FIXME: ugh, need to handle different styles here
272 271
     $this->_pdf->line($x1, $y1, $x2, $y2);
273
-  }
274
-
275
-  /**
276
-   * Draws a rectangle at x1,y1 with width w and height h
277
-   *
278
-   * See {@link Style::munge_colour()} for the format of the colour array.
279
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
280
-   * parameter (aka dash)
281
-   *
282
-   * @param float $x1
283
-   * @param float $y1
284
-   * @param float $w
285
-   * @param float $h
286
-   * @param array $color
287
-   * @param float $width
288
-   * @param array $style
289
-   */   
290
-  function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) {
272
+    }
273
+
274
+    /**
275
+     * Draws a rectangle at x1,y1 with width w and height h
276
+     *
277
+     * See {@link Style::munge_colour()} for the format of the colour array.
278
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
279
+     * parameter (aka dash)
280
+     *
281
+     * @param float $x1
282
+     * @param float $y1
283
+     * @param float $w
284
+     * @param float $h
285
+     * @param array $color
286
+     * @param float $width
287
+     * @param array $style
288
+     */   
289
+    function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) {
291 290
 
292 291
     if ( is_null($this->_last_line_width) || $width != $this->_last_line_width ) {
293
-      $this->_pdf->SetLineWidth($width);
294
-      $this->_last_line_width = $width;
292
+        $this->_pdf->SetLineWidth($width);
293
+        $this->_last_line_width = $width;
295 294
     }
296 295
 
297 296
     $this->_set_stroke_colour($color);
@@ -299,165 +298,165 @@  discard block
 block discarded – undo
299 298
     // FIXME: ugh, need to handle styles here
300 299
     $this->_pdf->rect($x1, $y1, $w, $h);
301 300
     
302
-  }
303
-
304
-  /**
305
-   * Draws a filled rectangle at x1,y1 with width w and height h
306
-   *
307
-   * See {@link Style::munge_colour()} for the format of the colour array.
308
-   *
309
-   * @param float $x1
310
-   * @param float $y1
311
-   * @param float $w
312
-   * @param float $h
313
-   * @param array $color
314
-   */   
315
-  function filled_rectangle($x1, $y1, $w, $h, $color) {
301
+    }
302
+
303
+    /**
304
+     * Draws a filled rectangle at x1,y1 with width w and height h
305
+     *
306
+     * See {@link Style::munge_colour()} for the format of the colour array.
307
+     *
308
+     * @param float $x1
309
+     * @param float $y1
310
+     * @param float $w
311
+     * @param float $h
312
+     * @param array $color
313
+     */   
314
+    function filled_rectangle($x1, $y1, $w, $h, $color) {
316 315
 
317 316
     $this->_set_fill_colour($color);
318 317
     
319 318
     // FIXME: ugh, need to handle styles here
320 319
     $this->_pdf->rect($x1, $y1, $w, $h, "F");
321
-  }
322
-
323
-  /**
324
-   * Draws a polygon
325
-   *
326
-   * The polygon is formed by joining all the points stored in the $points
327
-   * array.  $points has the following structure:
328
-   * <code>
329
-   * array(0 => x1,
330
-   *       1 => y1,
331
-   *       2 => x2,
332
-   *       3 => y2,
333
-   *       ...
334
-   *       );
335
-   * </code>
336
-   *
337
-   * See {@link Style::munge_colour()} for the format of the colour array.
338
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
339
-   * parameter (aka dash)   
340
-   *
341
-   * @param array $points
342
-   * @param array $color
343
-   * @param float $width
344
-   * @param array $style
345
-   * @param bool  $fill  Fills the polygon if true
346
-   */
347
-  function polygon($points, $color, $width = null, $style = null, $fill = false) {
320
+    }
321
+
322
+    /**
323
+     * Draws a polygon
324
+     *
325
+     * The polygon is formed by joining all the points stored in the $points
326
+     * array.  $points has the following structure:
327
+     * <code>
328
+     * array(0 => x1,
329
+     *       1 => y1,
330
+     *       2 => x2,
331
+     *       3 => y2,
332
+     *       ...
333
+     *       );
334
+     * </code>
335
+     *
336
+     * See {@link Style::munge_colour()} for the format of the colour array.
337
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
338
+     * parameter (aka dash)   
339
+     *
340
+     * @param array $points
341
+     * @param array $color
342
+     * @param float $width
343
+     * @param array $style
344
+     * @param bool  $fill  Fills the polygon if true
345
+     */
346
+    function polygon($points, $color, $width = null, $style = null, $fill = false) {
348 347
     // FIXME: FPDF sucks
349
-  }
350
-
351
-  /**
352
-   * Draws a circle at $x,$y with radius $r
353
-   *
354
-   * See {@link Style::munge_colour()} for the format of the colour array.
355
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
356
-   * parameter (aka dash)
357
-   *
358
-   * @param float $x
359
-   * @param float $y
360
-   * @param float $r
361
-   * @param array $color
362
-   * @param float $width
363
-   * @param array $style
364
-   * @param bool $fill Fills the circle if true   
365
-   */   
366
-  function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false){}
367
-
368
-  /**
369
-   * Add an image to the pdf.
370
-   *
371
-   * The image is placed at the specified x and y coordinates with the
372
-   * given width and height.
373
-   *
374
-   * @param string $img_url the path to the image
375
-   * @param string $img_type the type (e.g. extension) of the image
376
-   * @param float $x x position
377
-   * @param float $y y position
378
-   * @param int $w width (in pixels)
379
-   * @param int $h height (in pixels)
380
-   */
381
-  function image($img_url, $img_type, $x, $y, $w, $h){}
382
-
383
-  /**
384
-   * Writes text at the specified x and y coordinates
385
-   *
386
-   * See {@link Style::munge_colour()} for the format of the colour array.
387
-   *
388
-   * @param float $x
389
-   * @param float $y
390
-   * @param string $text the text to write
391
-   * @param string $font the font file to use
392
-   * @param float $size the font size, in points
393
-   * @param array $color
394
-   * @param float $adjust word spacing adjustment
395
-   */
396
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0){}
397
-
398
-  function javascript($code){}
348
+    }
349
+
350
+    /**
351
+     * Draws a circle at $x,$y with radius $r
352
+     *
353
+     * See {@link Style::munge_colour()} for the format of the colour array.
354
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
355
+     * parameter (aka dash)
356
+     *
357
+     * @param float $x
358
+     * @param float $y
359
+     * @param float $r
360
+     * @param array $color
361
+     * @param float $width
362
+     * @param array $style
363
+     * @param bool $fill Fills the circle if true   
364
+     */   
365
+    function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false){}
366
+
367
+    /**
368
+     * Add an image to the pdf.
369
+     *
370
+     * The image is placed at the specified x and y coordinates with the
371
+     * given width and height.
372
+     *
373
+     * @param string $img_url the path to the image
374
+     * @param string $img_type the type (e.g. extension) of the image
375
+     * @param float $x x position
376
+     * @param float $y y position
377
+     * @param int $w width (in pixels)
378
+     * @param int $h height (in pixels)
379
+     */
380
+    function image($img_url, $img_type, $x, $y, $w, $h){}
381
+
382
+    /**
383
+     * Writes text at the specified x and y coordinates
384
+     *
385
+     * See {@link Style::munge_colour()} for the format of the colour array.
386
+     *
387
+     * @param float $x
388
+     * @param float $y
389
+     * @param string $text the text to write
390
+     * @param string $font the font file to use
391
+     * @param float $size the font size, in points
392
+     * @param array $color
393
+     * @param float $adjust word spacing adjustment
394
+     */
395
+    function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0){}
396
+
397
+    function javascript($code){}
399 398
   
400
-  /**
401
-   * Add a named destination (similar to <a name="foo">...</a> in html)
402
-   *
403
-   * @param string $anchorname The name of the named destination
404
-   */
405
-  function add_named_dest($anchorname){}
406
-
407
-  /**
408
-   * Add a link to the pdf
409
-   *
410
-   * @param string $url The url to link to
411
-   * @param float  $x   The x position of the link
412
-   * @param float  $y   The y position of the link
413
-   * @param float  $width   The width of the link
414
-   * @param float  $height   The height of the link
415
-   */
416
-  function add_link($url, $x, $y, $width, $height){}
399
+    /**
400
+     * Add a named destination (similar to <a name="foo">...</a> in html)
401
+     *
402
+     * @param string $anchorname The name of the named destination
403
+     */
404
+    function add_named_dest($anchorname){}
405
+
406
+    /**
407
+     * Add a link to the pdf
408
+     *
409
+     * @param string $url The url to link to
410
+     * @param float  $x   The x position of the link
411
+     * @param float  $y   The y position of the link
412
+     * @param float  $width   The width of the link
413
+     * @param float  $height   The height of the link
414
+     */
415
+    function add_link($url, $x, $y, $width, $height){}
417 416
   
418
-  /**
419
-   * Calculates text size, in points
420
-   *
421
-   * @param string $text the text to be sized
422
-   * @param string $font the desired font
423
-   * @param float  $size the desired font size
424
-   * @param float  $spacing word spacing, if any
425
-   * @return float
426
-   */
427
-  function get_text_width($text, $font, $size, $spacing = 0){}
428
-
429
-  /**
430
-   * Calculates font height, in points
431
-   *
432
-   * @param string $font
433
-   * @param float $size
434
-   * @return float
435
-   */
436
-  function get_font_height($font, $size){}
417
+    /**
418
+     * Calculates text size, in points
419
+     *
420
+     * @param string $text the text to be sized
421
+     * @param string $font the desired font
422
+     * @param float  $size the desired font size
423
+     * @param float  $spacing word spacing, if any
424
+     * @return float
425
+     */
426
+    function get_text_width($text, $font, $size, $spacing = 0){}
427
+
428
+    /**
429
+     * Calculates font height, in points
430
+     *
431
+     * @param string $font
432
+     * @param float $size
433
+     * @return float
434
+     */
435
+    function get_font_height($font, $size){}
437 436
 
438 437
   
439
-  /**
440
-   * Starts a new page
441
-   *
442
-   * Subsequent drawing operations will appear on the new page.
443
-   */
444
-  function new_page(){}
445
-
446
-  /**
447
-   * Streams the PDF directly to the browser
448
-   *
449
-   * @param string $filename the name of the PDF file
450
-   * @param array  $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0
451
-   */
452
-  function stream($filename, $options = null){}
453
-
454
-  /**
455
-   * Returns the PDF as a string
456
-   *
457
-   * @param array  $options associative array: 'compress' => 1 or 0
458
-   * @return string
459
-   */
460
-  function output($options = null){}
438
+    /**
439
+     * Starts a new page
440
+     *
441
+     * Subsequent drawing operations will appear on the new page.
442
+     */
443
+    function new_page(){}
444
+
445
+    /**
446
+     * Streams the PDF directly to the browser
447
+     *
448
+     * @param string $filename the name of the PDF file
449
+     * @param array  $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0
450
+     */
451
+    function stream($filename, $options = null){}
452
+
453
+    /**
454
+     * Returns the PDF as a string
455
+     *
456
+     * @param array  $options associative array: 'compress' => 1 or 0
457
+     * @return string
458
+     */
459
+    function output($options = null){}
461 460
   
462 461
 }
463 462
     
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 /* $Id: tcpdf_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */
41 41
 
42
-require_once(DOMPDF_LIB_DIR . '/tcpdf/tcpdf.php');
42
+require_once(DOMPDF_LIB_DIR.'/tcpdf/tcpdf.php');
43 43
 
44 44
 /**
45 45
  * TCPDF PDF Rendering interface
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
    */
139 139
   function __construct($paper = "letter", $orientation = "portrait") {
140 140
    
141
-    if ( is_array($paper) )
141
+    if (is_array($paper))
142 142
       $size = $paper;
143
-    else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) )
143
+    else if (isset(self::$PAPER_SIZES[mb_strtolower($paper)]))
144 144
       $size = self::$PAPER_SIZE[$paper];
145 145
     else
146 146
       $size = self::$PAPER_SIZE["letter"];
147 147
 
148
-    if ( mb_strtolower($orientation) === "landscape" ) {
148
+    if (mb_strtolower($orientation) === "landscape") {
149 149
       $a = $size[3];
150 150
       $size[3] = $size[2];
151 151
       $size[2] = $a;
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
     $colour[1] = round(255 * $colour[1]);
187 187
     $colour[2] = round(255 * $colour[2]);
188 188
 
189
-    if ( is_null($this->_last_stroke_color) || $color != $this->_last_stroke_color ) {
190
-      $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]);
189
+    if (is_null($this->_last_stroke_color) || $color != $this->_last_stroke_color) {
190
+      $this->_pdf->SetDrawColor($color[0], $color[1], $color[2]);
191 191
       $this->_last_stroke_color = $color;
192 192
     }
193 193
 
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
     $colour[1] = round(255 * $colour[1]);
204 204
     $colour[2] = round(255 * $colour[2]);
205 205
 
206
-    if ( is_null($this->_last_fill_color) || $color != $this->_last_fill_color ) {
207
-      $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]);
206
+    if (is_null($this->_last_fill_color) || $color != $this->_last_fill_color) {
207
+      $this->_pdf->SetDrawColor($color[0], $color[1], $color[2]);
208 208
       $this->_last_fill_color = $color;
209 209
     }
210 210
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
    * @param int $count
242 242
    */
243 243
   function set_page_count($count) {
244
-    $this->_page_count = (int)$count;
244
+    $this->_page_count = (int) $count;
245 245
   }
246 246
 
247 247
   /**
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
    */
262 262
   function line($x1, $y1, $x2, $y2, $color, $width, $style = null) {
263 263
 
264
-    if ( is_null($this->_last_line_width) || $width != $this->_last_line_width ) {
264
+    if (is_null($this->_last_line_width) || $width != $this->_last_line_width) {
265 265
       $this->_pdf->SetLineWidth($width);
266 266
       $this->_last_line_width = $width;
267 267
     }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
    */   
290 290
   function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) {
291 291
 
292
-    if ( is_null($this->_last_line_width) || $width != $this->_last_line_width ) {
292
+    if (is_null($this->_last_line_width) || $width != $this->_last_line_width) {
293 293
       $this->_pdf->SetLineWidth($width);
294 294
       $this->_last_line_width = $width;
295 295
     }
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
    * @param array $style
364 364
    * @param bool $fill Fills the circle if true   
365 365
    */   
366
-  function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false){}
366
+  function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) {}
367 367
 
368 368
   /**
369 369
    * Add an image to the pdf.
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
    * @param int $w width (in pixels)
379 379
    * @param int $h height (in pixels)
380 380
    */
381
-  function image($img_url, $img_type, $x, $y, $w, $h){}
381
+  function image($img_url, $img_type, $x, $y, $w, $h) {}
382 382
 
383 383
   /**
384 384
    * Writes text at the specified x and y coordinates
@@ -393,16 +393,16 @@  discard block
 block discarded – undo
393 393
    * @param array $color
394 394
    * @param float $adjust word spacing adjustment
395 395
    */
396
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0){}
396
+  function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0) {}
397 397
 
398
-  function javascript($code){}
398
+  function javascript($code) {}
399 399
   
400 400
   /**
401 401
    * Add a named destination (similar to <a name="foo">...</a> in html)
402 402
    *
403 403
    * @param string $anchorname The name of the named destination
404 404
    */
405
-  function add_named_dest($anchorname){}
405
+  function add_named_dest($anchorname) {}
406 406
 
407 407
   /**
408 408
    * Add a link to the pdf
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
    * @param float  $width   The width of the link
414 414
    * @param float  $height   The height of the link
415 415
    */
416
-  function add_link($url, $x, $y, $width, $height){}
416
+  function add_link($url, $x, $y, $width, $height) {}
417 417
   
418 418
   /**
419 419
    * Calculates text size, in points
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
    * @param float  $spacing word spacing, if any
425 425
    * @return float
426 426
    */
427
-  function get_text_width($text, $font, $size, $spacing = 0){}
427
+  function get_text_width($text, $font, $size, $spacing = 0) {}
428 428
 
429 429
   /**
430 430
    * Calculates font height, in points
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
    * @param float $size
434 434
    * @return float
435 435
    */
436
-  function get_font_height($font, $size){}
436
+  function get_font_height($font, $size) {}
437 437
 
438 438
   
439 439
   /**
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
    *
442 442
    * Subsequent drawing operations will appear on the new page.
443 443
    */
444
-  function new_page(){}
444
+  function new_page() {}
445 445
 
446 446
   /**
447 447
    * Streams the PDF directly to the browser
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
    * @param string $filename the name of the PDF file
450 450
    * @param array  $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0
451 451
    */
452
-  function stream($filename, $options = null){}
452
+  function stream($filename, $options = null) {}
453 453
 
454 454
   /**
455 455
    * Returns the PDF as a string
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
    * @param array  $options associative array: 'compress' => 1 or 0
458 458
    * @return string
459 459
    */
460
-  function output($options = null){}
460
+  function output($options = null) {}
461 461
   
462 462
 }
463 463
     
Please login to merge, or discard this patch.
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -138,12 +138,13 @@
 block discarded – undo
138 138
    */
139 139
   function __construct($paper = "letter", $orientation = "portrait") {
140 140
    
141
-    if ( is_array($paper) )
142
-      $size = $paper;
143
-    else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) )
144
-      $size = self::$PAPER_SIZE[$paper];
145
-    else
146
-      $size = self::$PAPER_SIZE["letter"];
141
+    if ( is_array($paper) ) {
142
+          $size = $paper;
143
+    } else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) {
144
+          $size = self::$PAPER_SIZE[$paper];
145
+    } else {
146
+          $size = self::$PAPER_SIZE["letter"];
147
+    }
147 148
 
148 149
     if ( mb_strtolower($orientation) === "landscape" ) {
149 150
       $a = $size[3];
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/lib/class.pdf.php 5 patches
Doc Comments   +90 added lines patch added patch discarded remove patch
@@ -347,6 +347,8 @@  discard block
 block discarded – undo
347 347
 
348 348
   /**
349 349
    *destination object, used to specify the location for the user to jump to, presently on opening
350
+   * @param integer $id
351
+   * @param string $action
350 352
    */
351 353
   protected function  o_destination($id, $action, $options = '') {
352 354
     if  ($action !== 'new') {
@@ -384,6 +386,7 @@  discard block
 block discarded – undo
384 386
 
385 387
   /**
386 388
    * set the viewer preferences
389
+   * @param string $action
387 390
    */
388 391
   protected function  o_viewerPreferences($id, $action, $options = '') {
389 392
     if  ($action !== 'new') {
@@ -424,6 +427,7 @@  discard block
 block discarded – undo
424 427
 
425 428
   /**
426 429
    * define the document catalog, the overall controller for the document
430
+   * @param string $action
427 431
    */
428 432
   protected function  o_catalog($id, $action, $options = '') {
429 433
     if  ($action !== 'new') {
@@ -490,6 +494,8 @@  discard block
 block discarded – undo
490 494
 
491 495
   /**
492 496
    * object which is a parent to the pages in the document
497
+   * @param integer $id
498
+   * @param string $action
493 499
    */
494 500
   protected function  o_pages($id, $action, $options = '') {
495 501
     if  ($action !== 'new') {
@@ -623,6 +629,8 @@  discard block
 block discarded – undo
623 629
 
624 630
   /**
625 631
    * define the outlines in the doc, empty for now
632
+   * @param integer $id
633
+   * @param string $action
626 634
    */
627 635
   protected function  o_outlines($id, $action, $options = '') {
628 636
     if  ($action !== 'new') {
@@ -658,6 +666,8 @@  discard block
 block discarded – undo
658 666
 
659 667
   /**
660 668
    * an object to hold the font description
669
+   * @param integer $id
670
+   * @param string $action
661 671
    */
662 672
   protected function  o_font($id, $action, $options = '') {
663 673
     if  ($action !== 'new') {
@@ -827,6 +837,8 @@  discard block
 block discarded – undo
827 837
 
828 838
   /**
829 839
    * a font descriptor, needed for including additional fonts
840
+   * @param integer $id
841
+   * @param string $action
830 842
    */
831 843
   protected function  o_fontDescriptor($id, $action, $options = '') {
832 844
     if  ($action !== 'new') {
@@ -885,6 +897,8 @@  discard block
 block discarded – undo
885 897
 
886 898
   /**
887 899
    * the font encoding
900
+   * @param integer $id
901
+   * @param string $action
888 902
    */
889 903
   protected function  o_fontEncoding($id, $action, $options = '') {
890 904
     if  ($action !== 'new') {
@@ -930,6 +944,7 @@  discard block
 block discarded – undo
930 944
 
931 945
   /**
932 946
    * a descendent cid font,  needed for unicode fonts
947
+   * @param string $action
933 948
    */
934 949
   protected function  o_fontDescendentCID($id, $action, $options = '') {
935 950
     if  ($action !== 'new') {
@@ -1019,6 +1034,7 @@  discard block
 block discarded – undo
1019 1034
 
1020 1035
   /**
1021 1036
    * a font glyph to character map,  needed for unicode fonts
1037
+   * @param string $action
1022 1038
    */
1023 1039
   protected function  o_fontGIDtoCIDMap($id, $action, $options = '') {
1024 1040
     if  ($action !== 'new') {
@@ -1061,6 +1077,7 @@  discard block
 block discarded – undo
1061 1077
 
1062 1078
   /**
1063 1079
    * the document procset, solves some problems with printing to old PS printers
1080
+   * @param string $action
1064 1081
    */
1065 1082
   protected function  o_procset($id, $action, $options = '') {
1066 1083
     if  ($action !== 'new') {
@@ -1099,6 +1116,7 @@  discard block
 block discarded – undo
1099 1116
 
1100 1117
   /**
1101 1118
    * define the document information
1119
+   * @param integer $id
1102 1120
    */
1103 1121
   protected function  o_info($id, $action, $options = '') {
1104 1122
     if  ($action !== 'new') {
@@ -1151,6 +1169,8 @@  discard block
 block discarded – undo
1151 1169
 
1152 1170
   /**
1153 1171
    * an action object, used to link to URLS initially
1172
+   * @param integer $id
1173
+   * @param string $action
1154 1174
    */
1155 1175
   protected function  o_action($id, $action, $options = '') {
1156 1176
     if  ($action !== 'new') {
@@ -1200,6 +1220,8 @@  discard block
 block discarded – undo
1200 1220
   /**
1201 1221
    * an annotation object, this will add an annotation to the current page.
1202 1222
    * initially will support just link annotations
1223
+   * @param integer $id
1224
+   * @param string $action
1203 1225
    */
1204 1226
   protected function  o_annotation($id, $action, $options = '') {
1205 1227
     if  ($action !== 'new') {
@@ -1258,6 +1280,7 @@  discard block
 block discarded – undo
1258 1280
 
1259 1281
   /**
1260 1282
    * a page object, it also creates a contents object to hold its contents
1283
+   * @param string $action
1261 1284
    */
1262 1285
   protected function  o_page($id, $action, $options = '') {
1263 1286
     if  ($action !== 'new') {
@@ -1342,6 +1365,8 @@  discard block
 block discarded – undo
1342 1365
 
1343 1366
   /**
1344 1367
    * the contents objects hold all of the content which appears on pages
1368
+   * @param integer $id
1369
+   * @param string $action
1345 1370
    */
1346 1371
   protected function  o_contents($id, $action, $options = '') {
1347 1372
     if  ($action !== 'new') {
@@ -1397,6 +1422,10 @@  discard block
 block discarded – undo
1397 1422
     }
1398 1423
   }
1399 1424
 
1425
+  /**
1426
+   * @param integer $id
1427
+   * @param string $action
1428
+   */
1400 1429
   protected function  o_embedjs($id, $action, $code = '') {
1401 1430
     if  ($action !== 'new') {
1402 1431
       $o = & $this->objects[$id];
@@ -1419,6 +1448,10 @@  discard block
 block discarded – undo
1419 1448
     }
1420 1449
   }
1421 1450
   
1451
+  /**
1452
+   * @param integer $id
1453
+   * @param string $action
1454
+   */
1422 1455
   protected function  o_javascript($id, $action, $code = '') {
1423 1456
     if  ($action !== 'new') {
1424 1457
       $o = & $this->objects[$id];
@@ -1444,6 +1477,8 @@  discard block
 block discarded – undo
1444 1477
 
1445 1478
   /**
1446 1479
    * an image object, will be an XObject in the document, includes description and data
1480
+   * @param integer $id
1481
+   * @param string $action
1447 1482
    */
1448 1483
   protected function  o_image($id, $action, $options = '') {
1449 1484
     if  ($action !== 'new') {
@@ -1561,6 +1596,8 @@  discard block
 block discarded – undo
1561 1596
 
1562 1597
   /**
1563 1598
    * graphics state object
1599
+   * @param integer $id
1600
+   * @param string $action
1564 1601
    */
1565 1602
   protected function  o_extGState($id,  $action,  $options = "") {
1566 1603
     static  $valid_params =  array("LW",  "LC",  "LC",  "LJ",  "ML",
@@ -1604,6 +1641,8 @@  discard block
 block discarded – undo
1604 1641
 
1605 1642
   /**
1606 1643
    * encryption object.
1644
+   * @param integer $id
1645
+   * @param string $action
1607 1646
    */
1608 1647
   protected function  o_encryption($id, $action, $options = '') {
1609 1648
     if  ($action !== 'new') {
@@ -1679,6 +1718,7 @@  discard block
 block discarded – undo
1679 1718
 
1680 1719
   /**
1681 1720
    * calculate the 16 byte version of the 128 bit md5 digest of the string
1721
+   * @param string $string
1682 1722
    */
1683 1723
   function  md5_16($string) {
1684 1724
     $tmp =  md5($string);
@@ -1765,6 +1805,11 @@  discard block
 block discarded – undo
1765 1805
 
1766 1806
   /**
1767 1807
    * add a link in the document to an external URL
1808
+   * @param string $url
1809
+   * @param double $x0
1810
+   * @param double $y0
1811
+   * @param double $x1
1812
+   * @param double $y1
1768 1813
    */
1769 1814
   function  addLink($url, $x0, $y0, $x1, $y1) {
1770 1815
     $this->numObj++;
@@ -1775,6 +1820,11 @@  discard block
 block discarded – undo
1775 1820
 
1776 1821
   /**
1777 1822
    * add a link in the document to an internal destination (ie. within the document)
1823
+   * @param string $label
1824
+   * @param double $x0
1825
+   * @param double $y0
1826
+   * @param double $x1
1827
+   * @param double $y1
1778 1828
    */
1779 1829
   function  addInternalLink($label, $x0, $y0, $x1, $y1) {
1780 1830
     $this->numObj++;
@@ -2561,6 +2611,10 @@  discard block
 block discarded – undo
2561 2611
 
2562 2612
   /**
2563 2613
    * draw a line from one set of coordinates to another
2614
+   * @param double $x1
2615
+   * @param double $y1
2616
+   * @param double $x2
2617
+   * @param double $y2
2564 2618
    */
2565 2619
   function  line($x1, $y1, $x2, $y2) {
2566 2620
     $this->objects[$this->currentContents]['c'] .=
@@ -2735,6 +2789,7 @@  discard block
 block discarded – undo
2735 2789
 
2736 2790
   /**
2737 2791
    * draw a polygon, the syntax for this is similar to the GD polygon command
2792
+   * @param integer $np
2738 2793
    */
2739 2794
   function  polygon($p, $np, $f =  0) {
2740 2795
     $this->objects[$this->currentContents]['c'].=  "\n";
@@ -2755,6 +2810,10 @@  discard block
 block discarded – undo
2755 2810
   /**
2756 2811
    * a filled rectangle, note that it is the width and height of the rectangle which are the secondary paramaters, not
2757 2812
    * the coordinates of the upper-right corner
2813
+   * @param double $x1
2814
+   * @param double $y1
2815
+   * @param double $width
2816
+   * @param double $height
2758 2817
    */
2759 2818
   function  filledRectangle($x1, $y1, $width, $height) {
2760 2819
     $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1) .' '.sprintf('%.3F', $width) .' '.sprintf('%.3F', $height) .' re f';
@@ -2764,6 +2823,10 @@  discard block
 block discarded – undo
2764 2823
   /**
2765 2824
    * draw a rectangle, note that it is the width and height of the rectangle which are the secondary paramaters, not
2766 2825
    * the coordinates of the upper-right corner
2826
+   * @param double $x1
2827
+   * @param double $y1
2828
+   * @param double $width
2829
+   * @param double $height
2767 2830
    */
2768 2831
   function  rectangle($x1, $y1, $width, $height) {
2769 2832
     $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1) .' '.sprintf('%.3F', $width) .' '.sprintf('%.3F', $height) .' re S';
@@ -2875,6 +2938,7 @@  discard block
 block discarded – undo
2875 2938
 
2876 2939
   /**
2877 2940
    * return the height in units of the current font in the given size
2941
+   * @param double $size
2878 2942
    */
2879 2943
   function  getFontHeight($size) {
2880 2944
     if  (!$this->numFonts) {
@@ -3064,6 +3128,8 @@  discard block
 block discarded – undo
3064 3128
    * on the page the text will end
3065 3129
    *
3066 3130
    * @access private
3131
+   * @param integer $angle
3132
+   * @param integer $wa
3067 3133
    */
3068 3134
   function  PRVTgetTextPosition($x, $y, $angle, $size, $wa, $text) {
3069 3135
     // given this information return an array containing x and y for the end position as elements 0 and 1
@@ -3468,6 +3534,8 @@  discard block
 block discarded – undo
3468 3534
    * do a part of the calculation for sorting out the justification of the text
3469 3535
    *
3470 3536
    * @access private
3537
+   * @param integer $adjust
3538
+   * @param string $justification
3471 3539
    */
3472 3540
   function  PRVTadjustWrapText($text, $actual, $width, &$x, &$adjust, $justification) {
3473 3541
     switch  ($justification) {
@@ -3717,6 +3785,7 @@  discard block
 block discarded – undo
3717 3785
 
3718 3786
   /**
3719 3787
    * open an existing object for editing
3788
+   * @param integer $id
3720 3789
    */
3721 3790
   function  reopenObject($id) {
3722 3791
     $this->nStack++;
@@ -3748,6 +3817,7 @@  discard block
 block discarded – undo
3748 3817
 
3749 3818
   /**
3750 3819
    * stop an object from appearing on pages from this point on
3820
+   * @param integer $id
3751 3821
    */
3752 3822
   function  stopObject($id) {
3753 3823
     // if an object has been appearing on pages up to now, then stop it, this page will
@@ -3760,6 +3830,7 @@  discard block
 block discarded – undo
3760 3830
 
3761 3831
   /**
3762 3832
    * after an object has been created, it wil only show if it has been added, using this function.
3833
+   * @param integer $id
3763 3834
    */
3764 3835
   function  addObject($id, $options =  'add') {
3765 3836
     // add the specified object to the page
@@ -3835,6 +3906,7 @@  discard block
 block discarded – undo
3835 3906
 
3836 3907
   /**
3837 3908
    * add content to the documents info object
3909
+   * @param string $label
3838 3910
    */
3839 3911
   function  addInfo($label, $value =  0) {
3840 3912
     // this will only work if the label is one of the valid ones.
@@ -3870,6 +3942,8 @@  discard block
 block discarded – undo
3870 3942
    * extract an integer from a position in a byte stream
3871 3943
    *
3872 3944
    * @access private
3945
+   * @param integer $pos
3946
+   * @param integer $num
3873 3947
    */
3874 3948
   function  PRVT_getBytes(&$data, $pos, $num) {
3875 3949
     // return the integer represented by $num bytes from $pos within $data
@@ -3936,6 +4010,9 @@  discard block
 block discarded – undo
3936 4010
   /**
3937 4011
    * add a PNG image into the document, from a file
3938 4012
    * this should work with remote files
4013
+   * @param string $file
4014
+   * @param double $x
4015
+   * @param double $y
3939 4016
    */
3940 4017
   function  addPngFromFile($file, $x, $y, $w =  0, $h =  0) {
3941 4018
     //if already cached, need not to read again
@@ -3978,6 +4055,7 @@  discard block
 block discarded – undo
3978 4055
 
3979 4056
   /**
3980 4057
    * add a PNG image into the document, from a memory buffer of the file
4058
+   * @param null|string $data
3981 4059
    */
3982 4060
   function  addPngFromBuf($file, $x, $y, $w =  0, $h =  0, &$data) {
3983 4061
 	if ( isset($this->imagelist[$file]) ) {
@@ -4231,6 +4309,9 @@  discard block
 block discarded – undo
4231 4309
 
4232 4310
   /**
4233 4311
    * add a JPEG image into the document, from a file
4312
+   * @param string $img
4313
+   * @param double $x
4314
+   * @param double $y
4234 4315
    */
4235 4316
   function  addJpegFromFile($img, $x, $y, $w =  0, $h =  0) {
4236 4317
     // attempt to add a jpeg image straight from a file, using no GD commands
@@ -4336,6 +4417,10 @@  discard block
 block discarded – undo
4336 4417
   /* Check if image already added to pdf image directory.
4337 4418
    * If yes, need not to create again (pass empty data)
4338 4419
    */
4420
+
4421
+  /**
4422
+   * @param string $imgname
4423
+   */
4339 4424
   function  image_iscached($imgname) {
4340 4425
     return isset($this->imagelist[$imgname]);
4341 4426
   }
@@ -4345,6 +4430,7 @@  discard block
 block discarded – undo
4345 4430
    * common code used by the two JPEG adding functions
4346 4431
    *
4347 4432
    * @access private
4433
+   * @param null|string $data
4348 4434
    */
4349 4435
   function  addJpegImage_common(&$data, $x, $y, $w =  0, $h =  0, $imageWidth, $imageHeight, $channels =  3, $imgname) {
4350 4436
     if ( isset($this->imagelist[$imgname]) ) {
@@ -4377,6 +4463,7 @@  discard block
 block discarded – undo
4377 4463
 
4378 4464
   /**
4379 4465
    * specify where the document should open when it first starts
4466
+   * @param string $style
4380 4467
    */
4381 4468
   function  openHere($style, $a =  0, $b =  0, $c =  0) {
4382 4469
     // this function will open the document at a specified page, in a specified style
@@ -4402,6 +4489,8 @@  discard block
 block discarded – undo
4402 4489
 
4403 4490
   /**
4404 4491
    * create a labelled destination within the document
4492
+   * @param string $label
4493
+   * @param string $style
4405 4494
    */
4406 4495
   function  addDestination($label, $style, $a =  0, $b =  0, $c =  0) {
4407 4496
     // associates the given label with the destination, it is done this way so that a destination can be specified after
@@ -4420,6 +4509,7 @@  discard block
 block discarded – undo
4420 4509
    * define font families, this is used to initialize the font families for the default fonts
4421 4510
    * and for the user to add new ones for their fonts. The default bahavious can be overridden should
4422 4511
    * that be desired.
4512
+   * @param string $family
4423 4513
    */
4424 4514
   function  setFontFamily($family, $options =  '') {
4425 4515
     if  (!is_array($options)) {
Please login to merge, or discard this patch.
Indentation   +2039 added lines, -2039 removed lines patch added patch discarded remove patch
@@ -1,324 +1,324 @@  discard block
 block discarded – undo
1 1
 <?php
2
-  /**
3
-   * Cpdf
4
-   *
5
-   * http://www.ros.co.nz/pdf
6
-   *
7
-   * A PHP class to provide the basic functionality to create a pdf document without
8
-   * any requirement for additional modules.
9
-   *
10
-   * Note that the companion class CezPdf can be used to extend this class and dramatically
11
-   * simplify the creation of documents.
12
-   *
13
-   * Extended by Orion Richardson to support Unicode / UTF-8 characters using
14
-   * TCPDF and others as a guide.
15
-   *
16
-   * IMPORTANT NOTE
17
-   * there is no warranty, implied or otherwise with this software.
18
-   *
19
-   * LICENCE
20
-   * This code has been placed in the Public Domain for all to enjoy.
21
-   *
22
-   * @author       Wayne Munro <[email protected]>
23
-   * @contributor  Orion Richardson <[email protected]>
24
-   * @contributor  Helmut Tischer <[email protected]>
25
-   * @contributor  Ryan H. Masten <[email protected]>
26
-   * @version  009
27
-   * @package  Cpdf
28
-   *
29
-   * Changes
30
-   * @contributor Helmut Tischer <[email protected]>
31
-   * @version 0.5.1.htischer.20090507
32
-   * - On multiple identical png and jpg images, put only one copy into the pdf file and refer to it.
33
-   *   This reduces file size and rendering time.
34
-   * - Allow font metrics cache to be a different folder as the font metrics. This allows a read only installation.
35
-   * - Allow adding images directly from a gd object. This increases performance by avoiding temporary files.
36
-   * - On png image files remove alpa channel to allow display of typical png files in pdf.
37
-   * - On addImage avoid temporary file. Todo: Duplicate Image (currently not used)
38
-   * - Add a check function, whether image is already cached, This avoids double creation by caller which saves
39
-   *   CPU time and memory.
40
-   * @contributor Helmut Tischer <[email protected]>
41
-   * @version dompdf_trunk_with_helmut_mods.20090524
42
-   * - Allow temp and fontcache folders to be passed in by class creator
43
-   * @version dompdf_trunk_with_helmut_mods.20090528
44
-   * - typo 'decent' instead of 'descent' at various locations made getFontDescender worthless
45
-   */
2
+    /**
3
+     * Cpdf
4
+     *
5
+     * http://www.ros.co.nz/pdf
6
+     *
7
+     * A PHP class to provide the basic functionality to create a pdf document without
8
+     * any requirement for additional modules.
9
+     *
10
+     * Note that the companion class CezPdf can be used to extend this class and dramatically
11
+     * simplify the creation of documents.
12
+     *
13
+     * Extended by Orion Richardson to support Unicode / UTF-8 characters using
14
+     * TCPDF and others as a guide.
15
+     *
16
+     * IMPORTANT NOTE
17
+     * there is no warranty, implied or otherwise with this software.
18
+     *
19
+     * LICENCE
20
+     * This code has been placed in the Public Domain for all to enjoy.
21
+     *
22
+     * @author       Wayne Munro <[email protected]>
23
+     * @contributor  Orion Richardson <[email protected]>
24
+     * @contributor  Helmut Tischer <[email protected]>
25
+     * @contributor  Ryan H. Masten <[email protected]>
26
+     * @version  009
27
+     * @package  Cpdf
28
+     *
29
+     * Changes
30
+     * @contributor Helmut Tischer <[email protected]>
31
+     * @version 0.5.1.htischer.20090507
32
+     * - On multiple identical png and jpg images, put only one copy into the pdf file and refer to it.
33
+     *   This reduces file size and rendering time.
34
+     * - Allow font metrics cache to be a different folder as the font metrics. This allows a read only installation.
35
+     * - Allow adding images directly from a gd object. This increases performance by avoiding temporary files.
36
+     * - On png image files remove alpa channel to allow display of typical png files in pdf.
37
+     * - On addImage avoid temporary file. Todo: Duplicate Image (currently not used)
38
+     * - Add a check function, whether image is already cached, This avoids double creation by caller which saves
39
+     *   CPU time and memory.
40
+     * @contributor Helmut Tischer <[email protected]>
41
+     * @version dompdf_trunk_with_helmut_mods.20090524
42
+     * - Allow temp and fontcache folders to be passed in by class creator
43
+     * @version dompdf_trunk_with_helmut_mods.20090528
44
+     * - typo 'decent' instead of 'descent' at various locations made getFontDescender worthless
45
+     */
46 46
 
47 47
 /* $Id: class.pdf.php 217 2010-03-11 23:03:57Z ryan.masten $ */
48 48
 
49 49
 class  Cpdf {
50 50
 
51 51
 
52
-  /**
53
-   * the current number of pdf objects in the document
54
-   */
55
-  public  $numObj = 0;
52
+    /**
53
+     * the current number of pdf objects in the document
54
+     */
55
+    public  $numObj = 0;
56 56
 
57
-  /**
58
-   * this array contains all of the pdf objects, ready for final assembly
59
-   */
60
-  public  $objects =  array();
57
+    /**
58
+     * this array contains all of the pdf objects, ready for final assembly
59
+     */
60
+    public  $objects =  array();
61 61
 
62
-  /**
63
-   * the objectId (number within the objects array) of the document catalog
64
-   */
65
-  public  $catalogId;
62
+    /**
63
+     * the objectId (number within the objects array) of the document catalog
64
+     */
65
+    public  $catalogId;
66 66
 
67
-  /**
68
-   * array carrying information about the fonts that the system currently knows about
69
-   * used to ensure that a font is not loaded twice, among other things
70
-   */
71
-  public  $fonts = array();
67
+    /**
68
+     * array carrying information about the fonts that the system currently knows about
69
+     * used to ensure that a font is not loaded twice, among other things
70
+     */
71
+    public  $fonts = array();
72 72
   
73
-  /**
74
-   * the default font metrics file to use if no other font has been loaded
75
-   * the path to the directory containing the font metrics should be included
76
-   */
77
-  public  $defaultFont = './fonts/Helvetica.afm';
73
+    /**
74
+     * the default font metrics file to use if no other font has been loaded
75
+     * the path to the directory containing the font metrics should be included
76
+     */
77
+    public  $defaultFont = './fonts/Helvetica.afm';
78 78
   
79
-  /**
80
-   * a record of the current font
81
-   */
82
-  public  $currentFont = '';
79
+    /**
80
+     * a record of the current font
81
+     */
82
+    public  $currentFont = '';
83 83
 
84
-  /**
85
-   * the current base font
86
-   */
87
-  public  $currentBaseFont = '';
84
+    /**
85
+     * the current base font
86
+     */
87
+    public  $currentBaseFont = '';
88 88
 
89
-  /**
90
-   * the number of the current font within the font array
91
-   */
92
-  public  $currentFontNum = 0;
89
+    /**
90
+     * the number of the current font within the font array
91
+     */
92
+    public  $currentFontNum = 0;
93 93
 
94
-  /**
95
-   *
96
-   */
97
-  public  $currentNode;
94
+    /**
95
+     *
96
+     */
97
+    public  $currentNode;
98 98
 
99
-  /**
100
-   * object number of the current page
101
-   */
102
-  public  $currentPage;
99
+    /**
100
+     * object number of the current page
101
+     */
102
+    public  $currentPage;
103 103
 
104
-  /**
105
-   * object number of the currently active contents block
106
-   */
107
-  public  $currentContents;
104
+    /**
105
+     * object number of the currently active contents block
106
+     */
107
+    public  $currentContents;
108 108
 
109
-  /**
110
-   * number of fonts within the system
111
-   */
112
-  public  $numFonts = 0;
109
+    /**
110
+     * number of fonts within the system
111
+     */
112
+    public  $numFonts = 0;
113 113
 
114
-  /**
115
-   * Number of graphic state resources used
116
-   */
117
-  private  $numStates =  0;
114
+    /**
115
+     * Number of graphic state resources used
116
+     */
117
+    private  $numStates =  0;
118 118
 
119 119
 
120
-  /**
121
-   * current colour for fill operations, defaults to inactive value, all three components should be between 0 and 1 inclusive when active
122
-   */
123
-  public  $currentColour = array('r'=>-1, 'g'=>-1, 'b'=>-1);
120
+    /**
121
+     * current colour for fill operations, defaults to inactive value, all three components should be between 0 and 1 inclusive when active
122
+     */
123
+    public  $currentColour = array('r'=>-1, 'g'=>-1, 'b'=>-1);
124 124
 
125
-  /**
126
-   * current colour for stroke operations (lines etc.)
127
-   */
128
-  public  $currentStrokeColour = array('r'=>-1, 'g'=>-1, 'b'=>-1);
125
+    /**
126
+     * current colour for stroke operations (lines etc.)
127
+     */
128
+    public  $currentStrokeColour = array('r'=>-1, 'g'=>-1, 'b'=>-1);
129 129
 
130
-  /**
131
-   * current style that lines are drawn in
132
-   */
133
-  public  $currentLineStyle = '';
130
+    /**
131
+     * current style that lines are drawn in
132
+     */
133
+    public  $currentLineStyle = '';
134 134
 
135
-  /**
136
-   * current line transparency (partial graphics state)
137
-   */
138
-  public $currentLineTransparency = array("mode" => "Normal", "opacity" => 1.0);
135
+    /**
136
+     * current line transparency (partial graphics state)
137
+     */
138
+    public $currentLineTransparency = array("mode" => "Normal", "opacity" => 1.0);
139 139
   
140
-  /**
141
-   * current fill transparency (partial graphics state)
142
-   */
143
-  public $currentFillTransparency = array("mode" => "Normal", "opacity" => 1.0);
140
+    /**
141
+     * current fill transparency (partial graphics state)
142
+     */
143
+    public $currentFillTransparency = array("mode" => "Normal", "opacity" => 1.0);
144 144
   
145
-  /**
146
-   * an array which is used to save the state of the document, mainly the colours and styles
147
-   * it is used to temporarily change to another state, the change back to what it was before
148
-   */
149
-  public  $stateStack =  array();
145
+    /**
146
+     * an array which is used to save the state of the document, mainly the colours and styles
147
+     * it is used to temporarily change to another state, the change back to what it was before
148
+     */
149
+    public  $stateStack =  array();
150 150
 
151
-  /**
152
-   * number of elements within the state stack
153
-   */
154
-  public  $nStateStack =  0;
151
+    /**
152
+     * number of elements within the state stack
153
+     */
154
+    public  $nStateStack =  0;
155 155
 
156
-  /**
157
-   * number of page objects within the document
158
-   */
159
-  public  $numPages = 0;
156
+    /**
157
+     * number of page objects within the document
158
+     */
159
+    public  $numPages = 0;
160 160
 
161
-  /**
162
-   * object Id storage stack
163
-   */
164
-  public  $stack = array();
161
+    /**
162
+     * object Id storage stack
163
+     */
164
+    public  $stack = array();
165 165
 
166
-  /**
167
-   * number of elements within the object Id storage stack
168
-   */
169
-  public  $nStack = 0;
166
+    /**
167
+     * number of elements within the object Id storage stack
168
+     */
169
+    public  $nStack = 0;
170 170
 
171
-  /**
172
-   * an array which contains information about the objects which are not firmly attached to pages
173
-   * these have been added with the addObject function
174
-   */
175
-  public  $looseObjects = array();
171
+    /**
172
+     * an array which contains information about the objects which are not firmly attached to pages
173
+     * these have been added with the addObject function
174
+     */
175
+    public  $looseObjects = array();
176 176
 
177
-  /**
178
-   * array contains infomation about how the loose objects are to be added to the document
179
-   */
180
-  public  $addLooseObjects = array();
177
+    /**
178
+     * array contains infomation about how the loose objects are to be added to the document
179
+     */
180
+    public  $addLooseObjects = array();
181 181
 
182
-  /**
183
-   * the objectId of the information object for the document
184
-   * this contains authorship, title etc.
185
-   */
186
-  public  $infoObject = 0;
182
+    /**
183
+     * the objectId of the information object for the document
184
+     * this contains authorship, title etc.
185
+     */
186
+    public  $infoObject = 0;
187 187
 
188
-  /**
189
-   * number of images being tracked within the document
190
-   */
191
-  public  $numImages = 0;
188
+    /**
189
+     * number of images being tracked within the document
190
+     */
191
+    public  $numImages = 0;
192 192
 
193
-  /**
194
-   * an array containing options about the document
195
-   * it defaults to turning on the compression of the objects
196
-   */
197
-  public  $options = array('compression'=>1);
193
+    /**
194
+     * an array containing options about the document
195
+     * it defaults to turning on the compression of the objects
196
+     */
197
+    public  $options = array('compression'=>1);
198 198
 
199
-  /**
200
-   * the objectId of the first page of the document
201
-   */
202
-  public  $firstPageId;
199
+    /**
200
+     * the objectId of the first page of the document
201
+     */
202
+    public  $firstPageId;
203 203
 
204
-  /**
205
-   * used to track the last used value of the inter-word spacing, this is so that it is known
206
-   * when the spacing is changed.
207
-   */
208
-  public  $wordSpaceAdjust = 0;
204
+    /**
205
+     * used to track the last used value of the inter-word spacing, this is so that it is known
206
+     * when the spacing is changed.
207
+     */
208
+    public  $wordSpaceAdjust = 0;
209 209
 
210
-  /**
211
-   * the object Id of the procset object
212
-   */
213
-  public  $procsetObjectId;
210
+    /**
211
+     * the object Id of the procset object
212
+     */
213
+    public  $procsetObjectId;
214 214
 
215
-  /**
216
-   * store the information about the relationship between font families
217
-   * this used so that the code knows which font is the bold version of another font, etc.
218
-   * the value of this array is initialised in the constuctor function.
219
-   */
220
-  public  $fontFamilies =  array();
215
+    /**
216
+     * store the information about the relationship between font families
217
+     * this used so that the code knows which font is the bold version of another font, etc.
218
+     * the value of this array is initialised in the constuctor function.
219
+     */
220
+    public  $fontFamilies =  array();
221 221
  
222
-  /**
223
-   * folder for php serialized formats of font metrics files.
224
-   * If empty string, use same folder as original metrics files.
225
-   * This can be passed in from class creator.
226
-   * If this folder does not exist or is not writable, Cpdf will be **much** slower.
227
-   * Because of potential trouble with php safe mode, folder cannot be created at runtime.
228
-   */
229
-  public  $fontcache = '';
222
+    /**
223
+     * folder for php serialized formats of font metrics files.
224
+     * If empty string, use same folder as original metrics files.
225
+     * This can be passed in from class creator.
226
+     * If this folder does not exist or is not writable, Cpdf will be **much** slower.
227
+     * Because of potential trouble with php safe mode, folder cannot be created at runtime.
228
+     */
229
+    public  $fontcache = '';
230 230
   
231
-  /**
232
-   * The version of the font metrics cache file.
233
-   * This value must be manually incremented whenever the internal font data structure is modified.
234
-   */
235
-  public  $fontcacheVersion = 2;
231
+    /**
232
+     * The version of the font metrics cache file.
233
+     * This value must be manually incremented whenever the internal font data structure is modified.
234
+     */
235
+    public  $fontcacheVersion = 2;
236 236
 
237
-  /**
238
-   * temporary folder.
239
-   * If empty string, will attempty system tmp folder.
240
-   * This can be passed in from class creator.
241
-   * Only used for conversion of gd images to jpeg images.
242
-   */
243
-  public  $tmp = '';
237
+    /**
238
+     * temporary folder.
239
+     * If empty string, will attempty system tmp folder.
240
+     * This can be passed in from class creator.
241
+     * Only used for conversion of gd images to jpeg images.
242
+     */
243
+    public  $tmp = '';
244 244
 
245
-  /**
246
-   * track if the current font is bolded or italicised
247
-   */
248
-  public  $currentTextState =  '';
245
+    /**
246
+     * track if the current font is bolded or italicised
247
+     */
248
+    public  $currentTextState =  '';
249 249
 
250
-  /**
251
-   * messages are stored here during processing, these can be selected afterwards to give some useful debug information
252
-   */
253
-  public  $messages = '';
250
+    /**
251
+     * messages are stored here during processing, these can be selected afterwards to give some useful debug information
252
+     */
253
+    public  $messages = '';
254 254
 
255
-  /**
256
-   * the ancryption array for the document encryption is stored here
257
-   */
258
-  public  $arc4 = '';
255
+    /**
256
+     * the ancryption array for the document encryption is stored here
257
+     */
258
+    public  $arc4 = '';
259 259
 
260
-  /**
261
-   * the object Id of the encryption information
262
-   */
263
-  public  $arc4_objnum = 0;
260
+    /**
261
+     * the object Id of the encryption information
262
+     */
263
+    public  $arc4_objnum = 0;
264 264
 
265
-  /**
266
-   * the file identifier, used to uniquely identify a pdf document
267
-   */
268
-  public  $fileIdentifier = '';
265
+    /**
266
+     * the file identifier, used to uniquely identify a pdf document
267
+     */
268
+    public  $fileIdentifier = '';
269 269
 
270
-  /**
271
-   * a flag to say if a document is to be encrypted or not
272
-   */
273
-  public  $encrypted = 0;
270
+    /**
271
+     * a flag to say if a document is to be encrypted or not
272
+     */
273
+    public  $encrypted = 0;
274 274
 
275
-  /**
276
-   * the ancryption key for the encryption of all the document content (structure is not encrypted)
277
-   */
278
-  public  $encryptionKey = '';
275
+    /**
276
+     * the ancryption key for the encryption of all the document content (structure is not encrypted)
277
+     */
278
+    public  $encryptionKey = '';
279 279
 
280
-  /**
281
-   * array which forms a stack to keep track of nested callback functions
282
-   */
283
-  public  $callback =  array();
280
+    /**
281
+     * array which forms a stack to keep track of nested callback functions
282
+     */
283
+    public  $callback =  array();
284 284
 
285
-  /**
286
-   * the number of callback functions in the callback array
287
-   */
288
-  public  $nCallback =  0;
285
+    /**
286
+     * the number of callback functions in the callback array
287
+     */
288
+    public  $nCallback =  0;
289 289
 
290
-  /**
291
-   * store label->id pairs for named destinations, these will be used to replace internal links
292
-   * done this way so that destinations can be defined after the location that links to them
293
-   */
294
-  public  $destinations =  array();
290
+    /**
291
+     * store label->id pairs for named destinations, these will be used to replace internal links
292
+     * done this way so that destinations can be defined after the location that links to them
293
+     */
294
+    public  $destinations =  array();
295 295
 
296
-  /**
297
-   * store the stack for the transaction commands, each item in here is a record of the values of all the
298
-   * publiciables within the class, so that the user can rollback at will (from each 'start' command)
299
-   * note that this includes the objects array, so these can be large.
300
-   */
301
-  public  $checkpoint =  '';
296
+    /**
297
+     * store the stack for the transaction commands, each item in here is a record of the values of all the
298
+     * publiciables within the class, so that the user can rollback at will (from each 'start' command)
299
+     * note that this includes the objects array, so these can be large.
300
+     */
301
+    public  $checkpoint =  '';
302 302
 
303
-  /* Table of Image origin filenames and image labels which were already added with o_image().
303
+    /* Table of Image origin filenames and image labels which were already added with o_image().
304 304
    * Allows to merge identical images
305 305
    */
306
-  public  $imagelist = array();
306
+    public  $imagelist = array();
307 307
 
308
-  /**
309
-   * whether the text passed in should be treated as Unicode or just local character set.
310
-   */
311
-  public  $isUnicode = false;
308
+    /**
309
+     * whether the text passed in should be treated as Unicode or just local character set.
310
+     */
311
+    public  $isUnicode = false;
312 312
   
313
-  public  $javascript = '';
313
+    public  $javascript = '';
314 314
 
315
-  /**
316
-   * class constructor
317
-   * this will start a new document
318
-   * @var array array of 4 numbers, defining the bottom left and upper right corner of the page. first two are normally zero.
319
-   * @var boolean whether text will be treated as Unicode or not.
320
-   */
321
-  function  Cpdf ($pageSize = array(0, 0, 612, 792), $isUnicode = false, $fontcache = '', $tmp = '') {
315
+    /**
316
+     * class constructor
317
+     * this will start a new document
318
+     * @var array array of 4 numbers, defining the bottom left and upper right corner of the page. first two are normally zero.
319
+     * @var boolean whether text will be treated as Unicode or not.
320
+     */
321
+    function  Cpdf ($pageSize = array(0, 0, 612, 792), $isUnicode = false, $fontcache = '', $tmp = '') {
322 322
     $this->isUnicode = $isUnicode;
323 323
     $this->fontcache = $fontcache;
324 324
     $this->tmp = $tmp;
@@ -327,73 +327,73 @@  discard block
 block discarded – undo
327 327
     // also initialize the font families that are known about already
328 328
     $this->setFontFamily('init');
329 329
     //  $this->fileIdentifier = md5('xxxxxxxx'.time());
330
-  }
331
-
332
-
333
-  /**
334
-   * Document object methods (internal use only)
335
-   *
336
-   * There is about one object method for each type of object in the pdf document
337
-   * Each function has the same call list ($id,$action,$options).
338
-   * $id = the object ID of the object, or what it is to be if it is being created
339
-   * $action = a string specifying the action to be performed, though ALL must support:
340
-   *           'new' - create the object with the id $id
341
-   *           'out' - produce the output for the pdf object
342
-   * $options = optional, a string or array containing the various parameters for the object
343
-   *
344
-   * These, in conjunction with the output function are the ONLY way for output to be produced
345
-   * within the pdf 'file'.
346
-   */
330
+    }
347 331
 
348
-  /**
349
-   *destination object, used to specify the location for the user to jump to, presently on opening
350
-   */
351
-  protected function  o_destination($id, $action, $options = '') {
332
+
333
+    /**
334
+     * Document object methods (internal use only)
335
+     *
336
+     * There is about one object method for each type of object in the pdf document
337
+     * Each function has the same call list ($id,$action,$options).
338
+     * $id = the object ID of the object, or what it is to be if it is being created
339
+     * $action = a string specifying the action to be performed, though ALL must support:
340
+     *           'new' - create the object with the id $id
341
+     *           'out' - produce the output for the pdf object
342
+     * $options = optional, a string or array containing the various parameters for the object
343
+     *
344
+     * These, in conjunction with the output function are the ONLY way for output to be produced
345
+     * within the pdf 'file'.
346
+     */
347
+
348
+    /**
349
+     *destination object, used to specify the location for the user to jump to, presently on opening
350
+     */
351
+    protected function  o_destination($id, $action, $options = '') {
352 352
     if  ($action !== 'new') {
353
-      $o = & $this->objects[$id];
353
+        $o = & $this->objects[$id];
354 354
     }
355 355
 
356 356
     switch ($action) {
357 357
     case  'new':
358 358
       $this->objects[$id] = array('t'=>'destination', 'info'=>array());
359
-      $tmp =  '';
360
-      switch  ($options['type']) {
361
-      case  'XYZ':
359
+        $tmp =  '';
360
+        switch  ($options['type']) {
361
+        case  'XYZ':
362 362
       case  'FitR':
363 363
         $tmp =   ' '.$options['p3'].$tmp;
364
-      case  'FitH':
364
+        case  'FitH':
365 365
       case  'FitV':
366 366
       case  'FitBH':
367 367
       case  'FitBV':
368 368
         $tmp =   ' '.$options['p1'].' '.$options['p2'].$tmp;
369
-      case  'Fit':
369
+        case  'Fit':
370 370
       case  'FitB':
371 371
         $tmp =   $options['type'].$tmp;
372 372
         $this->objects[$id]['info']['string'] = $tmp;
373 373
         $this->objects[$id]['info']['page'] = $options['page'];
374
-      }
375
-      break;
374
+        }
375
+        break;
376 376
 
377 377
     case  'out':
378 378
       $tmp =  $o['info'];
379
-      $res = "\n".$id." 0 obj\n".'['.$tmp['page'].' 0 R /'.$tmp['string']."]\nendobj";
380
-      return  $res;
379
+        $res = "\n".$id." 0 obj\n".'['.$tmp['page'].' 0 R /'.$tmp['string']."]\nendobj";
380
+        return  $res;
381
+    }
381 382
     }
382
-  }
383 383
 
384 384
 
385
-  /**
386
-   * set the viewer preferences
387
-   */
388
-  protected function  o_viewerPreferences($id, $action, $options = '') {
385
+    /**
386
+     * set the viewer preferences
387
+     */
388
+    protected function  o_viewerPreferences($id, $action, $options = '') {
389 389
     if  ($action !== 'new') {
390
-      $o = & $this->objects[$id];
390
+        $o = & $this->objects[$id];
391 391
     }
392 392
 
393 393
     switch  ($action) {
394 394
     case  'new':
395 395
       $this->objects[$id] = array('t'=>'viewerPreferences', 'info'=>array());
396
-      break;
396
+        break;
397 397
 
398 398
     case  'add':
399 399
       foreach($options as  $k=>$v) {
@@ -406,167 +406,167 @@  discard block
 block discarded – undo
406 406
         case  'NonFullScreenPageMode':
407 407
         case  'Direction':
408 408
           $o['info'][$k] = $v;
409
-          break;
409
+            break;
410
+        }
410 411
         }
411
-      }
412
-      break;
412
+        break;
413 413
 
414 414
     case  'out':
415 415
       $res = "\n".$id." 0 obj\n".'<< ';
416
-      foreach($o['info'] as  $k=>$v) {
416
+        foreach($o['info'] as  $k=>$v) {
417 417
         $res.= "\n/".$k.' '.$v;
418
-      }
419
-      $res.= "\n>>\n";
420
-      return  $res;
418
+        }
419
+        $res.= "\n>>\n";
420
+        return  $res;
421
+    }
421 422
     }
422
-  }
423 423
 
424 424
 
425
-  /**
426
-   * define the document catalog, the overall controller for the document
427
-   */
428
-  protected function  o_catalog($id, $action, $options = '') {
425
+    /**
426
+     * define the document catalog, the overall controller for the document
427
+     */
428
+    protected function  o_catalog($id, $action, $options = '') {
429 429
     if  ($action !== 'new') {
430
-      $o = & $this->objects[$id];
430
+        $o = & $this->objects[$id];
431 431
     }
432 432
 
433 433
     switch  ($action) {
434 434
     case  'new':
435 435
       $this->objects[$id] = array('t'=>'catalog', 'info'=>array());
436
-      $this->catalogId = $id;
437
-      break;
436
+        $this->catalogId = $id;
437
+        break;
438 438
 
439 439
     case  'outlines':
440 440
     case  'pages':
441 441
     case  'openHere':
442 442
     case  'javascript':
443 443
       $o['info'][$action] = $options;
444
-      break;
444
+        break;
445 445
 
446 446
     case  'viewerPreferences':
447 447
       if  (!isset($o['info']['viewerPreferences'])) {
448 448
         $this->numObj++;
449 449
         $this->o_viewerPreferences($this->numObj, 'new');
450 450
         $o['info']['viewerPreferences'] = $this->numObj;
451
-      }
451
+        }
452 452
 
453
-      $vp =  $o['info']['viewerPreferences'];
454
-      $this->o_viewerPreferences($vp, 'add', $options);
453
+        $vp =  $o['info']['viewerPreferences'];
454
+        $this->o_viewerPreferences($vp, 'add', $options);
455 455
 
456
-      break;
456
+        break;
457 457
 
458 458
     case  'out':
459 459
       $res = "\n".$id." 0 obj\n".'<< /Type /Catalog';
460 460
 
461
-      foreach($o['info'] as  $k=>$v) {
461
+        foreach($o['info'] as  $k=>$v) {
462 462
         switch ($k) {
463 463
         case  'outlines':
464 464
           $res.= "\n".'/Outlines '.$v.' 0 R';
465
-          break;
465
+            break;
466 466
           
467 467
         case  'pages':
468 468
           $res.= "\n".'/Pages '.$v.' 0 R';
469
-          break;
469
+            break;
470 470
 
471 471
         case  'viewerPreferences':
472 472
           $res.= "\n".'/ViewerPreferences '.$v.' 0 R';
473
-          break;
473
+            break;
474 474
 
475 475
         case  'openHere':
476 476
           $res.= "\n".'/OpenAction '.$v.' 0 R';
477
-          break;
477
+            break;
478 478
 
479 479
         case  'javascript':
480 480
           $res.= "\n".'/Names <</JavaScript '.$v.' 0 R>>';
481
-          break;
481
+            break;
482
+        }
482 483
         }
483
-      }
484 484
 
485
-      $res.= " >>\nendobj";
486
-      return  $res;
485
+        $res.= " >>\nendobj";
486
+        return  $res;
487
+    }
487 488
     }
488
-  }
489 489
 
490 490
 
491
-  /**
492
-   * object which is a parent to the pages in the document
493
-   */
494
-  protected function  o_pages($id, $action, $options = '') {
491
+    /**
492
+     * object which is a parent to the pages in the document
493
+     */
494
+    protected function  o_pages($id, $action, $options = '') {
495 495
     if  ($action !== 'new') {
496
-      $o = & $this->objects[$id];
496
+        $o = & $this->objects[$id];
497 497
     }
498 498
 
499 499
     switch  ($action) {
500 500
     case  'new':
501 501
       $this->objects[$id] = array('t'=>'pages', 'info'=>array());
502
-      $this->o_catalog($this->catalogId, 'pages', $id);
503
-      break;
502
+        $this->o_catalog($this->catalogId, 'pages', $id);
503
+        break;
504 504
 
505 505
     case  'page':
506 506
       if  (!is_array($options)) {
507 507
         // then it will just be the id of the new page
508 508
         $o['info']['pages'][] = $options;
509
-      } else {
509
+        } else {
510 510
         // then it should be an array having 'id','rid','pos', where rid=the page to which this one will be placed relative
511 511
         // and pos is either 'before' or 'after', saying where this page will fit.
512 512
         if  (isset($options['id']) &&  isset($options['rid']) &&  isset($options['pos'])) {
513
-          $i =  array_search($options['rid'], $o['info']['pages']);
514
-          if  (isset($o['info']['pages'][$i]) &&  $o['info']['pages'][$i] == $options['rid']) {
513
+            $i =  array_search($options['rid'], $o['info']['pages']);
514
+            if  (isset($o['info']['pages'][$i]) &&  $o['info']['pages'][$i] == $options['rid']) {
515 515
 
516 516
             // then there is a match
517 517
             // make a space
518 518
             switch  ($options['pos']) {
519 519
             case  'before':
520 520
               $k =  $i;
521
-              break;
521
+                break;
522 522
 
523 523
             case  'after':
524 524
               $k = $i+1;
525
-              break;
525
+                break;
526 526
 
527 527
             default:
528 528
               $k = -1;
529
-              break;
529
+                break;
530 530
             }
531 531
 
532 532
             if  ($k >= 0) {
533
-              for  ($j = count($o['info']['pages']) -1;$j >= $k;$j--) {
533
+                for  ($j = count($o['info']['pages']) -1;$j >= $k;$j--) {
534 534
                 $o['info']['pages'][$j+1] = $o['info']['pages'][$j];
535
-              }
535
+                }
536 536
 
537
-              $o['info']['pages'][$k] = $options['id'];
537
+                $o['info']['pages'][$k] = $options['id'];
538
+            }
538 539
             }
539
-          }
540 540
         }
541
-      }
542
-      break;
541
+        }
542
+        break;
543 543
 
544 544
     case  'procset':
545 545
       $o['info']['procset'] = $options;
546
-      break;
546
+        break;
547 547
 
548 548
     case  'mediaBox':
549 549
       $o['info']['mediaBox'] = $options;
550
-      // which should be an array of 4 numbers
551
-      break;
550
+        // which should be an array of 4 numbers
551
+        break;
552 552
 
553 553
     case  'font':
554 554
       $o['info']['fonts'][] = array('objNum'=>$options['objNum'], 'fontNum'=>$options['fontNum']);
555
-      break;
555
+        break;
556 556
 
557 557
     case  'extGState':
558 558
       $o['info']['extGStates'][] =  array('objNum' => $options['objNum'],  'stateNum' => $options['stateNum']);
559
-      break;
559
+        break;
560 560
 
561 561
     case  'xObject':
562 562
       $o['info']['xObjects'][] = array('objNum'=>$options['objNum'], 'label'=>$options['label']);
563
-      break;
563
+        break;
564 564
 
565 565
     case  'out':
566 566
       if  (count($o['info']['pages'])) {
567 567
         $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Kids [";
568 568
         foreach($o['info']['pages'] as  $k=>$v) {
569
-          $res.= $v." 0 R\n";
569
+            $res.= $v." 0 R\n";
570 570
         }
571 571
 
572 572
         $res.= "]\n/Count ".count($this->objects[$id]['info']['pages']);
@@ -574,129 +574,129 @@  discard block
 block discarded – undo
574 574
         if  ( (isset($o['info']['fonts']) &&  count($o['info']['fonts'])) ||
575 575
               isset($o['info']['procset']) ||
576 576
               (isset($o['info']['extGStates']) &&  count($o['info']['extGStates']))) {
577
-          $res.= "\n/Resources <<";
577
+            $res.= "\n/Resources <<";
578 578
 
579
-          if  (isset($o['info']['procset'])) {
579
+            if  (isset($o['info']['procset'])) {
580 580
             $res.= "\n/ProcSet ".$o['info']['procset']." 0 R";
581
-          }
581
+            }
582 582
 
583
-          if  (isset($o['info']['fonts']) &&  count($o['info']['fonts'])) {
583
+            if  (isset($o['info']['fonts']) &&  count($o['info']['fonts'])) {
584 584
             $res.= "\n/Font << ";
585 585
             foreach($o['info']['fonts'] as  $finfo) {
586
-              $res.= "\n/F".$finfo['fontNum']." ".$finfo['objNum']." 0 R";
586
+                $res.= "\n/F".$finfo['fontNum']." ".$finfo['objNum']." 0 R";
587 587
             }
588 588
             $res.= "\n>>";
589
-          }
589
+            }
590 590
 
591
-          if  (isset($o['info']['xObjects']) &&  count($o['info']['xObjects'])) {
591
+            if  (isset($o['info']['xObjects']) &&  count($o['info']['xObjects'])) {
592 592
             $res.= "\n/XObject << ";
593 593
             foreach($o['info']['xObjects'] as  $finfo) {
594
-              $res.= "\n/".$finfo['label']." ".$finfo['objNum']." 0 R";
594
+                $res.= "\n/".$finfo['label']." ".$finfo['objNum']." 0 R";
595 595
             }
596 596
             $res.= "\n>>";
597
-          }
597
+            }
598 598
 
599
-          if  ( isset($o['info']['extGStates']) &&  count($o['info']['extGStates'])) {
599
+            if  ( isset($o['info']['extGStates']) &&  count($o['info']['extGStates'])) {
600 600
             $res.=  "\n/ExtGState << ";
601 601
             foreach ($o['info']['extGStates'] as  $gstate) {
602
-              $res.=  "\n/GS" . $gstate['stateNum'] . " " . $gstate['objNum'] . " 0 R";
602
+                $res.=  "\n/GS" . $gstate['stateNum'] . " " . $gstate['objNum'] . " 0 R";
603 603
             }
604 604
             $res.=  "\n>>";
605
-          }
605
+            }
606 606
 
607
-          $res.= "\n>>";
608
-          if  (isset($o['info']['mediaBox'])) {
607
+            $res.= "\n>>";
608
+            if  (isset($o['info']['mediaBox'])) {
609 609
             $tmp = $o['info']['mediaBox'];
610 610
             $res.= "\n/MediaBox [".sprintf('%.3F', $tmp[0]) .' '.sprintf('%.3F', $tmp[1]) .' '.sprintf('%.3F', $tmp[2]) .' '.sprintf('%.3F', $tmp[3]) .']';
611
-          }
611
+            }
612 612
         }
613 613
 
614 614
         $res.= "\n >>\nendobj";
615
-      } else {
615
+        } else {
616 616
         $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Count 0\n>>\nendobj";
617
-      }
617
+        }
618 618
 
619
-      return  $res;
619
+        return  $res;
620
+    }
620 621
     }
621
-  }
622 622
 
623 623
 
624
-  /**
625
-   * define the outlines in the doc, empty for now
626
-   */
627
-  protected function  o_outlines($id, $action, $options = '') {
624
+    /**
625
+     * define the outlines in the doc, empty for now
626
+     */
627
+    protected function  o_outlines($id, $action, $options = '') {
628 628
     if  ($action !== 'new') {
629
-      $o = & $this->objects[$id];
629
+        $o = & $this->objects[$id];
630 630
     }
631 631
 
632 632
     switch  ($action) {
633 633
     case  'new':
634 634
       $this->objects[$id] = array('t'=>'outlines', 'info'=>array('outlines'=>array()));
635
-      $this->o_catalog($this->catalogId, 'outlines', $id);
636
-      break;
635
+        $this->o_catalog($this->catalogId, 'outlines', $id);
636
+        break;
637 637
 
638 638
     case  'outline':
639 639
       $o['info']['outlines'][] = $options;
640
-      break;
640
+        break;
641 641
 
642 642
     case  'out':
643 643
       if  (count($o['info']['outlines'])) {
644 644
         $res = "\n".$id." 0 obj\n<< /Type /Outlines /Kids [";
645 645
         foreach($o['info']['outlines'] as  $k=>$v) {
646
-          $res.= $v." 0 R ";
646
+            $res.= $v." 0 R ";
647 647
         }
648 648
 
649 649
         $res.= "] /Count ".count($o['info']['outlines']) ." >>\nendobj";
650
-      } else {
650
+        } else {
651 651
         $res = "\n".$id." 0 obj\n<< /Type /Outlines /Count 0 >>\nendobj";
652
-      }
652
+        }
653 653
 
654
-      return  $res;
654
+        return  $res;
655
+    }
655 656
     }
656
-  }
657 657
 
658 658
 
659
-  /**
660
-   * an object to hold the font description
661
-   */
662
-  protected function  o_font($id, $action, $options = '') {
659
+    /**
660
+     * an object to hold the font description
661
+     */
662
+    protected function  o_font($id, $action, $options = '') {
663 663
     if  ($action !== 'new') {
664
-      $o = & $this->objects[$id];
664
+        $o = & $this->objects[$id];
665 665
     }
666 666
 
667 667
     switch  ($action) {
668 668
     case  'new':
669 669
       $this->objects[$id] =  array('t' => 'font', 'info' => array('name' => $options['name'], 'fontFileName' => $options['fontFileName'], 'SubType' => 'Type1'));
670
-      $fontNum =  $this->numFonts;
671
-      $this->objects[$id]['info']['fontNum'] =  $fontNum;
670
+        $fontNum =  $this->numFonts;
671
+        $this->objects[$id]['info']['fontNum'] =  $fontNum;
672 672
 
673
-      // deal with the encoding and the differences
674
-      if  (isset($options['differences'])) {
673
+        // deal with the encoding and the differences
674
+        if  (isset($options['differences'])) {
675 675
         // then we'll need an encoding dictionary
676 676
         $this->numObj++;
677 677
         $this->o_fontEncoding($this->numObj, 'new', $options);
678 678
         $this->objects[$id]['info']['encodingDictionary'] =  $this->numObj;
679
-      } else  if  (isset($options['encoding'])) {
679
+        } else  if  (isset($options['encoding'])) {
680 680
         // we can specify encoding here
681 681
         switch ($options['encoding']) {
682 682
         case  'WinAnsiEncoding':
683 683
         case  'MacRomanEncoding':
684 684
         case  'MacExpertEncoding':
685 685
           $this->objects[$id]['info']['encoding'] =  $options['encoding'];
686
-          break;
686
+            break;
687 687
 
688 688
         case  'none':
689 689
           break;
690 690
 
691 691
         default:
692 692
           $this->objects[$id]['info']['encoding'] =  'WinAnsiEncoding';
693
-          break;
693
+            break;
694 694
         }
695
-      } else {
695
+        } else {
696 696
         $this->objects[$id]['info']['encoding'] =  'WinAnsiEncoding';
697
-      }
697
+        }
698 698
 
699
-      if ($this->fonts[$options['fontFileName']]['isUnicode']) {
699
+        if ($this->fonts[$options['fontFileName']]['isUnicode']) {
700 700
         // For Unicode fonts, we need to incorporate font data into
701 701
         // sub-sections that are linked from the primary font section.
702 702
         // Look at o_fontGIDtoCID and o_fontDescendentCID functions
@@ -738,34 +738,34 @@  discard block
 block discarded – undo
738 738
         $cidFontId = ++$this->numObj;
739 739
         $this->o_fontDescendentCID($cidFontId, 'new', $options);
740 740
         $this->objects[$id]['info']['cidFont'] = $cidFontId;
741
-      }
741
+        }
742 742
       
743
-      // also tell the pages node about the new font
744
-      $this->o_pages($this->currentNode, 'font', array('fontNum' => $fontNum, 'objNum' => $id));
745
-      break;
743
+        // also tell the pages node about the new font
744
+        $this->o_pages($this->currentNode, 'font', array('fontNum' => $fontNum, 'objNum' => $id));
745
+        break;
746 746
 
747 747
     case  'add':
748 748
       foreach ($options as  $k => $v) {
749 749
         switch  ($k) {
750 750
         case  'BaseFont':
751 751
           $o['info']['name'] =  $v;
752
-          break;
752
+            break;
753 753
         case  'FirstChar':
754 754
         case  'LastChar':
755 755
         case  'Widths':
756 756
         case  'FontDescriptor':
757 757
         case  'SubType':
758 758
           $this->addMessage('o_font '.$k." : ".$v);
759
-          $o['info'][$k] =  $v;
760
-          break;
759
+            $o['info'][$k] =  $v;
760
+            break;
761
+        }
761 762
         }
762
-      }
763 763
 
764
-      // pass values down to descendent font
765
-      if (isset($o['info']['cidFont'])) {
764
+        // pass values down to descendent font
765
+        if (isset($o['info']['cidFont'])) {
766 766
         $this->o_fontDescendentCID($o['info']['cidFont'], 'add', $options);
767
-      }
768
-      break;
767
+        }
768
+        break;
769 769
 
770 770
     case  'out':
771 771
       if ($this->fonts[$this->objects[$id]['info']['fontFileName']]['isUnicode']) {
@@ -787,60 +787,60 @@  discard block
 block discarded – undo
787 787
         $res.=  "/ToUnicode ".$o['info']['toUnicode']." 0 R\n";
788 788
         $res.=  ">>\n";
789 789
         $res.=  "endobj";
790
-      } else {
791
-      $res =  "\n".$id." 0 obj\n<< /Type /Font\n/Subtype /".$o['info']['SubType']."\n";
792
-      $res.=  "/Name /F".$o['info']['fontNum']."\n";
793
-      $res.=  "/BaseFont /".$o['info']['name']."\n";
790
+        } else {
791
+        $res =  "\n".$id." 0 obj\n<< /Type /Font\n/Subtype /".$o['info']['SubType']."\n";
792
+        $res.=  "/Name /F".$o['info']['fontNum']."\n";
793
+        $res.=  "/BaseFont /".$o['info']['name']."\n";
794 794
 
795
-      if  (isset($o['info']['encodingDictionary'])) {
795
+        if  (isset($o['info']['encodingDictionary'])) {
796 796
         // then place a reference to the dictionary
797 797
         $res.=  "/Encoding ".$o['info']['encodingDictionary']." 0 R\n";
798
-      } else  if  (isset($o['info']['encoding'])) {
798
+        } else  if  (isset($o['info']['encoding'])) {
799 799
         // use the specified encoding
800 800
         $res.=  "/Encoding /".$o['info']['encoding']."\n";
801
-      }
801
+        }
802 802
 
803
-      if  (isset($o['info']['FirstChar'])) {
803
+        if  (isset($o['info']['FirstChar'])) {
804 804
         $res.=  "/FirstChar ".$o['info']['FirstChar']."\n";
805
-      }
805
+        }
806 806
 
807
-      if  (isset($o['info']['LastChar'])) {
807
+        if  (isset($o['info']['LastChar'])) {
808 808
         $res.=  "/LastChar ".$o['info']['LastChar']."\n";
809
-      }
809
+        }
810 810
 
811
-      if  (isset($o['info']['Widths'])) {
811
+        if  (isset($o['info']['Widths'])) {
812 812
         $res.=  "/Widths ".$o['info']['Widths']." 0 R\n";
813
-      }
813
+        }
814 814
 
815
-      if  (isset($o['info']['FontDescriptor'])) {
815
+        if  (isset($o['info']['FontDescriptor'])) {
816 816
         $res.=  "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n";
817
-      }
817
+        }
818 818
 
819 819
         $res.=  ">>\n";
820 820
         $res.=  "endobj";
821
-      }
821
+        }
822 822
 
823
-      return  $res;
823
+        return  $res;
824
+    }
824 825
     }
825
-  }
826 826
 
827 827
 
828
-  /**
829
-   * a font descriptor, needed for including additional fonts
830
-   */
831
-  protected function  o_fontDescriptor($id, $action, $options = '') {
828
+    /**
829
+     * a font descriptor, needed for including additional fonts
830
+     */
831
+    protected function  o_fontDescriptor($id, $action, $options = '') {
832 832
     if  ($action !== 'new') {
833
-      $o = & $this->objects[$id];
833
+        $o = & $this->objects[$id];
834 834
     }
835 835
 
836 836
     switch  ($action) {
837 837
     case  'new':
838 838
       $this->objects[$id] = array('t'=>'fontDescriptor', 'info'=>$options);
839
-      break;
839
+        break;
840 840
 
841 841
     case  'out':
842 842
       $res = "\n".$id." 0 obj\n<< /Type /FontDescriptor\n";
843
-      foreach ($o['info'] as  $label => $value) {
843
+        foreach ($o['info'] as  $label => $value) {
844 844
         switch  ($label) {
845 845
         case  'Ascent':
846 846
         case  'CapHeight':
@@ -857,111 +857,111 @@  discard block
 block discarded – undo
857 857
         case  'CharSet':
858 858
           if  (mb_strlen($value, '8bit')) {
859 859
             $res.= '/'.$label.' '.$value."\n";
860
-          }
860
+            }
861 861
 
862
-          break;
862
+            break;
863 863
         case  'FontFile':
864 864
         case  'FontFile2':
865 865
         case  'FontFile3':
866 866
           $res.= '/'.$label.' '.$value." 0 R\n";
867
-          break;
867
+            break;
868 868
 
869 869
         case  'FontBBox':
870 870
           $res.= '/'.$label.' ['.$value[0].' '.$value[1].' '.$value[2].' '.$value[3]."]\n";
871
-          break;
871
+            break;
872 872
 
873 873
         case  'FontName':
874 874
           $res.= '/'.$label.' /'.$value."\n";
875
-          break;
875
+            break;
876
+        }
876 877
         }
877
-      }
878 878
 
879
-      $res.= ">>\nendobj";
879
+        $res.= ">>\nendobj";
880 880
 
881
-      return  $res;
881
+        return  $res;
882
+    }
882 883
     }
883
-  }
884 884
 
885 885
 
886
-  /**
887
-   * the font encoding
888
-   */
889
-  protected function  o_fontEncoding($id, $action, $options = '') {
886
+    /**
887
+     * the font encoding
888
+     */
889
+    protected function  o_fontEncoding($id, $action, $options = '') {
890 890
     if  ($action !== 'new') {
891
-      $o = & $this->objects[$id];
891
+        $o = & $this->objects[$id];
892 892
     }
893 893
 
894 894
     switch  ($action) {
895 895
     case  'new':
896 896
       // the options array should contain 'differences' and maybe 'encoding'
897 897
       $this->objects[$id] = array('t'=>'fontEncoding', 'info'=>$options);
898
-      break;
898
+        break;
899 899
 
900 900
     case  'out':
901 901
       $res = "\n".$id." 0 obj\n<< /Type /Encoding\n";
902
-      if  (!isset($o['info']['encoding'])) {
902
+        if  (!isset($o['info']['encoding'])) {
903 903
         $o['info']['encoding'] = 'WinAnsiEncoding';
904
-      }
904
+        }
905 905
 
906
-      if  ($o['info']['encoding'] !== 'none') {
906
+        if  ($o['info']['encoding'] !== 'none') {
907 907
         $res.= "/BaseEncoding /".$o['info']['encoding']."\n";
908
-      }
908
+        }
909 909
 
910
-      $res.= "/Differences \n[";
910
+        $res.= "/Differences \n[";
911 911
 
912
-      $onum = -100;
912
+        $onum = -100;
913 913
 
914
-      foreach($o['info']['differences'] as  $num=>$label) {
914
+        foreach($o['info']['differences'] as  $num=>$label) {
915 915
         if  ($num != $onum+1) {
916
-          // we cannot make use of consecutive numbering
917
-          $res.=  "\n".$num." /".$label;
916
+            // we cannot make use of consecutive numbering
917
+            $res.=  "\n".$num." /".$label;
918 918
         } else {
919
-          $res.=  " /".$label;
919
+            $res.=  " /".$label;
920 920
         }
921 921
 
922 922
         $onum = $num;
923
-      }
923
+        }
924 924
 
925
-      $res.= "\n]\n>>\nendobj";
926
-      return  $res;
925
+        $res.= "\n]\n>>\nendobj";
926
+        return  $res;
927
+    }
927 928
     }
928
-  }
929 929
 
930 930
 
931
-  /**
932
-   * a descendent cid font,  needed for unicode fonts
933
-   */
934
-  protected function  o_fontDescendentCID($id, $action, $options = '') {
931
+    /**
932
+     * a descendent cid font,  needed for unicode fonts
933
+     */
934
+    protected function  o_fontDescendentCID($id, $action, $options = '') {
935 935
     if  ($action !== 'new') {
936
-      $o = & $this->objects[$id];
936
+        $o = & $this->objects[$id];
937 937
     }
938 938
 
939 939
     switch  ($action) {
940 940
     case  'new':
941 941
       $this->objects[$id] =  array('t'=>'fontDescendentCID', 'info'=>$options);
942 942
 
943
-      // we need a CID system info section
944
-      $cidSystemInfoId = ++$this->numObj;
945
-      $this->o_contents($cidSystemInfoId, 'new', 'raw');
946
-      $this->objects[$id]['info']['cidSystemInfo'] = $cidSystemInfoId;
947
-      $res=   "<</Registry (Adobe)\n"; // A string identifying an issuer of character collections
948
-      $res.=  "/Ordering (UCS)\n"; // A string that uniquely names a character collection issued by a specific registry
949
-      $res.=  "/Supplement 0\n"; // The supplement number of the character collection.
950
-      $res.=  ">>";
951
-      $this->objects[$cidSystemInfoId]['c'] = $res;
952
-
953
-      // and a CID to GID map
954
-      $cidToGidMapId = ++$this->numObj;
955
-      $this->o_fontGIDtoCIDMap($cidToGidMapId, 'new', $options);
956
-      $this->objects[$id]['info']['cidToGidMap'] = $cidToGidMapId;
957
-      break;
943
+        // we need a CID system info section
944
+        $cidSystemInfoId = ++$this->numObj;
945
+        $this->o_contents($cidSystemInfoId, 'new', 'raw');
946
+        $this->objects[$id]['info']['cidSystemInfo'] = $cidSystemInfoId;
947
+        $res=   "<</Registry (Adobe)\n"; // A string identifying an issuer of character collections
948
+        $res.=  "/Ordering (UCS)\n"; // A string that uniquely names a character collection issued by a specific registry
949
+        $res.=  "/Supplement 0\n"; // The supplement number of the character collection.
950
+        $res.=  ">>";
951
+        $this->objects[$cidSystemInfoId]['c'] = $res;
952
+
953
+        // and a CID to GID map
954
+        $cidToGidMapId = ++$this->numObj;
955
+        $this->o_fontGIDtoCIDMap($cidToGidMapId, 'new', $options);
956
+        $this->objects[$id]['info']['cidToGidMap'] = $cidToGidMapId;
957
+        break;
958 958
 
959 959
     case  'add':
960 960
       foreach ($options as  $k => $v) {
961 961
         switch  ($k) {
962 962
         case  'BaseFont':
963 963
           $o['info']['name'] =  $v;
964
-          break;
964
+            break;
965 965
 
966 966
         case  'FirstChar':
967 967
         case  'LastChar':
@@ -969,21 +969,21 @@  discard block
 block discarded – undo
969 969
         case  'FontDescriptor':
970 970
         case  'SubType':
971 971
           $this->addMessage('o_fontDescendentCID '.$k." : ".$v);
972
-          $o['info'][$k] =  $v;
973
-          break;
972
+            $o['info'][$k] =  $v;
973
+            break;
974
+        }
974 975
         }
975
-      }
976 976
 
977
-      // pass values down to cid to gid map
978
-      $this->o_fontGIDtoCIDMap($o['info']['cidToGidMap'], 'add', $options);
979
-      break;
977
+        // pass values down to cid to gid map
978
+        $this->o_fontGIDtoCIDMap($o['info']['cidToGidMap'], 'add', $options);
979
+        break;
980 980
 
981 981
     case  'out':
982 982
       $res =  "\n".$id." 0 obj\n";
983
-      $res.=  "<</Type /Font\n";
984
-      $res.=  "/Subtype /CIDFontType2\n";
985
-      $res.=  "/BaseFont /".$o['info']['name']."\n";
986
-      $res.=  "/CIDSystemInfo ".$o['info']['cidSystemInfo']." 0 R\n";
983
+        $res.=  "<</Type /Font\n";
984
+        $res.=  "/Subtype /CIDFontType2\n";
985
+        $res.=  "/BaseFont /".$o['info']['name']."\n";
986
+        $res.=  "/CIDSystemInfo ".$o['info']['cidSystemInfo']." 0 R\n";
987 987
 //      if  (isset($o['info']['FirstChar'])) {
988 988
 //        $res.=  "/FirstChar ".$o['info']['FirstChar']."\n";
989 989
 //      }
@@ -991,126 +991,126 @@  discard block
 block discarded – undo
991 991
 //      if  (isset($o['info']['LastChar'])) {
992 992
 //        $res.=  "/LastChar ".$o['info']['LastChar']."\n";
993 993
 //      }
994
-      if  (isset($o['info']['FontDescriptor'])) {
994
+        if  (isset($o['info']['FontDescriptor'])) {
995 995
         $res.=  "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n";
996
-      }
996
+        }
997 997
 
998
-      if  (isset($o['info']['MissingWidth'])) {
998
+        if  (isset($o['info']['MissingWidth'])) {
999 999
         $res.=  "/DW ".$o['info']['MissingWidth']."\n";
1000
-      }
1000
+        }
1001 1001
 
1002
-      if  (isset($o['info']['fontFileName']) && isset($this->fonts[$o['info']['fontFileName']]['CIDWidths'])) {
1002
+        if  (isset($o['info']['fontFileName']) && isset($this->fonts[$o['info']['fontFileName']]['CIDWidths'])) {
1003 1003
         $cid_widths = &$this->fonts[$o['info']['fontFileName']]['CIDWidths'];
1004 1004
         $w = '';
1005 1005
         foreach ($cid_widths as $cid => $width) {
1006
-          $w .= $cid.' ['.$width.'] ';
1006
+            $w .= $cid.' ['.$width.'] ';
1007 1007
         }
1008 1008
         $res.=  "/W [".$w."]\n";
1009
-      }
1009
+        }
1010 1010
 
1011
-      $res.=  "/CIDToGIDMap ".$o['info']['cidToGidMap']." 0 R\n";
1012
-      $res.=  ">>\n";
1013
-      $res.=  "endobj";
1011
+        $res.=  "/CIDToGIDMap ".$o['info']['cidToGidMap']." 0 R\n";
1012
+        $res.=  ">>\n";
1013
+        $res.=  "endobj";
1014 1014
 
1015
-      return  $res;
1015
+        return  $res;
1016
+    }
1016 1017
     }
1017
-  }
1018 1018
   
1019 1019
 
1020
-  /**
1021
-   * a font glyph to character map,  needed for unicode fonts
1022
-   */
1023
-  protected function  o_fontGIDtoCIDMap($id, $action, $options = '') {
1020
+    /**
1021
+     * a font glyph to character map,  needed for unicode fonts
1022
+     */
1023
+    protected function  o_fontGIDtoCIDMap($id, $action, $options = '') {
1024 1024
     if  ($action !== 'new') {
1025
-      $o = & $this->objects[$id];
1025
+        $o = & $this->objects[$id];
1026 1026
     }
1027 1027
 
1028 1028
     switch  ($action) {
1029 1029
     case  'new':
1030 1030
       $this->objects[$id] =  array('t'=>'fontGIDtoCIDMap', 'info'=>$options);
1031
-      break;
1031
+        break;
1032 1032
 
1033 1033
     case  'out':
1034 1034
       $res = "\n".$id." 0 obj\n";
1035
-      $tmp = $this->fonts[$o['info']['fontFileName']]['CIDtoGID'] = base64_decode($this->fonts[$o['info']['fontFileName']]['CIDtoGID']);
1036
-      $compressed = isset($this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed']) &&
1035
+        $tmp = $this->fonts[$o['info']['fontFileName']]['CIDtoGID'] = base64_decode($this->fonts[$o['info']['fontFileName']]['CIDtoGID']);
1036
+        $compressed = isset($this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed']) &&
1037 1037
                     $this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed'];
1038 1038
 
1039
-      if  (!$compressed && isset($o['raw'])) {
1039
+        if  (!$compressed && isset($o['raw'])) {
1040 1040
         $res.= $tmp;
1041
-      } else {
1041
+        } else {
1042 1042
         $res.=  "<<";
1043 1043
 
1044 1044
         if  (!$compressed && function_exists('gzcompress') &&  $this->options['compression']) {
1045
-          // then implement ZLIB based compression on this content stream
1046
-          $compressed = true;
1047
-          $tmp =  gzcompress($tmp,  6);
1045
+            // then implement ZLIB based compression on this content stream
1046
+            $compressed = true;
1047
+            $tmp =  gzcompress($tmp,  6);
1048 1048
         }
1049 1049
         if ($compressed) {
1050
-          $res.= "\n/Filter /FlateDecode";
1050
+            $res.= "\n/Filter /FlateDecode";
1051 1051
         }
1052 1052
 
1053 1053
         $res.= "\n/Length ".mb_strlen($tmp, '8bit') .">>\nstream\n".$tmp."\nendstream";
1054
-      }
1054
+        }
1055 1055
 
1056
-      $res.= "\nendobj";
1057
-      return  $res;
1056
+        $res.= "\nendobj";
1057
+        return  $res;
1058
+    }
1058 1059
     }
1059
-  }
1060 1060
   
1061 1061
 
1062
-  /**
1063
-   * the document procset, solves some problems with printing to old PS printers
1064
-   */
1065
-  protected function  o_procset($id, $action, $options = '') {
1062
+    /**
1063
+     * the document procset, solves some problems with printing to old PS printers
1064
+     */
1065
+    protected function  o_procset($id, $action, $options = '') {
1066 1066
     if  ($action !== 'new') {
1067
-      $o = & $this->objects[$id];
1067
+        $o = & $this->objects[$id];
1068 1068
     }
1069 1069
 
1070 1070
     switch  ($action) {
1071 1071
     case  'new':
1072 1072
       $this->objects[$id] = array('t'=>'procset', 'info'=>array('PDF'=>1, 'Text'=>1));
1073
-      $this->o_pages($this->currentNode, 'procset', $id);
1074
-      $this->procsetObjectId = $id;
1075
-      break;
1073
+        $this->o_pages($this->currentNode, 'procset', $id);
1074
+        $this->procsetObjectId = $id;
1075
+        break;
1076 1076
 
1077 1077
     case  'add':
1078 1078
       // this is to add new items to the procset list, despite the fact that this is considered
1079 1079
       // obselete, the items are required for printing to some postscript printers
1080 1080
       switch  ($options) {
1081
-      case  'ImageB':
1081
+        case  'ImageB':
1082 1082
       case  'ImageC':
1083 1083
       case  'ImageI':
1084 1084
         $o['info'][$options] = 1;
1085 1085
         break;
1086
-      }
1087
-      break;
1086
+        }
1087
+        break;
1088 1088
 
1089 1089
     case  'out':
1090 1090
       $res = "\n".$id." 0 obj\n[";
1091
-      foreach ($o['info'] as  $label=>$val) {
1091
+        foreach ($o['info'] as  $label=>$val) {
1092 1092
         $res.= '/'.$label.' ';
1093
-      }
1094
-      $res.= "]\nendobj";
1095
-      return  $res;
1093
+        }
1094
+        $res.= "]\nendobj";
1095
+        return  $res;
1096
+    }
1096 1097
     }
1097
-  }
1098 1098
 
1099 1099
 
1100
-  /**
1101
-   * define the document information
1102
-   */
1103
-  protected function  o_info($id, $action, $options = '') {
1100
+    /**
1101
+     * define the document information
1102
+     */
1103
+    protected function  o_info($id, $action, $options = '') {
1104 1104
     if  ($action !== 'new') {
1105
-      $o = & $this->objects[$id];
1105
+        $o = & $this->objects[$id];
1106 1106
     }
1107 1107
 
1108 1108
     switch  ($action) {
1109 1109
     case  'new':
1110 1110
       $this->infoObject = $id;
1111
-      $date = 'D:'.@date('Ymd');
1112
-      $this->objects[$id] = array('t'=>'info', 'info'=>array('Creator'=>'R and OS php pdf writer, http://www.ros.co.nz', 'CreationDate'=>$date));
1113
-      break;
1111
+        $date = 'D:'.@date('Ymd');
1112
+        $this->objects[$id] = array('t'=>'info', 'info'=>array('Creator'=>'R and OS php pdf writer, http://www.ros.co.nz', 'CreationDate'=>$date));
1113
+        break;
1114 1114
     case  'Title':
1115 1115
     case  'Author':
1116 1116
     case  'Subject':
@@ -1121,107 +1121,107 @@  discard block
 block discarded – undo
1121 1121
     case  'ModDate':
1122 1122
     case  'Trapped':
1123 1123
       $o['info'][$action] = $options;
1124
-      break;
1124
+        break;
1125 1125
 
1126 1126
     case  'out':
1127 1127
       if  ($this->encrypted) {
1128 1128
         $this->encryptInit($id);
1129
-      }
1129
+        }
1130 1130
 
1131
-      $res = "\n".$id." 0 obj\n<<\n";
1132
-      foreach ($o['info'] as  $k=>$v) {
1131
+        $res = "\n".$id." 0 obj\n<<\n";
1132
+        foreach ($o['info'] as  $k=>$v) {
1133 1133
         $res.= '/'.$k.' (';
1134 1134
         // dates must be outputted as-is, without Unicode transformations
1135 1135
         $raw = ($k === 'CreationDate' || $k === 'ModDate');
1136 1136
         $c = $v;
1137 1137
 
1138 1138
         if  ($this->encrypted) {
1139
-          $c = $this->ARC4($c);
1139
+            $c = $this->ARC4($c);
1140 1140
         }
1141 1141
 
1142 1142
         $res.= ($raw) ? $c : $this->filterText($c);
1143 1143
         $res.= ")\n";
1144
-      }
1144
+        }
1145 1145
 
1146
-      $res.= ">>\nendobj";
1147
-      return  $res;
1146
+        $res.= ">>\nendobj";
1147
+        return  $res;
1148
+    }
1148 1149
     }
1149
-  }
1150 1150
 
1151 1151
 
1152
-  /**
1153
-   * an action object, used to link to URLS initially
1154
-   */
1155
-  protected function  o_action($id, $action, $options = '') {
1152
+    /**
1153
+     * an action object, used to link to URLS initially
1154
+     */
1155
+    protected function  o_action($id, $action, $options = '') {
1156 1156
     if  ($action !== 'new') {
1157
-      $o = & $this->objects[$id];
1157
+        $o = & $this->objects[$id];
1158 1158
     }
1159 1159
 
1160 1160
     switch  ($action) {
1161 1161
     case  'new':
1162 1162
       if  (is_array($options)) {
1163 1163
         $this->objects[$id] = array('t'=>'action', 'info'=>$options, 'type'=>$options['type']);
1164
-      } else {
1164
+        } else {
1165 1165
         // then assume a URI action
1166 1166
         $this->objects[$id] = array('t'=>'action', 'info'=>$options, 'type'=>'URI');
1167
-      }
1168
-      break;
1167
+        }
1168
+        break;
1169 1169
 
1170 1170
     case  'out':
1171 1171
       if  ($this->encrypted) {
1172 1172
         $this->encryptInit($id);
1173
-      }
1173
+        }
1174 1174
 
1175
-      $res = "\n".$id." 0 obj\n<< /Type /Action";
1176
-      switch ($o['type']) {
1177
-      case  'ilink':
1175
+        $res = "\n".$id." 0 obj\n<< /Type /Action";
1176
+        switch ($o['type']) {
1177
+        case  'ilink':
1178 1178
         // there will be an 'label' setting, this is the name of the destination
1179 1179
         $res.= "\n/S /GoTo\n/D ".$this->destinations[(string)$o['info']['label']]." 0 R";
1180 1180
         break;
1181 1181
 
1182
-      case  'URI':
1182
+        case  'URI':
1183 1183
         $res.= "\n/S /URI\n/URI (";
1184 1184
         if  ($this->encrypted) {
1185
-          $res.= $this->filterText($this->ARC4($o['info']));
1185
+            $res.= $this->filterText($this->ARC4($o['info']));
1186 1186
         } else {
1187
-          $res.= $this->filterText($o['info']);
1187
+            $res.= $this->filterText($o['info']);
1188 1188
         }
1189 1189
 
1190 1190
         $res.= ")";
1191 1191
         break;
1192
-      }
1192
+        }
1193 1193
 
1194
-      $res.= "\n>>\nendobj";
1195
-      return  $res;
1194
+        $res.= "\n>>\nendobj";
1195
+        return  $res;
1196
+    }
1196 1197
     }
1197
-  }
1198 1198
 
1199 1199
 
1200
-  /**
1201
-   * an annotation object, this will add an annotation to the current page.
1202
-   * initially will support just link annotations
1203
-   */
1204
-  protected function  o_annotation($id, $action, $options = '') {
1200
+    /**
1201
+     * an annotation object, this will add an annotation to the current page.
1202
+     * initially will support just link annotations
1203
+     */
1204
+    protected function  o_annotation($id, $action, $options = '') {
1205 1205
     if  ($action !== 'new') {
1206
-      $o = & $this->objects[$id];
1206
+        $o = & $this->objects[$id];
1207 1207
     }
1208 1208
 
1209 1209
     switch  ($action) {
1210 1210
     case  'new':
1211 1211
       // add the annotation to the current page
1212 1212
       $pageId =  $this->currentPage;
1213
-      $this->o_page($pageId, 'annot', $id);
1213
+        $this->o_page($pageId, 'annot', $id);
1214 1214
 
1215
-      // and add the action object which is going to be required
1216
-      switch ($options['type']) {
1217
-      case  'link':
1215
+        // and add the action object which is going to be required
1216
+        switch ($options['type']) {
1217
+        case  'link':
1218 1218
         $this->objects[$id] = array('t'=>'annotation', 'info'=>$options);
1219 1219
         $this->numObj++;
1220 1220
         $this->o_action($this->numObj, 'new', $options['url']);
1221 1221
         $this->objects[$id]['info']['actionId'] = $this->numObj;
1222 1222
         break;
1223 1223
 
1224
-      case  'ilink':
1224
+        case  'ilink':
1225 1225
         // this is to a named internal link
1226 1226
         $label =  $options['label'];
1227 1227
         $this->objects[$id] = array('t'=>'annotation', 'info'=>$options);
@@ -1229,199 +1229,199 @@  discard block
 block discarded – undo
1229 1229
         $this->o_action($this->numObj, 'new', array('type'=>'ilink', 'label'=>$label));
1230 1230
         $this->objects[$id]['info']['actionId'] = $this->numObj;
1231 1231
         break;
1232
-      }
1233
-      break;
1232
+        }
1233
+        break;
1234 1234
 
1235 1235
     case  'out':
1236 1236
       $res = "\n".$id." 0 obj\n<< /Type /Annot";
1237
-      switch ($o['info']['type']) {
1238
-      case  'link':
1237
+        switch ($o['info']['type']) {
1238
+        case  'link':
1239 1239
       case  'ilink':
1240 1240
         $res.=  "\n/Subtype /Link";
1241 1241
         break;
1242
-      }
1243
-      $res.= "\n/A ".$o['info']['actionId']." 0 R";
1244
-      $res.= "\n/Border [0 0 0]";
1245
-      $res.= "\n/H /I";
1246
-      $res.= "\n/Rect [ ";
1242
+        }
1243
+        $res.= "\n/A ".$o['info']['actionId']." 0 R";
1244
+        $res.= "\n/Border [0 0 0]";
1245
+        $res.= "\n/H /I";
1246
+        $res.= "\n/Rect [ ";
1247 1247
 
1248
-      foreach($o['info']['rect'] as  $v) {
1248
+        foreach($o['info']['rect'] as  $v) {
1249 1249
         $res.=  sprintf("%.4F ", $v);
1250
-      }
1250
+        }
1251 1251
 
1252
-      $res.= "]";
1253
-      $res.= "\n>>\nendobj";
1254
-      return  $res;
1252
+        $res.= "]";
1253
+        $res.= "\n>>\nendobj";
1254
+        return  $res;
1255
+    }
1255 1256
     }
1256
-  }
1257 1257
 
1258 1258
 
1259
-  /**
1260
-   * a page object, it also creates a contents object to hold its contents
1261
-   */
1262
-  protected function  o_page($id, $action, $options = '') {
1259
+    /**
1260
+     * a page object, it also creates a contents object to hold its contents
1261
+     */
1262
+    protected function  o_page($id, $action, $options = '') {
1263 1263
     if  ($action !== 'new') {
1264
-      $o = & $this->objects[$id];
1264
+        $o = & $this->objects[$id];
1265 1265
     }
1266 1266
 
1267 1267
     switch  ($action) {
1268 1268
     case  'new':
1269 1269
       $this->numPages++;
1270
-      $this->objects[$id] = array('t'=>'page', 'info'=>array('parent'=>$this->currentNode, 'pageNum'=>$this->numPages));
1270
+        $this->objects[$id] = array('t'=>'page', 'info'=>array('parent'=>$this->currentNode, 'pageNum'=>$this->numPages));
1271 1271
 
1272
-      if  (is_array($options)) {
1272
+        if  (is_array($options)) {
1273 1273
         // then this must be a page insertion, array should contain 'rid','pos'=[before|after]
1274 1274
         $options['id'] = $id;
1275 1275
         $this->o_pages($this->currentNode, 'page', $options);
1276
-      } else {
1276
+        } else {
1277 1277
         $this->o_pages($this->currentNode, 'page', $id);
1278
-      }
1279
-
1280
-      $this->currentPage = $id;
1281
-      //make a contents object to go with this page
1282
-      $this->numObj++;
1283
-      $this->o_contents($this->numObj, 'new', $id);
1284
-      $this->currentContents = $this->numObj;
1285
-      $this->objects[$id]['info']['contents'] = array();
1286
-      $this->objects[$id]['info']['contents'][] = $this->numObj;
1287
-
1288
-      $match =  ($this->numPages%2 ?  'odd' :  'even');
1289
-      foreach($this->addLooseObjects as  $oId=>$target) {
1278
+        }
1279
+
1280
+        $this->currentPage = $id;
1281
+        //make a contents object to go with this page
1282
+        $this->numObj++;
1283
+        $this->o_contents($this->numObj, 'new', $id);
1284
+        $this->currentContents = $this->numObj;
1285
+        $this->objects[$id]['info']['contents'] = array();
1286
+        $this->objects[$id]['info']['contents'][] = $this->numObj;
1287
+
1288
+        $match =  ($this->numPages%2 ?  'odd' :  'even');
1289
+        foreach($this->addLooseObjects as  $oId=>$target) {
1290 1290
         if  ($target === 'all' || $match === $target) {
1291
-          $this->objects[$id]['info']['contents'][] = $oId;
1291
+            $this->objects[$id]['info']['contents'][] = $oId;
1292 1292
         }
1293
-      }
1294
-      break;
1293
+        }
1294
+        break;
1295 1295
 
1296 1296
     case  'content':
1297 1297
       $o['info']['contents'][] = $options;
1298
-      break;
1298
+        break;
1299 1299
 
1300 1300
     case  'annot':
1301 1301
       // add an annotation to this page
1302 1302
       if  (!isset($o['info']['annot'])) {
1303 1303
         $o['info']['annot'] = array();
1304
-      }
1304
+        }
1305 1305
 
1306
-      // $options should contain the id of the annotation dictionary
1307
-      $o['info']['annot'][] = $options;
1308
-      break;
1306
+        // $options should contain the id of the annotation dictionary
1307
+        $o['info']['annot'][] = $options;
1308
+        break;
1309 1309
 
1310 1310
     case  'out':
1311 1311
       $res = "\n".$id." 0 obj\n<< /Type /Page";
1312
-      $res.= "\n/Parent ".$o['info']['parent']." 0 R";
1312
+        $res.= "\n/Parent ".$o['info']['parent']." 0 R";
1313 1313
 
1314
-      if  (isset($o['info']['annot'])) {
1314
+        if  (isset($o['info']['annot'])) {
1315 1315
         $res.= "\n/Annots [";
1316 1316
         foreach($o['info']['annot'] as  $aId) {
1317
-          $res.= " ".$aId." 0 R";
1317
+            $res.= " ".$aId." 0 R";
1318 1318
         }
1319 1319
         $res.= " ]";
1320
-      }
1320
+        }
1321 1321
 
1322
-      $count =  count($o['info']['contents']);
1323
-      if  ($count == 1) {
1322
+        $count =  count($o['info']['contents']);
1323
+        if  ($count == 1) {
1324 1324
         $res.= "\n/Contents ".$o['info']['contents'][0]." 0 R";
1325
-      } else  if  ($count>1) {
1325
+        } else  if  ($count>1) {
1326 1326
         $res.= "\n/Contents [\n";
1327 1327
 
1328 1328
         // reverse the page contents so added objects are below normal content
1329 1329
         //foreach (array_reverse($o['info']['contents']) as  $cId) {
1330 1330
         // Back to normal now that I've got transparency working --Benj
1331 1331
         foreach ($o['info']['contents'] as  $cId) {
1332
-          $res.= $cId." 0 R\n";
1332
+            $res.= $cId." 0 R\n";
1333 1333
         }
1334 1334
         $res.= "]";
1335
-      }
1335
+        }
1336 1336
 
1337
-      $res.= "\n>>\nendobj";
1338
-      return  $res;
1337
+        $res.= "\n>>\nendobj";
1338
+        return  $res;
1339
+    }
1339 1340
     }
1340
-  }
1341 1341
 
1342 1342
 
1343
-  /**
1344
-   * the contents objects hold all of the content which appears on pages
1345
-   */
1346
-  protected function  o_contents($id, $action, $options = '') {
1343
+    /**
1344
+     * the contents objects hold all of the content which appears on pages
1345
+     */
1346
+    protected function  o_contents($id, $action, $options = '') {
1347 1347
     if  ($action !== 'new') {
1348
-      $o = & $this->objects[$id];
1348
+        $o = & $this->objects[$id];
1349 1349
     }
1350 1350
 
1351 1351
     switch  ($action) {
1352 1352
     case  'new':
1353 1353
       $this->objects[$id] = array('t'=>'contents', 'c'=>'', 'info'=>array());
1354
-      if  (mb_strlen($options, '8bit') &&  intval($options)) {
1354
+        if  (mb_strlen($options, '8bit') &&  intval($options)) {
1355 1355
         // then this contents is the primary for a page
1356 1356
         $this->objects[$id]['onPage'] = $options;
1357
-      } else  if  ($options === 'raw') {
1357
+        } else  if  ($options === 'raw') {
1358 1358
         // then this page contains some other type of system object
1359 1359
         $this->objects[$id]['raw'] = 1;
1360
-      }
1361
-      break;
1360
+        }
1361
+        break;
1362 1362
 
1363 1363
     case  'add':
1364 1364
       // add more options to the decleration
1365 1365
       foreach ($options as  $k=>$v) {
1366 1366
         $o['info'][$k] = $v;
1367
-      }
1367
+        }
1368 1368
 
1369 1369
     case  'out':
1370 1370
       $tmp = $o['c'];
1371
-      $res =  "\n".$id." 0 obj\n";
1371
+        $res =  "\n".$id." 0 obj\n";
1372 1372
 
1373
-      if  (isset($this->objects[$id]['raw'])) {
1373
+        if  (isset($this->objects[$id]['raw'])) {
1374 1374
         $res.= $tmp;
1375
-      } else {
1375
+        } else {
1376 1376
         $res.=  "<<";
1377 1377
         if  (function_exists('gzcompress') &&  $this->options['compression']) {
1378
-          // then implement ZLIB based compression on this content stream
1379
-          $res.= " /Filter /FlateDecode";
1380
-          $tmp =  gzcompress($tmp,  6);
1378
+            // then implement ZLIB based compression on this content stream
1379
+            $res.= " /Filter /FlateDecode";
1380
+            $tmp =  gzcompress($tmp,  6);
1381 1381
         }
1382 1382
 
1383 1383
         if  ($this->encrypted) {
1384
-          $this->encryptInit($id);
1385
-          $tmp =  $this->ARC4($tmp);
1384
+            $this->encryptInit($id);
1385
+            $tmp =  $this->ARC4($tmp);
1386 1386
         }
1387 1387
 
1388 1388
         foreach($o['info'] as  $k=>$v) {
1389
-          $res.=  "\n/".$k.' '.$v;
1389
+            $res.=  "\n/".$k.' '.$v;
1390 1390
         }
1391 1391
 
1392 1392
         $res.= "\n/Length ".mb_strlen($tmp, '8bit') ." >>\nstream\n".$tmp."\nendstream";
1393
-      }
1393
+        }
1394 1394
 
1395
-      $res.= "\nendobj";
1396
-      return  $res;
1395
+        $res.= "\nendobj";
1396
+        return  $res;
1397
+    }
1397 1398
     }
1398
-  }
1399 1399
 
1400
-  protected function  o_embedjs($id, $action, $code = '') {
1400
+    protected function  o_embedjs($id, $action, $code = '') {
1401 1401
     if  ($action !== 'new') {
1402
-      $o = & $this->objects[$id];
1402
+        $o = & $this->objects[$id];
1403 1403
     }
1404 1404
 
1405 1405
     switch  ($action) {
1406 1406
     case  'new':
1407 1407
       $this->objects[$id] = array('t'=>'embedjs', 'info'=>array(
1408 1408
         'Names' => '[(EmbeddedJS) '.($id+1).' 0 R]'
1409
-      ));
1410
-      break;
1409
+        ));
1410
+        break;
1411 1411
 
1412 1412
     case  'out':
1413 1413
       $res .= "\n".$id." 0 obj\n".'<< ';
1414
-      foreach($o['info'] as  $k=>$v) {
1414
+        foreach($o['info'] as  $k=>$v) {
1415 1415
         $res.=  "\n/".$k.' '.$v;
1416
-      }
1417
-      $res.= "\n>>\nendobj";
1418
-      return  $res;
1416
+        }
1417
+        $res.= "\n>>\nendobj";
1418
+        return  $res;
1419
+    }
1419 1420
     }
1420
-  }
1421 1421
   
1422
-  protected function  o_javascript($id, $action, $code = '') {
1422
+    protected function  o_javascript($id, $action, $code = '') {
1423 1423
     if  ($action !== 'new') {
1424
-      $o = & $this->objects[$id];
1424
+        $o = & $this->objects[$id];
1425 1425
     }
1426 1426
 
1427 1427
     switch  ($action) {
@@ -1429,71 +1429,71 @@  discard block
 block discarded – undo
1429 1429
       $this->objects[$id] = array('t'=>'javascript', 'info'=>array(
1430 1430
         'S' => '/JavaScript',
1431 1431
         'JS' => '('.$this->filterText($code).')',
1432
-      ));
1433
-      break;
1432
+        ));
1433
+        break;
1434 1434
 
1435 1435
     case  'out':
1436 1436
       $res = "\n".$id." 0 obj\n".'<< ';
1437
-      foreach($o['info'] as  $k=>$v) {
1437
+        foreach($o['info'] as  $k=>$v) {
1438 1438
         $res.=  "\n/".$k.' '.$v;
1439
-      }
1440
-      $res.= "\n>>\nendobj";
1441
-      return  $res;
1439
+        }
1440
+        $res.= "\n>>\nendobj";
1441
+        return  $res;
1442
+    }
1442 1443
     }
1443
-  }
1444 1444
 
1445
-  /**
1446
-   * an image object, will be an XObject in the document, includes description and data
1447
-   */
1448
-  protected function  o_image($id, $action, $options = '') {
1445
+    /**
1446
+     * an image object, will be an XObject in the document, includes description and data
1447
+     */
1448
+    protected function  o_image($id, $action, $options = '') {
1449 1449
     if  ($action !== 'new') {
1450
-      $o = & $this->objects[$id];
1450
+        $o = & $this->objects[$id];
1451 1451
     }
1452 1452
 
1453 1453
     switch ($action) {
1454 1454
     case  'new':
1455 1455
       // make the new object
1456 1456
       $this->objects[$id] = array('t'=>'image', 'data'=>&$options['data'], 'info'=>array());
1457
-      $this->objects[$id]['info']['Type'] = '/XObject';
1458
-      $this->objects[$id]['info']['Subtype'] = '/Image';
1459
-      $this->objects[$id]['info']['Width'] = $options['iw'];
1460
-      $this->objects[$id]['info']['Height'] = $options['ih'];
1457
+        $this->objects[$id]['info']['Type'] = '/XObject';
1458
+        $this->objects[$id]['info']['Subtype'] = '/Image';
1459
+        $this->objects[$id]['info']['Width'] = $options['iw'];
1460
+        $this->objects[$id]['info']['Height'] = $options['ih'];
1461 1461
 
1462
-      if  (!isset($options['type']) ||  $options['type'] === 'jpg') {
1462
+        if  (!isset($options['type']) ||  $options['type'] === 'jpg') {
1463 1463
         if  (!isset($options['channels'])) {
1464
-          $options['channels'] = 3;
1464
+            $options['channels'] = 3;
1465 1465
         }
1466 1466
 
1467 1467
         switch ($options['channels']) {
1468 1468
         case  1:
1469 1469
           $this->objects[$id]['info']['ColorSpace'] = '/DeviceGray';
1470
-          break;
1470
+            break;
1471 1471
 
1472 1472
         default:
1473 1473
           $this->objects[$id]['info']['ColorSpace'] = '/DeviceRGB';
1474
-          break;
1474
+            break;
1475 1475
         }
1476 1476
 
1477 1477
         $this->objects[$id]['info']['Filter'] = '/DCTDecode';
1478 1478
         $this->objects[$id]['info']['BitsPerComponent'] = 8;
1479
-      } else  if  ($options['type'] === 'png') {
1479
+        } else  if  ($options['type'] === 'png') {
1480 1480
         $this->objects[$id]['info']['Filter'] = '/FlateDecode';
1481 1481
         $this->objects[$id]['info']['DecodeParms'] = '<< /Predictor 15 /Colors '.$options['ncolor'].' /Columns '.$options['iw'].' /BitsPerComponent '.$options['bitsPerComponent'].'>>';
1482 1482
 
1483 1483
         if  (mb_strlen($options['pdata'], '8bit')) {
1484
-          $tmp =  ' [ /Indexed /DeviceRGB '.(mb_strlen($options['pdata'], '8bit') /3-1) .' ';
1485
-          $this->numObj++;
1486
-          $this->o_contents($this->numObj, 'new');
1487
-          $this->objects[$this->numObj]['c'] = $options['pdata'];
1488
-          $tmp.= $this->numObj.' 0 R';
1489
-          $tmp.= ' ]';
1490
-          $this->objects[$id]['info']['ColorSpace'] =  $tmp;
1491
-          if  (isset($options['transparency'])) {
1484
+            $tmp =  ' [ /Indexed /DeviceRGB '.(mb_strlen($options['pdata'], '8bit') /3-1) .' ';
1485
+            $this->numObj++;
1486
+            $this->o_contents($this->numObj, 'new');
1487
+            $this->objects[$this->numObj]['c'] = $options['pdata'];
1488
+            $tmp.= $this->numObj.' 0 R';
1489
+            $tmp.= ' ]';
1490
+            $this->objects[$id]['info']['ColorSpace'] =  $tmp;
1491
+            if  (isset($options['transparency'])) {
1492 1492
             switch ($options['transparency']['type']) {
1493 1493
             case  'indexed':
1494 1494
               $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] ';
1495
-              $this->objects[$id]['info']['Mask'] =  $tmp;
1496
-              break;
1495
+                $this->objects[$id]['info']['Mask'] =  $tmp;
1496
+                break;
1497 1497
 
1498 1498
             case 'color-key':
1499 1499
               $tmp = ' [ '.
@@ -1501,19 +1501,19 @@  discard block
 block discarded – undo
1501 1501
                 $options['transparency']['g'] . ' ' . $options['transparency']['g'] .
1502 1502
                 $options['transparency']['b'] . ' ' . $options['transparency']['b'] .
1503 1503
                 ' ] ';
1504
-              $this->objects[$id]['info']['Mask'] = $tmp;
1505
-              pre_r($tmp);
1506
-              break;
1504
+                $this->objects[$id]['info']['Mask'] = $tmp;
1505
+                pre_r($tmp);
1506
+                break;
1507 1507
               
1508 1508
             }
1509
-          }
1509
+            }
1510 1510
         } else {
1511
-          if  (isset($options['transparency'])) {
1511
+            if  (isset($options['transparency'])) {
1512 1512
             switch ($options['transparency']['type']) {
1513 1513
             case  'indexed':
1514 1514
               $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] ';
1515
-              $this->objects[$id]['info']['Mask'] =  $tmp;
1516
-              break;
1515
+                $this->objects[$id]['info']['Mask'] =  $tmp;
1516
+                break;
1517 1517
 
1518 1518
             case 'color-key':
1519 1519
               $tmp = ' [ '.
@@ -1521,329 +1521,329 @@  discard block
 block discarded – undo
1521 1521
                 $options['transparency']['g'] . ' ' . $options['transparency']['g'] . ' ' .
1522 1522
                 $options['transparency']['b'] . ' ' . $options['transparency']['b'] .
1523 1523
                 ' ] ';
1524
-              $this->objects[$id]['info']['Mask'] = $tmp;
1525
-              break;              
1524
+                $this->objects[$id]['info']['Mask'] = $tmp;
1525
+                break;              
1526
+            }
1526 1527
             }
1527
-          }
1528
-          $this->objects[$id]['info']['ColorSpace'] = '/'.$options['color'];
1528
+            $this->objects[$id]['info']['ColorSpace'] = '/'.$options['color'];
1529 1529
         }
1530 1530
 
1531 1531
         $this->objects[$id]['info']['BitsPerComponent'] = $options['bitsPerComponent'];
1532
-      }
1532
+        }
1533 1533
 
1534
-      // assign it a place in the named resource dictionary as an external object, according to
1535
-      // the label passed in with it.
1536
-      $this->o_pages($this->currentNode, 'xObject', array('label'=>$options['label'], 'objNum'=>$id));
1534
+        // assign it a place in the named resource dictionary as an external object, according to
1535
+        // the label passed in with it.
1536
+        $this->o_pages($this->currentNode, 'xObject', array('label'=>$options['label'], 'objNum'=>$id));
1537 1537
 
1538
-      // also make sure that we have the right procset object for it.
1539
-      $this->o_procset($this->procsetObjectId, 'add', 'ImageC');
1540
-      break;
1538
+        // also make sure that we have the right procset object for it.
1539
+        $this->o_procset($this->procsetObjectId, 'add', 'ImageC');
1540
+        break;
1541 1541
 
1542 1542
     case  'out':
1543 1543
       $tmp = &$o['data'];
1544
-      $res =  "\n".$id." 0 obj\n<<";
1544
+        $res =  "\n".$id." 0 obj\n<<";
1545 1545
 
1546
-      foreach($o['info'] as  $k=>$v) {
1546
+        foreach($o['info'] as  $k=>$v) {
1547 1547
         $res.= "\n/".$k.' '.$v;
1548
-      }
1548
+        }
1549 1549
 
1550
-      if  ($this->encrypted) {
1550
+        if  ($this->encrypted) {
1551 1551
         $this->encryptInit($id);
1552 1552
         $tmp =  $this->ARC4($tmp);
1553
-      }
1553
+        }
1554 1554
 
1555
-      $res.= "\n/Length ".mb_strlen($tmp, '8bit') .">>\nstream\n".$tmp."\nendstream\nendobj";
1555
+        $res.= "\n/Length ".mb_strlen($tmp, '8bit') .">>\nstream\n".$tmp."\nendstream\nendobj";
1556 1556
 
1557
-      return  $res;
1557
+        return  $res;
1558
+    }
1558 1559
     }
1559
-  }
1560 1560
 
1561 1561
 
1562
-  /**
1563
-   * graphics state object
1564
-   */
1565
-  protected function  o_extGState($id,  $action,  $options = "") {
1562
+    /**
1563
+     * graphics state object
1564
+     */
1565
+    protected function  o_extGState($id,  $action,  $options = "") {
1566 1566
     static  $valid_params =  array("LW",  "LC",  "LC",  "LJ",  "ML",
1567
-                                   "D",  "RI",  "OP",  "op",  "OPM",
1568
-                                   "Font",  "BG",  "BG2",  "UCR",
1569
-                                   "TR",  "TR2",  "HT",  "FL",
1570
-                                   "SM",  "SA",  "BM",  "SMask",
1571
-                                   "CA",  "ca",  "AIS",  "TK");
1567
+                                    "D",  "RI",  "OP",  "op",  "OPM",
1568
+                                    "Font",  "BG",  "BG2",  "UCR",
1569
+                                    "TR",  "TR2",  "HT",  "FL",
1570
+                                    "SM",  "SA",  "BM",  "SMask",
1571
+                                    "CA",  "ca",  "AIS",  "TK");
1572 1572
 
1573 1573
     if  ($action !==  "new") {
1574
-      $o = & $this->objects[$id];
1574
+        $o = & $this->objects[$id];
1575 1575
     }
1576 1576
 
1577 1577
     switch  ($action) {
1578 1578
     case  "new":
1579 1579
       $this->objects[$id] =  array('t' => 'extGState',  'info' => $options);
1580 1580
 
1581
-      // Tell the pages about the new resource
1582
-      $this->numStates++;
1583
-      $this->o_pages($this->currentNode,  'extGState',  array("objNum" => $id,  "stateNum" => $this->numStates));
1584
-      break;
1581
+        // Tell the pages about the new resource
1582
+        $this->numStates++;
1583
+        $this->o_pages($this->currentNode,  'extGState',  array("objNum" => $id,  "stateNum" => $this->numStates));
1584
+        break;
1585 1585
 
1586 1586
     case  "out":
1587 1587
       $res =
1588 1588
         "\n" . $id . " 0 obj\n".
1589 1589
         "<< /Type /ExtGState\n";
1590 1590
 
1591
-      foreach ($o["info"] as  $parameter => $value) {
1591
+        foreach ($o["info"] as  $parameter => $value) {
1592 1592
         if  ( !in_array($parameter,  $valid_params))
1593
-          continue;
1593
+            continue;
1594 1594
         $res.=  "/$parameter $value\n";
1595
-      }
1595
+        }
1596 1596
 
1597
-      $res.=
1597
+        $res.=
1598 1598
         ">>\n".
1599 1599
         "endobj";
1600
-      return  $res;
1600
+        return  $res;
1601
+    }
1601 1602
     }
1602
-  }
1603 1603
 
1604 1604
 
1605
-  /**
1606
-   * encryption object.
1607
-   */
1608
-  protected function  o_encryption($id, $action, $options = '') {
1605
+    /**
1606
+     * encryption object.
1607
+     */
1608
+    protected function  o_encryption($id, $action, $options = '') {
1609 1609
     if  ($action !== 'new') {
1610
-      $o = & $this->objects[$id];
1610
+        $o = & $this->objects[$id];
1611 1611
     }
1612 1612
 
1613 1613
     switch ($action) {
1614 1614
     case  'new':
1615 1615
       // make the new object
1616 1616
       $this->objects[$id] = array('t'=>'encryption', 'info'=>$options);
1617
-      $this->arc4_objnum = $id;
1617
+        $this->arc4_objnum = $id;
1618 1618
 
1619
-      // figure out the additional paramaters required
1620
-      $pad =  chr(0x28) .chr(0xBF) .chr(0x4E) .chr(0x5E) .chr(0x4E) .chr(0x75) .chr(0x8A) .chr(0x41) .chr(0x64) .chr(0x00) .chr(0x4E) .chr(0x56) .chr(0xFF) .chr(0xFA) .chr(0x01) .chr(0x08) .chr(0x2E) .chr(0x2E) .chr(0x00) .chr(0xB6) .chr(0xD0) .chr(0x68) .chr(0x3E) .chr(0x80) .chr(0x2F) .chr(0x0C) .chr(0xA9) .chr(0xFE) .chr(0x64) .chr(0x53) .chr(0x69) .chr(0x7A);
1621
-      $len =  mb_strlen($options['owner'], '8bit');
1619
+        // figure out the additional paramaters required
1620
+        $pad =  chr(0x28) .chr(0xBF) .chr(0x4E) .chr(0x5E) .chr(0x4E) .chr(0x75) .chr(0x8A) .chr(0x41) .chr(0x64) .chr(0x00) .chr(0x4E) .chr(0x56) .chr(0xFF) .chr(0xFA) .chr(0x01) .chr(0x08) .chr(0x2E) .chr(0x2E) .chr(0x00) .chr(0xB6) .chr(0xD0) .chr(0x68) .chr(0x3E) .chr(0x80) .chr(0x2F) .chr(0x0C) .chr(0xA9) .chr(0xFE) .chr(0x64) .chr(0x53) .chr(0x69) .chr(0x7A);
1621
+        $len =  mb_strlen($options['owner'], '8bit');
1622 1622
 
1623
-      if  ($len>32) {
1623
+        if  ($len>32) {
1624 1624
         $owner =  substr($options['owner'], 0, 32);
1625
-      } else  if  ($len<32) {
1625
+        } else  if  ($len<32) {
1626 1626
         $owner =  $options['owner'].substr($pad, 0, 32-$len);
1627
-      } else {
1627
+        } else {
1628 1628
         $owner =  $options['owner'];
1629
-      }
1629
+        }
1630 1630
 
1631
-      $len =  mb_strlen($options['user'], '8bit');
1632
-      if  ($len>32) {
1631
+        $len =  mb_strlen($options['user'], '8bit');
1632
+        if  ($len>32) {
1633 1633
         $user =  substr($options['user'], 0, 32);
1634
-      } else  if  ($len<32) {
1634
+        } else  if  ($len<32) {
1635 1635
         $user =  $options['user'].substr($pad, 0, 32-$len);
1636
-      } else {
1636
+        } else {
1637 1637
         $user =  $options['user'];
1638
-      }
1639
-
1640
-      $tmp =  $this->md5_16($owner);
1641
-      $okey =  substr($tmp, 0, 5);
1642
-      $this->ARC4_init($okey);
1643
-      $ovalue = $this->ARC4($user);
1644
-      $this->objects[$id]['info']['O'] = $ovalue;
1645
-
1646
-      // now make the u value, phew.
1647
-      $tmp =  $this->md5_16($user.$ovalue.chr($options['p']) .chr(255) .chr(255) .chr(255) .$this->fileIdentifier);
1648
-
1649
-      $ukey =  substr($tmp, 0, 5);
1650
-      $this->ARC4_init($ukey);
1651
-      $this->encryptionKey =  $ukey;
1652
-      $this->encrypted = 1;
1653
-      $uvalue = $this->ARC4($pad);
1654
-      $this->objects[$id]['info']['U'] = $uvalue;
1655
-      $this->encryptionKey = $ukey;
1656
-      // initialize the arc4 array
1657
-      break;
1638
+        }
1639
+
1640
+        $tmp =  $this->md5_16($owner);
1641
+        $okey =  substr($tmp, 0, 5);
1642
+        $this->ARC4_init($okey);
1643
+        $ovalue = $this->ARC4($user);
1644
+        $this->objects[$id]['info']['O'] = $ovalue;
1645
+
1646
+        // now make the u value, phew.
1647
+        $tmp =  $this->md5_16($user.$ovalue.chr($options['p']) .chr(255) .chr(255) .chr(255) .$this->fileIdentifier);
1648
+
1649
+        $ukey =  substr($tmp, 0, 5);
1650
+        $this->ARC4_init($ukey);
1651
+        $this->encryptionKey =  $ukey;
1652
+        $this->encrypted = 1;
1653
+        $uvalue = $this->ARC4($pad);
1654
+        $this->objects[$id]['info']['U'] = $uvalue;
1655
+        $this->encryptionKey = $ukey;
1656
+        // initialize the arc4 array
1657
+        break;
1658 1658
 
1659 1659
     case  'out':
1660 1660
       $res =  "\n".$id." 0 obj\n<<";
1661
-      $res.= "\n/Filter /Standard";
1662
-      $res.= "\n/V 1";
1663
-      $res.= "\n/R 2";
1664
-      $res.= "\n/O (".$this->filterText($o['info']['O']) .')';
1665
-      $res.= "\n/U (".$this->filterText($o['info']['U']) .')';
1666
-      // and the p-value needs to be converted to account for the twos-complement approach
1667
-      $o['info']['p'] =  (($o['info']['p']^255) +1) *-1;
1668
-      $res.= "\n/P ".($o['info']['p']);
1669
-      $res.= "\n>>\nendobj";
1670
-      return  $res;
1671
-    }
1672
-  }
1673
-
1674
-
1675
-  /**
1676
-   * ARC4 functions
1677
-   * A series of function to implement ARC4 encoding in PHP
1678
-   */
1661
+        $res.= "\n/Filter /Standard";
1662
+        $res.= "\n/V 1";
1663
+        $res.= "\n/R 2";
1664
+        $res.= "\n/O (".$this->filterText($o['info']['O']) .')';
1665
+        $res.= "\n/U (".$this->filterText($o['info']['U']) .')';
1666
+        // and the p-value needs to be converted to account for the twos-complement approach
1667
+        $o['info']['p'] =  (($o['info']['p']^255) +1) *-1;
1668
+        $res.= "\n/P ".($o['info']['p']);
1669
+        $res.= "\n>>\nendobj";
1670
+        return  $res;
1671
+    }
1672
+    }
1679 1673
 
1680
-  /**
1681
-   * calculate the 16 byte version of the 128 bit md5 digest of the string
1682
-   */
1683
-  function  md5_16($string) {
1674
+
1675
+    /**
1676
+     * ARC4 functions
1677
+     * A series of function to implement ARC4 encoding in PHP
1678
+     */
1679
+
1680
+    /**
1681
+     * calculate the 16 byte version of the 128 bit md5 digest of the string
1682
+     */
1683
+    function  md5_16($string) {
1684 1684
     $tmp =  md5($string);
1685 1685
     $out = '';
1686 1686
     for  ($i = 0;$i <= 30;$i = $i+2) {
1687
-      $out.= chr(hexdec(substr($tmp, $i, 2)));
1687
+        $out.= chr(hexdec(substr($tmp, $i, 2)));
1688 1688
     }
1689 1689
     return  $out;
1690
-  }
1690
+    }
1691 1691
 
1692 1692
 
1693
-  /**
1694
-   * initialize the encryption for processing a particular object
1695
-   */
1696
-  function  encryptInit($id) {
1693
+    /**
1694
+     * initialize the encryption for processing a particular object
1695
+     */
1696
+    function  encryptInit($id) {
1697 1697
     $tmp =  $this->encryptionKey;
1698 1698
     $hex =  dechex($id);
1699 1699
     if  (mb_strlen($hex, '8bit') <6) {
1700
-      $hex =  substr('000000', 0, 6-mb_strlen($hex, '8bit')) .$hex;
1700
+        $hex =  substr('000000', 0, 6-mb_strlen($hex, '8bit')) .$hex;
1701 1701
     }
1702 1702
     $tmp.=  chr(hexdec(substr($hex, 4, 2))) .chr(hexdec(substr($hex, 2, 2))) .chr(hexdec(substr($hex, 0, 2))) .chr(0) .chr(0);
1703 1703
     $key =  $this->md5_16($tmp);
1704 1704
     $this->ARC4_init(substr($key, 0, 10));
1705
-  }
1705
+    }
1706 1706
 
1707 1707
 
1708
-  /**
1709
-   * initialize the ARC4 encryption
1710
-   */
1711
-  function  ARC4_init($key = '') {
1708
+    /**
1709
+     * initialize the ARC4 encryption
1710
+     */
1711
+    function  ARC4_init($key = '') {
1712 1712
     $this->arc4 =  '';
1713 1713
 
1714 1714
     // setup the control array
1715 1715
     if  (mb_strlen($key, '8bit') == 0) {
1716
-      return;
1716
+        return;
1717 1717
     }
1718 1718
 
1719 1719
     $k =  '';
1720 1720
     while (mb_strlen($k, '8bit') <256) {
1721
-      $k.= $key;
1721
+        $k.= $key;
1722 1722
     }
1723 1723
 
1724 1724
     $k = substr($k, 0, 256);
1725 1725
     for  ($i = 0;$i<256;$i++) {
1726
-      $this->arc4.=  chr($i);
1726
+        $this->arc4.=  chr($i);
1727 1727
     }
1728 1728
 
1729 1729
     $j = 0;
1730 1730
 
1731 1731
     for  ($i = 0;$i<256;$i++) {
1732
-      $t =  $this->arc4[$i];
1733
-      $j =  ($j + ord($t)  + ord($k[$i])) %256;
1734
-      $this->arc4[$i] = $this->arc4[$j];
1735
-      $this->arc4[$j] = $t;
1732
+        $t =  $this->arc4[$i];
1733
+        $j =  ($j + ord($t)  + ord($k[$i])) %256;
1734
+        $this->arc4[$i] = $this->arc4[$j];
1735
+        $this->arc4[$j] = $t;
1736
+    }
1736 1737
     }
1737
-  }
1738 1738
 
1739 1739
 
1740
-  /**
1741
-   * ARC4 encrypt a text string
1742
-   */
1743
-  function  ARC4($text) {
1740
+    /**
1741
+     * ARC4 encrypt a text string
1742
+     */
1743
+    function  ARC4($text) {
1744 1744
     $len = mb_strlen($text, '8bit');
1745 1745
     $a = 0;
1746 1746
     $b = 0;
1747 1747
     $c =  $this->arc4;
1748 1748
     $out = '';
1749 1749
     for  ($i = 0;$i<$len;$i++) {
1750
-      $a =  ($a+1) %256;
1751
-      $t =  $c[$a];
1752
-      $b =  ($b+ord($t)) %256;
1753
-      $c[$a] = $c[$b];
1754
-      $c[$b] = $t;
1755
-      $k =  ord($c[(ord($c[$a]) +ord($c[$b])) %256]);
1756
-      $out.= chr(ord($text[$i])  ^ $k);
1750
+        $a =  ($a+1) %256;
1751
+        $t =  $c[$a];
1752
+        $b =  ($b+ord($t)) %256;
1753
+        $c[$a] = $c[$b];
1754
+        $c[$b] = $t;
1755
+        $k =  ord($c[(ord($c[$a]) +ord($c[$b])) %256]);
1756
+        $out.= chr(ord($text[$i])  ^ $k);
1757 1757
     }
1758 1758
     return  $out;
1759
-  }
1759
+    }
1760 1760
 
1761 1761
 
1762
-  /**
1763
-   * functions which can be called to adjust or add to the document
1764
-   */
1762
+    /**
1763
+     * functions which can be called to adjust or add to the document
1764
+     */
1765 1765
 
1766
-  /**
1767
-   * add a link in the document to an external URL
1768
-   */
1769
-  function  addLink($url, $x0, $y0, $x1, $y1) {
1766
+    /**
1767
+     * add a link in the document to an external URL
1768
+     */
1769
+    function  addLink($url, $x0, $y0, $x1, $y1) {
1770 1770
     $this->numObj++;
1771 1771
     $info =  array('type'=>'link', 'url'=>$url, 'rect'=>array($x0, $y0, $x1, $y1));
1772 1772
     $this->o_annotation($this->numObj, 'new', $info);
1773
-  }
1773
+    }
1774 1774
 
1775 1775
 
1776
-  /**
1777
-   * add a link in the document to an internal destination (ie. within the document)
1778
-   */
1779
-  function  addInternalLink($label, $x0, $y0, $x1, $y1) {
1776
+    /**
1777
+     * add a link in the document to an internal destination (ie. within the document)
1778
+     */
1779
+    function  addInternalLink($label, $x0, $y0, $x1, $y1) {
1780 1780
     $this->numObj++;
1781 1781
     $info =  array('type'=>'ilink', 'label'=>$label, 'rect'=>array($x0, $y0, $x1, $y1));
1782 1782
     $this->o_annotation($this->numObj, 'new', $info);
1783
-  }
1783
+    }
1784 1784
 
1785 1785
 
1786
-  /**
1787
-   * set the encryption of the document
1788
-   * can be used to turn it on and/or set the passwords which it will have.
1789
-   * also the functions that the user will have are set here, such as print, modify, add
1790
-   */
1791
-  function  setEncryption($userPass = '', $ownerPass = '', $pc = array()) {
1786
+    /**
1787
+     * set the encryption of the document
1788
+     * can be used to turn it on and/or set the passwords which it will have.
1789
+     * also the functions that the user will have are set here, such as print, modify, add
1790
+     */
1791
+    function  setEncryption($userPass = '', $ownerPass = '', $pc = array()) {
1792 1792
     $p = bindec(11000000);
1793 1793
 
1794 1794
     $options =  array('print'=>4, 'modify'=>8, 'copy'=>16, 'add'=>32);
1795 1795
 
1796 1796
     foreach($pc as  $k=>$v) {
1797
-      if  ($v &&  isset($options[$k])) {
1797
+        if  ($v &&  isset($options[$k])) {
1798 1798
         $p+= $options[$k];
1799
-      } else  if  (isset($options[$v])) {
1799
+        } else  if  (isset($options[$v])) {
1800 1800
         $p+= $options[$v];
1801
-      }
1801
+        }
1802 1802
     }
1803 1803
 
1804 1804
     // implement encryption on the document
1805 1805
     if  ($this->arc4_objnum ==  0) {
1806
-      // then the block does not exist already, add it.
1807
-      $this->numObj++;
1808
-      if  (mb_strlen($ownerPass) == 0) {
1806
+        // then the block does not exist already, add it.
1807
+        $this->numObj++;
1808
+        if  (mb_strlen($ownerPass) == 0) {
1809 1809
         $ownerPass = $userPass;
1810
-      }
1810
+        }
1811 1811
 
1812
-      $this->o_encryption($this->numObj, 'new', array('user'=>$userPass, 'owner'=>$ownerPass, 'p'=>$p));
1812
+        $this->o_encryption($this->numObj, 'new', array('user'=>$userPass, 'owner'=>$ownerPass, 'p'=>$p));
1813
+    }
1813 1814
     }
1814
-  }
1815 1815
 
1816 1816
 
1817
-  /**
1818
-   * should be used for internal checks, not implemented as yet
1819
-   */
1820
-  function  checkAllHere() {
1821
-  }
1817
+    /**
1818
+     * should be used for internal checks, not implemented as yet
1819
+     */
1820
+    function  checkAllHere() {
1821
+    }
1822 1822
 
1823 1823
 
1824
-  /**
1825
-   * return the pdf stream as a string returned from the function
1826
-   */
1827
-  function  output($debug = false) {
1824
+    /**
1825
+     * return the pdf stream as a string returned from the function
1826
+     */
1827
+    function  output($debug = false) {
1828 1828
     if  ($debug) {
1829
-      // turn compression off
1830
-      $this->options['compression'] = 0;
1829
+        // turn compression off
1830
+        $this->options['compression'] = 0;
1831 1831
     }
1832 1832
     
1833 1833
     if ($this->javascript) {
1834
-      $this->numObj++;
1834
+        $this->numObj++;
1835 1835
       
1836
-      $js_id = $this->numObj;
1837
-      $this->o_embedjs($js_id, 'new');
1838
-      $this->o_javascript(++$this->numObj, 'new', $this->javascript);
1836
+        $js_id = $this->numObj;
1837
+        $this->o_embedjs($js_id, 'new');
1838
+        $this->o_javascript(++$this->numObj, 'new', $this->javascript);
1839 1839
       
1840
-      $id =  $this->catalogId;
1840
+        $id =  $this->catalogId;
1841 1841
       
1842
-      $this->o_catalog($id, 'javascript', $js_id);
1842
+        $this->o_catalog($id, 'javascript', $js_id);
1843 1843
     }
1844 1844
 
1845 1845
     if  ($this->arc4_objnum) {
1846
-      $this->ARC4_init($this->encryptionKey);
1846
+        $this->ARC4_init($this->encryptionKey);
1847 1847
     }
1848 1848
 
1849 1849
     $this->checkAllHere();
@@ -1854,43 +1854,43 @@  discard block
 block discarded – undo
1854 1854
     $pos = mb_strlen($content, '8bit');
1855 1855
 
1856 1856
     foreach($this->objects as  $k=>$v) {
1857
-      $tmp = 'o_'.$v['t'];
1858
-      $cont = $this->$tmp($k, 'out');
1859
-      $content.= $cont;
1860
-      $xref[] = $pos;
1861
-      $pos+= mb_strlen($cont, '8bit');
1857
+        $tmp = 'o_'.$v['t'];
1858
+        $cont = $this->$tmp($k, 'out');
1859
+        $content.= $cont;
1860
+        $xref[] = $pos;
1861
+        $pos+= mb_strlen($cont, '8bit');
1862 1862
     }
1863 1863
 
1864 1864
     $content.= "\nxref\n0 ".(count($xref) +1) ."\n0000000000 65535 f \n";
1865 1865
 
1866 1866
     foreach($xref as  $p) {
1867
-      $content.= str_pad($p,  10,  "0",  STR_PAD_LEFT)  . " 00000 n \n";
1867
+        $content.= str_pad($p,  10,  "0",  STR_PAD_LEFT)  . " 00000 n \n";
1868 1868
     }
1869 1869
 
1870 1870
     $content.= "trailer\n<<\n/Size ".(count($xref) +1) ."\n/Root 1 0 R\n/Info ".$this->infoObject." 0 R\n";
1871 1871
 
1872 1872
     // if encryption has been applied to this document then add the marker for this dictionary
1873 1873
     if  ($this->arc4_objnum > 0) {
1874
-      $content.=  "/Encrypt ".$this->arc4_objnum." 0 R\n";
1874
+        $content.=  "/Encrypt ".$this->arc4_objnum." 0 R\n";
1875 1875
     }
1876 1876
 
1877 1877
     if  (mb_strlen($this->fileIdentifier, '8bit')) {
1878
-      $content.=  "/ID[<".$this->fileIdentifier."><".$this->fileIdentifier.">]\n";
1878
+        $content.=  "/ID[<".$this->fileIdentifier."><".$this->fileIdentifier.">]\n";
1879 1879
     }
1880 1880
 
1881 1881
     $content.=  ">>\nstartxref\n".$pos."\n%%EOF\n";
1882 1882
 
1883 1883
     return  $content;
1884
-  }
1885
-
1886
-  /**
1887
-   * intialize a new document
1888
-   * if this is called on an existing document results may be unpredictable, but the existing document would be lost at minimum
1889
-   * this function is called automatically by the constructor function
1890
-   *
1891
-   * @access private
1892
-   */
1893
-  function  newDocument($pageSize = array(0, 0, 612, 792)) {
1884
+    }
1885
+
1886
+    /**
1887
+     * intialize a new document
1888
+     * if this is called on an existing document results may be unpredictable, but the existing document would be lost at minimum
1889
+     * this function is called automatically by the constructor function
1890
+     *
1891
+     * @access private
1892
+     */
1893
+    function  newDocument($pageSize = array(0, 0, 612, 792)) {
1894 1894
     $this->numObj = 0;
1895 1895
     $this->objects =  array();
1896 1896
 
@@ -1918,32 +1918,32 @@  discard block
 block discarded – undo
1918 1918
     // need to store the first page id as there is no way to get it to the user during
1919 1919
     // startup
1920 1920
     $this->firstPageId =  $this->currentContents;
1921
-  }
1922
-
1923
-  /**
1924
-   * open the font file and return a php structure containing it.
1925
-   * first check if this one has been done before and saved in a form more suited to php
1926
-   * note that if a php serialized version does not exist it will try and make one, but will
1927
-   * require write access to the directory to do it... it is MUCH faster to have these serialized
1928
-   * files.
1929
-   *
1930
-   * @access private
1931
-   */
1932
-  function  openFont($font) {
1921
+    }
1922
+
1923
+    /**
1924
+     * open the font file and return a php structure containing it.
1925
+     * first check if this one has been done before and saved in a form more suited to php
1926
+     * note that if a php serialized version does not exist it will try and make one, but will
1927
+     * require write access to the directory to do it... it is MUCH faster to have these serialized
1928
+     * files.
1929
+     *
1930
+     * @access private
1931
+     */
1932
+    function  openFont($font) {
1933 1933
     // assume that $font contains the path and file but not the extension
1934 1934
     $pos = strrpos($font, '/');
1935 1935
 
1936 1936
     if  ($pos === false) {
1937
-      $dir =  './';
1938
-      $name =  $font;
1937
+        $dir =  './';
1938
+        $name =  $font;
1939 1939
     } else {
1940
-      $dir = substr($font, 0, $pos+1);
1941
-      $name = substr($font, $pos+1);
1940
+        $dir = substr($font, 0, $pos+1);
1941
+        $name = substr($font, $pos+1);
1942 1942
     }
1943 1943
     
1944 1944
     $fontcache = $this->fontcache;
1945 1945
     if ($fontcache == '') {
1946
-    	$fontcache = $dir;
1946
+        $fontcache = $dir;
1947 1947
     }
1948 1948
     
1949 1949
     //$name       filename without folder and extension of font metrics
@@ -1964,42 +1964,42 @@  discard block
 block discarded – undo
1964 1964
     $cache_name = 'php_' . $metrics_name;
1965 1965
     $this->addMessage('metrics: '.$metrics_name.', cache: '.$cache_name);
1966 1966
     if  (file_exists($fontcache . $cache_name)) {
1967
-      $this->addMessage('openFont: php file exists ' . $fontcache . $cache_name);
1968
-      $tmp =  file_get_contents($fontcache . $cache_name);
1969
-      eval($tmp);
1967
+        $this->addMessage('openFont: php file exists ' . $fontcache . $cache_name);
1968
+        $tmp =  file_get_contents($fontcache . $cache_name);
1969
+        eval($tmp);
1970 1970
 
1971
-      if  (!isset($this->fonts[$font]['_version_']) ||  $this->fonts[$font]['_version_'] != $this->fontcacheVersion) {
1971
+        if  (!isset($this->fonts[$font]['_version_']) ||  $this->fonts[$font]['_version_'] != $this->fontcacheVersion) {
1972 1972
         // if the font file is old, then clear it out and prepare for re-creation
1973 1973
         $this->addMessage('openFont: clear out, make way for new version.');
1974 1974
         unset($this->fonts[$font]);
1975
-      }
1975
+        }
1976 1976
     }
1977 1977
 
1978 1978
     if  (!isset($this->fonts[$font]) &&  file_exists($dir . $metrics_name)) {
1979
-      // then rebuild the php_<font>.afm file from the <font>.afm file
1980
-      $this->addMessage('openFont: build php file from ' . $dir . $metrics_name);
1981
-      $data =  array();
1979
+        // then rebuild the php_<font>.afm file from the <font>.afm file
1980
+        $this->addMessage('openFont: build php file from ' . $dir . $metrics_name);
1981
+        $data =  array();
1982 1982
       
1983
-      // Since we're not going to enable Unicode for the core fonts we need to use a font-based
1984
-      // setting for Unicode support rather than a global setting.
1985
-      $data['isUnicode'] = (strtolower(substr($metrics_name, -3)) !== 'afm');
1983
+        // Since we're not going to enable Unicode for the core fonts we need to use a font-based
1984
+        // setting for Unicode support rather than a global setting.
1985
+        $data['isUnicode'] = (strtolower(substr($metrics_name, -3)) !== 'afm');
1986 1986
       
1987
-      $cidtogid = '';
1988
-      if ($data['isUnicode']) {
1987
+        $cidtogid = '';
1988
+        if ($data['isUnicode']) {
1989 1989
         $cidtogid = str_pad('', 256*256*2, "\x00");
1990
-      }
1990
+        }
1991 1991
 
1992
-      $file =  file($dir . $metrics_name);
1992
+        $file =  file($dir . $metrics_name);
1993 1993
 
1994
-      foreach ($file as  $rowA) {
1994
+        foreach ($file as  $rowA) {
1995 1995
         $row = trim($rowA);
1996 1996
         $pos = strpos($row, ' ');
1997 1997
 
1998 1998
         if  ($pos) {
1999
-          // then there must be some keyword
2000
-          $key =  substr($row, 0, $pos);
2001
-          switch  ($key) {
2002
-          case  'FontName':
1999
+            // then there must be some keyword
2000
+            $key =  substr($row, 0, $pos);
2001
+            switch  ($key) {
2002
+            case  'FontName':
2003 2003
           case  'FullName':
2004 2004
           case  'FamilyName':
2005 2005
           case  'Weight':
@@ -2021,140 +2021,140 @@  discard block
 block discarded – undo
2021 2021
             $data[$key] = trim(substr($row, $pos));
2022 2022
             break;
2023 2023
 
2024
-          case  'FontBBox':
2024
+            case  'FontBBox':
2025 2025
             $data[$key] = explode(' ', trim(substr($row, $pos)));
2026 2026
             break;
2027 2027
 
2028
-          case  'C': // Found in AFM files
2028
+            case  'C': // Found in AFM files
2029 2029
             //C 39 ; WX 222 ; N quoteright ; B 53 463 157 718 ;
2030 2030
             $bits = explode(';', trim($row));
2031 2031
             $dtmp = array();
2032 2032
 
2033 2033
             foreach($bits as  $bit) {
2034
-              $bits2 =  explode(' ', trim($bit));
2035
-              if  (mb_strlen($bits2[0], '8bit')) {
2034
+                $bits2 =  explode(' ', trim($bit));
2035
+                if  (mb_strlen($bits2[0], '8bit')) {
2036 2036
                 if  (count($bits2) >2) {
2037
-                  $dtmp[$bits2[0]] = array();
2038
-                  for  ($i = 1;$i<count($bits2);$i++) {
2037
+                    $dtmp[$bits2[0]] = array();
2038
+                    for  ($i = 1;$i<count($bits2);$i++) {
2039 2039
                     $dtmp[$bits2[0]][] = $bits2[$i];
2040
-                  }
2040
+                    }
2041 2041
                 } else  if  (count($bits2) == 2) {
2042
-                  $dtmp[$bits2[0]] = $bits2[1];
2042
+                    $dtmp[$bits2[0]] = $bits2[1];
2043
+                }
2043 2044
                 }
2044
-              }
2045 2045
             }
2046 2046
 
2047 2047
             $cc = (int)$dtmp['C'];
2048 2048
             if  ($cc >= 0) {
2049
-              $data['C'][$dtmp['C']] = $dtmp;
2050
-              $data['C'][$dtmp['N']] = $dtmp;
2049
+                $data['C'][$dtmp['C']] = $dtmp;
2050
+                $data['C'][$dtmp['N']] = $dtmp;
2051 2051
             } else {
2052
-              $data['C'][$dtmp['N']] = $dtmp;
2052
+                $data['C'][$dtmp['N']] = $dtmp;
2053 2053
             }
2054 2054
 
2055 2055
             if  (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2056
-              $data['MissingWidth'] = $width;
2056
+                $data['MissingWidth'] = $width;
2057 2057
             }
2058 2058
             
2059 2059
             break;
2060 2060
 
2061
-          case  'U': // Found in UFM files
2061
+            case  'U': // Found in UFM files
2062 2062
             if ($data['isUnicode']) {
2063
-              // U 827 ; WX 0 ; N squaresubnosp ; G 675 ;
2064
-              $bits = explode(';', trim($row));
2065
-              $dtmp = array();
2063
+                // U 827 ; WX 0 ; N squaresubnosp ; G 675 ;
2064
+                $bits = explode(';', trim($row));
2065
+                $dtmp = array();
2066 2066
 
2067
-              foreach($bits as  $bit) {
2067
+                foreach($bits as  $bit) {
2068 2068
                 $bits2 =  explode(' ', trim($bit));
2069 2069
                 if  (mb_strlen($bits2[0], '8bit')) {
2070
-                  if  (count($bits2) >2) {
2070
+                    if  (count($bits2) >2) {
2071 2071
                     $dtmp[$bits2[0]] = array();
2072 2072
                     for  ($i = 1;$i<count($bits2);$i++) {
2073
-                      $dtmp[$bits2[0]][] = $bits2[$i];
2073
+                        $dtmp[$bits2[0]][] = $bits2[$i];
2074 2074
                     }
2075
-                  } else  if  (count($bits2) == 2) {
2075
+                    } else  if  (count($bits2) == 2) {
2076 2076
                     $dtmp[$bits2[0]] = $bits2[1];
2077
-                  }
2077
+                    }
2078
+                }
2078 2079
                 }
2079
-              }
2080 2080
 
2081
-              $cc = (int)$dtmp['U'];
2082
-              $glyph = $dtmp['G'];
2083
-              $width = $dtmp['WX'];
2084
-              if  ($cc >= 0) {
2081
+                $cc = (int)$dtmp['U'];
2082
+                $glyph = $dtmp['G'];
2083
+                $width = $dtmp['WX'];
2084
+                if  ($cc >= 0) {
2085 2085
                 // Set values in CID to GID map
2086 2086
                 if ($cc >= 0 && $cc < 0xFFFF && $glyph) {
2087
-                  $cidtogid[$cc*2] = chr($glyph >> 8);
2088
-                  $cidtogid[$cc*2 + 1] = chr($glyph & 0xFF);
2087
+                    $cidtogid[$cc*2] = chr($glyph >> 8);
2088
+                    $cidtogid[$cc*2 + 1] = chr($glyph & 0xFF);
2089 2089
                 }
2090 2090
 
2091 2091
                 $data['C'][$dtmp['U']] = $dtmp;
2092 2092
                 $data['C'][$dtmp['N']] = $dtmp;
2093
-              } else {
2093
+                } else {
2094 2094
                 $data['C'][$dtmp['N']] = $dtmp;
2095
-              }
2095
+                }
2096 2096
               
2097
-              if  (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2097
+                if  (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2098 2098
                 $data['MissingWidth'] = $width;
2099
-              }
2099
+                }
2100 2100
             }
2101 2101
             break;
2102 2102
 
2103
-          case  'KPX':
2103
+            case  'KPX':
2104 2104
             //KPX Adieresis yacute -40
2105 2105
             $bits = explode(' ', trim($row));
2106 2106
             $data['KPX'][$bits[1]][$bits[2]] = $bits[3];
2107 2107
             break;
2108
-          }
2108
+            }
2109
+        }
2109 2110
         }
2110
-      }
2111 2111
 
2112
-      //    echo $cidtogid; die("CIDtoGID Displayed!");
2113
-      if  (function_exists('gzcompress') &&  $this->options['compression']) {
2112
+        //    echo $cidtogid; die("CIDtoGID Displayed!");
2113
+        if  (function_exists('gzcompress') &&  $this->options['compression']) {
2114 2114
         // then implement ZLIB based compression on CIDtoGID string
2115 2115
         $data['CIDtoGID_Compressed'] = true;
2116 2116
         $cidtogid =  gzcompress($cidtogid,  6);
2117
-      }
2118
-      $data['CIDtoGID'] = base64_encode($cidtogid);
2119
-      $data['_version_'] = $this->fontcacheVersion;
2120
-      $this->fonts[$font] = $data;
2121
-
2122
-      //Because of potential trouble with php safe mode, expect that the folder already exists.
2123
-      //If not existing, this will hit performance because of missing cached results.
2124
-      if ( is_dir(substr($fontcache,0,-1)) ) {
2117
+        }
2118
+        $data['CIDtoGID'] = base64_encode($cidtogid);
2119
+        $data['_version_'] = $this->fontcacheVersion;
2120
+        $this->fonts[$font] = $data;
2121
+
2122
+        //Because of potential trouble with php safe mode, expect that the folder already exists.
2123
+        //If not existing, this will hit performance because of missing cached results.
2124
+        if ( is_dir(substr($fontcache,0,-1)) ) {
2125 2125
         file_put_contents($fontcache . $cache_name,  '$this->fonts[$font]=' . var_export($data,  true)  . ';');
2126
-      }
2126
+        }
2127 2127
     }
2128 2128
     
2129 2129
     if  (!isset($this->fonts[$font])) {
2130
-      $this->addMessage("openFont: no font file found for $font.  Do you need to run load_font.php?");
2131
-      //echo 'Font not Found '.$font;
2130
+        $this->addMessage("openFont: no font file found for $font.  Do you need to run load_font.php?");
2131
+        //echo 'Font not Found '.$font;
2132 2132
     }
2133 2133
 
2134 2134
     //pre_r($this->messages);
2135
-  }
2136
-
2137
-  /**
2138
-   * if the font is not loaded then load it and make the required object
2139
-   * else just make it the current font
2140
-   * the encoding array can contain 'encoding'=> 'none','WinAnsiEncoding','MacRomanEncoding' or 'MacExpertEncoding'
2141
-   * note that encoding='none' will need to be used for symbolic fonts
2142
-   * and 'differences' => an array of mappings between numbers 0->255 and character names.
2143
-   *
2144
-   */
2145
-  function  selectFont($fontName, $encoding =  '', $set =  true) {
2135
+    }
2136
+
2137
+    /**
2138
+     * if the font is not loaded then load it and make the required object
2139
+     * else just make it the current font
2140
+     * the encoding array can contain 'encoding'=> 'none','WinAnsiEncoding','MacRomanEncoding' or 'MacExpertEncoding'
2141
+     * note that encoding='none' will need to be used for symbolic fonts
2142
+     * and 'differences' => an array of mappings between numbers 0->255 and character names.
2143
+     *
2144
+     */
2145
+    function  selectFont($fontName, $encoding =  '', $set =  true) {
2146 2146
     $ext = substr($fontName, -4);
2147 2147
     if  ($ext === '.afm' || $ext === '.ufm') {
2148
-      $fontName = substr($fontName, 0, mb_strlen($fontName)-4);
2148
+        $fontName = substr($fontName, 0, mb_strlen($fontName)-4);
2149 2149
     }
2150 2150
 
2151 2151
     if  (!isset($this->fonts[$fontName])) {
2152
-      $this->addMessage("selectFont: selecting - $fontName - $encoding, $set");
2152
+        $this->addMessage("selectFont: selecting - $fontName - $encoding, $set");
2153 2153
 
2154
-      // load the file
2155
-      $this->openFont($fontName);
2154
+        // load the file
2155
+        $this->openFont($fontName);
2156 2156
 
2157
-      if  (isset($this->fonts[$fontName])) {
2157
+        if  (isset($this->fonts[$fontName])) {
2158 2158
         $this->numObj++;
2159 2159
         $this->numFonts++;
2160 2160
 
@@ -2165,17 +2165,17 @@  discard block
 block discarded – undo
2165 2165
         $options =  array('name' => $name, 'fontFileName' => $fontName);
2166 2166
 
2167 2167
         if  (is_array($encoding)) {
2168
-          // then encoding and differences might be set
2169
-          if  (isset($encoding['encoding'])) {
2168
+            // then encoding and differences might be set
2169
+            if  (isset($encoding['encoding'])) {
2170 2170
             $options['encoding'] =  $encoding['encoding'];
2171
-          }
2171
+            }
2172 2172
 
2173
-          if  (isset($encoding['differences'])) {
2173
+            if  (isset($encoding['differences'])) {
2174 2174
             $options['differences'] =  $encoding['differences'];
2175
-          }
2175
+            }
2176 2176
         } else  if  (mb_strlen($encoding, '8bit')) {
2177
-          // then perhaps only the encoding has been set
2178
-          $options['encoding'] =  $encoding;
2177
+            // then perhaps only the encoding has been set
2178
+            $options['encoding'] =  $encoding;
2179 2179
         }
2180 2180
 
2181 2181
         $fontObj =  $this->numObj;
@@ -2187,11 +2187,11 @@  discard block
 block discarded – undo
2187 2187
         // references into the font object
2188 2188
         $basefile =  $fontName;
2189 2189
         if  (file_exists($basefile.'.pfb')) {
2190
-          $fbtype =  'pfb';
2190
+            $fbtype =  'pfb';
2191 2191
         } else  if  (file_exists($basefile.'.ttf')) {
2192
-          $fbtype =  'ttf';
2192
+            $fbtype =  'ttf';
2193 2193
         } else {
2194
-          $fbtype =  '';
2194
+            $fbtype =  '';
2195 2195
         }
2196 2196
 
2197 2197
         $fbfile =  $basefile.'.'.$fbtype;
@@ -2203,74 +2203,74 @@  discard block
 block discarded – undo
2203 2203
         // OAR - I don't understand this old check
2204 2204
         // if  (substr($fontName, -4) ===  '.afm' &&  strlen($fbtype)) {
2205 2205
         if  (mb_strlen($fbtype, '8bit')) {
2206
-          $adobeFontName =  $this->fonts[$fontName]['FontName'];
2207
-          //        $fontObj = $this->numObj;
2208
-          $this->addMessage('selectFont: adding font file - '.$fbfile.' - '.$adobeFontName);
2206
+            $adobeFontName =  $this->fonts[$fontName]['FontName'];
2207
+            //        $fontObj = $this->numObj;
2208
+            $this->addMessage('selectFont: adding font file - '.$fbfile.' - '.$adobeFontName);
2209 2209
 
2210
-          // find the array of font widths, and put that into an object.
2211
-          $firstChar =  -1;
2212
-          $lastChar =  0;
2213
-          $widths =  array();
2214
-          $cid_widths = array();
2210
+            // find the array of font widths, and put that into an object.
2211
+            $firstChar =  -1;
2212
+            $lastChar =  0;
2213
+            $widths =  array();
2214
+            $cid_widths = array();
2215 2215
 
2216
-          foreach ($this->fonts[$fontName]['C'] as  $num => $d) {
2216
+            foreach ($this->fonts[$fontName]['C'] as  $num => $d) {
2217 2217
             if  (intval($num) >0 ||  $num ==  '0') {
2218
-              if (!$this->fonts[$fontName]['isUnicode']) {
2218
+                if (!$this->fonts[$fontName]['isUnicode']) {
2219 2219
                 // With Unicode, widths array isn't used
2220 2220
                 if  ($lastChar>0 &&  $num>$lastChar+1) {
2221
-                  for ($i =  $lastChar+1;$i<$num;$i++) {
2221
+                    for ($i =  $lastChar+1;$i<$num;$i++) {
2222 2222
                     $widths[] =  0;
2223
-                  }
2223
+                    }
2224
+                }
2224 2225
                 }
2225
-              }
2226 2226
 
2227
-              $widths[] =  $d['WX'];
2227
+                $widths[] =  $d['WX'];
2228 2228
 
2229
-              if ($this->fonts[$fontName]['isUnicode']) {
2229
+                if ($this->fonts[$fontName]['isUnicode']) {
2230 2230
                 $cid_widths[$num] =  $d['WX'];
2231
-              }
2231
+                }
2232 2232
 
2233
-              if  ($firstChar ==  -1) {
2233
+                if  ($firstChar ==  -1) {
2234 2234
                 $firstChar =  $num;
2235
-              }
2235
+                }
2236 2236
 
2237
-              $lastChar =  $num;
2237
+                $lastChar =  $num;
2238
+            }
2238 2239
             }
2239
-          }
2240 2240
 
2241
-          // also need to adjust the widths for the differences array
2242
-          if  (isset($options['differences'])) {
2241
+            // also need to adjust the widths for the differences array
2242
+            if  (isset($options['differences'])) {
2243 2243
             foreach($options['differences'] as  $charNum => $charName) {
2244
-              if  ($charNum > $lastChar) {
2244
+                if  ($charNum > $lastChar) {
2245 2245
                 if (!$this->fonts[$fontName]['isUnicode']) {
2246
-                  // With Unicode, widths array isn't used
2247
-                  for ($i =  $lastChar + 1; $i <=  $charNum; $i++) {
2246
+                    // With Unicode, widths array isn't used
2247
+                    for ($i =  $lastChar + 1; $i <=  $charNum; $i++) {
2248 2248
                     $widths[] =  0;
2249
-                  }
2249
+                    }
2250 2250
                 }
2251 2251
 
2252 2252
                 $lastChar =  $charNum;
2253
-              }
2253
+                }
2254 2254
 
2255
-              if  (isset($this->fonts[$fontName]['C'][$charName])) {
2255
+                if  (isset($this->fonts[$fontName]['C'][$charName])) {
2256 2256
                 $widths[$charNum-$firstChar] =  $this->fonts[$fontName]['C'][$charName]['WX'];
2257 2257
                 if ($this->fonts[$fontName]['isUnicode']) {
2258
-                  $cid_widths[$charName] =  $this->fonts[$fontName]['C'][$charName]['WX'];
2258
+                    $cid_widths[$charName] =  $this->fonts[$fontName]['C'][$charName]['WX'];
2259 2259
                 }
2260
-              }
2260
+                }
2261
+            }
2261 2262
             }
2262
-          }
2263 2263
 
2264
-          if ($this->fonts[$fontName]['isUnicode']) {
2264
+            if ($this->fonts[$fontName]['isUnicode']) {
2265 2265
             $this->fonts[$fontName]['CIDWidths'] = $cid_widths;
2266
-          }
2266
+            }
2267 2267
 
2268
-          $this->addMessage('selectFont: FirstChar = '.$firstChar);
2269
-          $this->addMessage('selectFont: LastChar = '.$lastChar);
2268
+            $this->addMessage('selectFont: FirstChar = '.$firstChar);
2269
+            $this->addMessage('selectFont: LastChar = '.$lastChar);
2270 2270
 
2271
-          $widthid = -1;
2271
+            $widthid = -1;
2272 2272
 
2273
-          if (!$this->fonts[$fontName]['isUnicode']) {
2273
+            if (!$this->fonts[$fontName]['isUnicode']) {
2274 2274
             // With Unicode, widths array isn't used
2275 2275
 
2276 2276
             $this->numObj++;
@@ -2278,147 +2278,147 @@  discard block
 block discarded – undo
2278 2278
             $this->objects[$this->numObj]['c'].=  '[';
2279 2279
 
2280 2280
             foreach($widths as  $width) {
2281
-              $this->objects[$this->numObj]['c'].=  ' '.$width;
2281
+                $this->objects[$this->numObj]['c'].=  ' '.$width;
2282 2282
             }
2283 2283
 
2284 2284
             $this->objects[$this->numObj]['c'].=  ' ]';
2285 2285
             $widthid =  $this->numObj;
2286
-          }
2286
+            }
2287 2287
 
2288
-          $missing_width = 500;
2289
-          $stemV = 70;
2288
+            $missing_width = 500;
2289
+            $stemV = 70;
2290 2290
 
2291
-          if (isset($this->fonts[$fontName]['MissingWidth'])) {
2291
+            if (isset($this->fonts[$fontName]['MissingWidth'])) {
2292 2292
             $missing_width =  $this->fonts[$fontName]['MissingWidth'];
2293
-          }
2294
-          if (isset($this->fonts[$fontName]['StdVW'])) {
2293
+            }
2294
+            if (isset($this->fonts[$fontName]['StdVW'])) {
2295 2295
             $stemV = $this->fonts[$fontName]['StdVW'];
2296
-          } elseif (isset($this->fonts[$fontName]['Weight']) && preg_match('!(bold|black)!i', $this->fonts[$fontName]['Weight'])) {
2296
+            } elseif (isset($this->fonts[$fontName]['Weight']) && preg_match('!(bold|black)!i', $this->fonts[$fontName]['Weight'])) {
2297 2297
             $stemV = 120;
2298
-          }
2298
+            }
2299 2299
 
2300
-          // load the pfb file, and put that into an object too.
2301
-          // note that pdf supports only binary format type 1 font files, though there is a
2302
-          // simple utility to convert them from pfa to pfb.
2303
-          $data =  file_get_contents($fbfile);
2300
+            // load the pfb file, and put that into an object too.
2301
+            // note that pdf supports only binary format type 1 font files, though there is a
2302
+            // simple utility to convert them from pfa to pfb.
2303
+            $data =  file_get_contents($fbfile);
2304 2304
 
2305
-          // create the font descriptor
2306
-          $this->numObj++;
2307
-          $fontDescriptorId =  $this->numObj;
2305
+            // create the font descriptor
2306
+            $this->numObj++;
2307
+            $fontDescriptorId =  $this->numObj;
2308 2308
 
2309
-          $this->numObj++;
2310
-          $pfbid =  $this->numObj;
2309
+            $this->numObj++;
2310
+            $pfbid =  $this->numObj;
2311 2311
 
2312
-          // determine flags (more than a little flakey, hopefully will not matter much)
2313
-          $flags =  0;
2312
+            // determine flags (more than a little flakey, hopefully will not matter much)
2313
+            $flags =  0;
2314 2314
 
2315
-          if  ($this->fonts[$fontName]['ItalicAngle'] !=  0) {
2315
+            if  ($this->fonts[$fontName]['ItalicAngle'] !=  0) {
2316 2316
             $flags+=  pow(2, 6);
2317
-          }
2317
+            }
2318 2318
 
2319
-          if  ($this->fonts[$fontName]['IsFixedPitch'] === 'true') {
2319
+            if  ($this->fonts[$fontName]['IsFixedPitch'] === 'true') {
2320 2320
             $flags+=  1;
2321
-          }
2321
+            }
2322 2322
 
2323
-          $flags+=  pow(2, 5); // assume non-sybolic
2324
-          $list =  array(
2323
+            $flags+=  pow(2, 5); // assume non-sybolic
2324
+            $list =  array(
2325 2325
             'Ascent' => 'Ascender', 
2326 2326
             'CapHeight' => 'CapHeight', 
2327 2327
             'MissingWidth' => 'MissingWidth', 
2328 2328
             'Descent' => 'Descender', 
2329 2329
             'FontBBox' => 'FontBBox', 
2330 2330
             'ItalicAngle' => 'ItalicAngle'
2331
-          );
2332
-          $fdopt =  array(
2331
+            );
2332
+            $fdopt =  array(
2333 2333
             'Flags' => $flags, 
2334 2334
             'FontName' => $adobeFontName, 
2335 2335
             'StemV' => $stemV
2336
-          );
2336
+            );
2337 2337
 
2338
-          foreach($list as  $k => $v) {
2338
+            foreach($list as  $k => $v) {
2339 2339
             if  (isset($this->fonts[$fontName][$v])) {
2340
-              $fdopt[$k] =  $this->fonts[$fontName][$v];
2340
+                $fdopt[$k] =  $this->fonts[$fontName][$v];
2341
+            }
2341 2342
             }
2342
-          }
2343 2343
 
2344
-          if  ($fbtype === 'pfb') {
2344
+            if  ($fbtype === 'pfb') {
2345 2345
             $fdopt['FontFile'] =  $pfbid;
2346
-          } else  if  ($fbtype === 'ttf') {
2346
+            } else  if  ($fbtype === 'ttf') {
2347 2347
             $fdopt['FontFile2'] =  $pfbid;
2348
-          }
2348
+            }
2349 2349
 
2350
-          $this->o_fontDescriptor($fontDescriptorId, 'new', $fdopt);
2350
+            $this->o_fontDescriptor($fontDescriptorId, 'new', $fdopt);
2351 2351
 
2352
-          // embed the font program
2353
-          $this->o_contents($this->numObj, 'new');
2354
-          $this->objects[$pfbid]['c'].=  $data;
2352
+            // embed the font program
2353
+            $this->o_contents($this->numObj, 'new');
2354
+            $this->objects[$pfbid]['c'].=  $data;
2355 2355
 
2356
-          // determine the cruicial lengths within this file
2357
-          if  ($fbtype === 'pfb') {
2356
+            // determine the cruicial lengths within this file
2357
+            if  ($fbtype === 'pfb') {
2358 2358
             $l1 =  strpos($data, 'eexec') +6;
2359 2359
             $l2 =  strpos($data, '00000000') -$l1;
2360 2360
             $l3 =  mb_strlen($data, '8bit') -$l2-$l1;
2361 2361
             $this->o_contents($this->numObj, 'add', array('Length1' => $l1, 'Length2' => $l2, 'Length3' => $l3));
2362
-          } else  if  ($fbtype == 'ttf') {
2362
+            } else  if  ($fbtype == 'ttf') {
2363 2363
             $l1 =  mb_strlen($data, '8bit');
2364 2364
             $this->o_contents($this->numObj, 'add', array('Length1' => $l1));
2365
-          }
2365
+            }
2366 2366
 
2367
-          // tell the font object about all this new stuff
2368
-          $tmp =  array('BaseFont' => $adobeFontName, 'MissingWidth' => $missing_width, 'Widths' => $widthid, 'FirstChar' => $firstChar, 'LastChar' => $lastChar, 'FontDescriptor' => $fontDescriptorId);
2367
+            // tell the font object about all this new stuff
2368
+            $tmp =  array('BaseFont' => $adobeFontName, 'MissingWidth' => $missing_width, 'Widths' => $widthid, 'FirstChar' => $firstChar, 'LastChar' => $lastChar, 'FontDescriptor' => $fontDescriptorId);
2369 2369
 
2370
-          if  ($fbtype === 'ttf') {
2370
+            if  ($fbtype === 'ttf') {
2371 2371
             $tmp['SubType'] =  'TrueType';
2372
-          }
2372
+            }
2373 2373
 
2374
-          $this->addMessage('adding extra info to font.('.$fontObj.')');
2374
+            $this->addMessage('adding extra info to font.('.$fontObj.')');
2375 2375
 
2376
-          foreach($tmp as  $fk => $fv) {
2376
+            foreach($tmp as  $fk => $fv) {
2377 2377
             $this->addMessage($fk." : ".$fv);
2378
-          }
2378
+            }
2379 2379
 
2380
-          $this->o_font($fontObj, 'add', $tmp);
2380
+            $this->o_font($fontObj, 'add', $tmp);
2381 2381
         } else {
2382
-          $this->addMessage('selectFont: pfb or ttf file not found, ok if this is one of the 14 standard fonts');
2382
+            $this->addMessage('selectFont: pfb or ttf file not found, ok if this is one of the 14 standard fonts');
2383 2383
         }
2384 2384
 
2385 2385
         // also set the differences here, note that this means that these will take effect only the
2386 2386
         //first time that a font is selected, else they are ignored
2387 2387
         if  (isset($options['differences'])) {
2388
-          $this->fonts[$fontName]['differences'] =  $options['differences'];
2388
+            $this->fonts[$fontName]['differences'] =  $options['differences'];
2389
+        }
2389 2390
         }
2390
-      }
2391 2391
     }
2392 2392
 
2393 2393
     if  ($set &&  isset($this->fonts[$fontName])) {
2394
-      // so if for some reason the font was not set in the last one then it will not be selected
2395
-      $this->currentBaseFont =  $fontName;
2394
+        // so if for some reason the font was not set in the last one then it will not be selected
2395
+        $this->currentBaseFont =  $fontName;
2396 2396
 
2397
-      // the next lines mean that if a new font is selected, then the current text state will be
2398
-      // applied to it as well.
2399
-      $this->currentFont =  $this->currentBaseFont;
2400
-      $this->currentFontNum =  $this->fonts[$this->currentFont]['fontNum'];
2397
+        // the next lines mean that if a new font is selected, then the current text state will be
2398
+        // applied to it as well.
2399
+        $this->currentFont =  $this->currentBaseFont;
2400
+        $this->currentFontNum =  $this->fonts[$this->currentFont]['fontNum'];
2401 2401
 
2402
-      //$this->setCurrentFont();
2402
+        //$this->setCurrentFont();
2403 2403
     }
2404 2404
 
2405 2405
     return  $this->currentFontNum;
2406 2406
     //return $this->numObj;
2407
-  }
2408
-
2409
-  /**
2410
-   * sets up the current font, based on the font families, and the current text state
2411
-   * note that this system is quite flexible, a bold-italic font can be completely different to a
2412
-   * italic-bold font, and even bold-bold will have to be defined within the family to have meaning
2413
-   * This function is to be called whenever the currentTextState is changed, it will update
2414
-   * the currentFont setting to whatever the appropriatte family one is.
2415
-   * If the user calls selectFont themselves then that will reset the currentBaseFont, and the currentFont
2416
-   * This function will change the currentFont to whatever it should be, but will not change the
2417
-   * currentBaseFont.
2418
-   *
2419
-   * @access private
2420
-   */
2421
-  function  setCurrentFont() {
2407
+    }
2408
+
2409
+    /**
2410
+     * sets up the current font, based on the font families, and the current text state
2411
+     * note that this system is quite flexible, a bold-italic font can be completely different to a
2412
+     * italic-bold font, and even bold-bold will have to be defined within the family to have meaning
2413
+     * This function is to be called whenever the currentTextState is changed, it will update
2414
+     * the currentFont setting to whatever the appropriatte family one is.
2415
+     * If the user calls selectFont themselves then that will reset the currentBaseFont, and the currentFont
2416
+     * This function will change the currentFont to whatever it should be, but will not change the
2417
+     * currentBaseFont.
2418
+     *
2419
+     * @access private
2420
+     */
2421
+    function  setCurrentFont() {
2422 2422
     //   if (strlen($this->currentBaseFont) == 0){
2423 2423
     //     // then assume an initial font
2424 2424
     //     $this->selectFont($this->defaultFont);
@@ -2440,185 +2440,185 @@  discard block
 block discarded – undo
2440 2440
     $this->currentFont =  $this->currentBaseFont;
2441 2441
     $this->currentFontNum =  $this->fonts[$this->currentFont]['fontNum'];
2442 2442
     //  }
2443
-  }
2443
+    }
2444 2444
 
2445 2445
 
2446
-  /**
2447
-   * function for the user to find out what the ID is of the first page that was created during
2448
-   * startup - useful if they wish to add something to it later.
2449
-   */
2450
-  function  getFirstPageId() {
2446
+    /**
2447
+     * function for the user to find out what the ID is of the first page that was created during
2448
+     * startup - useful if they wish to add something to it later.
2449
+     */
2450
+    function  getFirstPageId() {
2451 2451
     return  $this->firstPageId;
2452
-  }
2452
+    }
2453 2453
 
2454 2454
 
2455
-  /**
2456
-   * add content to the currently active object
2457
-   *
2458
-   * @access private
2459
-   */
2460
-  function  addContent($content) {
2455
+    /**
2456
+     * add content to the currently active object
2457
+     *
2458
+     * @access private
2459
+     */
2460
+    function  addContent($content) {
2461 2461
     $this->objects[$this->currentContents]['c'].=  $content;
2462
-  }
2462
+    }
2463 2463
 
2464 2464
 
2465
-  /**
2466
-   * sets the colour for fill operations
2467
-   */
2468
-  function  setColor($r, $g, $b, $force =  0) {
2465
+    /**
2466
+     * sets the colour for fill operations
2467
+     */
2468
+    function  setColor($r, $g, $b, $force =  0) {
2469 2469
     if  ($r >=  0 &&  ($force ||  $r !=  $this->currentColour['r'] ||  $g !=  $this->currentColour['g'] ||  $b !=  $this->currentColour['b'])) {
2470
-      $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $r) .' '.sprintf('%.3F', $g) .' '.sprintf('%.3F', $b) .' rg';
2471
-      $this->currentColour =  array('r' => $r, 'g' => $g, 'b' => $b);
2470
+        $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $r) .' '.sprintf('%.3F', $g) .' '.sprintf('%.3F', $b) .' rg';
2471
+        $this->currentColour =  array('r' => $r, 'g' => $g, 'b' => $b);
2472
+    }
2472 2473
     }
2473
-  }
2474 2474
 
2475 2475
 
2476
-  /**
2477
-   * sets the colour for stroke operations
2478
-   */
2479
-  function  setStrokeColor($r, $g, $b, $force =  0) {
2476
+    /**
2477
+     * sets the colour for stroke operations
2478
+     */
2479
+    function  setStrokeColor($r, $g, $b, $force =  0) {
2480 2480
     if  ($r >=  0 &&  ($force ||  $r !=  $this->currentStrokeColour['r'] ||  $g !=  $this->currentStrokeColour['g'] ||  $b !=  $this->currentStrokeColour['b'])) {
2481
-      $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $r) .' '.sprintf('%.3F', $g) .' '.sprintf('%.3F', $b) .' RG';
2482
-      $this->currentStrokeColour =  array('r' => $r, 'g' => $g, 'b' => $b);
2481
+        $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $r) .' '.sprintf('%.3F', $g) .' '.sprintf('%.3F', $b) .' RG';
2482
+        $this->currentStrokeColour =  array('r' => $r, 'g' => $g, 'b' => $b);
2483
+    }
2483 2484
     }
2484
-  }
2485 2485
 
2486 2486
 
2487
-  /**
2488
-   * Set the graphics state for compositions
2489
-   */
2490
-  function  setGraphicsState($parameters) {
2487
+    /**
2488
+     * Set the graphics state for compositions
2489
+     */
2490
+    function  setGraphicsState($parameters) {
2491 2491
     // Create a new graphics state object
2492 2492
     // FIXME: should actually keep track of states that have already been created...
2493 2493
     $this->numObj++;
2494 2494
     $this->o_extGState($this->numObj,  'new',  $parameters);
2495 2495
     $this->objects[ $this->currentContents ]['c'].=  "\n/GS" . $this->numStates . " gs";
2496
-  }
2497
-
2498
-
2499
-  /**
2500
-   * Set current blend mode & opacity for lines.
2501
-   *
2502
-   * Valid blend modes are:
2503
-   *
2504
-   * Normal, Multiply, Screen, Overlay, Darken, Lighten,
2505
-   * ColorDogde, ColorBurn, HardLight, SoftLight, Difference,
2506
-   * Exclusion
2507
-   *
2508
-   * @param string $mode the blend mode to use
2509
-   * @param float $opacity 0.0 fully transparent, 1.0 fully opaque
2510
-   */
2511
-  function setLineTransparency($mode, $opacity) {
2496
+    }
2497
+
2498
+
2499
+    /**
2500
+     * Set current blend mode & opacity for lines.
2501
+     *
2502
+     * Valid blend modes are:
2503
+     *
2504
+     * Normal, Multiply, Screen, Overlay, Darken, Lighten,
2505
+     * ColorDogde, ColorBurn, HardLight, SoftLight, Difference,
2506
+     * Exclusion
2507
+     *
2508
+     * @param string $mode the blend mode to use
2509
+     * @param float $opacity 0.0 fully transparent, 1.0 fully opaque
2510
+     */
2511
+    function setLineTransparency($mode, $opacity) {
2512 2512
     static $blend_modes = array("Normal", "Multiply", "Screen",
2513 2513
                                 "Overlay", "Darken", "Lighten",
2514 2514
                                 "ColorDogde", "ColorBurn", "HardLight",
2515 2515
                                 "SoftLight", "Difference", "Exclusion");
2516 2516
 
2517 2517
     if ( !in_array($mode, $blend_modes) )
2518
-      $mode = "Normal";
2518
+        $mode = "Normal";
2519 2519
     
2520 2520
     // Only create a new graphics state if required
2521 2521
     if ( $mode == $this->currentLineTransparency["mode"]  &&
2522 2522
          $opacity == $this->currentLineTransparency["opacity"] )
2523
-      return;
2523
+        return;
2524 2524
 
2525 2525
     $options = array("BM" => "/$mode",
2526
-                     "CA" => (float)$opacity);
2526
+                        "CA" => (float)$opacity);
2527 2527
 
2528 2528
     $this->setGraphicsState($options);
2529
-  }
2529
+    }
2530 2530
   
2531
-  /**
2532
-   * Set current blend mode & opacity for filled objects.
2533
-   *
2534
-   * Valid blend modes are:
2535
-   *
2536
-   * Normal, Multiply, Screen, Overlay, Darken, Lighten,
2537
-   * ColorDogde, ColorBurn, HardLight, SoftLight, Difference,
2538
-   * Exclusion
2539
-   *
2540
-   * @param string $mode the blend mode to use
2541
-   * @param float $opacity 0.0 fully transparent, 1.0 fully opaque
2542
-   */
2543
-  function setFillTransparency($mode, $opacity) {
2531
+    /**
2532
+     * Set current blend mode & opacity for filled objects.
2533
+     *
2534
+     * Valid blend modes are:
2535
+     *
2536
+     * Normal, Multiply, Screen, Overlay, Darken, Lighten,
2537
+     * ColorDogde, ColorBurn, HardLight, SoftLight, Difference,
2538
+     * Exclusion
2539
+     *
2540
+     * @param string $mode the blend mode to use
2541
+     * @param float $opacity 0.0 fully transparent, 1.0 fully opaque
2542
+     */
2543
+    function setFillTransparency($mode, $opacity) {
2544 2544
     static $blend_modes = array("Normal", "Multiply", "Screen",
2545 2545
                                 "Overlay", "Darken", "Lighten",
2546 2546
                                 "ColorDogde", "ColorBurn", "HardLight",
2547 2547
                                 "SoftLight", "Difference", "Exclusion");
2548 2548
 
2549 2549
     if ( !in_array($mode, $blend_modes) )
2550
-      $mode = "Normal";
2550
+        $mode = "Normal";
2551 2551
 
2552 2552
     if ( $mode == $this->currentFillTransparency["mode"]  &&
2553 2553
          $opacity == $this->currentFillTransparency["opacity"] )
2554
-      return;
2554
+        return;
2555 2555
 
2556 2556
     $options = array("BM" => "/$mode",
2557
-                     "ca" => (float)$opacity);
2557
+                        "ca" => (float)$opacity);
2558 2558
     
2559 2559
     $this->setGraphicsState($options);
2560
-  }
2560
+    }
2561 2561
 
2562
-  /**
2563
-   * draw a line from one set of coordinates to another
2564
-   */
2565
-  function  line($x1, $y1, $x2, $y2) {
2562
+    /**
2563
+     * draw a line from one set of coordinates to another
2564
+     */
2565
+    function  line($x1, $y1, $x2, $y2) {
2566 2566
     $this->objects[$this->currentContents]['c'] .=
2567
-      "\n".sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1) .' m '.sprintf('%.3F', $x2) .' '.sprintf('%.3F', $y2) .' l S';
2568
-  }
2567
+        "\n".sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1) .' m '.sprintf('%.3F', $x2) .' '.sprintf('%.3F', $y2) .' l S';
2568
+    }
2569 2569
 
2570 2570
 
2571
-  /**
2572
-   * draw a bezier curve based on 4 control points
2573
-   */
2574
-  function  curve($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3) {
2571
+    /**
2572
+     * draw a bezier curve based on 4 control points
2573
+     */
2574
+    function  curve($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3) {
2575 2575
     // in the current line style, draw a bezier curve from (x0,y0) to (x3,y3) using the other two points
2576 2576
     // as the control points for the curve.
2577 2577
     $this->objects[$this->currentContents]['c'] .=
2578
-      "\n".sprintf('%.3F', $x0) .' '.sprintf('%.3F', $y0) .' m '.sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1);
2578
+        "\n".sprintf('%.3F', $x0) .' '.sprintf('%.3F', $y0) .' m '.sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1);
2579 2579
 
2580 2580
     $this->objects[$this->currentContents]['c'] .=
2581
-      ' '.sprintf('%.3F', $x2) .' '.sprintf('%.3F', $y2) .' '.sprintf('%.3F', $x3) .' '.sprintf('%.3F', $y3) .' c S';
2582
-  }
2581
+        ' '.sprintf('%.3F', $x2) .' '.sprintf('%.3F', $y2) .' '.sprintf('%.3F', $x3) .' '.sprintf('%.3F', $y3) .' c S';
2582
+    }
2583 2583
 
2584 2584
 
2585
-  /**
2586
-   * draw a part of an ellipse
2587
-   */
2588
-  function  partEllipse($x0, $y0, $astart, $afinish, $r1, $r2 =  0, $angle =  0, $nSeg =  8) {
2585
+    /**
2586
+     * draw a part of an ellipse
2587
+     */
2588
+    function  partEllipse($x0, $y0, $astart, $afinish, $r1, $r2 =  0, $angle =  0, $nSeg =  8) {
2589 2589
     $this->ellipse($x0, $y0, $r1, $r2, $angle, $nSeg, $astart, $afinish, 0);
2590
-  }
2590
+    }
2591 2591
 
2592 2592
 
2593
-  /**
2594
-   * draw a filled ellipse
2595
-   */
2596
-  function  filledEllipse($x0, $y0, $r1, $r2 =  0, $angle =  0, $nSeg =  8, $astart =  0, $afinish =  360) {
2593
+    /**
2594
+     * draw a filled ellipse
2595
+     */
2596
+    function  filledEllipse($x0, $y0, $r1, $r2 =  0, $angle =  0, $nSeg =  8, $astart =  0, $afinish =  360) {
2597 2597
     return  $this->ellipse($x0, $y0, $r1, $r2 =  0, $angle, $nSeg, $astart, $afinish, 1, 1);
2598
-  }
2599
-
2600
-
2601
-  /**
2602
-   * draw an ellipse
2603
-   * note that the part and filled ellipse are just special cases of this function
2604
-   *
2605
-   * draws an ellipse in the current line style
2606
-   * centered at $x0,$y0, radii $r1,$r2
2607
-   * if $r2 is not set, then a circle is drawn
2608
-   * nSeg is not allowed to be less than 2, as this will simply draw a line (and will even draw a
2609
-   * pretty crappy shape at 2, as we are approximating with bezier curves.
2610
-   */
2611
-  function  ellipse($x0, $y0, $r1, $r2 =  0, $angle =  0, $nSeg =  8, $astart =  0, $afinish =  360, $close =  1, $fill =  0) {
2598
+    }
2599
+
2600
+
2601
+    /**
2602
+     * draw an ellipse
2603
+     * note that the part and filled ellipse are just special cases of this function
2604
+     *
2605
+     * draws an ellipse in the current line style
2606
+     * centered at $x0,$y0, radii $r1,$r2
2607
+     * if $r2 is not set, then a circle is drawn
2608
+     * nSeg is not allowed to be less than 2, as this will simply draw a line (and will even draw a
2609
+     * pretty crappy shape at 2, as we are approximating with bezier curves.
2610
+     */
2611
+    function  ellipse($x0, $y0, $r1, $r2 =  0, $angle =  0, $nSeg =  8, $astart =  0, $afinish =  360, $close =  1, $fill =  0) {
2612 2612
     if  ($r1 ==  0) {
2613
-      return;
2613
+        return;
2614 2614
     }
2615 2615
 
2616 2616
     if  ($r2 ==  0) {
2617
-      $r2 =  $r1;
2617
+        $r2 =  $r1;
2618 2618
     }
2619 2619
 
2620 2620
     if  ($nSeg < 2) {
2621
-      $nSeg =  2;
2621
+        $nSeg =  2;
2622 2622
     }
2623 2623
 
2624 2624
     $astart =  deg2rad((float)$astart);
@@ -2629,16 +2629,16 @@  discard block
 block discarded – undo
2629 2629
     $dtm =  $dt/3;
2630 2630
 
2631 2631
     if  ($angle !=  0) {
2632
-      $a =  -1*deg2rad((float)$angle);
2632
+        $a =  -1*deg2rad((float)$angle);
2633 2633
 
2634
-      $tmp  =  "\n q ";
2635
-      $tmp .=  sprintf('%.3F', cos($a)) .' '.sprintf('%.3F', (-1.0*sin($a))) .' '.sprintf('%.3F', sin($a)) .' '.sprintf('%.3F', cos($a)) .' ';
2636
-      $tmp .=  sprintf('%.3F', $x0) .' '.sprintf('%.3F', $y0) .' cm';
2634
+        $tmp  =  "\n q ";
2635
+        $tmp .=  sprintf('%.3F', cos($a)) .' '.sprintf('%.3F', (-1.0*sin($a))) .' '.sprintf('%.3F', sin($a)) .' '.sprintf('%.3F', cos($a)) .' ';
2636
+        $tmp .=  sprintf('%.3F', $x0) .' '.sprintf('%.3F', $y0) .' cm';
2637 2637
 
2638
-      $this->objects[$this->currentContents]['c'].=  $tmp;
2638
+        $this->objects[$this->currentContents]['c'].=  $tmp;
2639 2639
 
2640
-      $x0 =  0;
2641
-      $y0 =  0;
2640
+        $x0 =  0;
2641
+        $y0 =  0;
2642 2642
     }
2643 2643
 
2644 2644
     $t1 =  $astart;
@@ -2650,183 +2650,183 @@  discard block
 block discarded – undo
2650 2650
     $this->objects[$this->currentContents]['c'] .=  "\n".sprintf('%.3F', $a0) .' '.sprintf('%.3F', $b0) .' m ';
2651 2651
 
2652 2652
     for  ($i = 1; $i <=  $nSeg; $i++) {
2653
-      // draw this bit of the total curve
2654
-      $t1 =  $i * $dt + $astart;
2655
-      $a1 =  $x0 + $r1 * cos($t1);
2656
-      $b1 =  $y0 + $r2 * sin($t1);
2657
-      $c1 = -$r1 * sin($t1);
2658
-      $d1 =  $r2 * cos($t1);
2659
-
2660
-      $this->objects[$this->currentContents]['c']
2653
+        // draw this bit of the total curve
2654
+        $t1 =  $i * $dt + $astart;
2655
+        $a1 =  $x0 + $r1 * cos($t1);
2656
+        $b1 =  $y0 + $r2 * sin($t1);
2657
+        $c1 = -$r1 * sin($t1);
2658
+        $d1 =  $r2 * cos($t1);
2659
+
2660
+        $this->objects[$this->currentContents]['c']
2661 2661
         .=  "\n".sprintf('%.3F', ($a0+$c0*$dtm)) .' '.sprintf('%.3F', ($b0 + $d0 * $dtm));
2662 2662
 
2663
-      $this->objects[$this->currentContents]['c'] .=
2663
+        $this->objects[$this->currentContents]['c'] .=
2664 2664
         ' '.sprintf('%.3F', ($a1-$c1*$dtm)) .' '.sprintf('%.3F', ($b1-$d1*$dtm)) .' '.sprintf('%.3F', $a1) .' '.sprintf('%.3F', $b1) .' c';
2665 2665
 
2666
-      $a0 =  $a1;
2667
-      $b0 =  $b1;
2668
-      $c0 =  $c1;
2669
-      $d0 =  $d1;
2666
+        $a0 =  $a1;
2667
+        $b0 =  $b1;
2668
+        $c0 =  $c1;
2669
+        $d0 =  $d1;
2670 2670
     }
2671 2671
 
2672 2672
     if  ($fill) {
2673
-      $this->objects[$this->currentContents]['c'].=  ' f';
2673
+        $this->objects[$this->currentContents]['c'].=  ' f';
2674 2674
     } else if ($close) {
2675 2675
         $this->objects[$this->currentContents]['c'].=  ' s';
2676 2676
         // small 's' signifies closing the path as well
2677 2677
     } else {
2678
-      $this->objects[$this->currentContents]['c'].=  ' S';
2678
+        $this->objects[$this->currentContents]['c'].=  ' S';
2679 2679
     }
2680 2680
 
2681 2681
     if  ($angle !=  0) {
2682
-      $this->objects[$this->currentContents]['c'].=  ' Q';
2683
-    }
2684
-  }
2685
-
2686
-
2687
-  /**
2688
-   * this sets the line drawing style.
2689
-   * width, is the thickness of the line in user units
2690
-   * cap is the type of cap to put on the line, values can be 'butt','round','square'
2691
-   *    where the diffference between 'square' and 'butt' is that 'square' projects a flat end past the
2692
-   *    end of the line.
2693
-   * join can be 'miter', 'round', 'bevel'
2694
-   * dash is an array which sets the dash pattern, is a series of length values, which are the lengths of the
2695
-   *   on and off dashes.
2696
-   *   (2) represents 2 on, 2 off, 2 on , 2 off ...
2697
-   *   (2,1) is 2 on, 1 off, 2 on, 1 off.. etc
2698
-   * phase is a modifier on the dash pattern which is used to shift the point at which the pattern starts.
2699
-   */
2700
-  function  setLineStyle($width =  1, $cap =  '', $join =  '', $dash =  '', $phase =  0) {
2682
+        $this->objects[$this->currentContents]['c'].=  ' Q';
2683
+    }
2684
+    }
2685
+
2686
+
2687
+    /**
2688
+     * this sets the line drawing style.
2689
+     * width, is the thickness of the line in user units
2690
+     * cap is the type of cap to put on the line, values can be 'butt','round','square'
2691
+     *    where the diffference between 'square' and 'butt' is that 'square' projects a flat end past the
2692
+     *    end of the line.
2693
+     * join can be 'miter', 'round', 'bevel'
2694
+     * dash is an array which sets the dash pattern, is a series of length values, which are the lengths of the
2695
+     *   on and off dashes.
2696
+     *   (2) represents 2 on, 2 off, 2 on , 2 off ...
2697
+     *   (2,1) is 2 on, 1 off, 2 on, 1 off.. etc
2698
+     * phase is a modifier on the dash pattern which is used to shift the point at which the pattern starts.
2699
+     */
2700
+    function  setLineStyle($width =  1, $cap =  '', $join =  '', $dash =  '', $phase =  0) {
2701 2701
     // this is quite inefficient in that it sets all the parameters whenever 1 is changed, but will fix another day
2702 2702
     $string =  '';
2703 2703
 
2704 2704
     if  ($width>0) {
2705
-      $string.=  $width.' w';
2705
+        $string.=  $width.' w';
2706 2706
     }
2707 2707
 
2708 2708
     $ca =  array('butt' => 0, 'round' => 1, 'square' => 2);
2709 2709
 
2710 2710
     if  (isset($ca[$cap])) {
2711
-      $string.=  ' '.$ca[$cap].' J';
2711
+        $string.=  ' '.$ca[$cap].' J';
2712 2712
     }
2713 2713
 
2714 2714
     $ja =  array('miter' => 0, 'round' => 1, 'bevel' => 2);
2715 2715
 
2716 2716
     if  (isset($ja[$join])) {
2717
-      $string.=  ' '.$ja[$join].' j';
2717
+        $string.=  ' '.$ja[$join].' j';
2718 2718
     }
2719 2719
 
2720 2720
     if  (is_array($dash)) {
2721
-      $string.=  ' [';
2721
+        $string.=  ' [';
2722 2722
 
2723
-      foreach ($dash as  $len) {
2723
+        foreach ($dash as  $len) {
2724 2724
         $string.=  ' '.$len;
2725
-      }
2725
+        }
2726 2726
 
2727
-      $string.=  ' ] '.$phase.' d';
2727
+        $string.=  ' ] '.$phase.' d';
2728 2728
     }
2729 2729
 
2730 2730
     $this->currentLineStyle =  $string;
2731 2731
     $this->objects[$this->currentContents]['c'].=  "\n".$string;
2732
-  }
2732
+    }
2733 2733
 
2734 2734
 
2735 2735
 
2736
-  /**
2737
-   * draw a polygon, the syntax for this is similar to the GD polygon command
2738
-   */
2739
-  function  polygon($p, $np, $f =  0) {
2736
+    /**
2737
+     * draw a polygon, the syntax for this is similar to the GD polygon command
2738
+     */
2739
+    function  polygon($p, $np, $f =  0) {
2740 2740
     $this->objects[$this->currentContents]['c'].=  "\n";
2741 2741
     $this->objects[$this->currentContents]['c'].=  sprintf('%.3F', $p[0]) .' '.sprintf('%.3F', $p[1]) .' m ';
2742 2742
 
2743 2743
     for  ($i =  2; $i < $np * 2; $i =  $i + 2) {
2744
-      $this->objects[$this->currentContents]['c'].=  sprintf('%.3F', $p[$i]) .' '.sprintf('%.3F', $p[$i+1]) .' l ';
2744
+        $this->objects[$this->currentContents]['c'].=  sprintf('%.3F', $p[$i]) .' '.sprintf('%.3F', $p[$i+1]) .' l ';
2745 2745
     }
2746 2746
 
2747 2747
     if  ($f ==  1) {
2748
-      $this->objects[$this->currentContents]['c'].=  ' f';
2748
+        $this->objects[$this->currentContents]['c'].=  ' f';
2749 2749
     } else {
2750
-      $this->objects[$this->currentContents]['c'].=  ' S';
2750
+        $this->objects[$this->currentContents]['c'].=  ' S';
2751
+    }
2751 2752
     }
2752
-  }
2753 2753
 
2754 2754
 
2755
-  /**
2756
-   * a filled rectangle, note that it is the width and height of the rectangle which are the secondary paramaters, not
2757
-   * the coordinates of the upper-right corner
2758
-   */
2759
-  function  filledRectangle($x1, $y1, $width, $height) {
2755
+    /**
2756
+     * a filled rectangle, note that it is the width and height of the rectangle which are the secondary paramaters, not
2757
+     * the coordinates of the upper-right corner
2758
+     */
2759
+    function  filledRectangle($x1, $y1, $width, $height) {
2760 2760
     $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1) .' '.sprintf('%.3F', $width) .' '.sprintf('%.3F', $height) .' re f';
2761
-  }
2761
+    }
2762 2762
 
2763 2763
 
2764
-  /**
2765
-   * draw a rectangle, note that it is the width and height of the rectangle which are the secondary paramaters, not
2766
-   * the coordinates of the upper-right corner
2767
-   */
2768
-  function  rectangle($x1, $y1, $width, $height) {
2764
+    /**
2765
+     * draw a rectangle, note that it is the width and height of the rectangle which are the secondary paramaters, not
2766
+     * the coordinates of the upper-right corner
2767
+     */
2768
+    function  rectangle($x1, $y1, $width, $height) {
2769 2769
     $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1) .' '.sprintf('%.3F', $width) .' '.sprintf('%.3F', $height) .' re S';
2770
-  }
2770
+    }
2771 2771
 
2772 2772
 
2773
-  /**
2774
-   * add a new page to the document
2775
-   * this also makes the new page the current active object
2776
-   */
2777
-  function  newPage($insert =  0, $id =  0, $pos =  'after') {
2773
+    /**
2774
+     * add a new page to the document
2775
+     * this also makes the new page the current active object
2776
+     */
2777
+    function  newPage($insert =  0, $id =  0, $pos =  'after') {
2778 2778
     // if there is a state saved, then go up the stack closing them
2779 2779
     // then on the new page, re-open them with the right setings
2780 2780
 
2781 2781
     if  ($this->nStateStack) {
2782
-      for  ($i =  $this->nStateStack;$i >=  1;$i--) {
2782
+        for  ($i =  $this->nStateStack;$i >=  1;$i--) {
2783 2783
         $this->restoreState($i);
2784
-      }
2784
+        }
2785 2785
     }
2786 2786
 
2787 2787
     $this->numObj++;
2788 2788
 
2789 2789
     if  ($insert) {
2790
-      // the id from the ezPdf class is the id of the contents of the page, not the page object itself
2791
-      // query that object to find the parent
2792
-      $rid =  $this->objects[$id]['onPage'];
2793
-      $opt =  array('rid' => $rid, 'pos' => $pos);
2794
-      $this->o_page($this->numObj, 'new', $opt);
2790
+        // the id from the ezPdf class is the id of the contents of the page, not the page object itself
2791
+        // query that object to find the parent
2792
+        $rid =  $this->objects[$id]['onPage'];
2793
+        $opt =  array('rid' => $rid, 'pos' => $pos);
2794
+        $this->o_page($this->numObj, 'new', $opt);
2795 2795
     } else {
2796
-      $this->o_page($this->numObj, 'new');
2796
+        $this->o_page($this->numObj, 'new');
2797 2797
     }
2798 2798
 
2799 2799
     // if there is a stack saved, then put that onto the page
2800 2800
     if  ($this->nStateStack) {
2801
-      for  ($i =  1;$i <=  $this->nStateStack;$i++) {
2801
+        for  ($i =  1;$i <=  $this->nStateStack;$i++) {
2802 2802
         $this->saveState($i);
2803
-      }
2803
+        }
2804 2804
     }
2805 2805
 
2806 2806
     // and if there has been a stroke or fill colour set, then transfer them
2807 2807
     if  ($this->currentColour['r'] >=  0) {
2808
-      $this->setColor($this->currentColour['r'], $this->currentColour['g'], $this->currentColour['b'], 1);
2808
+        $this->setColor($this->currentColour['r'], $this->currentColour['g'], $this->currentColour['b'], 1);
2809 2809
     }
2810 2810
 
2811 2811
     if  ($this->currentStrokeColour['r'] >=  0) {
2812
-      $this->setStrokeColor($this->currentStrokeColour['r'], $this->currentStrokeColour['g'], $this->currentStrokeColour['b'], 1);
2812
+        $this->setStrokeColor($this->currentStrokeColour['r'], $this->currentStrokeColour['g'], $this->currentStrokeColour['b'], 1);
2813 2813
     }
2814 2814
 
2815 2815
     // if there is a line style set, then put this in too
2816 2816
     if  (mb_strlen($this->currentLineStyle, '8bit')) {
2817
-      $this->objects[$this->currentContents]['c'].=  "\n".$this->currentLineStyle;
2817
+        $this->objects[$this->currentContents]['c'].=  "\n".$this->currentLineStyle;
2818 2818
     }
2819 2819
 
2820 2820
     // the call to the o_page object set currentContents to the present page, so this can be returned as the page id
2821 2821
     return  $this->currentContents;
2822
-  }
2822
+    }
2823 2823
 
2824 2824
 
2825
-  /**
2826
-   * output the pdf code, streaming it to the browser
2827
-   * the relevant headers are set so that hopefully the browser will recognise it
2828
-   */
2829
-  function  stream($options =  '') {
2825
+    /**
2826
+     * output the pdf code, streaming it to the browser
2827
+     * the relevant headers are set so that hopefully the browser will recognise it
2828
+     */
2829
+    function  stream($options =  '') {
2830 2830
     // setting the options allows the adjustment of the headers
2831 2831
     // values at the moment are:
2832 2832
     // 'Content-Disposition' => 'filename'  - sets the filename, though not too sure how well this will
@@ -2837,16 +2837,16 @@  discard block
 block discarded – undo
2837 2837
     // 'compress' = > 1 or 0 - apply content stream compression, this is on (1) by default
2838 2838
     // 'Attachment' => 1 or 0 - if 1, force the browser to open a download dialog
2839 2839
     if  (!is_array($options)) {
2840
-      $options =  array();
2840
+        $options =  array();
2841 2841
     }
2842 2842
 
2843 2843
     if  ( headers_sent())
2844
-      die("Unable to stream pdf: headers already sent");
2844
+        die("Unable to stream pdf: headers already sent");
2845 2845
 
2846 2846
     if  ( isset($options['compress']) &&  $options['compress'] ==  0) {
2847
-      $tmp =  ltrim($this->output(1));
2847
+        $tmp =  ltrim($this->output(1));
2848 2848
     } else {
2849
-      $tmp =  ltrim($this->output());
2849
+        $tmp =  ltrim($this->output());
2850 2850
     }
2851 2851
 
2852 2852
     header("Cache-Control: private");
@@ -2857,28 +2857,28 @@  discard block
 block discarded – undo
2857 2857
     $fileName =  (isset($options['Content-Disposition']) ?  $options['Content-Disposition'] :  'file.pdf');
2858 2858
 
2859 2859
     if  ( !isset($options["Attachment"]))
2860
-      $options["Attachment"] =  true;
2860
+        $options["Attachment"] =  true;
2861 2861
 
2862 2862
     $attachment =  $options["Attachment"] ?  "attachment" :  "inline";
2863 2863
 
2864 2864
     header("Content-Disposition: $attachment; filename=\"$fileName\"");
2865 2865
 
2866 2866
     if  (isset($options['Accept-Ranges']) &&  $options['Accept-Ranges'] ==  1) {
2867
-      //FIXME: Is this the correct value ... spec says 1#range-unit
2868
-      header("Accept-Ranges: " . mb_strlen($tmp, '8bit'));
2867
+        //FIXME: Is this the correct value ... spec says 1#range-unit
2868
+        header("Accept-Ranges: " . mb_strlen($tmp, '8bit'));
2869 2869
     }
2870 2870
 
2871 2871
     echo  $tmp;
2872 2872
     flush();
2873
-  }
2873
+    }
2874 2874
 
2875 2875
 
2876
-  /**
2877
-   * return the height in units of the current font in the given size
2878
-   */
2879
-  function  getFontHeight($size) {
2876
+    /**
2877
+     * return the height in units of the current font in the given size
2878
+     */
2879
+    function  getFontHeight($size) {
2880 2880
     if  (!$this->numFonts) {
2881
-      $this->selectFont($this->defaultFont);
2881
+        $this->selectFont($this->defaultFont);
2882 2882
     }
2883 2883
     
2884 2884
     // for the current font, and the given size, what is the height of the font in user units
@@ -2887,165 +2887,165 @@  discard block
 block discarded – undo
2887 2887
     // have to adjust by a font offset for Windows fonts.  unfortunately it looks like
2888 2888
     // the bounding box calculations are wrong and I don't know why.
2889 2889
     if (isset($this->fonts[$this->currentFont]['FontHeightOffset'])) {
2890
-      // For CourierNew from Windows this needs to be -646 to match the
2891
-      // Adobe native Courier font.
2892
-      //
2893
-      // For FreeMono from GNU this needs to be -337 to match the
2894
-      // Courier font.
2895
-      //
2896
-      // Both have been added manually to the .afm and .ufm files.
2897
-      $h += (int)$this->fonts[$this->currentFont]['FontHeightOffset'];
2890
+        // For CourierNew from Windows this needs to be -646 to match the
2891
+        // Adobe native Courier font.
2892
+        //
2893
+        // For FreeMono from GNU this needs to be -337 to match the
2894
+        // Courier font.
2895
+        //
2896
+        // Both have been added manually to the .afm and .ufm files.
2897
+        $h += (int)$this->fonts[$this->currentFont]['FontHeightOffset'];
2898 2898
     }
2899 2899
 
2900 2900
     return  $size*$h/1000;
2901
-  }
2901
+    }
2902 2902
 
2903 2903
 
2904
-  /**
2905
-   * return the font descender, this will normally return a negative number
2906
-   * if you add this number to the baseline, you get the level of the bottom of the font
2907
-   * it is in the pdf user units
2908
-   */
2909
-  function  getFontDescender($size) {
2904
+    /**
2905
+     * return the font descender, this will normally return a negative number
2906
+     * if you add this number to the baseline, you get the level of the bottom of the font
2907
+     * it is in the pdf user units
2908
+     */
2909
+    function  getFontDescender($size) {
2910 2910
     // note that this will most likely return a negative value
2911 2911
     if  (!$this->numFonts) {
2912
-      $this->selectFont($this->defaultFont);
2912
+        $this->selectFont($this->defaultFont);
2913 2913
     }
2914 2914
 
2915 2915
     //$h = $this->fonts[$this->currentFont]['FontBBox'][1];
2916 2916
     $h = $this->fonts[$this->currentFont]['Descender'];
2917 2917
 
2918 2918
     return  $size*$h/1000;
2919
-  }
2919
+    }
2920 2920
 
2921 2921
 
2922
-  /**
2923
-   * filter the text, this is applied to all text just before being inserted into the pdf document
2924
-   * it escapes the various things that need to be escaped, and so on
2925
-   *
2926
-   * @access private
2927
-   */
2928
-  function  filterText($text, $bom = true) {
2922
+    /**
2923
+     * filter the text, this is applied to all text just before being inserted into the pdf document
2924
+     * it escapes the various things that need to be escaped, and so on
2925
+     *
2926
+     * @access private
2927
+     */
2928
+    function  filterText($text, $bom = true) {
2929 2929
     if (!$this->numFonts) {
2930
-      $this->selectFont($this->defaultFont);
2930
+        $this->selectFont($this->defaultFont);
2931 2931
     }
2932 2932
     
2933
-  	$cf = $this->currentFont;
2933
+        $cf = $this->currentFont;
2934 2934
     if ($this->fonts[$cf]['isUnicode']) {
2935
-      $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
2936
-      $text =  $this->utf8toUtf16BE($text, $bom);
2935
+        $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
2936
+        $text =  $this->utf8toUtf16BE($text, $bom);
2937 2937
     } else {
2938
-      if (in_array('Windows-1252', mb_list_encodings())) {
2938
+        if (in_array('Windows-1252', mb_list_encodings())) {
2939 2939
         $text = mb_convert_encoding($text, 'Windows-1252', 'UTF-8');
2940
-      } else {
2940
+        } else {
2941 2941
         $text = mb_convert_encoding($text, 'iso-8859-1', 'UTF-8');
2942
-      }
2943
-      $text = html_entity_decode($text, ENT_QUOTES);
2942
+        }
2943
+        $text = html_entity_decode($text, ENT_QUOTES);
2944 2944
     }
2945 2945
 
2946 2946
     // the chr(13) substitution fixes a bug seen in TCPDF (bug #1421290)
2947 2947
     $text = strtr($text, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(13) => '\r'));
2948 2948
     return  $text;
2949
-  }
2950
-
2951
-  /**
2952
-   * return array containing codepoints (UTF-8 character values) for the
2953
-   * string passed in.
2954
-   *
2955
-   * based on the excellent TCPDF code by Nicola Asuni and the
2956
-   * RFC for UTF-8 at http://www.faqs.org/rfcs/rfc3629.html
2957
-   *
2958
-   * @access private
2959
-   * @author Orion Richardson
2960
-   * @since January 5, 2008
2961
-   * @param string $text UTF-8 string to process
2962
-   * @return array UTF-8 codepoints array for the string
2963
-   */
2964
-  function  utf8toCodePointsArray(&$text) {
2949
+    }
2950
+
2951
+    /**
2952
+     * return array containing codepoints (UTF-8 character values) for the
2953
+     * string passed in.
2954
+     *
2955
+     * based on the excellent TCPDF code by Nicola Asuni and the
2956
+     * RFC for UTF-8 at http://www.faqs.org/rfcs/rfc3629.html
2957
+     *
2958
+     * @access private
2959
+     * @author Orion Richardson
2960
+     * @since January 5, 2008
2961
+     * @param string $text UTF-8 string to process
2962
+     * @return array UTF-8 codepoints array for the string
2963
+     */
2964
+    function  utf8toCodePointsArray(&$text) {
2965 2965
     $length = mb_strlen($text, '8bit'); // http://www.php.net/manual/en/function.mb-strlen.php#77040
2966 2966
     $unicode = array(); // array containing unicode values
2967 2967
     $bytes = array(); // array containing single character byte sequences
2968 2968
     $numbytes = 1; // number of octetc needed to represent the UTF-8 character
2969 2969
     
2970 2970
     for ($i = 0; $i < $length; $i++) {
2971
-      $c = ord($text[$i]); // get one string character at time
2972
-      if (count($bytes) == 0) { // get starting octect
2971
+        $c = ord($text[$i]); // get one string character at time
2972
+        if (count($bytes) == 0) { // get starting octect
2973 2973
         if ($c <= 0x7F) {
2974
-          $unicode[] = $c; // use the character "as is" because is ASCII
2975
-          $numbytes = 1;
2974
+            $unicode[] = $c; // use the character "as is" because is ASCII
2975
+            $numbytes = 1;
2976 2976
         } elseif (($c >> 0x05) == 0x06) { // 2 bytes character (0x06 = 110 BIN)
2977
-          $bytes[] = ($c - 0xC0) << 0x06;
2978
-          $numbytes = 2;
2977
+            $bytes[] = ($c - 0xC0) << 0x06;
2978
+            $numbytes = 2;
2979 2979
         } elseif (($c >> 0x04) == 0x0E) { // 3 bytes character (0x0E = 1110 BIN)
2980
-          $bytes[] = ($c - 0xE0) << 0x0C;
2981
-          $numbytes = 3;
2980
+            $bytes[] = ($c - 0xE0) << 0x0C;
2981
+            $numbytes = 3;
2982 2982
         } elseif (($c >> 0x03) == 0x1E) { // 4 bytes character (0x1E = 11110 BIN)
2983
-          $bytes[] = ($c - 0xF0) << 0x12;
2984
-          $numbytes = 4;
2983
+            $bytes[] = ($c - 0xF0) << 0x12;
2984
+            $numbytes = 4;
2985 2985
         } else {
2986
-          // use replacement character for other invalid sequences
2987
-          $unicode[] = 0xFFFD;
2988
-          $bytes = array();
2989
-          $numbytes = 1;
2986
+            // use replacement character for other invalid sequences
2987
+            $unicode[] = 0xFFFD;
2988
+            $bytes = array();
2989
+            $numbytes = 1;
2990 2990
         }
2991
-      } elseif (($c >> 0x06) == 0x02) { // bytes 2, 3 and 4 must start with 0x02 = 10 BIN
2991
+        } elseif (($c >> 0x06) == 0x02) { // bytes 2, 3 and 4 must start with 0x02 = 10 BIN
2992 2992
         $bytes[] = $c - 0x80;
2993 2993
         if (count($bytes) == $numbytes) {
2994
-          // compose UTF-8 bytes to a single unicode value
2995
-          $c = $bytes[0];
2996
-          for ($j = 1; $j < $numbytes; $j++) {
2994
+            // compose UTF-8 bytes to a single unicode value
2995
+            $c = $bytes[0];
2996
+            for ($j = 1; $j < $numbytes; $j++) {
2997 2997
             $c += ($bytes[$j] << (($numbytes - $j - 1) * 0x06));
2998
-          }
2999
-          if ((($c >= 0xD800) AND ($c <= 0xDFFF)) OR ($c >= 0x10FFFF)) {
2998
+            }
2999
+            if ((($c >= 0xD800) AND ($c <= 0xDFFF)) OR ($c >= 0x10FFFF)) {
3000 3000
             // The definition of UTF-8 prohibits encoding character numbers between
3001 3001
             // U+D800 and U+DFFF, which are reserved for use with the UTF-16
3002 3002
             // encoding form (as surrogate pairs) and do not directly represent
3003 3003
             // characters.
3004 3004
             $unicode[] = 0xFFFD; // use replacement character
3005
-          } else {
3005
+            } else {
3006 3006
             $unicode[] = $c; // add char to array
3007
-          }
3008
-          // reset data for next char
3009
-          $bytes = array();
3010
-          $numbytes = 1;
3007
+            }
3008
+            // reset data for next char
3009
+            $bytes = array();
3010
+            $numbytes = 1;
3011 3011
         }
3012
-      } else {
3012
+        } else {
3013 3013
         // use replacement character for other invalid sequences
3014 3014
         $unicode[] = 0xFFFD;
3015 3015
         $bytes = array();
3016 3016
         $numbytes = 1;
3017
-      }
3017
+        }
3018 3018
     }
3019 3019
     return $unicode;
3020
-  }
3021
-
3022
-  /**
3023
-   * convert UTF-8 to UTF-16 with an additional byte order marker
3024
-   * at the front if required.
3025
-   *
3026
-   * based on the excellent TCPDF code by Nicola Asuni and the
3027
-   * RFC for UTF-8 at http://www.faqs.org/rfcs/rfc3629.html
3028
-   *
3029
-   * @access private
3030
-   * @author Orion Richardson
3031
-   * @since January 5, 2008
3032
-   * @param string $text UTF-8 string to process
3033
-   * @param boolean $bom whether to add the byte order marker
3034
-   * @return string UTF-16 result string
3035
-   */
3036
-  function  utf8toUtf16BE(&$text, $bom = true) {
3020
+    }
3021
+
3022
+    /**
3023
+     * convert UTF-8 to UTF-16 with an additional byte order marker
3024
+     * at the front if required.
3025
+     *
3026
+     * based on the excellent TCPDF code by Nicola Asuni and the
3027
+     * RFC for UTF-8 at http://www.faqs.org/rfcs/rfc3629.html
3028
+     *
3029
+     * @access private
3030
+     * @author Orion Richardson
3031
+     * @since January 5, 2008
3032
+     * @param string $text UTF-8 string to process
3033
+     * @param boolean $bom whether to add the byte order marker
3034
+     * @return string UTF-16 result string
3035
+     */
3036
+    function  utf8toUtf16BE(&$text, $bom = true) {
3037 3037
     $cf =  $this->currentFont;
3038 3038
     if (!$this->fonts[$cf]['isUnicode']) return $text;
3039 3039
     $out = $bom ? "\xFE\xFF" : '';
3040 3040
     
3041 3041
     $unicode = $this->utf8toCodePointsArray($text);
3042 3042
     foreach ($unicode as $c) {
3043
-      if ($c == 0xFFFD) {
3043
+        if ($c == 0xFFFD) {
3044 3044
         $out .= "\xFF\xFD"; // replacement character
3045
-      } elseif ($c < 0x10000) {
3045
+        } elseif ($c < 0x10000) {
3046 3046
         $out .= chr($c >> 0x08);
3047 3047
         $out .= chr($c & 0xFF);
3048
-       } else {
3048
+        } else {
3049 3049
         $c -= 0x10000;
3050 3050
         $w1 = 0xD800 | ($c >> 0x10);
3051 3051
         $w2 = 0xDC00 | ($c & 0x3FF);
@@ -3053,19 +3053,19 @@  discard block
 block discarded – undo
3053 3053
         $out .= chr($w1 & 0xFF);
3054 3054
         $out .= chr($w2 >> 0x08);
3055 3055
         $out .= chr($w2 & 0xFF);
3056
-      }
3056
+        }
3057 3057
     }
3058 3058
     return $out;
3059
-  }
3059
+    }
3060 3060
 
3061 3061
 
3062
-  /**
3063
-   * given a start position and information about how text is to be laid out, calculate where
3064
-   * on the page the text will end
3065
-   *
3066
-   * @access private
3067
-   */
3068
-  function  PRVTgetTextPosition($x, $y, $angle, $size, $wa, $text) {
3062
+    /**
3063
+     * given a start position and information about how text is to be laid out, calculate where
3064
+     * on the page the text will end
3065
+     *
3066
+     * @access private
3067
+     */
3068
+    function  PRVTgetTextPosition($x, $y, $angle, $size, $wa, $text) {
3069 3069
     // given this information return an array containing x and y for the end position as elements 0 and 1
3070 3070
     $w =  $this->getTextWidth($size, $text);
3071 3071
 
@@ -3076,66 +3076,66 @@  discard block
 block discarded – undo
3076 3076
     $a =  deg2rad((float)$angle);
3077 3077
 
3078 3078
     return  array(cos($a) *$w+$x, -sin($a) *$w+$y);
3079
-  }
3079
+    }
3080 3080
 
3081 3081
 
3082
-  /**
3083
-   * wrapper function for PRVTcheckTextDirective1
3084
-   *
3085
-   * @access private
3086
-   */
3087
-  function  PRVTcheckTextDirective(&$text, $i, &$f) {
3082
+    /**
3083
+     * wrapper function for PRVTcheckTextDirective1
3084
+     *
3085
+     * @access private
3086
+     */
3087
+    function  PRVTcheckTextDirective(&$text, $i, &$f) {
3088 3088
     return  0;
3089 3089
     $x =  0;
3090 3090
     $y =  0;
3091 3091
     return  $this->PRVTcheckTextDirective1($text, $i, $f, 0, $x, $y);
3092
-  }
3092
+    }
3093 3093
 
3094 3094
 
3095
-  /**
3096
-   * checks if the text stream contains a control directive
3097
-   * if so then makes some changes and returns the number of characters involved in the directive
3098
-   * this has been re-worked to include everything neccesary to find the current writing point, so that
3099
-   * the location can be sent to the callback function if required
3100
-   * if the directive does not require a font change, then $f should be set to 0
3101
-   *
3102
-   * @access private
3103
-   */
3104
-  function  PRVTcheckTextDirective1(&$text, $i, &$f, $final, &$x, &$y, $size =  0, $angle =  0, $wordSpaceAdjust =  0) {
3095
+    /**
3096
+     * checks if the text stream contains a control directive
3097
+     * if so then makes some changes and returns the number of characters involved in the directive
3098
+     * this has been re-worked to include everything neccesary to find the current writing point, so that
3099
+     * the location can be sent to the callback function if required
3100
+     * if the directive does not require a font change, then $f should be set to 0
3101
+     *
3102
+     * @access private
3103
+     */
3104
+    function  PRVTcheckTextDirective1(&$text, $i, &$f, $final, &$x, &$y, $size =  0, $angle =  0, $wordSpaceAdjust =  0) {
3105 3105
     return  0;
3106 3106
     $directive =  0;
3107 3107
     $j =  $i;
3108 3108
     if  ($text[$j] === '<') {
3109
-      $j++;
3110
-      switch ($text[$j]) {
3111
-      case  '/':
3109
+        $j++;
3110
+        switch ($text[$j]) {
3111
+        case  '/':
3112 3112
         $j++;
3113 3113
         if  (mb_strlen($text) <=  $j) {
3114
-          return  $directive;
3114
+            return  $directive;
3115 3115
         }
3116 3116
 
3117 3117
         switch ($text[$j]) {
3118 3118
         case  'b':
3119 3119
         case  'i':
3120 3120
           $j++;
3121
-          if  ($text[$j] === '>') {
3121
+            if  ($text[$j] === '>') {
3122 3122
             $p =  mb_strrpos($this->currentTextState, $text[$j-1]);
3123 3123
 
3124 3124
             if  ($p !==  false) {
3125
-              // then there is one to remove
3126
-              $this->currentTextState =  mb_substr($this->currentTextState, 0, $p) .substr($this->currentTextState, $p+1);
3125
+                // then there is one to remove
3126
+                $this->currentTextState =  mb_substr($this->currentTextState, 0, $p) .substr($this->currentTextState, $p+1);
3127 3127
             }
3128 3128
 
3129 3129
             $directive =  $j-$i+1;
3130
-          }
3131
-          break;
3130
+            }
3131
+            break;
3132 3132
 
3133 3133
         case  'c':
3134 3134
           // this this might be a callback function
3135 3135
           $j++;
3136
-          $k =  mb_strpos($text, '>', $j);
3136
+            $k =  mb_strpos($text, '>', $j);
3137 3137
 
3138
-          if  ($k !==  false &&  $text[$j] === ':') {
3138
+            if  ($k !==  false &&  $text[$j] === ':') {
3139 3139
             // then this will be treated as a callback directive
3140 3140
             $directive =  $k-$i+1;
3141 3141
             $f =  0;
@@ -3144,18 +3144,18 @@  discard block
 block discarded – undo
3144 3144
             $b1 =  mb_strpos($tmp, ':');
3145 3145
 
3146 3146
             if  ($b1 !==  false) {
3147
-              $func =  mb_substr($tmp, 0, $b1);
3148
-              $parm =  mb_substr($tmp, $b1+1);
3147
+                $func =  mb_substr($tmp, 0, $b1);
3148
+                $parm =  mb_substr($tmp, $b1+1);
3149 3149
             } else {
3150
-              $func =  $tmp;
3151
-              $parm =  '';
3150
+                $func =  $tmp;
3151
+                $parm =  '';
3152 3152
             }
3153 3153
 
3154 3154
             if  (!isset($func) ||  !mb_strlen(trim($func), '8bit')) {
3155
-              $directive =  0;
3155
+                $directive =  0;
3156 3156
             } else {
3157
-              // only call the function if this is the final call
3158
-              if  ($final) {
3157
+                // only call the function if this is the final call
3158
+                if  ($final) {
3159 3159
                 // need to assess the text position, calculate the text width to this point
3160 3160
                 // can use getTextWidth to find the text width I think
3161 3161
                 $tmp =  $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
@@ -3166,76 +3166,76 @@  discard block
 block discarded – undo
3166 3166
                 $ret =  $this->$func($info);
3167 3167
 
3168 3168
                 if  (is_array($ret)) {
3169
-                  // then the return from the callback function could set the position, to start with, later will do font colour, and font
3170
-                  foreach($ret as  $rk => $rv) {
3169
+                    // then the return from the callback function could set the position, to start with, later will do font colour, and font
3170
+                    foreach($ret as  $rk => $rv) {
3171 3171
                     switch ($rk) {
3172 3172
                     case  'x':
3173 3173
                     case  'y':
3174 3174
                       $$rk =  $rv;
3175
-                      break;
3175
+                        break;
3176
+                    }
3176 3177
                     }
3177
-                  }
3178 3178
                 }
3179 3179
 
3180 3180
                 // also remove from to the stack
3181 3181
                 // for simplicity, just take from the end, fix this another day
3182 3182
                 $this->nCallback--;
3183 3183
                 if  ($this->nCallback<0) {
3184
-                  $this->nCallBack =  0;
3184
+                    $this->nCallBack =  0;
3185
+                }
3185 3186
                 }
3186
-              }
3187 3187
             }
3188
-          }
3189
-          break;
3188
+            }
3189
+            break;
3190 3190
         }
3191 3191
         break;
3192 3192
 
3193
-      case  'b':
3193
+        case  'b':
3194 3194
       case  'i':
3195 3195
         $j++;
3196 3196
         if  ($text[$j] === '>') {
3197
-          $this->currentTextState.=  $text[$j-1];
3198
-          $directive =  $j-$i+1;
3197
+            $this->currentTextState.=  $text[$j-1];
3198
+            $directive =  $j-$i+1;
3199 3199
         }
3200 3200
         break;
3201 3201
 
3202
-      case  'C':
3202
+        case  'C':
3203 3203
         $noClose =  1;
3204
-      case  'c':
3204
+        case  'c':
3205 3205
         // this this might be a callback function
3206 3206
         $j++;
3207 3207
         $k =  mb_strpos($text, '>', $j);
3208 3208
 
3209 3209
         if  ($k !==  false &&  $text[$j] ===  ':') {
3210
-          // then this will be treated as a callback directive
3211
-          $directive =  $k-$i+1;
3210
+            // then this will be treated as a callback directive
3211
+            $directive =  $k-$i+1;
3212 3212
 
3213
-          $f =  0;
3213
+            $f =  0;
3214 3214
 
3215
-          // split the remainder on colons to get the function name and the paramater
3216
-          //          $bits = explode(':',substr($text,$j+1,$k-$j-1));
3217
-          $tmp =  mb_substr($text, $j+1, $k-$j-1);
3218
-          $b1 =  mb_strpos($tmp, ':');
3215
+            // split the remainder on colons to get the function name and the paramater
3216
+            //          $bits = explode(':',substr($text,$j+1,$k-$j-1));
3217
+            $tmp =  mb_substr($text, $j+1, $k-$j-1);
3218
+            $b1 =  mb_strpos($tmp, ':');
3219 3219
 
3220
-          if  ($b1 !==  false) {
3220
+            if  ($b1 !==  false) {
3221 3221
             $func =  mb_substr($tmp, 0, $b1);
3222 3222
             $parm =  mb_substr($tmp, $b1+1);
3223
-          } else {
3223
+            } else {
3224 3224
             $func =  $tmp;
3225 3225
             $parm =  '';
3226
-          }
3226
+            }
3227 3227
 
3228
-          if  (!isset($func) ||  !mb_strlen(trim($func), '8bit')) {
3228
+            if  (!isset($func) ||  !mb_strlen(trim($func), '8bit')) {
3229 3229
             $directive =  0;
3230
-          } else {
3230
+            } else {
3231 3231
             // only call the function if this is the final call, ie, the one actually doing printing, not measurement
3232 3232
             if  ($final) {
3233
-              // need to assess the text position, calculate the text width to this point
3234
-              // can use getTextWidth to find the text width I think
3235
-              // also add the text height and descender
3236
-              $tmp =  $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
3233
+                // need to assess the text position, calculate the text width to this point
3234
+                // can use getTextWidth to find the text width I think
3235
+                // also add the text height and descender
3236
+                $tmp =  $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
3237 3237
 
3238
-              $info =  array(
3238
+                $info =  array(
3239 3239
                 'x' => $tmp[0], 
3240 3240
                 'y' => $tmp[1], 
3241 3241
                 'angle' => $angle, 
@@ -3244,79 +3244,79 @@  discard block
 block discarded – undo
3244 3244
                 'f' => $func, 
3245 3245
                 'height' => $this->getFontHeight($size), 
3246 3246
                 'descender' => $this->getFontDescender($size)
3247
-              );
3248
-              $x =  $tmp[0];
3249
-              $y =  $tmp[1];
3247
+                );
3248
+                $x =  $tmp[0];
3249
+                $y =  $tmp[1];
3250 3250
 
3251
-              if  (!isset($noClose) ||  !$noClose) {
3251
+                if  (!isset($noClose) ||  !$noClose) {
3252 3252
                 // only add to the stack if this is a small 'c', therefore is a start-stop pair
3253 3253
                 $this->nCallback++;
3254 3254
                 $info['nCallback'] =  $this->nCallback;
3255 3255
                 $this->callback[$this->nCallback] =  $info;
3256
-              }
3256
+                }
3257 3257
 
3258
-              $ret =  $this->$func($info);
3259
-              if  (is_array($ret)) {
3258
+                $ret =  $this->$func($info);
3259
+                if  (is_array($ret)) {
3260 3260
                 // then the return from the callback function could set the position, to start with, later will do font colour, and font
3261 3261
                 foreach($ret as  $rk => $rv) {
3262
-                  switch ($rk) {
3263
-                  case  'x':
3262
+                    switch ($rk) {
3263
+                    case  'x':
3264 3264
                   case  'y':
3265 3265
                     $$rk =  $rv;
3266 3266
                     break;
3267
-                  }
3267
+                    }
3268
+                }
3268 3269
                 }
3269
-              }
3270 3270
             }
3271
-          }
3271
+            }
3272 3272
         }
3273 3273
         break;
3274
-      }
3274
+        }
3275 3275
     }
3276 3276
 
3277 3277
     return  $directive;
3278
-  }
3278
+    }
3279 3279
 
3280 3280
 
3281
-  /**
3282
-   * add text to the document, at a specified location, size and angle on the page
3283
-   */
3284
-  function  addText($x, $y, $size, $text, $angle =  0, $wordSpaceAdjust =  0) {
3281
+    /**
3282
+     * add text to the document, at a specified location, size and angle on the page
3283
+     */
3284
+    function  addText($x, $y, $size, $text, $angle =  0, $wordSpaceAdjust =  0) {
3285 3285
     if  (!$this->numFonts) {
3286
-      $this->selectFont($this->defaultFont);
3286
+        $this->selectFont($this->defaultFont);
3287 3287
     }
3288 3288
 
3289 3289
     // if there are any open callbacks, then they should be called, to show the start of the line
3290 3290
     if  ($this->nCallback>0) {
3291
-      for  ($i =  $this->nCallback;$i>0;$i--) {
3291
+        for  ($i =  $this->nCallback;$i>0;$i--) {
3292 3292
         // call each function
3293 3293
         $info =  array('x' => $x,
3294
-                       'y' => $y,
3295
-                       'angle' => $angle,
3296
-                       'status' => 'sol',
3297
-                       'p' => $this->callback[$i]['p'],
3298
-                       'nCallback' => $this->callback[$i]['nCallback'],
3299
-                       'height' => $this->callback[$i]['height'],
3300
-                       'descender' => $this->callback[$i]['descender']);
3294
+                        'y' => $y,
3295
+                        'angle' => $angle,
3296
+                        'status' => 'sol',
3297
+                        'p' => $this->callback[$i]['p'],
3298
+                        'nCallback' => $this->callback[$i]['nCallback'],
3299
+                        'height' => $this->callback[$i]['height'],
3300
+                        'descender' => $this->callback[$i]['descender']);
3301 3301
 
3302 3302
         $func =  $this->callback[$i]['f'];
3303 3303
         $this->$func($info);
3304
-      }
3304
+        }
3305 3305
     }
3306 3306
 
3307 3307
     if  ($angle ==  0) {
3308
-      $this->objects[$this->currentContents]['c'].=  "\n".'BT '.sprintf('%.3F', $x) .' '.sprintf('%.3F', $y) .' Td';
3308
+        $this->objects[$this->currentContents]['c'].=  "\n".'BT '.sprintf('%.3F', $x) .' '.sprintf('%.3F', $y) .' Td';
3309 3309
     } else {
3310
-      $a =  deg2rad((float)$angle);
3311
-      $tmp =  "\n".'BT ';
3312
-      $tmp.=  sprintf('%.3F', cos($a)) .' '.sprintf('%.3F', (-1.0*sin($a))) .' '.sprintf('%.3F', sin($a)) .' '.sprintf('%.3F', cos($a)) .' ';
3313
-      $tmp.=  sprintf('%.3F', $x) .' '.sprintf('%.3F', $y) .' Tm';
3314
-      $this->objects[$this->currentContents]['c'].=  $tmp;
3310
+        $a =  deg2rad((float)$angle);
3311
+        $tmp =  "\n".'BT ';
3312
+        $tmp.=  sprintf('%.3F', cos($a)) .' '.sprintf('%.3F', (-1.0*sin($a))) .' '.sprintf('%.3F', sin($a)) .' '.sprintf('%.3F', cos($a)) .' ';
3313
+        $tmp.=  sprintf('%.3F', $x) .' '.sprintf('%.3F', $y) .' Tm';
3314
+        $this->objects[$this->currentContents]['c'].=  $tmp;
3315 3315
     }
3316 3316
 
3317 3317
     if  ($wordSpaceAdjust !=  0 ||  $wordSpaceAdjust !=  $this->wordSpaceAdjust) {
3318
-      $this->wordSpaceAdjust =  $wordSpaceAdjust;
3319
-      $this->objects[$this->currentContents]['c'].=  ' '.sprintf('%.3F', $wordSpaceAdjust) .' Tw';
3318
+        $this->wordSpaceAdjust =  $wordSpaceAdjust;
3319
+        $this->objects[$this->currentContents]['c'].=  ' '.sprintf('%.3F', $wordSpaceAdjust) .' Tw';
3320 3320
     }
3321 3321
 
3322 3322
     $len =  mb_strlen($text);
@@ -3366,47 +3366,47 @@  discard block
 block discarded – undo
3366 3366
      }
3367 3367
     */
3368 3368
     if  ($start < $len) {
3369
-      $part =  $text; // OAR - Don't need this anymore, given that $start always equals zero.  substr($text, $start);
3370
-      $this->objects[$this->currentContents]['c'].=  ' /F'.$this->currentFontNum.' '.sprintf('%.1F', $size) .' Tf ';
3371
-      $this->objects[$this->currentContents]['c'].=  ' ('.$this->filterText($part, false) .') Tj';
3369
+        $part =  $text; // OAR - Don't need this anymore, given that $start always equals zero.  substr($text, $start);
3370
+        $this->objects[$this->currentContents]['c'].=  ' /F'.$this->currentFontNum.' '.sprintf('%.1F', $size) .' Tf ';
3371
+        $this->objects[$this->currentContents]['c'].=  ' ('.$this->filterText($part, false) .') Tj';
3372 3372
     }
3373 3373
 
3374 3374
     $this->objects[$this->currentContents]['c'].=  ' ET';
3375 3375
 
3376 3376
     // if there are any open callbacks, then they should be called, to show the end of the line
3377 3377
     if  ($this->nCallback>0) {
3378
-      for  ($i =  $this->nCallback;$i>0;$i--) {
3378
+        for  ($i =  $this->nCallback;$i>0;$i--) {
3379 3379
         // call each function
3380 3380
         $tmp =  $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, $text);
3381 3381
         $info =  array(
3382
-          'x' => $tmp[0], 
3383
-          'y' => $tmp[1], 
3384
-          'angle' => $angle,
3385
-          'status' => 'eol', 
3386
-          'p' => $this->callback[$i]['p'], 
3387
-          'nCallback' => $this->callback[$i]['nCallback'], 
3388
-          'height' => $this->callback[$i]['height'], 
3389
-          'descender' => $this->callback[$i]['descender']
3382
+            'x' => $tmp[0], 
3383
+            'y' => $tmp[1], 
3384
+            'angle' => $angle,
3385
+            'status' => 'eol', 
3386
+            'p' => $this->callback[$i]['p'], 
3387
+            'nCallback' => $this->callback[$i]['nCallback'], 
3388
+            'height' => $this->callback[$i]['height'], 
3389
+            'descender' => $this->callback[$i]['descender']
3390 3390
         );
3391 3391
         $func =  $this->callback[$i]['f'];
3392 3392
         $this->$func($info);
3393
-      }
3393
+        }
3394
+    }
3394 3395
     }
3395
-  }
3396 3396
 
3397 3397
 
3398
-  /**
3399
-   * calculate how wide a given text string will be on a page, at a given size.
3400
-   * this can be called externally, but is alse used by the other class functions
3401
-   */
3402
-  function  getTextWidth($size, $text, $spacing =  0) {
3398
+    /**
3399
+     * calculate how wide a given text string will be on a page, at a given size.
3400
+     * this can be called externally, but is alse used by the other class functions
3401
+     */
3402
+    function  getTextWidth($size, $text, $spacing =  0) {
3403 3403
     // this function should not change any of the settings, though it will need to
3404 3404
     // track any directives which change during calculation, so copy them at the start
3405 3405
     // and put them back at the end.
3406 3406
     $store_currentTextState =  $this->currentTextState;
3407 3407
 
3408 3408
     if  (!$this->numFonts) {
3409
-      $this->selectFont($this->defaultFont);
3409
+        $this->selectFont($this->defaultFont);
3410 3410
     }
3411 3411
 
3412 3412
     // converts a number or a float to a string so it can get the width
@@ -3418,33 +3418,33 @@  discard block
 block discarded – undo
3418 3418
     $cf =  $this->currentFont;
3419 3419
     $space_scale =  1000 / $size;
3420 3420
     if ( $this->fonts[$cf]['isUnicode']) {
3421
-      // for Unicode, use the code points array to calculate width rather
3422
-      // than just the string itself
3423
-      $unicode =  $this->utf8toCodePointsArray($text);
3421
+        // for Unicode, use the code points array to calculate width rather
3422
+        // than just the string itself
3423
+        $unicode =  $this->utf8toCodePointsArray($text);
3424 3424
 
3425
-      foreach ($unicode as $char) {
3425
+        foreach ($unicode as $char) {
3426 3426
         // check if we have to replace character
3427
-      if  ( isset($this->fonts[$cf]['differences'][$char])) {
3428
-          $char =  $this->fonts[$cf]['differences'][$char];
3427
+        if  ( isset($this->fonts[$cf]['differences'][$char])) {
3428
+            $char =  $this->fonts[$cf]['differences'][$char];
3429 3429
         }
3430 3430
         // add the character width
3431 3431
         if  ( isset($this->fonts[$cf]['C'][$char]['WX'])) {
3432
-          $w+=  $this->fonts[$cf]['C'][$char]['WX'];
3432
+            $w+=  $this->fonts[$cf]['C'][$char]['WX'];
3433 3433
         }
3434 3434
         // add additional padding for space
3435 3435
         if  ( $char ==  32) {  // Space
3436
-          $w+=  $spacing * $space_scale;
3436
+            $w+=  $spacing * $space_scale;
3437
+        }
3437 3438
         }
3438
-      }
3439 3439
 
3440 3440
     } else {
3441
-      $len =  mb_strlen($text, 'Windows-1252');
3441
+        $len =  mb_strlen($text, 'Windows-1252');
3442 3442
 
3443
-      for  ($i =  0; $i < $len; $i++) {
3443
+        for  ($i =  0; $i < $len; $i++) {
3444 3444
         $char =  ord($text[$i]);
3445 3445
         // check if we have to replace character
3446 3446
         if  ( isset($this->fonts[$cf]['differences'][$char])) {
3447
-          $char =  $this->fonts[$cf]['differences'][$char];
3447
+            $char =  $this->fonts[$cf]['differences'][$char];
3448 3448
         }
3449 3449
         // add the character width
3450 3450
         if  ( isset($this->fonts[$cf]['C'][$char]['WX'])) {
@@ -3452,60 +3452,60 @@  discard block
 block discarded – undo
3452 3452
         }
3453 3453
         // add additional padding for space
3454 3454
         if  ( $char ==  32) {  // Space
3455
-          $w+=  $spacing * $space_scale;
3455
+            $w+=  $spacing * $space_scale;
3456
+        }
3456 3457
         }
3457
-      }
3458 3458
     }
3459 3459
 
3460 3460
     $this->currentTextState =  $store_currentTextState;
3461 3461
     $this->setCurrentFont();
3462 3462
 
3463 3463
     return  $w*$size/1000;
3464
-  }
3464
+    }
3465 3465
 
3466 3466
 
3467
-  /**
3468
-   * do a part of the calculation for sorting out the justification of the text
3469
-   *
3470
-   * @access private
3471
-   */
3472
-  function  PRVTadjustWrapText($text, $actual, $width, &$x, &$adjust, $justification) {
3467
+    /**
3468
+     * do a part of the calculation for sorting out the justification of the text
3469
+     *
3470
+     * @access private
3471
+     */
3472
+    function  PRVTadjustWrapText($text, $actual, $width, &$x, &$adjust, $justification) {
3473 3473
     switch  ($justification) {
3474 3474
     case  'left':
3475 3475
       return;
3476 3476
 
3477 3477
     case  'right':
3478 3478
       $x+=  $width-$actual;
3479
-      break;
3479
+        break;
3480 3480
 
3481 3481
     case  'center':
3482 3482
     case  'centre':
3483 3483
       $x+=  ($width-$actual) /2;
3484
-      break;
3484
+        break;
3485 3485
 
3486 3486
     case  'full':
3487 3487
       // count the number of words
3488 3488
       $words =  explode(' ', $text);
3489
-      $nspaces =  count($words) -1;
3489
+        $nspaces =  count($words) -1;
3490 3490
 
3491
-      if  ($nspaces>0) {
3491
+        if  ($nspaces>0) {
3492 3492
         $adjust =  ($width-$actual) /$nspaces;
3493
-      } else {
3493
+        } else {
3494 3494
         $adjust =  0;
3495
-      }
3496
-      break;
3495
+        }
3496
+        break;
3497
+    }
3497 3498
     }
3498
-  }
3499 3499
 
3500 3500
 
3501
-  /**
3502
-   * add text to the page, but ensure that it fits within a certain width
3503
-   * if it does not fit then put in as much as possible, splitting at word boundaries
3504
-   * and return the remainder.
3505
-   * justification and angle can also be specified for the text
3506
-   */
3507
-  function  addTextWrap($x, $y, $width, $size, $text, $justification =  'left', $angle =  0, $test =  0) {
3508
-  	// TODO - need to support Unicode
3501
+    /**
3502
+     * add text to the page, but ensure that it fits within a certain width
3503
+     * if it does not fit then put in as much as possible, splitting at word boundaries
3504
+     * and return the remainder.
3505
+     * justification and angle can also be specified for the text
3506
+     */
3507
+    function  addTextWrap($x, $y, $width, $size, $text, $justification =  'left', $angle =  0, $test =  0) {
3508
+        // TODO - need to support Unicode
3509 3509
     $cf =  $this->currentFont;
3510 3510
     if ($this->fonts[$cf]['isUnicode']) {
3511 3511
         die("addTextWrap does not support Unicode yet!");
@@ -3521,12 +3521,12 @@  discard block
 block discarded – undo
3521 3521
     $store_currentTextState =  $this->currentTextState;
3522 3522
 
3523 3523
     if  (!$this->numFonts) {
3524
-      $this->selectFont($this->defaultFont);
3524
+        $this->selectFont($this->defaultFont);
3525 3525
     }
3526 3526
 
3527 3527
     if  ($width <=  0) {
3528
-      // error, pretend it printed ok, otherwise risking a loop
3529
-      return  '';
3528
+        // error, pretend it printed ok, otherwise risking a loop
3529
+        return  '';
3530 3530
     }
3531 3531
 
3532 3532
     $w =  0;
@@ -3537,38 +3537,38 @@  discard block
 block discarded – undo
3537 3537
     $tw =  $width/$size*1000;
3538 3538
 
3539 3539
     for  ($i =  0;$i<$len;$i++) {
3540
-      $f =  1;
3541
-      $directive =  0;
3542
-      //$this->PRVTcheckTextDirective($text,$i,$f);
3543
-      if  ($directive) {
3540
+        $f =  1;
3541
+        $directive =  0;
3542
+        //$this->PRVTcheckTextDirective($text,$i,$f);
3543
+        if  ($directive) {
3544 3544
         if  ($f) {
3545
-          $this->setCurrentFont();
3546
-          $cf =  $this->currentFont;
3545
+            $this->setCurrentFont();
3546
+            $cf =  $this->currentFont;
3547 3547
         }
3548 3548
 
3549 3549
         $i =  $i+$directive-1;
3550
-      } else {
3550
+        } else {
3551 3551
         $cOrd =  ord($text[$i]);
3552 3552
 
3553 3553
         if  (isset($this->fonts[$cf]['differences'][$cOrd])) {
3554
-          // then this character is being replaced by another
3555
-          $cOrd2 =  $this->fonts[$cf]['differences'][$cOrd];
3554
+            // then this character is being replaced by another
3555
+            $cOrd2 =  $this->fonts[$cf]['differences'][$cOrd];
3556 3556
         } else {
3557
-          $cOrd2 =  $cOrd;
3557
+            $cOrd2 =  $cOrd;
3558 3558
         }
3559 3559
 
3560 3560
         if  (isset($this->fonts[$cf]['C'][$cOrd2]['WX'])) {
3561
-          $w+=  $this->fonts[$cf]['C'][$cOrd2]['WX'];
3561
+            $w+=  $this->fonts[$cf]['C'][$cOrd2]['WX'];
3562 3562
         }
3563 3563
 
3564 3564
         if  ($w>$tw) {
3565
-          // then we need to truncate this line
3566
-          if  ($break>0) {
3565
+            // then we need to truncate this line
3566
+            if  ($break>0) {
3567 3567
             // then we have somewhere that we can split :)
3568 3568
             if  ($text[$break] ===  ' ') {
3569
-              $tmp =  mb_substr($text, 0, $break);
3569
+                $tmp =  mb_substr($text, 0, $break);
3570 3570
             } else {
3571
-              $tmp =  mb_substr($text, 0, $break+1);
3571
+                $tmp =  mb_substr($text, 0, $break+1);
3572 3572
             }
3573 3573
 
3574 3574
             $adjust =  0;
@@ -3579,18 +3579,18 @@  discard block
 block discarded – undo
3579 3579
             $this->setCurrentFont();
3580 3580
 
3581 3581
             if  (!$test) {
3582
-              $this->addText($x, $y, $size, $tmp, $angle, $adjust);
3582
+                $this->addText($x, $y, $size, $tmp, $angle, $adjust);
3583 3583
             }
3584 3584
 
3585 3585
             return  mb_substr($text, $break+1);
3586
-          } else {
3586
+            } else {
3587 3587
             // just split before the current character
3588 3588
             $tmp =  mb_substr($text, 0, $i);
3589 3589
             $adjust =  0;
3590 3590
             $ctmp =  ord($text[$i]);
3591 3591
 
3592 3592
             if  (isset($this->fonts[$cf]['differences'][$ctmp])) {
3593
-              $ctmp =  $this->fonts[$cf]['differences'][$ctmp];
3593
+                $ctmp =  $this->fonts[$cf]['differences'][$ctmp];
3594 3594
             }
3595 3595
 
3596 3596
             $tmpw =  ($w-$this->fonts[$cf]['C'][$ctmp]['WX']) *$size/1000;
@@ -3601,34 +3601,34 @@  discard block
 block discarded – undo
3601 3601
             $this->setCurrentFont();
3602 3602
 
3603 3603
             if  (!$test) {
3604
-              $this->addText($x, $y, $size, $tmp, $angle, $adjust);
3604
+                $this->addText($x, $y, $size, $tmp, $angle, $adjust);
3605 3605
             }
3606 3606
 
3607 3607
             return  mb_substr($text, $i);
3608
-          }
3608
+            }
3609 3609
         }
3610 3610
 
3611 3611
         if  ($text[$i] ===  '-') {
3612
-          $break =  $i;
3613
-          $breakWidth =  $w*$size/1000;
3612
+            $break =  $i;
3613
+            $breakWidth =  $w*$size/1000;
3614 3614
         }
3615 3615
 
3616 3616
         if  ($text[$i] ===  ' ') {
3617
-          $break =  $i;
3618
-          $ctmp =  ord($text[$i]);
3617
+            $break =  $i;
3618
+            $ctmp =  ord($text[$i]);
3619 3619
 
3620
-          if  (isset($this->fonts[$cf]['differences'][$ctmp])) {
3620
+            if  (isset($this->fonts[$cf]['differences'][$ctmp])) {
3621 3621
             $ctmp =  $this->fonts[$cf]['differences'][$ctmp];
3622
-          }
3622
+            }
3623 3623
 
3624
-          $breakWidth =  ($w-$this->fonts[$cf]['C'][$ctmp]['WX']) *$size/1000;
3624
+            $breakWidth =  ($w-$this->fonts[$cf]['C'][$ctmp]['WX']) *$size/1000;
3625
+        }
3625 3626
         }
3626
-      }
3627 3627
     }
3628 3628
 
3629 3629
     // then there was no need to break this line
3630 3630
     if  ($justification ===  'full') {
3631
-      $justification =  'left';
3631
+        $justification =  'left';
3632 3632
     }
3633 3633
 
3634 3634
     $adjust =  0;
@@ -3641,68 +3641,68 @@  discard block
 block discarded – undo
3641 3641
     $this->setCurrentFont();
3642 3642
 
3643 3643
     if  (!$test) {
3644
-      $this->addText($x, $y, $size, $text, $angle, $adjust, $angle);
3644
+        $this->addText($x, $y, $size, $text, $angle, $adjust, $angle);
3645 3645
     }
3646 3646
 
3647 3647
     return  '';
3648
-  }
3648
+    }
3649 3649
 
3650 3650
 
3651
-  /**
3652
-   * this will be called at a new page to return the state to what it was on the
3653
-   * end of the previous page, before the stack was closed down
3654
-   * This is to get around not being able to have open 'q' across pages
3655
-   *
3656
-   */
3657
-  function  saveState($pageEnd =  0) {
3651
+    /**
3652
+     * this will be called at a new page to return the state to what it was on the
3653
+     * end of the previous page, before the stack was closed down
3654
+     * This is to get around not being able to have open 'q' across pages
3655
+     *
3656
+     */
3657
+    function  saveState($pageEnd =  0) {
3658 3658
     if  ($pageEnd) {
3659
-      // this will be called at a new page to return the state to what it was on the
3660
-      // end of the previous page, before the stack was closed down
3661
-      // This is to get around not being able to have open 'q' across pages
3662
-      $opt =  $this->stateStack[$pageEnd];
3663
-      // ok to use this as stack starts numbering at 1
3664
-      $this->setColor($opt['col']['r'], $opt['col']['g'], $opt['col']['b'], 1);
3665
-      $this->setStrokeColor($opt['str']['r'], $opt['str']['g'], $opt['str']['b'], 1);
3666
-      $this->objects[$this->currentContents]['c'].=  "\n".$opt['lin'];
3667
-      //    $this->currentLineStyle = $opt['lin'];
3659
+        // this will be called at a new page to return the state to what it was on the
3660
+        // end of the previous page, before the stack was closed down
3661
+        // This is to get around not being able to have open 'q' across pages
3662
+        $opt =  $this->stateStack[$pageEnd];
3663
+        // ok to use this as stack starts numbering at 1
3664
+        $this->setColor($opt['col']['r'], $opt['col']['g'], $opt['col']['b'], 1);
3665
+        $this->setStrokeColor($opt['str']['r'], $opt['str']['g'], $opt['str']['b'], 1);
3666
+        $this->objects[$this->currentContents]['c'].=  "\n".$opt['lin'];
3667
+        //    $this->currentLineStyle = $opt['lin'];
3668 3668
     } else {
3669
-      $this->nStateStack++;
3670
-      $this->stateStack[$this->nStateStack] =  array(
3669
+        $this->nStateStack++;
3670
+        $this->stateStack[$this->nStateStack] =  array(
3671 3671
         'col' => $this->currentColour, 
3672 3672
         'str' => $this->currentStrokeColour, 
3673 3673
         'lin' => $this->currentLineStyle
3674
-      );
3674
+        );
3675 3675
     }
3676 3676
 
3677 3677
     $this->objects[$this->currentContents]['c'].=  "\nq";
3678
-  }
3678
+    }
3679 3679
 
3680 3680
 
3681
-  /**
3682
-   * restore a previously saved state
3683
-   */
3684
-  function  restoreState($pageEnd =  0) {
3681
+    /**
3682
+     * restore a previously saved state
3683
+     */
3684
+    function  restoreState($pageEnd =  0) {
3685 3685
     if  (!$pageEnd) {
3686
-      $n =  $this->nStateStack;
3687
-      $this->currentColour =  $this->stateStack[$n]['col'];
3688
-      $this->currentStrokeColour =  $this->stateStack[$n]['str'];
3689
-      $this->objects[$this->currentContents]['c'].=  "\n".$this->stateStack[$n]['lin'];
3690
-      $this->currentLineStyle =  $this->stateStack[$n]['lin'];
3691
-      unset($this->stateStack[$n]);
3692
-      $this->nStateStack--;
3686
+        $n =  $this->nStateStack;
3687
+        $this->currentColour =  $this->stateStack[$n]['col'];
3688
+        $this->currentStrokeColour =  $this->stateStack[$n]['str'];
3689
+        $this->objects[$this->currentContents]['c'].=  "\n".$this->stateStack[$n]['lin'];
3690
+        $this->currentLineStyle =  $this->stateStack[$n]['lin'];
3691
+        unset($this->stateStack[$n]);
3692
+        $this->nStateStack--;
3693 3693
     }
3694 3694
     
3695 3695
     $this->objects[$this->currentContents]['c'].=  "\nQ";
3696
-  }
3696
+    }
3697 3697
 
3698 3698
 
3699
-  /**
3700
-   * make a loose object, the output will go into this object, until it is closed, then will revert to
3701
-   * the current one.
3702
-   * this object will not appear until it is included within a page.
3703
-   * the function will return the object number
3704
-   */
3705
-  function  openObject() {
3699
+    /**
3700
+     * make a loose object, the output will go into this object, until it is closed, then will revert to
3701
+     * the current one.
3702
+     * this object will not appear until it is included within a page.
3703
+     * the function will return the object number
3704
+     */
3705
+    function  openObject() {
3706 3706
     $this->nStack++;
3707 3707
     $this->stack[$this->nStack] =  array('c' => $this->currentContents, 'p' => $this->currentPage);
3708 3708
     // add a new object of the content type, to hold the data flow
@@ -3712,315 +3712,315 @@  discard block
 block discarded – undo
3712 3712
     $this->looseObjects[$this->numObj] =  1;
3713 3713
 
3714 3714
     return  $this->numObj;
3715
-  }
3715
+    }
3716 3716
 
3717 3717
 
3718
-  /**
3719
-   * open an existing object for editing
3720
-   */
3721
-  function  reopenObject($id) {
3718
+    /**
3719
+     * open an existing object for editing
3720
+     */
3721
+    function  reopenObject($id) {
3722 3722
     $this->nStack++;
3723 3723
     $this->stack[$this->nStack] =  array('c' => $this->currentContents, 'p' => $this->currentPage);
3724 3724
     $this->currentContents =  $id;
3725 3725
 
3726 3726
     // also if this object is the primary contents for a page, then set the current page to its parent
3727 3727
     if  (isset($this->objects[$id]['onPage'])) {
3728
-      $this->currentPage =  $this->objects[$id]['onPage'];
3728
+        $this->currentPage =  $this->objects[$id]['onPage'];
3729
+    }
3729 3730
     }
3730
-  }
3731 3731
 
3732 3732
 
3733
-  /**
3734
-   * close an object
3735
-   */
3736
-  function  closeObject() {
3733
+    /**
3734
+     * close an object
3735
+     */
3736
+    function  closeObject() {
3737 3737
     // close the object, as long as there was one open in the first place, which will be indicated by
3738 3738
     // an objectId on the stack.
3739 3739
     if  ($this->nStack>0) {
3740
-      $this->currentContents =  $this->stack[$this->nStack]['c'];
3741
-      $this->currentPage =  $this->stack[$this->nStack]['p'];
3742
-      $this->nStack--;
3743
-      // easier to probably not worry about removing the old entries, they will be overwritten
3744
-      // if there are new ones.
3740
+        $this->currentContents =  $this->stack[$this->nStack]['c'];
3741
+        $this->currentPage =  $this->stack[$this->nStack]['p'];
3742
+        $this->nStack--;
3743
+        // easier to probably not worry about removing the old entries, they will be overwritten
3744
+        // if there are new ones.
3745
+    }
3745 3746
     }
3746
-  }
3747 3747
 
3748 3748
 
3749
-  /**
3750
-   * stop an object from appearing on pages from this point on
3751
-   */
3752
-  function  stopObject($id) {
3749
+    /**
3750
+     * stop an object from appearing on pages from this point on
3751
+     */
3752
+    function  stopObject($id) {
3753 3753
     // if an object has been appearing on pages up to now, then stop it, this page will
3754 3754
     // be the last one that could contian it.
3755 3755
     if  (isset($this->addLooseObjects[$id])) {
3756
-      $this->addLooseObjects[$id] =  '';
3756
+        $this->addLooseObjects[$id] =  '';
3757
+    }
3757 3758
     }
3758
-  }
3759 3759
 
3760 3760
 
3761
-  /**
3762
-   * after an object has been created, it wil only show if it has been added, using this function.
3763
-   */
3764
-  function  addObject($id, $options =  'add') {
3761
+    /**
3762
+     * after an object has been created, it wil only show if it has been added, using this function.
3763
+     */
3764
+    function  addObject($id, $options =  'add') {
3765 3765
     // add the specified object to the page
3766 3766
     if  (isset($this->looseObjects[$id]) &&  $this->currentContents !=  $id) {
3767
-      // then it is a valid object, and it is not being added to itself
3768
-      switch ($options) {
3769
-      case  'all':
3767
+        // then it is a valid object, and it is not being added to itself
3768
+        switch ($options) {
3769
+        case  'all':
3770 3770
         // then this object is to be added to this page (done in the next block) and
3771 3771
         // all future new pages.
3772 3772
         $this->addLooseObjects[$id] =  'all';
3773 3773
 
3774
-      case  'add':
3774
+        case  'add':
3775 3775
         if  (isset($this->objects[$this->currentContents]['onPage'])) {
3776
-          // then the destination contents is the primary for the page
3777
-          // (though this object is actually added to that page)
3778
-          $this->o_page($this->objects[$this->currentContents]['onPage'], 'content', $id);
3776
+            // then the destination contents is the primary for the page
3777
+            // (though this object is actually added to that page)
3778
+            $this->o_page($this->objects[$this->currentContents]['onPage'], 'content', $id);
3779 3779
         }
3780 3780
         break;
3781 3781
 
3782
-      case  'even':
3782
+        case  'even':
3783 3783
         $this->addLooseObjects[$id] =  'even';
3784 3784
         $pageObjectId =  $this->objects[$this->currentContents]['onPage'];
3785 3785
         if  ($this->objects[$pageObjectId]['info']['pageNum']%2 ==  0) {
3786
-          $this->addObject($id);
3787
-          // hacky huh :)
3786
+            $this->addObject($id);
3787
+            // hacky huh :)
3788 3788
         }
3789 3789
         break;
3790 3790
 
3791
-      case  'odd':
3791
+        case  'odd':
3792 3792
         $this->addLooseObjects[$id] =  'odd';
3793 3793
         $pageObjectId =  $this->objects[$this->currentContents]['onPage'];
3794 3794
         if  ($this->objects[$pageObjectId]['info']['pageNum']%2 ==  1) {
3795
-          $this->addObject($id);
3796
-          // hacky huh :)
3795
+            $this->addObject($id);
3796
+            // hacky huh :)
3797 3797
         }
3798 3798
         break;
3799 3799
 
3800
-      case  'next':
3800
+        case  'next':
3801 3801
         $this->addLooseObjects[$id] =  'all';
3802 3802
         break;
3803 3803
 
3804
-      case  'nexteven':
3804
+        case  'nexteven':
3805 3805
         $this->addLooseObjects[$id] =  'even';
3806 3806
         break;
3807 3807
 
3808
-      case  'nextodd':
3808
+        case  'nextodd':
3809 3809
         $this->addLooseObjects[$id] =  'odd';
3810 3810
         break;
3811
-      }
3811
+        }
3812
+    }
3812 3813
     }
3813
-  }
3814 3814
 
3815 3815
 
3816
-  /**
3817
-   * return a storable representation of a specific object
3818
-   */
3819
-  function  serializeObject($id) {
3816
+    /**
3817
+     * return a storable representation of a specific object
3818
+     */
3819
+    function  serializeObject($id) {
3820 3820
     if  ( array_key_exists($id,  $this->objects))
3821
-      return  var_export($this->objects[$id],  true);
3822
-  }
3821
+        return  var_export($this->objects[$id],  true);
3822
+    }
3823 3823
 
3824 3824
 
3825
-  /**
3826
-   * restore an object from its stored representation.  returns its new object id.
3827
-   */
3828
-  function  restoreSerializedObject($obj) {
3825
+    /**
3826
+     * restore an object from its stored representation.  returns its new object id.
3827
+     */
3828
+    function  restoreSerializedObject($obj) {
3829 3829
     $obj_id =  $this->openObject();
3830 3830
     eval('$this->objects[$obj_id] = ' . $obj . ';');
3831 3831
     $this->closeObject();
3832 3832
     return  $obj_id;
3833
-  }
3833
+    }
3834 3834
 
3835 3835
 
3836
-  /**
3837
-   * add content to the documents info object
3838
-   */
3839
-  function  addInfo($label, $value =  0) {
3836
+    /**
3837
+     * add content to the documents info object
3838
+     */
3839
+    function  addInfo($label, $value =  0) {
3840 3840
     // this will only work if the label is one of the valid ones.
3841 3841
     // modify this so that arrays can be passed as well.
3842 3842
     // if $label is an array then assume that it is key => value pairs
3843 3843
     // else assume that they are both scalar, anything else will probably error
3844 3844
     if  (is_array($label)) {
3845
-      foreach ($label as  $l => $v) {
3845
+        foreach ($label as  $l => $v) {
3846 3846
         $this->o_info($this->infoObject, $l, $v);
3847
-      }
3847
+        }
3848 3848
     } else {
3849
-      $this->o_info($this->infoObject, $label, $value);
3849
+        $this->o_info($this->infoObject, $label, $value);
3850
+    }
3850 3851
     }
3851
-  }
3852 3852
 
3853 3853
 
3854
-  /**
3855
-   * set the viewer preferences of the document, it is up to the browser to obey these.
3856
-   */
3857
-  function  setPreferences($label, $value =  0) {
3854
+    /**
3855
+     * set the viewer preferences of the document, it is up to the browser to obey these.
3856
+     */
3857
+    function  setPreferences($label, $value =  0) {
3858 3858
     // this will only work if the label is one of the valid ones.
3859 3859
     if  (is_array($label)) {
3860
-      foreach ($label as  $l => $v) {
3860
+        foreach ($label as  $l => $v) {
3861 3861
         $this->o_catalog($this->catalogId, 'viewerPreferences', array($l => $v));
3862
-      }
3862
+        }
3863 3863
     } else {
3864
-      $this->o_catalog($this->catalogId, 'viewerPreferences', array($label => $value));
3864
+        $this->o_catalog($this->catalogId, 'viewerPreferences', array($label => $value));
3865
+    }
3865 3866
     }
3866
-  }
3867 3867
 
3868 3868
 
3869
-  /**
3870
-   * extract an integer from a position in a byte stream
3871
-   *
3872
-   * @access private
3873
-   */
3874
-  function  PRVT_getBytes(&$data, $pos, $num) {
3869
+    /**
3870
+     * extract an integer from a position in a byte stream
3871
+     *
3872
+     * @access private
3873
+     */
3874
+    function  PRVT_getBytes(&$data, $pos, $num) {
3875 3875
     // return the integer represented by $num bytes from $pos within $data
3876 3876
     $ret =  0;
3877 3877
     for  ($i =  0;$i<$num;$i++) {
3878
-      $ret =  $ret*256;
3879
-      $ret+=  ord($data[$pos+$i]);
3878
+        $ret =  $ret*256;
3879
+        $ret+=  ord($data[$pos+$i]);
3880 3880
     }
3881 3881
 
3882 3882
     return  $ret;
3883
-  }
3883
+    }
3884 3884
 
3885 3885
 
3886
-  /**
3887
-   * add a PNG image into the document, from a GD object
3888
-   * this should work with remote files
3889
-   */
3890
-  function addImagePng($file, $x, $y, $w =  0, $h =  0, &$img) {
3886
+    /**
3887
+     * add a PNG image into the document, from a GD object
3888
+     * this should work with remote files
3889
+     */
3890
+    function addImagePng($file, $x, $y, $w =  0, $h =  0, &$img) {
3891 3891
     //if already cached, need not to read again
3892
-	if ( isset($this->imagelist[$file]) ) {
3893
-	  $data = null;
3894
-	} else {
3895
-  	  // Example for transparency handling on new image. Retain for current image
3896
-      // $tIndex = imagecolortransparent($img);
3897
-      // if ($tIndex > 0) {
3898
-      //   $tColor    = imagecolorsforindex($img, $tIndex);
3899
-      //   $new_tIndex    = imagecolorallocate($new_img, $tColor['red'], $tColor['green'], $tColor['blue']);
3900
-      //   imagefill($new_img, 0, 0, $new_tIndex);
3901
-      //   imagecolortransparent($new_img, $new_tIndex);
3902
-      // }
3903
-	  // blending mode (literal/blending) on drawing into current image. not relevant when not saved or not drawn
3904
-	  //imagealphablending($img, true);
3905
-	  //default, but explicitely set to ensure pdf compatibility
3906
-      imagesavealpha($img, false);
3892
+    if ( isset($this->imagelist[$file]) ) {
3893
+        $data = null;
3894
+    } else {
3895
+        // Example for transparency handling on new image. Retain for current image
3896
+        // $tIndex = imagecolortransparent($img);
3897
+        // if ($tIndex > 0) {
3898
+        //   $tColor    = imagecolorsforindex($img, $tIndex);
3899
+        //   $new_tIndex    = imagecolorallocate($new_img, $tColor['red'], $tColor['green'], $tColor['blue']);
3900
+        //   imagefill($new_img, 0, 0, $new_tIndex);
3901
+        //   imagecolortransparent($new_img, $new_tIndex);
3902
+        // }
3903
+        // blending mode (literal/blending) on drawing into current image. not relevant when not saved or not drawn
3904
+        //imagealphablending($img, true);
3905
+        //default, but explicitely set to ensure pdf compatibility
3906
+        imagesavealpha($img, false);
3907 3907
       
3908
-      $error =  0;
3909
-      //DEBUG_IMG_TEMP
3910
-      //debugpng
3911
-      if (DEBUGPNG) print '[addImagePng '.$file.']';
3908
+        $error =  0;
3909
+        //DEBUG_IMG_TEMP
3910
+        //debugpng
3911
+        if (DEBUGPNG) print '[addImagePng '.$file.']';
3912 3912
 
3913
-      ob_start();
3914
-      @imagepng($img);
3915
-      //$data = ob_get_contents(); ob_end_clean();
3916
-      $data = ob_get_clean();
3913
+        ob_start();
3914
+        @imagepng($img);
3915
+        //$data = ob_get_contents(); ob_end_clean();
3916
+        $data = ob_get_clean();
3917 3917
 
3918
-      if ($data == '') {
3918
+        if ($data == '') {
3919 3919
         $error = 1;
3920 3920
         $errormsg = 'trouble writing file from GD';
3921 3921
         //DEBUG_IMG_TEMP
3922 3922
         //debugpng
3923 3923
         if (DEBUGPNG) print 'trouble writing file from GD';
3924
-	  }
3924
+        }
3925 3925
 
3926
-      if  ($error) {
3926
+        if  ($error) {
3927 3927
         $this->addMessage('PNG error - ('.$file.') '.$errormsg);
3928 3928
         return;
3929
-      }
3929
+        }
3930 3930
     }  //End isset($this->imagelist[$file]) (png Duplicate removal)
3931 3931
 
3932 3932
     $this->addPngFromBuf($file, $x, $y, $w, $h, $data);
3933
-  }
3933
+    }
3934 3934
 
3935 3935
 
3936
-  /**
3937
-   * add a PNG image into the document, from a file
3938
-   * this should work with remote files
3939
-   */
3940
-  function  addPngFromFile($file, $x, $y, $w =  0, $h =  0) {
3936
+    /**
3937
+     * add a PNG image into the document, from a file
3938
+     * this should work with remote files
3939
+     */
3940
+    function  addPngFromFile($file, $x, $y, $w =  0, $h =  0) {
3941 3941
     //if already cached, need not to read again
3942
-	if ( isset($this->imagelist[$file]) ) {
3943
-	  $img = null;
3944
-	} else {
3945
-      //png files typically contain an alpha channel.
3946
-      //pdf file format or class.pdf does not support alpha blending.
3947
-      //on alpha blended images, more transparent areas have a color near black.
3948
-      //This appears in the result on not storing the alpha channel.
3949
-      //Correct would be the box background image or its parent when transparent.
3950
-      //But this would make the image dependent on the background.
3951
-      //Therefore create an image with white background and copy in
3952
-      //A more natural background than black is white.
3953
-      //Therefore create an empty image with white background and merge the
3954
-      //image in with alpha blending.
3955
-      $imgtmp = @imagecreatefrompng($file);
3956
-      if (!$imgtmp) {
3942
+    if ( isset($this->imagelist[$file]) ) {
3943
+        $img = null;
3944
+    } else {
3945
+        //png files typically contain an alpha channel.
3946
+        //pdf file format or class.pdf does not support alpha blending.
3947
+        //on alpha blended images, more transparent areas have a color near black.
3948
+        //This appears in the result on not storing the alpha channel.
3949
+        //Correct would be the box background image or its parent when transparent.
3950
+        //But this would make the image dependent on the background.
3951
+        //Therefore create an image with white background and copy in
3952
+        //A more natural background than black is white.
3953
+        //Therefore create an empty image with white background and merge the
3954
+        //image in with alpha blending.
3955
+        $imgtmp = @imagecreatefrompng($file);
3956
+        if (!$imgtmp) {
3957 3957
         return;
3958
-      }
3959
-      $sx = imagesx($imgtmp);
3960
-      $sy = imagesy($imgtmp);
3961
-      $img = imagecreatetruecolor($sx,$sy);
3962
-      imagealphablending($img, true);
3963
-  	  $ti = imagecolortransparent($imgtmp);
3964
-	  if ($ti >= 0) {
3965
-	    $tc = imagecolorsforindex($imgtmp,$ti);
3958
+        }
3959
+        $sx = imagesx($imgtmp);
3960
+        $sy = imagesy($imgtmp);
3961
+        $img = imagecreatetruecolor($sx,$sy);
3962
+        imagealphablending($img, true);
3963
+        $ti = imagecolortransparent($imgtmp);
3964
+        if ($ti >= 0) {
3965
+        $tc = imagecolorsforindex($imgtmp,$ti);
3966 3966
         $ti = imagecolorallocate($img,$tc['red'],$tc['green'],$tc['blue']);
3967 3967
         imagefill($img,0,0,$ti);
3968 3968
         imagecolortransparent($img, $ti);
3969
-      } else {
3969
+        } else {
3970 3970
         imagefill($img,1,1,imagecolorallocate($img,255,255,255));
3971
-      }
3972
-      imagecopy($img,$imgtmp,0,0,0,0,$sx,$sy);
3973
-      imagedestroy($imgtmp);
3971
+        }
3972
+        imagecopy($img,$imgtmp,0,0,0,0,$sx,$sy);
3973
+        imagedestroy($imgtmp);
3974 3974
     }
3975 3975
     $this->addImagePng($file, $x, $y, $w, $h, $img);
3976
-  }
3976
+    }
3977 3977
 
3978 3978
 
3979
-  /**
3980
-   * add a PNG image into the document, from a memory buffer of the file
3981
-   */
3982
-  function  addPngFromBuf($file, $x, $y, $w =  0, $h =  0, &$data) {
3983
-	if ( isset($this->imagelist[$file]) ) {
3984
-      //debugpng
3985
-      //if (DEBUGPNG) print '[addPngFromBuf Duplicate '.$file.']';
3986
-	  $data = null;
3987
-      $info['width'] = $this->imagelist[$file]['w'];
3988
-      $info['height'] = $this->imagelist[$file]['h'];
3989
-      $label = $this->imagelist[$file]['label'];
3990
-
3991
-	} else {
3992
-      if ($data == null) {
3993
-      	$this->addMessage('addPngFromBuf error - ('.$imgname.') data not present!');
3979
+    /**
3980
+     * add a PNG image into the document, from a memory buffer of the file
3981
+     */
3982
+    function  addPngFromBuf($file, $x, $y, $w =  0, $h =  0, &$data) {
3983
+    if ( isset($this->imagelist[$file]) ) {
3984
+        //debugpng
3985
+        //if (DEBUGPNG) print '[addPngFromBuf Duplicate '.$file.']';
3986
+        $data = null;
3987
+        $info['width'] = $this->imagelist[$file]['w'];
3988
+        $info['height'] = $this->imagelist[$file]['h'];
3989
+        $label = $this->imagelist[$file]['label'];
3990
+
3991
+    } else {
3992
+        if ($data == null) {
3993
+            $this->addMessage('addPngFromBuf error - ('.$imgname.') data not present!');
3994 3994
         return;
3995
-      }
3996
-      //debugpng
3997
-      //if (DEBUGPNG) print '[addPngFromBuf file='.$file.']';
3995
+        }
3996
+        //debugpng
3997
+        //if (DEBUGPNG) print '[addPngFromBuf file='.$file.']';
3998 3998
     $error =  0;
3999 3999
 
4000 4000
     if  (!$error) {
4001
-      $header =  chr(137) .chr(80) .chr(78) .chr(71) .chr(13) .chr(10) .chr(26) .chr(10);
4002
-      if  (mb_substr($data, 0, 8, '8bit') !=  $header) {
4001
+        $header =  chr(137) .chr(80) .chr(78) .chr(71) .chr(13) .chr(10) .chr(26) .chr(10);
4002
+        if  (mb_substr($data, 0, 8, '8bit') !=  $header) {
4003 4003
         $error =  1;
4004 4004
         //debugpng
4005 4005
         if (DEBUGPNG) print '[addPngFromFile this file does not have a valid header '.$file.']';
4006 4006
 
4007 4007
         $errormsg =  'this file does not have a valid header';
4008
-      }
4008
+        }
4009 4009
     }
4010 4010
 
4011 4011
 
4012 4012
     if  (!$error) {
4013
-      // set pointer
4014
-      $p =  8;
4015
-      $len =  mb_strlen($data, '8bit');
4013
+        // set pointer
4014
+        $p =  8;
4015
+        $len =  mb_strlen($data, '8bit');
4016 4016
 
4017
-      // cycle through the file, identifying chunks
4018
-      $haveHeader =  0;
4019
-      $info =  array();
4020
-      $idata =  '';
4021
-      $pdata =  '';
4017
+        // cycle through the file, identifying chunks
4018
+        $haveHeader =  0;
4019
+        $info =  array();
4020
+        $idata =  '';
4021
+        $pdata =  '';
4022 4022
 
4023
-      while  ($p < $len) {
4023
+        while  ($p < $len) {
4024 4024
         $chunkLen =  $this->PRVT_getBytes($data, $p, 4);
4025 4025
         $chunkType =  mb_substr($data, $p+4, 4, '8bit');
4026 4026
         //      echo $chunkType.' - '.$chunkLen.'<br>';
@@ -4028,48 +4028,48 @@  discard block
 block discarded – undo
4028 4028
         case  'IHDR':
4029 4029
           // this is where all the file information comes from
4030 4030
           $info['width'] =  $this->PRVT_getBytes($data, $p+8, 4);
4031
-          $info['height'] =  $this->PRVT_getBytes($data, $p+12, 4);
4032
-          $info['bitDepth'] =  ord($data[$p+16]);
4033
-          $info['colorType'] =  ord($data[$p+17]);
4034
-          $info['compressionMethod'] =  ord($data[$p+18]);
4035
-          $info['filterMethod'] =  ord($data[$p+19]);
4036
-          $info['interlaceMethod'] =  ord($data[$p+20]);
4037
-
4038
-          //print_r($info);
4039
-          $haveHeader =  1;
4040
-          if  ($info['compressionMethod'] !=  0) {
4031
+            $info['height'] =  $this->PRVT_getBytes($data, $p+12, 4);
4032
+            $info['bitDepth'] =  ord($data[$p+16]);
4033
+            $info['colorType'] =  ord($data[$p+17]);
4034
+            $info['compressionMethod'] =  ord($data[$p+18]);
4035
+            $info['filterMethod'] =  ord($data[$p+19]);
4036
+            $info['interlaceMethod'] =  ord($data[$p+20]);
4037
+
4038
+            //print_r($info);
4039
+            $haveHeader =  1;
4040
+            if  ($info['compressionMethod'] !=  0) {
4041 4041
             $error =  1;
4042 4042
 
4043 4043
             //debugpng
4044 4044
             if (DEBUGPNG) print '[addPngFromFile unsupported compression method '.$file.']';
4045 4045
 
4046 4046
             $errormsg =  'unsupported compression method';
4047
-          }
4047
+            }
4048 4048
 
4049
-          if  ($info['filterMethod'] !=  0) {
4049
+            if  ($info['filterMethod'] !=  0) {
4050 4050
             $error =  1;
4051 4051
 
4052 4052
             //debugpng
4053 4053
             if (DEBUGPNG) print '[addPngFromFile unsupported filter method '.$file.']';
4054 4054
 
4055 4055
             $errormsg =  'unsupported filter method';
4056
-          }
4057
-          break;
4056
+            }
4057
+            break;
4058 4058
 
4059 4059
         case  'PLTE':
4060 4060
           $pdata.=  mb_substr($data, $p+8, $chunkLen, '8bit');
4061
-          break;
4061
+            break;
4062 4062
 
4063 4063
         case  'IDAT':
4064 4064
           $idata.=  mb_substr($data, $p+8, $chunkLen, '8bit');
4065
-          break;
4065
+            break;
4066 4066
 
4067 4067
         case  'tRNS':
4068 4068
           //this chunk can only occur once and it must occur after the PLTE chunk and before IDAT chunk
4069 4069
           //print "tRNS found, color type = ".$info['colorType']."\n";
4070 4070
           $transparency =  array();
4071 4071
 
4072
-          if  ($info['colorType'] ==  3) {
4072
+            if  ($info['colorType'] ==  3) {
4073 4073
             // indexed color, rbg
4074 4074
             /* corresponding to entries in the plte chunk
4075 4075
              Alpha for palette index 0: 1 byte
@@ -4083,13 +4083,13 @@  discard block
 block discarded – undo
4083 4083
             $trans =  0;
4084 4084
 
4085 4085
             for  ($i =  $chunkLen;$i >=  0;$i--) {
4086
-              if  (ord($data[$p+8+$i]) ==  0) {
4086
+                if  (ord($data[$p+8+$i]) ==  0) {
4087 4087
                 $trans =  $i;
4088
-              }
4088
+                }
4089 4089
             }
4090 4090
 
4091 4091
             $transparency['data'] =  $trans;
4092
-          } elseif ($info['colorType'] ==  0) {
4092
+            } elseif ($info['colorType'] ==  0) {
4093 4093
             // grayscale
4094 4094
             /* corresponding to entries in the plte chunk
4095 4095
              Gray: 2 bytes, range 0 .. (2^bitdepth)-1
@@ -4098,7 +4098,7 @@  discard block
 block discarded – undo
4098 4098
             $transparency['type'] =  'indexed';
4099 4099
 
4100 4100
             $transparency['data'] =  ord($data[$p+8+1]);
4101
-          } elseif ($info['colorType'] ==  2) {
4101
+            } elseif ($info['colorType'] ==  2) {
4102 4102
             // truecolor
4103 4103
             /* corresponding to entries in the plte chunk
4104 4104
              Red: 2 bytes, range 0 .. (2^bitdepth)-1
@@ -4114,176 +4114,176 @@  discard block
 block discarded – undo
4114 4114
 
4115 4115
             $transparency['type'] = 'color-key';
4116 4116
             
4117
-          } else {
4117
+            } else {
4118 4118
             //unsupported transparency type
4119 4119
             //debugpng
4120 4120
             if (DEBUGPNG) print '[addPngFromFile unsupported transparency type '.$file.']';
4121
-          }
4122
-          // KS End new code
4123
-          break;
4121
+            }
4122
+            // KS End new code
4123
+            break;
4124 4124
 
4125 4125
         default:
4126 4126
           break;
4127 4127
         }
4128 4128
 
4129 4129
         $p+=  $chunkLen+12;
4130
-      }
4130
+        }
4131 4131
 
4132 4132
 
4133
-      if (!$haveHeader) {
4133
+        if (!$haveHeader) {
4134 4134
         $error =  1;
4135 4135
 
4136 4136
         //debugpng
4137 4137
         if (DEBUGPNG) print '[addPngFromFile information header is missing '.$file.']';
4138 4138
 
4139 4139
         $errormsg =  'information header is missing';
4140
-      }
4140
+        }
4141 4141
 
4142
-      if  (isset($info['interlaceMethod']) &&  $info['interlaceMethod']) {
4142
+        if  (isset($info['interlaceMethod']) &&  $info['interlaceMethod']) {
4143 4143
         $error =  1;
4144 4144
 
4145 4145
         //debugpng
4146 4146
         if (DEBUGPNG) print '[addPngFromFile no support for interlaced images in pdf '.$file.']';
4147 4147
 
4148 4148
         $errormsg =  'There appears to be no support for interlaced images in pdf.';
4149
-      }
4149
+        }
4150 4150
     }
4151 4151
 
4152 4152
     if  (!$error &&  $info['bitDepth'] > 8) {
4153
-      $error =  1;
4153
+        $error =  1;
4154 4154
 
4155
-      //debugpng
4156
-      if (DEBUGPNG) print '[addPngFromFile bit depth of 8 or less is supported '.$file.']';
4155
+        //debugpng
4156
+        if (DEBUGPNG) print '[addPngFromFile bit depth of 8 or less is supported '.$file.']';
4157 4157
 
4158
-      $errormsg =  'only bit depth of 8 or less is supported';
4158
+        $errormsg =  'only bit depth of 8 or less is supported';
4159 4159
     }
4160 4160
 
4161 4161
     if  (!$error) {
4162
-      if  ($info['colorType'] !=  2 &&  $info['colorType'] !=  0 &&  $info['colorType'] !=  3) {
4162
+        if  ($info['colorType'] !=  2 &&  $info['colorType'] !=  0 &&  $info['colorType'] !=  3) {
4163 4163
         $error =  1;
4164 4164
 
4165 4165
         //debugpng
4166 4166
         if (DEBUGPNG) print '[addPngFromFile alpha channel not supported: '.$info['colorType'].' '.$file.']';
4167 4167
 
4168 4168
         $errormsg =  'transparancey alpha channel not supported, transparency only supported for palette images.';
4169
-      } else {
4169
+        } else {
4170 4170
         switch  ($info['colorType']) {
4171 4171
         case  3:
4172 4172
           $color =  'DeviceRGB';
4173
-          $ncolor =  1;
4174
-          break;
4173
+            $ncolor =  1;
4174
+            break;
4175 4175
 
4176 4176
         case  2:
4177 4177
           $color =  'DeviceRGB';
4178
-          $ncolor =  3;
4179
-          break;
4178
+            $ncolor =  3;
4179
+            break;
4180 4180
 
4181 4181
         case  0:
4182 4182
           $color =  'DeviceGray';
4183
-          $ncolor =  1;
4184
-          break;
4183
+            $ncolor =  1;
4184
+            break;
4185
+        }
4185 4186
         }
4186
-      }
4187 4187
     }
4188 4188
 
4189 4189
     if  ($error) {
4190
-      $this->addMessage('PNG error - ('.$file.') '.$errormsg);
4191
-      return;
4190
+        $this->addMessage('PNG error - ('.$file.') '.$errormsg);
4191
+        return;
4192 4192
     }
4193 4193
 
4194
-      //print_r($info);
4195
-      // so this image is ok... add it in.
4196
-      $this->numImages++;
4197
-      $im =  $this->numImages;
4198
-      $label =  'I'.$im;
4199
-      $this->numObj++;
4194
+        //print_r($info);
4195
+        // so this image is ok... add it in.
4196
+        $this->numImages++;
4197
+        $im =  $this->numImages;
4198
+        $label =  'I'.$im;
4199
+        $this->numObj++;
4200 4200
 
4201
-      //  $this->o_image($this->numObj,'new',array('label' => $label,'data' => $idata,'iw' => $w,'ih' => $h,'type' => 'png','ic' => $info['width']));
4202
-      $options =  array('label' => $label, 'data' => $idata, 'bitsPerComponent' => $info['bitDepth'], 'pdata' => $pdata, 'iw' => $info['width'], 'ih' => $info['height'], 'type' => 'png', 'color' => $color, 'ncolor' => $ncolor);
4201
+        //  $this->o_image($this->numObj,'new',array('label' => $label,'data' => $idata,'iw' => $w,'ih' => $h,'type' => 'png','ic' => $info['width']));
4202
+        $options =  array('label' => $label, 'data' => $idata, 'bitsPerComponent' => $info['bitDepth'], 'pdata' => $pdata, 'iw' => $info['width'], 'ih' => $info['height'], 'type' => 'png', 'color' => $color, 'ncolor' => $ncolor);
4203 4203
 
4204
-      if  (isset($transparency)) {
4204
+        if  (isset($transparency)) {
4205 4205
         $options['transparency'] =  $transparency;
4206
-      }
4206
+        }
4207 4207
 
4208
-      $this->o_image($this->numObj, 'new', $options);
4209
-      $this->imagelist[$file] = array('label' =>$label, 'w' => $info['width'], 'h' => $info['height']);
4208
+        $this->o_image($this->numObj, 'new', $options);
4209
+        $this->imagelist[$file] = array('label' =>$label, 'w' => $info['width'], 'h' => $info['height']);
4210 4210
     }
4211 4211
 
4212 4212
     if  ($w <=  0 && $h <=  0) {
4213
-      $w =  $info['width'];
4214
-      $h =  $info['height'];
4213
+        $w =  $info['width'];
4214
+        $h =  $info['height'];
4215 4215
     }
4216 4216
 
4217 4217
     if  ($w <=  0) {
4218
-      $w =  $h/$info['height']*$info['width'];
4218
+        $w =  $h/$info['height']*$info['width'];
4219 4219
     }
4220 4220
 
4221 4221
     if  ($h <=  0) {
4222
-      $h =  $w*$info['height']/$info['width'];
4222
+        $h =  $w*$info['height']/$info['width'];
4223 4223
     }
4224 4224
 
4225 4225
     $this->objects[$this->currentContents]['c'].=  "\nq";
4226 4226
     $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $w) ." 0 0 ".sprintf('%.3F', $h) ." ".sprintf('%.3F', $x) ." ".sprintf('%.3F', $y) ." cm";
4227 4227
     $this->objects[$this->currentContents]['c'].=  "\n/".$label.' Do';
4228 4228
     $this->objects[$this->currentContents]['c'].=  "\nQ";
4229
-  }
4229
+    }
4230 4230
 
4231 4231
 
4232
-  /**
4233
-   * add a JPEG image into the document, from a file
4234
-   */
4235
-  function  addJpegFromFile($img, $x, $y, $w =  0, $h =  0) {
4232
+    /**
4233
+     * add a JPEG image into the document, from a file
4234
+     */
4235
+    function  addJpegFromFile($img, $x, $y, $w =  0, $h =  0) {
4236 4236
     // attempt to add a jpeg image straight from a file, using no GD commands
4237 4237
     // note that this function is unable to operate on a remote file.
4238 4238
 
4239 4239
     if  (!file_exists($img)) {
4240
-      return;
4240
+        return;
4241 4241
     }
4242 4242
 
4243
-	if ( isset($this->imagelist[$img]) ) {
4244
-	  $data = null;
4245
-      $imageWidth = $this->imagelist[$img]['w'];
4246
-      $imageHeight = $this->imagelist[$img]['h'];
4247
-      $channels =  $this->imagelist[$img]['c'];
4248
-	} else {
4249
-      $tmp =  getimagesize($img);
4250
-      $imageWidth =  $tmp[0];
4251
-      $imageHeight =  $tmp[1];
4243
+    if ( isset($this->imagelist[$img]) ) {
4244
+        $data = null;
4245
+        $imageWidth = $this->imagelist[$img]['w'];
4246
+        $imageHeight = $this->imagelist[$img]['h'];
4247
+        $channels =  $this->imagelist[$img]['c'];
4248
+    } else {
4249
+        $tmp =  getimagesize($img);
4250
+        $imageWidth =  $tmp[0];
4251
+        $imageHeight =  $tmp[1];
4252 4252
 
4253
-      if  (isset($tmp['channels'])) {
4253
+        if  (isset($tmp['channels'])) {
4254 4254
         $channels =  $tmp['channels'];
4255
-      } else {
4255
+        } else {
4256 4256
         $channels =  3;
4257
-      }
4257
+        }
4258 4258
 
4259
-      //$fp = fopen($img,'rb');
4260
-      $data =  file_get_contents($img);
4261
-      //fread($fp,filesize($img));
4262
-      //fclose($fp);
4259
+        //$fp = fopen($img,'rb');
4260
+        $data =  file_get_contents($img);
4261
+        //fread($fp,filesize($img));
4262
+        //fclose($fp);
4263 4263
     }
4264 4264
 
4265 4265
     if  ($w <=  0 &&  $h <=  0) {
4266
-      $w =  $imageWidth;
4266
+        $w =  $imageWidth;
4267 4267
     }
4268 4268
 
4269 4269
     if  ($w ==  0) {
4270
-      $w =  $h/$imageHeight*$imageWidth;
4270
+        $w =  $h/$imageHeight*$imageWidth;
4271 4271
     }
4272 4272
 
4273 4273
     if  ($h ==  0) {
4274
-      $h =  $w*$imageHeight/$imageWidth;
4274
+        $h =  $w*$imageHeight/$imageWidth;
4275 4275
     }
4276 4276
 
4277 4277
     $this->addJpegImage_common($data, $x, $y, $w, $h, $imageWidth, $imageHeight, $channels, $img);
4278
-  }
4278
+    }
4279 4279
 
4280 4280
 
4281
-  /**
4282
-   * add an image into the document, from a GD object
4283
-   * this function is not all that reliable, and I would probably encourage people to use
4284
-   * the file based functions
4285
-   */
4286
-  function  addImage(&$img, $x, $y, $w =  0, $h =  0, $quality =  75) {
4281
+    /**
4282
+     * add an image into the document, from a GD object
4283
+     * this function is not all that reliable, and I would probably encourage people to use
4284
+     * the file based functions
4285
+     */
4286
+    function  addImage(&$img, $x, $y, $w =  0, $h =  0, $quality =  75) {
4287 4287
     /* Todo:
4288 4288
      * Pass in original filename as $imgname
4289 4289
      * If already cached like image_iscached(), allow empty $img
@@ -4303,7 +4303,7 @@  discard block
 block discarded – undo
4303 4303
     // there seems to be some problem here in that images that have quality set above 75 do not appear
4304 4304
     // not too sure why this is, but in the meantime I have restricted this to 75.
4305 4305
     if  ($quality>75) {
4306
-      $quality =  75;
4306
+        $quality =  75;
4307 4307
     }
4308 4308
 
4309 4309
     // if the width or height are set to zero, then set the other one based on keeping the image
@@ -4312,15 +4312,15 @@  discard block
 block discarded – undo
4312 4312
     $imageHeight =  imagesy($img);
4313 4313
 
4314 4314
     if  ($w <=  0 &&  $h <=  0) {
4315
-      return;
4315
+        return;
4316 4316
     }
4317 4317
 
4318 4318
     if  ($w ==  0) {
4319
-      $w =  $h/$imageHeight*$imageWidth;
4319
+        $w =  $h/$imageHeight*$imageWidth;
4320 4320
     }
4321 4321
 
4322 4322
     if  ($h ==  0) {
4323
-      $h =  $w*$imageHeight/$imageWidth;
4323
+        $h =  $w*$imageHeight/$imageWidth;
4324 4324
     }
4325 4325
 
4326 4326
     // gotta get the data out of the img..
@@ -4330,55 +4330,55 @@  discard block
 block discarded – undo
4330 4330
     $data = ob_get_clean();
4331 4331
 
4332 4332
     $this->addJpegImage_common($data, $x, $y, $w, $h, $imageWidth, $imageHeight, $imgname);
4333
-  }
4333
+    }
4334 4334
 
4335 4335
 
4336
-  /* Check if image already added to pdf image directory.
4336
+    /* Check if image already added to pdf image directory.
4337 4337
    * If yes, need not to create again (pass empty data)
4338 4338
    */
4339
-  function  image_iscached($imgname) {
4339
+    function  image_iscached($imgname) {
4340 4340
     return isset($this->imagelist[$imgname]);
4341
-  }
4341
+    }
4342 4342
 
4343 4343
 
4344
-  /**
4345
-   * common code used by the two JPEG adding functions
4346
-   *
4347
-   * @access private
4348
-   */
4349
-  function  addJpegImage_common(&$data, $x, $y, $w =  0, $h =  0, $imageWidth, $imageHeight, $channels =  3, $imgname) {
4344
+    /**
4345
+     * common code used by the two JPEG adding functions
4346
+     *
4347
+     * @access private
4348
+     */
4349
+    function  addJpegImage_common(&$data, $x, $y, $w =  0, $h =  0, $imageWidth, $imageHeight, $channels =  3, $imgname) {
4350 4350
     if ( isset($this->imagelist[$imgname]) ) {
4351
-      $label = $this->imagelist[$imgname]['label'];
4352
-      //debugpng
4353
-      //if (DEBUGPNG) print '[addJpegImage_common Duplicate '.$imgname.']';
4351
+        $label = $this->imagelist[$imgname]['label'];
4352
+        //debugpng
4353
+        //if (DEBUGPNG) print '[addJpegImage_common Duplicate '.$imgname.']';
4354 4354
 
4355 4355
     } else {
4356
-      if ($data == null) {
4357
-      	$this->addMessage('addJpegImage_common error - ('.$imgname.') data not present!');
4356
+        if ($data == null) {
4357
+            $this->addMessage('addJpegImage_common error - ('.$imgname.') data not present!');
4358 4358
         return;
4359
-      }
4359
+        }
4360 4360
 
4361
-      // note that this function is not to be called externally
4362
-      // it is just the common code between the GD and the file options
4363
-      $this->numImages++;
4364
-      $im =  $this->numImages;
4365
-      $label =  'I'.$im;
4366
-      $this->numObj++;
4367
-      $this->o_image($this->numObj, 'new', array('label' => $label, 'data' => &$data, 'iw' => $imageWidth, 'ih' => $imageHeight, 'channels' => $channels));
4368
-      $this->imagelist[$imgname] = array('label' =>$label, 'w' => $imageWidth, 'h' => $imageHeight, 'c'=> $channels );
4361
+        // note that this function is not to be called externally
4362
+        // it is just the common code between the GD and the file options
4363
+        $this->numImages++;
4364
+        $im =  $this->numImages;
4365
+        $label =  'I'.$im;
4366
+        $this->numObj++;
4367
+        $this->o_image($this->numObj, 'new', array('label' => $label, 'data' => &$data, 'iw' => $imageWidth, 'ih' => $imageHeight, 'channels' => $channels));
4368
+        $this->imagelist[$imgname] = array('label' =>$label, 'w' => $imageWidth, 'h' => $imageHeight, 'c'=> $channels );
4369 4369
     }
4370 4370
 
4371 4371
     $this->objects[$this->currentContents]['c'].=  "\nq";
4372 4372
     $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $w) ." 0 0 ".sprintf('%.3F', $h) ." ".sprintf('%.3F', $x) ." ".sprintf('%.3F', $y) ." cm";
4373 4373
     $this->objects[$this->currentContents]['c'].=  "\n/".$label.' Do';
4374 4374
     $this->objects[$this->currentContents]['c'].=  "\nQ";
4375
-  }
4375
+    }
4376 4376
 
4377 4377
 
4378
-  /**
4379
-   * specify where the document should open when it first starts
4380
-   */
4381
-  function  openHere($style, $a =  0, $b =  0, $c =  0) {
4378
+    /**
4379
+     * specify where the document should open when it first starts
4380
+     */
4381
+    function  openHere($style, $a =  0, $b =  0, $c =  0) {
4382 4382
     // this function will open the document at a specified page, in a specified style
4383 4383
     // the values for style, and the required paramters are:
4384 4384
     // 'XYZ'  left, top, zoom
@@ -4393,17 +4393,17 @@  discard block
 block discarded – undo
4393 4393
     $this->o_destination($this->numObj, 'new', array('page' => $this->currentPage, 'type' => $style, 'p1' => $a, 'p2' => $b, 'p3' => $c));
4394 4394
     $id =  $this->catalogId;
4395 4395
     $this->o_catalog($id, 'openHere', $this->numObj);
4396
-  }
4396
+    }
4397 4397
   
4398
-  function addJavascript($code) {
4398
+    function addJavascript($code) {
4399 4399
     $this->javascript .= $code;
4400
-  }
4400
+    }
4401 4401
 
4402 4402
 
4403
-  /**
4404
-   * create a labelled destination within the document
4405
-   */
4406
-  function  addDestination($label, $style, $a =  0, $b =  0, $c =  0) {
4403
+    /**
4404
+     * create a labelled destination within the document
4405
+     */
4406
+    function  addDestination($label, $style, $a =  0, $b =  0, $c =  0) {
4407 4407
     // associates the given label with the destination, it is done this way so that a destination can be specified after
4408 4408
     // it has been linked to
4409 4409
     // styles are the same as the 'openHere' function
@@ -4413,78 +4413,78 @@  discard block
 block discarded – undo
4413 4413
 
4414 4414
     // store the label->idf relationship, note that this means that labels can be used only once
4415 4415
     $this->destinations["$label"] =  $id;
4416
-  }
4416
+    }
4417 4417
 
4418 4418
 
4419
-  /**
4420
-   * define font families, this is used to initialize the font families for the default fonts
4421
-   * and for the user to add new ones for their fonts. The default bahavious can be overridden should
4422
-   * that be desired.
4423
-   */
4424
-  function  setFontFamily($family, $options =  '') {
4419
+    /**
4420
+     * define font families, this is used to initialize the font families for the default fonts
4421
+     * and for the user to add new ones for their fonts. The default bahavious can be overridden should
4422
+     * that be desired.
4423
+     */
4424
+    function  setFontFamily($family, $options =  '') {
4425 4425
     if  (!is_array($options)) {
4426
-      if  ($family ===  'init') {
4426
+        if  ($family ===  'init') {
4427 4427
         // set the known family groups
4428 4428
         // these font families will be used to enable bold and italic markers to be included
4429 4429
         // within text streams. html forms will be used... <b></b> <i></i>
4430 4430
         $this->fontFamilies['Helvetica.afm'] =
4431
-          array('b' => 'Helvetica-Bold.afm',
4431
+            array('b' => 'Helvetica-Bold.afm',
4432 4432
                 'i' => 'Helvetica-Oblique.afm',
4433 4433
                 'bi' => 'Helvetica-BoldOblique.afm',
4434 4434
                 'ib' => 'Helvetica-BoldOblique.afm');
4435 4435
 
4436 4436
         $this->fontFamilies['Courier.afm'] =
4437
-          array('b' => 'Courier-Bold.afm',
4437
+            array('b' => 'Courier-Bold.afm',
4438 4438
                 'i' => 'Courier-Oblique.afm',
4439 4439
                 'bi' => 'Courier-BoldOblique.afm',
4440 4440
                 'ib' => 'Courier-BoldOblique.afm');
4441 4441
 
4442 4442
         $this->fontFamilies['Times-Roman.afm'] =
4443
-          array('b' => 'Times-Bold.afm',
4443
+            array('b' => 'Times-Bold.afm',
4444 4444
                 'i' => 'Times-Italic.afm',
4445 4445
                 'bi' => 'Times-BoldItalic.afm',
4446 4446
                 'ib' => 'Times-BoldItalic.afm');
4447
-      }
4447
+        }
4448 4448
     } else {
4449 4449
 
4450
-      // the user is trying to set a font family
4451
-      // note that this can also be used to set the base ones to something else
4452
-      if  (mb_strlen($family)) {
4450
+        // the user is trying to set a font family
4451
+        // note that this can also be used to set the base ones to something else
4452
+        if  (mb_strlen($family)) {
4453 4453
         $this->fontFamilies[$family] =  $options;
4454
-      }
4454
+        }
4455
+    }
4455 4456
     }
4456
-  }
4457 4457
 
4458 4458
 
4459
-  /**
4460
-   * used to add messages for use in debugging
4461
-   */
4462
-  function  addMessage($message) {
4459
+    /**
4460
+     * used to add messages for use in debugging
4461
+     */
4462
+    function  addMessage($message) {
4463 4463
     $this->messages.=  $message."\n";
4464
-  }
4464
+    }
4465 4465
 
4466 4466
 
4467
-  /**
4468
-   * a few functions which should allow the document to be treated transactionally.
4469
-   */
4470
-  function  transaction($action) {
4467
+    /**
4468
+     * a few functions which should allow the document to be treated transactionally.
4469
+     */
4470
+    function  transaction($action) {
4471 4471
     switch  ($action) {
4472 4472
     case  'start':
4473 4473
       // store all the data away into the checkpoint variable
4474 4474
       $data =  get_object_vars($this);
4475
-      $this->checkpoint =  $data;
4476
-      unset($data);
4477
-      break;
4475
+        $this->checkpoint =  $data;
4476
+        unset($data);
4477
+        break;
4478 4478
 
4479 4479
     case  'commit':
4480 4480
       if  (is_array($this->checkpoint) &&  isset($this->checkpoint['checkpoint'])) {
4481 4481
         $tmp =  $this->checkpoint['checkpoint'];
4482 4482
         $this->checkpoint =  $tmp;
4483 4483
         unset($tmp);
4484
-      } else {
4484
+        } else {
4485 4485
         $this->checkpoint =  '';
4486
-      }
4487
-      break;
4486
+        }
4487
+        break;
4488 4488
 
4489 4489
     case  'rewind':
4490 4490
       // do not destroy the current checkpoint, but move us back to the state then, so that we can try again
@@ -4493,25 +4493,25 @@  discard block
 block discarded – undo
4493 4493
         $tmp =  $this->checkpoint;
4494 4494
 
4495 4495
         foreach ($tmp as  $k => $v) {
4496
-          if  ($k !==  'checkpoint') {
4496
+            if  ($k !==  'checkpoint') {
4497 4497
             $this->$k =  $v;
4498
-          }
4498
+            }
4499 4499
         }
4500 4500
         unset($tmp);
4501
-      }
4502
-      break;
4501
+        }
4502
+        break;
4503 4503
 
4504 4504
     case  'abort':
4505 4505
       if  (is_array($this->checkpoint)) {
4506 4506
         // can only abort if were inside a checkpoint
4507 4507
         $tmp =  $this->checkpoint;
4508 4508
         foreach ($tmp as  $k => $v) {
4509
-          $this->$k =  $v;
4509
+            $this->$k =  $v;
4510 4510
         }
4511 4511
         unset($tmp);
4512
-      }
4513
-      break;
4512
+        }
4513
+        break;
4514
+    }
4514 4515
     }
4515
-  }
4516 4516
 }
4517 4517
 // end of class
Please login to merge, or discard this patch.
Switch Indentation   +1218 added lines, -1218 removed lines patch added patch discarded remove patch
@@ -354,30 +354,30 @@  discard block
 block discarded – undo
354 354
     }
355 355
 
356 356
     switch ($action) {
357
-    case  'new':
358
-      $this->objects[$id] = array('t'=>'destination', 'info'=>array());
359
-      $tmp =  '';
360
-      switch  ($options['type']) {
361
-      case  'XYZ':
362
-      case  'FitR':
363
-        $tmp =   ' '.$options['p3'].$tmp;
364
-      case  'FitH':
365
-      case  'FitV':
366
-      case  'FitBH':
367
-      case  'FitBV':
368
-        $tmp =   ' '.$options['p1'].' '.$options['p2'].$tmp;
369
-      case  'Fit':
370
-      case  'FitB':
371
-        $tmp =   $options['type'].$tmp;
372
-        $this->objects[$id]['info']['string'] = $tmp;
373
-        $this->objects[$id]['info']['page'] = $options['page'];
374
-      }
357
+        case  'new':
358
+          $this->objects[$id] = array('t'=>'destination', 'info'=>array());
359
+          $tmp =  '';
360
+          switch  ($options['type']) {
361
+              case  'XYZ':
362
+              case  'FitR':
363
+                $tmp =   ' '.$options['p3'].$tmp;
364
+              case  'FitH':
365
+              case  'FitV':
366
+              case  'FitBH':
367
+              case  'FitBV':
368
+                $tmp =   ' '.$options['p1'].' '.$options['p2'].$tmp;
369
+              case  'Fit':
370
+              case  'FitB':
371
+                $tmp =   $options['type'].$tmp;
372
+                $this->objects[$id]['info']['string'] = $tmp;
373
+                $this->objects[$id]['info']['page'] = $options['page'];
374
+          }
375 375
       break;
376 376
 
377
-    case  'out':
378
-      $tmp =  $o['info'];
379
-      $res = "\n".$id." 0 obj\n".'['.$tmp['page'].' 0 R /'.$tmp['string']."]\nendobj";
380
-      return  $res;
377
+        case  'out':
378
+          $tmp =  $o['info'];
379
+          $res = "\n".$id." 0 obj\n".'['.$tmp['page'].' 0 R /'.$tmp['string']."]\nendobj";
380
+          return  $res;
381 381
     }
382 382
   }
383 383
 
@@ -391,33 +391,33 @@  discard block
 block discarded – undo
391 391
     }
392 392
 
393 393
     switch  ($action) {
394
-    case  'new':
395
-      $this->objects[$id] = array('t'=>'viewerPreferences', 'info'=>array());
396
-      break;
397
-
398
-    case  'add':
399
-      foreach($options as  $k=>$v) {
400
-        switch  ($k) {
401
-        case  'HideToolbar':
402
-        case  'HideMenubar':
403
-        case  'HideWindowUI':
404
-        case  'FitWindow':
405
-        case  'CenterWindow':
406
-        case  'NonFullScreenPageMode':
407
-        case  'Direction':
408
-          $o['info'][$k] = $v;
394
+        case  'new':
395
+          $this->objects[$id] = array('t'=>'viewerPreferences', 'info'=>array());
409 396
           break;
410
-        }
397
+
398
+        case  'add':
399
+          foreach($options as  $k=>$v) {
400
+            switch  ($k) {
401
+                case  'HideToolbar':
402
+                case  'HideMenubar':
403
+                case  'HideWindowUI':
404
+                case  'FitWindow':
405
+                case  'CenterWindow':
406
+                case  'NonFullScreenPageMode':
407
+                case  'Direction':
408
+                  $o['info'][$k] = $v;
409
+                  break;
410
+            }
411 411
       }
412 412
       break;
413 413
 
414
-    case  'out':
415
-      $res = "\n".$id." 0 obj\n".'<< ';
416
-      foreach($o['info'] as  $k=>$v) {
417
-        $res.= "\n/".$k.' '.$v;
418
-      }
419
-      $res.= "\n>>\n";
420
-      return  $res;
414
+        case  'out':
415
+          $res = "\n".$id." 0 obj\n".'<< ';
416
+          foreach($o['info'] as  $k=>$v) {
417
+            $res.= "\n/".$k.' '.$v;
418
+          }
419
+          $res.= "\n>>\n";
420
+          return  $res;
421 421
     }
422 422
   }
423 423
 
@@ -431,55 +431,55 @@  discard block
 block discarded – undo
431 431
     }
432 432
 
433 433
     switch  ($action) {
434
-    case  'new':
435
-      $this->objects[$id] = array('t'=>'catalog', 'info'=>array());
436
-      $this->catalogId = $id;
437
-      break;
434
+        case  'new':
435
+          $this->objects[$id] = array('t'=>'catalog', 'info'=>array());
436
+          $this->catalogId = $id;
437
+          break;
438 438
 
439
-    case  'outlines':
440
-    case  'pages':
441
-    case  'openHere':
442
-    case  'javascript':
443
-      $o['info'][$action] = $options;
444
-      break;
439
+        case  'outlines':
440
+        case  'pages':
441
+        case  'openHere':
442
+        case  'javascript':
443
+          $o['info'][$action] = $options;
444
+          break;
445 445
 
446
-    case  'viewerPreferences':
447
-      if  (!isset($o['info']['viewerPreferences'])) {
448
-        $this->numObj++;
449
-        $this->o_viewerPreferences($this->numObj, 'new');
450
-        $o['info']['viewerPreferences'] = $this->numObj;
451
-      }
446
+        case  'viewerPreferences':
447
+          if  (!isset($o['info']['viewerPreferences'])) {
448
+            $this->numObj++;
449
+            $this->o_viewerPreferences($this->numObj, 'new');
450
+            $o['info']['viewerPreferences'] = $this->numObj;
451
+          }
452 452
 
453
-      $vp =  $o['info']['viewerPreferences'];
454
-      $this->o_viewerPreferences($vp, 'add', $options);
453
+          $vp =  $o['info']['viewerPreferences'];
454
+          $this->o_viewerPreferences($vp, 'add', $options);
455 455
 
456
-      break;
456
+          break;
457 457
 
458
-    case  'out':
459
-      $res = "\n".$id." 0 obj\n".'<< /Type /Catalog';
458
+        case  'out':
459
+          $res = "\n".$id." 0 obj\n".'<< /Type /Catalog';
460 460
 
461
-      foreach($o['info'] as  $k=>$v) {
462
-        switch ($k) {
463
-        case  'outlines':
464
-          $res.= "\n".'/Outlines '.$v.' 0 R';
465
-          break;
461
+          foreach($o['info'] as  $k=>$v) {
462
+            switch ($k) {
463
+                case  'outlines':
464
+                  $res.= "\n".'/Outlines '.$v.' 0 R';
465
+                  break;
466 466
           
467
-        case  'pages':
468
-          $res.= "\n".'/Pages '.$v.' 0 R';
469
-          break;
467
+                case  'pages':
468
+                  $res.= "\n".'/Pages '.$v.' 0 R';
469
+                  break;
470 470
 
471
-        case  'viewerPreferences':
472
-          $res.= "\n".'/ViewerPreferences '.$v.' 0 R';
473
-          break;
471
+                case  'viewerPreferences':
472
+                  $res.= "\n".'/ViewerPreferences '.$v.' 0 R';
473
+                  break;
474 474
 
475
-        case  'openHere':
476
-          $res.= "\n".'/OpenAction '.$v.' 0 R';
477
-          break;
475
+                case  'openHere':
476
+                  $res.= "\n".'/OpenAction '.$v.' 0 R';
477
+                  break;
478 478
 
479
-        case  'javascript':
480
-          $res.= "\n".'/Names <</JavaScript '.$v.' 0 R>>';
481
-          break;
482
-        }
479
+                case  'javascript':
480
+                  $res.= "\n".'/Names <</JavaScript '.$v.' 0 R>>';
481
+                  break;
482
+            }
483 483
       }
484 484
 
485 485
       $res.= " >>\nendobj";
@@ -497,37 +497,37 @@  discard block
 block discarded – undo
497 497
     }
498 498
 
499 499
     switch  ($action) {
500
-    case  'new':
501
-      $this->objects[$id] = array('t'=>'pages', 'info'=>array());
502
-      $this->o_catalog($this->catalogId, 'pages', $id);
503
-      break;
500
+        case  'new':
501
+          $this->objects[$id] = array('t'=>'pages', 'info'=>array());
502
+          $this->o_catalog($this->catalogId, 'pages', $id);
503
+          break;
504 504
 
505
-    case  'page':
506
-      if  (!is_array($options)) {
507
-        // then it will just be the id of the new page
508
-        $o['info']['pages'][] = $options;
509
-      } else {
510
-        // then it should be an array having 'id','rid','pos', where rid=the page to which this one will be placed relative
511
-        // and pos is either 'before' or 'after', saying where this page will fit.
512
-        if  (isset($options['id']) &&  isset($options['rid']) &&  isset($options['pos'])) {
513
-          $i =  array_search($options['rid'], $o['info']['pages']);
514
-          if  (isset($o['info']['pages'][$i]) &&  $o['info']['pages'][$i] == $options['rid']) {
515
-
516
-            // then there is a match
517
-            // make a space
518
-            switch  ($options['pos']) {
519
-            case  'before':
520
-              $k =  $i;
521
-              break;
505
+        case  'page':
506
+          if  (!is_array($options)) {
507
+            // then it will just be the id of the new page
508
+            $o['info']['pages'][] = $options;
509
+          } else {
510
+            // then it should be an array having 'id','rid','pos', where rid=the page to which this one will be placed relative
511
+            // and pos is either 'before' or 'after', saying where this page will fit.
512
+            if  (isset($options['id']) &&  isset($options['rid']) &&  isset($options['pos'])) {
513
+              $i =  array_search($options['rid'], $o['info']['pages']);
514
+              if  (isset($o['info']['pages'][$i]) &&  $o['info']['pages'][$i] == $options['rid']) {
515
+
516
+                // then there is a match
517
+                // make a space
518
+                switch  ($options['pos']) {
519
+                    case  'before':
520
+                      $k =  $i;
521
+                      break;
522 522
 
523
-            case  'after':
524
-              $k = $i+1;
525
-              break;
523
+                    case  'after':
524
+                      $k = $i+1;
525
+                      break;
526 526
 
527
-            default:
528
-              $k = -1;
529
-              break;
530
-            }
527
+                    default:
528
+                      $k = -1;
529
+                      break;
530
+                }
531 531
 
532 532
             if  ($k >= 0) {
533 533
               for  ($j = count($o['info']['pages']) -1;$j >= $k;$j--) {
@@ -541,82 +541,82 @@  discard block
 block discarded – undo
541 541
       }
542 542
       break;
543 543
 
544
-    case  'procset':
545
-      $o['info']['procset'] = $options;
546
-      break;
544
+        case  'procset':
545
+          $o['info']['procset'] = $options;
546
+          break;
547 547
 
548
-    case  'mediaBox':
549
-      $o['info']['mediaBox'] = $options;
550
-      // which should be an array of 4 numbers
551
-      break;
548
+        case  'mediaBox':
549
+          $o['info']['mediaBox'] = $options;
550
+          // which should be an array of 4 numbers
551
+          break;
552 552
 
553
-    case  'font':
554
-      $o['info']['fonts'][] = array('objNum'=>$options['objNum'], 'fontNum'=>$options['fontNum']);
555
-      break;
553
+        case  'font':
554
+          $o['info']['fonts'][] = array('objNum'=>$options['objNum'], 'fontNum'=>$options['fontNum']);
555
+          break;
556 556
 
557
-    case  'extGState':
558
-      $o['info']['extGStates'][] =  array('objNum' => $options['objNum'],  'stateNum' => $options['stateNum']);
559
-      break;
557
+        case  'extGState':
558
+          $o['info']['extGStates'][] =  array('objNum' => $options['objNum'],  'stateNum' => $options['stateNum']);
559
+          break;
560 560
 
561
-    case  'xObject':
562
-      $o['info']['xObjects'][] = array('objNum'=>$options['objNum'], 'label'=>$options['label']);
563
-      break;
561
+        case  'xObject':
562
+          $o['info']['xObjects'][] = array('objNum'=>$options['objNum'], 'label'=>$options['label']);
563
+          break;
564 564
 
565
-    case  'out':
566
-      if  (count($o['info']['pages'])) {
567
-        $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Kids [";
568
-        foreach($o['info']['pages'] as  $k=>$v) {
569
-          $res.= $v." 0 R\n";
570
-        }
565
+        case  'out':
566
+          if  (count($o['info']['pages'])) {
567
+            $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Kids [";
568
+            foreach($o['info']['pages'] as  $k=>$v) {
569
+              $res.= $v." 0 R\n";
570
+            }
571 571
 
572
-        $res.= "]\n/Count ".count($this->objects[$id]['info']['pages']);
572
+            $res.= "]\n/Count ".count($this->objects[$id]['info']['pages']);
573 573
 
574
-        if  ( (isset($o['info']['fonts']) &&  count($o['info']['fonts'])) ||
575
-              isset($o['info']['procset']) ||
576
-              (isset($o['info']['extGStates']) &&  count($o['info']['extGStates']))) {
577
-          $res.= "\n/Resources <<";
574
+            if  ( (isset($o['info']['fonts']) &&  count($o['info']['fonts'])) ||
575
+                  isset($o['info']['procset']) ||
576
+                  (isset($o['info']['extGStates']) &&  count($o['info']['extGStates']))) {
577
+              $res.= "\n/Resources <<";
578 578
 
579
-          if  (isset($o['info']['procset'])) {
580
-            $res.= "\n/ProcSet ".$o['info']['procset']." 0 R";
581
-          }
579
+              if  (isset($o['info']['procset'])) {
580
+                $res.= "\n/ProcSet ".$o['info']['procset']." 0 R";
581
+              }
582 582
 
583
-          if  (isset($o['info']['fonts']) &&  count($o['info']['fonts'])) {
584
-            $res.= "\n/Font << ";
585
-            foreach($o['info']['fonts'] as  $finfo) {
586
-              $res.= "\n/F".$finfo['fontNum']." ".$finfo['objNum']." 0 R";
587
-            }
588
-            $res.= "\n>>";
589
-          }
583
+              if  (isset($o['info']['fonts']) &&  count($o['info']['fonts'])) {
584
+                $res.= "\n/Font << ";
585
+                foreach($o['info']['fonts'] as  $finfo) {
586
+                  $res.= "\n/F".$finfo['fontNum']." ".$finfo['objNum']." 0 R";
587
+                }
588
+                $res.= "\n>>";
589
+              }
590 590
 
591
-          if  (isset($o['info']['xObjects']) &&  count($o['info']['xObjects'])) {
592
-            $res.= "\n/XObject << ";
593
-            foreach($o['info']['xObjects'] as  $finfo) {
594
-              $res.= "\n/".$finfo['label']." ".$finfo['objNum']." 0 R";
595
-            }
596
-            $res.= "\n>>";
597
-          }
591
+              if  (isset($o['info']['xObjects']) &&  count($o['info']['xObjects'])) {
592
+                $res.= "\n/XObject << ";
593
+                foreach($o['info']['xObjects'] as  $finfo) {
594
+                  $res.= "\n/".$finfo['label']." ".$finfo['objNum']." 0 R";
595
+                }
596
+                $res.= "\n>>";
597
+              }
598 598
 
599
-          if  ( isset($o['info']['extGStates']) &&  count($o['info']['extGStates'])) {
600
-            $res.=  "\n/ExtGState << ";
601
-            foreach ($o['info']['extGStates'] as  $gstate) {
602
-              $res.=  "\n/GS" . $gstate['stateNum'] . " " . $gstate['objNum'] . " 0 R";
599
+              if  ( isset($o['info']['extGStates']) &&  count($o['info']['extGStates'])) {
600
+                $res.=  "\n/ExtGState << ";
601
+                foreach ($o['info']['extGStates'] as  $gstate) {
602
+                  $res.=  "\n/GS" . $gstate['stateNum'] . " " . $gstate['objNum'] . " 0 R";
603
+                }
604
+                $res.=  "\n>>";
605
+              }
606
+
607
+              $res.= "\n>>";
608
+              if  (isset($o['info']['mediaBox'])) {
609
+                $tmp = $o['info']['mediaBox'];
610
+                $res.= "\n/MediaBox [".sprintf('%.3F', $tmp[0]) .' '.sprintf('%.3F', $tmp[1]) .' '.sprintf('%.3F', $tmp[2]) .' '.sprintf('%.3F', $tmp[3]) .']';
611
+              }
603 612
             }
604
-            $res.=  "\n>>";
605
-          }
606 613
 
607
-          $res.= "\n>>";
608
-          if  (isset($o['info']['mediaBox'])) {
609
-            $tmp = $o['info']['mediaBox'];
610
-            $res.= "\n/MediaBox [".sprintf('%.3F', $tmp[0]) .' '.sprintf('%.3F', $tmp[1]) .' '.sprintf('%.3F', $tmp[2]) .' '.sprintf('%.3F', $tmp[3]) .']';
614
+            $res.= "\n >>\nendobj";
615
+          } else {
616
+            $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Count 0\n>>\nendobj";
611 617
           }
612
-        }
613 618
 
614
-        $res.= "\n >>\nendobj";
615
-      } else {
616
-        $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Count 0\n>>\nendobj";
617
-      }
618
-
619
-      return  $res;
619
+          return  $res;
620 620
     }
621 621
   }
622 622
 
@@ -630,28 +630,28 @@  discard block
 block discarded – undo
630 630
     }
631 631
 
632 632
     switch  ($action) {
633
-    case  'new':
634
-      $this->objects[$id] = array('t'=>'outlines', 'info'=>array('outlines'=>array()));
635
-      $this->o_catalog($this->catalogId, 'outlines', $id);
636
-      break;
633
+        case  'new':
634
+          $this->objects[$id] = array('t'=>'outlines', 'info'=>array('outlines'=>array()));
635
+          $this->o_catalog($this->catalogId, 'outlines', $id);
636
+          break;
637 637
 
638
-    case  'outline':
639
-      $o['info']['outlines'][] = $options;
640
-      break;
638
+        case  'outline':
639
+          $o['info']['outlines'][] = $options;
640
+          break;
641 641
 
642
-    case  'out':
643
-      if  (count($o['info']['outlines'])) {
644
-        $res = "\n".$id." 0 obj\n<< /Type /Outlines /Kids [";
645
-        foreach($o['info']['outlines'] as  $k=>$v) {
646
-          $res.= $v." 0 R ";
647
-        }
642
+        case  'out':
643
+          if  (count($o['info']['outlines'])) {
644
+            $res = "\n".$id." 0 obj\n<< /Type /Outlines /Kids [";
645
+            foreach($o['info']['outlines'] as  $k=>$v) {
646
+              $res.= $v." 0 R ";
647
+            }
648 648
 
649
-        $res.= "] /Count ".count($o['info']['outlines']) ." >>\nendobj";
650
-      } else {
651
-        $res = "\n".$id." 0 obj\n<< /Type /Outlines /Count 0 >>\nendobj";
652
-      }
649
+            $res.= "] /Count ".count($o['info']['outlines']) ." >>\nendobj";
650
+          } else {
651
+            $res = "\n".$id." 0 obj\n<< /Type /Outlines /Count 0 >>\nendobj";
652
+          }
653 653
 
654
-      return  $res;
654
+          return  $res;
655 655
     }
656 656
   }
657 657
 
@@ -665,33 +665,33 @@  discard block
 block discarded – undo
665 665
     }
666 666
 
667 667
     switch  ($action) {
668
-    case  'new':
669
-      $this->objects[$id] =  array('t' => 'font', 'info' => array('name' => $options['name'], 'fontFileName' => $options['fontFileName'], 'SubType' => 'Type1'));
670
-      $fontNum =  $this->numFonts;
671
-      $this->objects[$id]['info']['fontNum'] =  $fontNum;
672
-
673
-      // deal with the encoding and the differences
674
-      if  (isset($options['differences'])) {
675
-        // then we'll need an encoding dictionary
676
-        $this->numObj++;
677
-        $this->o_fontEncoding($this->numObj, 'new', $options);
678
-        $this->objects[$id]['info']['encodingDictionary'] =  $this->numObj;
679
-      } else  if  (isset($options['encoding'])) {
680
-        // we can specify encoding here
681
-        switch ($options['encoding']) {
682
-        case  'WinAnsiEncoding':
683
-        case  'MacRomanEncoding':
684
-        case  'MacExpertEncoding':
685
-          $this->objects[$id]['info']['encoding'] =  $options['encoding'];
686
-          break;
687
-
688
-        case  'none':
689
-          break;
668
+        case  'new':
669
+          $this->objects[$id] =  array('t' => 'font', 'info' => array('name' => $options['name'], 'fontFileName' => $options['fontFileName'], 'SubType' => 'Type1'));
670
+          $fontNum =  $this->numFonts;
671
+          $this->objects[$id]['info']['fontNum'] =  $fontNum;
690 672
 
691
-        default:
692
-          $this->objects[$id]['info']['encoding'] =  'WinAnsiEncoding';
693
-          break;
694
-        }
673
+          // deal with the encoding and the differences
674
+          if  (isset($options['differences'])) {
675
+            // then we'll need an encoding dictionary
676
+            $this->numObj++;
677
+            $this->o_fontEncoding($this->numObj, 'new', $options);
678
+            $this->objects[$id]['info']['encodingDictionary'] =  $this->numObj;
679
+          } else  if  (isset($options['encoding'])) {
680
+            // we can specify encoding here
681
+            switch ($options['encoding']) {
682
+                case  'WinAnsiEncoding':
683
+                case  'MacRomanEncoding':
684
+                case  'MacExpertEncoding':
685
+                  $this->objects[$id]['info']['encoding'] =  $options['encoding'];
686
+                  break;
687
+
688
+                case  'none':
689
+                  break;
690
+
691
+                default:
692
+                  $this->objects[$id]['info']['encoding'] =  'WinAnsiEncoding';
693
+                  break;
694
+            }
695 695
       } else {
696 696
         $this->objects[$id]['info']['encoding'] =  'WinAnsiEncoding';
697 697
       }
@@ -744,21 +744,21 @@  discard block
 block discarded – undo
744 744
       $this->o_pages($this->currentNode, 'font', array('fontNum' => $fontNum, 'objNum' => $id));
745 745
       break;
746 746
 
747
-    case  'add':
748
-      foreach ($options as  $k => $v) {
749
-        switch  ($k) {
750
-        case  'BaseFont':
751
-          $o['info']['name'] =  $v;
752
-          break;
753
-        case  'FirstChar':
754
-        case  'LastChar':
755
-        case  'Widths':
756
-        case  'FontDescriptor':
757
-        case  'SubType':
758
-          $this->addMessage('o_font '.$k." : ".$v);
759
-          $o['info'][$k] =  $v;
760
-          break;
761
-        }
747
+        case  'add':
748
+          foreach ($options as  $k => $v) {
749
+            switch  ($k) {
750
+                case  'BaseFont':
751
+                  $o['info']['name'] =  $v;
752
+                  break;
753
+                case  'FirstChar':
754
+                case  'LastChar':
755
+                case  'Widths':
756
+                case  'FontDescriptor':
757
+                case  'SubType':
758
+                  $this->addMessage('o_font '.$k." : ".$v);
759
+                  $o['info'][$k] =  $v;
760
+                  break;
761
+            }
762 762
       }
763 763
 
764 764
       // pass values down to descendent font
@@ -767,60 +767,60 @@  discard block
 block discarded – undo
767 767
       }
768 768
       break;
769 769
 
770
-    case  'out':
771
-      if ($this->fonts[$this->objects[$id]['info']['fontFileName']]['isUnicode']) {
772
-        // For Unicode fonts, we need to incorporate font data into
773
-        // sub-sections that are linked from the primary font section.
774
-        // Look at o_fontGIDtoCID and o_fontDescendentCID functions
775
-        // for more informaiton.
776
-        //
777
-        // All of this code is adapted from the excellent changes made to
778
-        // transform FPDF to TCPDF (http://tcpdf.sourceforge.net/)
779
-
780
-        $res =  "\n".$id." 0 obj\n<</Type /Font\n/Subtype /Type0\n";
781
-        $res.=  "/BaseFont /".$o['info']['name']."\n";
782
-
783
-        // The horizontal identity mapping for 2-byte CIDs; may be used
784
-        // with CIDFonts using any Registry, Ordering, and Supplement values.
785
-        $res.=  "/Encoding /Identity-H\n";
786
-        $res.=  "/DescendantFonts [".$o['info']['cidFont']." 0 R]\n";
787
-        $res.=  "/ToUnicode ".$o['info']['toUnicode']." 0 R\n";
788
-        $res.=  ">>\n";
789
-        $res.=  "endobj";
790
-      } else {
791
-      $res =  "\n".$id." 0 obj\n<< /Type /Font\n/Subtype /".$o['info']['SubType']."\n";
792
-      $res.=  "/Name /F".$o['info']['fontNum']."\n";
793
-      $res.=  "/BaseFont /".$o['info']['name']."\n";
794
-
795
-      if  (isset($o['info']['encodingDictionary'])) {
796
-        // then place a reference to the dictionary
797
-        $res.=  "/Encoding ".$o['info']['encodingDictionary']." 0 R\n";
798
-      } else  if  (isset($o['info']['encoding'])) {
799
-        // use the specified encoding
800
-        $res.=  "/Encoding /".$o['info']['encoding']."\n";
801
-      }
770
+        case  'out':
771
+          if ($this->fonts[$this->objects[$id]['info']['fontFileName']]['isUnicode']) {
772
+            // For Unicode fonts, we need to incorporate font data into
773
+            // sub-sections that are linked from the primary font section.
774
+            // Look at o_fontGIDtoCID and o_fontDescendentCID functions
775
+            // for more informaiton.
776
+            //
777
+            // All of this code is adapted from the excellent changes made to
778
+            // transform FPDF to TCPDF (http://tcpdf.sourceforge.net/)
779
+
780
+            $res =  "\n".$id." 0 obj\n<</Type /Font\n/Subtype /Type0\n";
781
+            $res.=  "/BaseFont /".$o['info']['name']."\n";
782
+
783
+            // The horizontal identity mapping for 2-byte CIDs; may be used
784
+            // with CIDFonts using any Registry, Ordering, and Supplement values.
785
+            $res.=  "/Encoding /Identity-H\n";
786
+            $res.=  "/DescendantFonts [".$o['info']['cidFont']." 0 R]\n";
787
+            $res.=  "/ToUnicode ".$o['info']['toUnicode']." 0 R\n";
788
+            $res.=  ">>\n";
789
+            $res.=  "endobj";
790
+          } else {
791
+          $res =  "\n".$id." 0 obj\n<< /Type /Font\n/Subtype /".$o['info']['SubType']."\n";
792
+          $res.=  "/Name /F".$o['info']['fontNum']."\n";
793
+          $res.=  "/BaseFont /".$o['info']['name']."\n";
794
+
795
+          if  (isset($o['info']['encodingDictionary'])) {
796
+            // then place a reference to the dictionary
797
+            $res.=  "/Encoding ".$o['info']['encodingDictionary']." 0 R\n";
798
+          } else  if  (isset($o['info']['encoding'])) {
799
+            // use the specified encoding
800
+            $res.=  "/Encoding /".$o['info']['encoding']."\n";
801
+          }
802 802
 
803
-      if  (isset($o['info']['FirstChar'])) {
804
-        $res.=  "/FirstChar ".$o['info']['FirstChar']."\n";
805
-      }
803
+          if  (isset($o['info']['FirstChar'])) {
804
+            $res.=  "/FirstChar ".$o['info']['FirstChar']."\n";
805
+          }
806 806
 
807
-      if  (isset($o['info']['LastChar'])) {
808
-        $res.=  "/LastChar ".$o['info']['LastChar']."\n";
809
-      }
807
+          if  (isset($o['info']['LastChar'])) {
808
+            $res.=  "/LastChar ".$o['info']['LastChar']."\n";
809
+          }
810 810
 
811
-      if  (isset($o['info']['Widths'])) {
812
-        $res.=  "/Widths ".$o['info']['Widths']." 0 R\n";
813
-      }
811
+          if  (isset($o['info']['Widths'])) {
812
+            $res.=  "/Widths ".$o['info']['Widths']." 0 R\n";
813
+          }
814 814
 
815
-      if  (isset($o['info']['FontDescriptor'])) {
816
-        $res.=  "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n";
817
-      }
815
+          if  (isset($o['info']['FontDescriptor'])) {
816
+            $res.=  "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n";
817
+          }
818 818
 
819
-        $res.=  ">>\n";
820
-        $res.=  "endobj";
821
-      }
819
+            $res.=  ">>\n";
820
+            $res.=  "endobj";
821
+          }
822 822
 
823
-      return  $res;
823
+          return  $res;
824 824
     }
825 825
   }
826 826
 
@@ -834,46 +834,46 @@  discard block
 block discarded – undo
834 834
     }
835 835
 
836 836
     switch  ($action) {
837
-    case  'new':
838
-      $this->objects[$id] = array('t'=>'fontDescriptor', 'info'=>$options);
839
-      break;
837
+        case  'new':
838
+          $this->objects[$id] = array('t'=>'fontDescriptor', 'info'=>$options);
839
+          break;
840 840
 
841
-    case  'out':
842
-      $res = "\n".$id." 0 obj\n<< /Type /FontDescriptor\n";
843
-      foreach ($o['info'] as  $label => $value) {
844
-        switch  ($label) {
845
-        case  'Ascent':
846
-        case  'CapHeight':
847
-        case  'Descent':
848
-        case  'Flags':
849
-        case  'ItalicAngle':
850
-        case  'StemV':
851
-        case  'AvgWidth':
852
-        case  'Leading':
853
-        case  'MaxWidth':
854
-        case  'MissingWidth':
855
-        case  'StemH':
856
-        case  'XHeight':
857
-        case  'CharSet':
858
-          if  (mb_strlen($value, '8bit')) {
859
-            $res.= '/'.$label.' '.$value."\n";
860
-          }
841
+        case  'out':
842
+          $res = "\n".$id." 0 obj\n<< /Type /FontDescriptor\n";
843
+          foreach ($o['info'] as  $label => $value) {
844
+            switch  ($label) {
845
+                case  'Ascent':
846
+                case  'CapHeight':
847
+                case  'Descent':
848
+                case  'Flags':
849
+                case  'ItalicAngle':
850
+                case  'StemV':
851
+                case  'AvgWidth':
852
+                case  'Leading':
853
+                case  'MaxWidth':
854
+                case  'MissingWidth':
855
+                case  'StemH':
856
+                case  'XHeight':
857
+                case  'CharSet':
858
+                  if  (mb_strlen($value, '8bit')) {
859
+                    $res.= '/'.$label.' '.$value."\n";
860
+                  }
861 861
 
862
-          break;
863
-        case  'FontFile':
864
-        case  'FontFile2':
865
-        case  'FontFile3':
866
-          $res.= '/'.$label.' '.$value." 0 R\n";
867
-          break;
862
+                  break;
863
+                case  'FontFile':
864
+                case  'FontFile2':
865
+                case  'FontFile3':
866
+                  $res.= '/'.$label.' '.$value." 0 R\n";
867
+                  break;
868 868
 
869
-        case  'FontBBox':
870
-          $res.= '/'.$label.' ['.$value[0].' '.$value[1].' '.$value[2].' '.$value[3]."]\n";
871
-          break;
869
+                case  'FontBBox':
870
+                  $res.= '/'.$label.' ['.$value[0].' '.$value[1].' '.$value[2].' '.$value[3]."]\n";
871
+                  break;
872 872
 
873
-        case  'FontName':
874
-          $res.= '/'.$label.' /'.$value."\n";
875
-          break;
876
-        }
873
+                case  'FontName':
874
+                  $res.= '/'.$label.' /'.$value."\n";
875
+                  break;
876
+            }
877 877
       }
878 878
 
879 879
       $res.= ">>\nendobj";
@@ -892,38 +892,38 @@  discard block
 block discarded – undo
892 892
     }
893 893
 
894 894
     switch  ($action) {
895
-    case  'new':
896
-      // the options array should contain 'differences' and maybe 'encoding'
897
-      $this->objects[$id] = array('t'=>'fontEncoding', 'info'=>$options);
898
-      break;
895
+        case  'new':
896
+          // the options array should contain 'differences' and maybe 'encoding'
897
+          $this->objects[$id] = array('t'=>'fontEncoding', 'info'=>$options);
898
+          break;
899 899
 
900
-    case  'out':
901
-      $res = "\n".$id." 0 obj\n<< /Type /Encoding\n";
902
-      if  (!isset($o['info']['encoding'])) {
903
-        $o['info']['encoding'] = 'WinAnsiEncoding';
904
-      }
900
+        case  'out':
901
+          $res = "\n".$id." 0 obj\n<< /Type /Encoding\n";
902
+          if  (!isset($o['info']['encoding'])) {
903
+            $o['info']['encoding'] = 'WinAnsiEncoding';
904
+          }
905 905
 
906
-      if  ($o['info']['encoding'] !== 'none') {
907
-        $res.= "/BaseEncoding /".$o['info']['encoding']."\n";
908
-      }
906
+          if  ($o['info']['encoding'] !== 'none') {
907
+            $res.= "/BaseEncoding /".$o['info']['encoding']."\n";
908
+          }
909 909
 
910
-      $res.= "/Differences \n[";
910
+          $res.= "/Differences \n[";
911 911
 
912
-      $onum = -100;
912
+          $onum = -100;
913 913
 
914
-      foreach($o['info']['differences'] as  $num=>$label) {
915
-        if  ($num != $onum+1) {
916
-          // we cannot make use of consecutive numbering
917
-          $res.=  "\n".$num." /".$label;
918
-        } else {
919
-          $res.=  " /".$label;
920
-        }
914
+          foreach($o['info']['differences'] as  $num=>$label) {
915
+            if  ($num != $onum+1) {
916
+              // we cannot make use of consecutive numbering
917
+              $res.=  "\n".$num." /".$label;
918
+            } else {
919
+              $res.=  " /".$label;
920
+            }
921 921
 
922
-        $onum = $num;
923
-      }
922
+            $onum = $num;
923
+          }
924 924
 
925
-      $res.= "\n]\n>>\nendobj";
926
-      return  $res;
925
+          $res.= "\n]\n>>\nendobj";
926
+          return  $res;
927 927
     }
928 928
   }
929 929
 
@@ -937,82 +937,82 @@  discard block
 block discarded – undo
937 937
     }
938 938
 
939 939
     switch  ($action) {
940
-    case  'new':
941
-      $this->objects[$id] =  array('t'=>'fontDescendentCID', 'info'=>$options);
942
-
943
-      // we need a CID system info section
944
-      $cidSystemInfoId = ++$this->numObj;
945
-      $this->o_contents($cidSystemInfoId, 'new', 'raw');
946
-      $this->objects[$id]['info']['cidSystemInfo'] = $cidSystemInfoId;
947
-      $res=   "<</Registry (Adobe)\n"; // A string identifying an issuer of character collections
948
-      $res.=  "/Ordering (UCS)\n"; // A string that uniquely names a character collection issued by a specific registry
949
-      $res.=  "/Supplement 0\n"; // The supplement number of the character collection.
950
-      $res.=  ">>";
951
-      $this->objects[$cidSystemInfoId]['c'] = $res;
952
-
953
-      // and a CID to GID map
954
-      $cidToGidMapId = ++$this->numObj;
955
-      $this->o_fontGIDtoCIDMap($cidToGidMapId, 'new', $options);
956
-      $this->objects[$id]['info']['cidToGidMap'] = $cidToGidMapId;
957
-      break;
958
-
959
-    case  'add':
960
-      foreach ($options as  $k => $v) {
961
-        switch  ($k) {
962
-        case  'BaseFont':
963
-          $o['info']['name'] =  $v;
940
+        case  'new':
941
+          $this->objects[$id] =  array('t'=>'fontDescendentCID', 'info'=>$options);
942
+
943
+          // we need a CID system info section
944
+          $cidSystemInfoId = ++$this->numObj;
945
+          $this->o_contents($cidSystemInfoId, 'new', 'raw');
946
+          $this->objects[$id]['info']['cidSystemInfo'] = $cidSystemInfoId;
947
+          $res=   "<</Registry (Adobe)\n"; // A string identifying an issuer of character collections
948
+          $res.=  "/Ordering (UCS)\n"; // A string that uniquely names a character collection issued by a specific registry
949
+          $res.=  "/Supplement 0\n"; // The supplement number of the character collection.
950
+          $res.=  ">>";
951
+          $this->objects[$cidSystemInfoId]['c'] = $res;
952
+
953
+          // and a CID to GID map
954
+          $cidToGidMapId = ++$this->numObj;
955
+          $this->o_fontGIDtoCIDMap($cidToGidMapId, 'new', $options);
956
+          $this->objects[$id]['info']['cidToGidMap'] = $cidToGidMapId;
964 957
           break;
965 958
 
966
-        case  'FirstChar':
967
-        case  'LastChar':
968
-        case  'MissingWidth':
969
-        case  'FontDescriptor':
970
-        case  'SubType':
971
-          $this->addMessage('o_fontDescendentCID '.$k." : ".$v);
972
-          $o['info'][$k] =  $v;
973
-          break;
974
-        }
959
+        case  'add':
960
+          foreach ($options as  $k => $v) {
961
+            switch  ($k) {
962
+                case  'BaseFont':
963
+                  $o['info']['name'] =  $v;
964
+                  break;
965
+
966
+                case  'FirstChar':
967
+                case  'LastChar':
968
+                case  'MissingWidth':
969
+                case  'FontDescriptor':
970
+                case  'SubType':
971
+                  $this->addMessage('o_fontDescendentCID '.$k." : ".$v);
972
+                  $o['info'][$k] =  $v;
973
+                  break;
974
+            }
975 975
       }
976 976
 
977 977
       // pass values down to cid to gid map
978 978
       $this->o_fontGIDtoCIDMap($o['info']['cidToGidMap'], 'add', $options);
979 979
       break;
980 980
 
981
-    case  'out':
982
-      $res =  "\n".$id." 0 obj\n";
983
-      $res.=  "<</Type /Font\n";
984
-      $res.=  "/Subtype /CIDFontType2\n";
985
-      $res.=  "/BaseFont /".$o['info']['name']."\n";
986
-      $res.=  "/CIDSystemInfo ".$o['info']['cidSystemInfo']." 0 R\n";
987
-//      if  (isset($o['info']['FirstChar'])) {
988
-//        $res.=  "/FirstChar ".$o['info']['FirstChar']."\n";
989
-//      }
990
-
991
-//      if  (isset($o['info']['LastChar'])) {
992
-//        $res.=  "/LastChar ".$o['info']['LastChar']."\n";
993
-//      }
994
-      if  (isset($o['info']['FontDescriptor'])) {
995
-        $res.=  "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n";
996
-      }
981
+        case  'out':
982
+          $res =  "\n".$id." 0 obj\n";
983
+          $res.=  "<</Type /Font\n";
984
+          $res.=  "/Subtype /CIDFontType2\n";
985
+          $res.=  "/BaseFont /".$o['info']['name']."\n";
986
+          $res.=  "/CIDSystemInfo ".$o['info']['cidSystemInfo']." 0 R\n";
987
+    //      if  (isset($o['info']['FirstChar'])) {
988
+    //        $res.=  "/FirstChar ".$o['info']['FirstChar']."\n";
989
+    //      }
990
+
991
+    //      if  (isset($o['info']['LastChar'])) {
992
+    //        $res.=  "/LastChar ".$o['info']['LastChar']."\n";
993
+    //      }
994
+          if  (isset($o['info']['FontDescriptor'])) {
995
+            $res.=  "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n";
996
+          }
997 997
 
998
-      if  (isset($o['info']['MissingWidth'])) {
999
-        $res.=  "/DW ".$o['info']['MissingWidth']."\n";
1000
-      }
998
+          if  (isset($o['info']['MissingWidth'])) {
999
+            $res.=  "/DW ".$o['info']['MissingWidth']."\n";
1000
+          }
1001 1001
 
1002
-      if  (isset($o['info']['fontFileName']) && isset($this->fonts[$o['info']['fontFileName']]['CIDWidths'])) {
1003
-        $cid_widths = &$this->fonts[$o['info']['fontFileName']]['CIDWidths'];
1004
-        $w = '';
1005
-        foreach ($cid_widths as $cid => $width) {
1006
-          $w .= $cid.' ['.$width.'] ';
1007
-        }
1008
-        $res.=  "/W [".$w."]\n";
1009
-      }
1002
+          if  (isset($o['info']['fontFileName']) && isset($this->fonts[$o['info']['fontFileName']]['CIDWidths'])) {
1003
+            $cid_widths = &$this->fonts[$o['info']['fontFileName']]['CIDWidths'];
1004
+            $w = '';
1005
+            foreach ($cid_widths as $cid => $width) {
1006
+              $w .= $cid.' ['.$width.'] ';
1007
+            }
1008
+            $res.=  "/W [".$w."]\n";
1009
+          }
1010 1010
 
1011
-      $res.=  "/CIDToGIDMap ".$o['info']['cidToGidMap']." 0 R\n";
1012
-      $res.=  ">>\n";
1013
-      $res.=  "endobj";
1011
+          $res.=  "/CIDToGIDMap ".$o['info']['cidToGidMap']." 0 R\n";
1012
+          $res.=  ">>\n";
1013
+          $res.=  "endobj";
1014 1014
 
1015
-      return  $res;
1015
+          return  $res;
1016 1016
     }
1017 1017
   }
1018 1018
   
@@ -1026,35 +1026,35 @@  discard block
 block discarded – undo
1026 1026
     }
1027 1027
 
1028 1028
     switch  ($action) {
1029
-    case  'new':
1030
-      $this->objects[$id] =  array('t'=>'fontGIDtoCIDMap', 'info'=>$options);
1031
-      break;
1029
+        case  'new':
1030
+          $this->objects[$id] =  array('t'=>'fontGIDtoCIDMap', 'info'=>$options);
1031
+          break;
1032 1032
 
1033
-    case  'out':
1034
-      $res = "\n".$id." 0 obj\n";
1035
-      $tmp = $this->fonts[$o['info']['fontFileName']]['CIDtoGID'] = base64_decode($this->fonts[$o['info']['fontFileName']]['CIDtoGID']);
1036
-      $compressed = isset($this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed']) &&
1037
-                    $this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed'];
1033
+        case  'out':
1034
+          $res = "\n".$id." 0 obj\n";
1035
+          $tmp = $this->fonts[$o['info']['fontFileName']]['CIDtoGID'] = base64_decode($this->fonts[$o['info']['fontFileName']]['CIDtoGID']);
1036
+          $compressed = isset($this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed']) &&
1037
+                        $this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed'];
1038 1038
 
1039
-      if  (!$compressed && isset($o['raw'])) {
1040
-        $res.= $tmp;
1041
-      } else {
1042
-        $res.=  "<<";
1039
+          if  (!$compressed && isset($o['raw'])) {
1040
+            $res.= $tmp;
1041
+          } else {
1042
+            $res.=  "<<";
1043 1043
 
1044
-        if  (!$compressed && function_exists('gzcompress') &&  $this->options['compression']) {
1045
-          // then implement ZLIB based compression on this content stream
1046
-          $compressed = true;
1047
-          $tmp =  gzcompress($tmp,  6);
1048
-        }
1049
-        if ($compressed) {
1050
-          $res.= "\n/Filter /FlateDecode";
1051
-        }
1044
+            if  (!$compressed && function_exists('gzcompress') &&  $this->options['compression']) {
1045
+              // then implement ZLIB based compression on this content stream
1046
+              $compressed = true;
1047
+              $tmp =  gzcompress($tmp,  6);
1048
+            }
1049
+            if ($compressed) {
1050
+              $res.= "\n/Filter /FlateDecode";
1051
+            }
1052 1052
 
1053
-        $res.= "\n/Length ".mb_strlen($tmp, '8bit') .">>\nstream\n".$tmp."\nendstream";
1054
-      }
1053
+            $res.= "\n/Length ".mb_strlen($tmp, '8bit') .">>\nstream\n".$tmp."\nendstream";
1054
+          }
1055 1055
 
1056
-      $res.= "\nendobj";
1057
-      return  $res;
1056
+          $res.= "\nendobj";
1057
+          return  $res;
1058 1058
     }
1059 1059
   }
1060 1060
   
@@ -1068,31 +1068,31 @@  discard block
 block discarded – undo
1068 1068
     }
1069 1069
 
1070 1070
     switch  ($action) {
1071
-    case  'new':
1072
-      $this->objects[$id] = array('t'=>'procset', 'info'=>array('PDF'=>1, 'Text'=>1));
1073
-      $this->o_pages($this->currentNode, 'procset', $id);
1074
-      $this->procsetObjectId = $id;
1075
-      break;
1071
+        case  'new':
1072
+          $this->objects[$id] = array('t'=>'procset', 'info'=>array('PDF'=>1, 'Text'=>1));
1073
+          $this->o_pages($this->currentNode, 'procset', $id);
1074
+          $this->procsetObjectId = $id;
1075
+          break;
1076 1076
 
1077
-    case  'add':
1078
-      // this is to add new items to the procset list, despite the fact that this is considered
1079
-      // obselete, the items are required for printing to some postscript printers
1080
-      switch  ($options) {
1081
-      case  'ImageB':
1082
-      case  'ImageC':
1083
-      case  'ImageI':
1084
-        $o['info'][$options] = 1;
1085
-        break;
1086
-      }
1077
+        case  'add':
1078
+          // this is to add new items to the procset list, despite the fact that this is considered
1079
+          // obselete, the items are required for printing to some postscript printers
1080
+          switch  ($options) {
1081
+              case  'ImageB':
1082
+              case  'ImageC':
1083
+              case  'ImageI':
1084
+                $o['info'][$options] = 1;
1085
+                break;
1086
+          }
1087 1087
       break;
1088 1088
 
1089
-    case  'out':
1090
-      $res = "\n".$id." 0 obj\n[";
1091
-      foreach ($o['info'] as  $label=>$val) {
1092
-        $res.= '/'.$label.' ';
1093
-      }
1094
-      $res.= "]\nendobj";
1095
-      return  $res;
1089
+        case  'out':
1090
+          $res = "\n".$id." 0 obj\n[";
1091
+          foreach ($o['info'] as  $label=>$val) {
1092
+            $res.= '/'.$label.' ';
1093
+          }
1094
+          $res.= "]\nendobj";
1095
+          return  $res;
1096 1096
     }
1097 1097
   }
1098 1098
 
@@ -1106,45 +1106,45 @@  discard block
 block discarded – undo
1106 1106
     }
1107 1107
 
1108 1108
     switch  ($action) {
1109
-    case  'new':
1110
-      $this->infoObject = $id;
1111
-      $date = 'D:'.@date('Ymd');
1112
-      $this->objects[$id] = array('t'=>'info', 'info'=>array('Creator'=>'R and OS php pdf writer, http://www.ros.co.nz', 'CreationDate'=>$date));
1113
-      break;
1114
-    case  'Title':
1115
-    case  'Author':
1116
-    case  'Subject':
1117
-    case  'Keywords':
1118
-    case  'Creator':
1119
-    case  'Producer':
1120
-    case  'CreationDate':
1121
-    case  'ModDate':
1122
-    case  'Trapped':
1123
-      $o['info'][$action] = $options;
1124
-      break;
1109
+        case  'new':
1110
+          $this->infoObject = $id;
1111
+          $date = 'D:'.@date('Ymd');
1112
+          $this->objects[$id] = array('t'=>'info', 'info'=>array('Creator'=>'R and OS php pdf writer, http://www.ros.co.nz', 'CreationDate'=>$date));
1113
+          break;
1114
+        case  'Title':
1115
+        case  'Author':
1116
+        case  'Subject':
1117
+        case  'Keywords':
1118
+        case  'Creator':
1119
+        case  'Producer':
1120
+        case  'CreationDate':
1121
+        case  'ModDate':
1122
+        case  'Trapped':
1123
+          $o['info'][$action] = $options;
1124
+          break;
1125 1125
 
1126
-    case  'out':
1127
-      if  ($this->encrypted) {
1128
-        $this->encryptInit($id);
1129
-      }
1126
+        case  'out':
1127
+          if  ($this->encrypted) {
1128
+            $this->encryptInit($id);
1129
+          }
1130 1130
 
1131
-      $res = "\n".$id." 0 obj\n<<\n";
1132
-      foreach ($o['info'] as  $k=>$v) {
1133
-        $res.= '/'.$k.' (';
1134
-        // dates must be outputted as-is, without Unicode transformations
1135
-        $raw = ($k === 'CreationDate' || $k === 'ModDate');
1136
-        $c = $v;
1131
+          $res = "\n".$id." 0 obj\n<<\n";
1132
+          foreach ($o['info'] as  $k=>$v) {
1133
+            $res.= '/'.$k.' (';
1134
+            // dates must be outputted as-is, without Unicode transformations
1135
+            $raw = ($k === 'CreationDate' || $k === 'ModDate');
1136
+            $c = $v;
1137 1137
 
1138
-        if  ($this->encrypted) {
1139
-          $c = $this->ARC4($c);
1140
-        }
1138
+            if  ($this->encrypted) {
1139
+              $c = $this->ARC4($c);
1140
+            }
1141 1141
 
1142
-        $res.= ($raw) ? $c : $this->filterText($c);
1143
-        $res.= ")\n";
1144
-      }
1142
+            $res.= ($raw) ? $c : $this->filterText($c);
1143
+            $res.= ")\n";
1144
+          }
1145 1145
 
1146
-      $res.= ">>\nendobj";
1147
-      return  $res;
1146
+          $res.= ">>\nendobj";
1147
+          return  $res;
1148 1148
     }
1149 1149
   }
1150 1150
 
@@ -1158,38 +1158,38 @@  discard block
 block discarded – undo
1158 1158
     }
1159 1159
 
1160 1160
     switch  ($action) {
1161
-    case  'new':
1162
-      if  (is_array($options)) {
1163
-        $this->objects[$id] = array('t'=>'action', 'info'=>$options, 'type'=>$options['type']);
1164
-      } else {
1165
-        // then assume a URI action
1166
-        $this->objects[$id] = array('t'=>'action', 'info'=>$options, 'type'=>'URI');
1167
-      }
1168
-      break;
1169
-
1170
-    case  'out':
1171
-      if  ($this->encrypted) {
1172
-        $this->encryptInit($id);
1173
-      }
1161
+        case  'new':
1162
+          if  (is_array($options)) {
1163
+            $this->objects[$id] = array('t'=>'action', 'info'=>$options, 'type'=>$options['type']);
1164
+          } else {
1165
+            // then assume a URI action
1166
+            $this->objects[$id] = array('t'=>'action', 'info'=>$options, 'type'=>'URI');
1167
+          }
1168
+          break;
1174 1169
 
1175
-      $res = "\n".$id." 0 obj\n<< /Type /Action";
1176
-      switch ($o['type']) {
1177
-      case  'ilink':
1178
-        // there will be an 'label' setting, this is the name of the destination
1179
-        $res.= "\n/S /GoTo\n/D ".$this->destinations[(string)$o['info']['label']]." 0 R";
1180
-        break;
1170
+        case  'out':
1171
+          if  ($this->encrypted) {
1172
+            $this->encryptInit($id);
1173
+          }
1181 1174
 
1182
-      case  'URI':
1183
-        $res.= "\n/S /URI\n/URI (";
1184
-        if  ($this->encrypted) {
1185
-          $res.= $this->filterText($this->ARC4($o['info']));
1186
-        } else {
1187
-          $res.= $this->filterText($o['info']);
1188
-        }
1175
+          $res = "\n".$id." 0 obj\n<< /Type /Action";
1176
+          switch ($o['type']) {
1177
+              case  'ilink':
1178
+                // there will be an 'label' setting, this is the name of the destination
1179
+                $res.= "\n/S /GoTo\n/D ".$this->destinations[(string)$o['info']['label']]." 0 R";
1180
+                break;
1181
+
1182
+              case  'URI':
1183
+                $res.= "\n/S /URI\n/URI (";
1184
+                if  ($this->encrypted) {
1185
+                  $res.= $this->filterText($this->ARC4($o['info']));
1186
+                } else {
1187
+                  $res.= $this->filterText($o['info']);
1188
+                }
1189 1189
 
1190
-        $res.= ")";
1191
-        break;
1192
-      }
1190
+                $res.= ")";
1191
+                break;
1192
+          }
1193 1193
 
1194 1194
       $res.= "\n>>\nendobj";
1195 1195
       return  $res;
@@ -1207,39 +1207,39 @@  discard block
 block discarded – undo
1207 1207
     }
1208 1208
 
1209 1209
     switch  ($action) {
1210
-    case  'new':
1211
-      // add the annotation to the current page
1212
-      $pageId =  $this->currentPage;
1213
-      $this->o_page($pageId, 'annot', $id);
1214
-
1215
-      // and add the action object which is going to be required
1216
-      switch ($options['type']) {
1217
-      case  'link':
1218
-        $this->objects[$id] = array('t'=>'annotation', 'info'=>$options);
1219
-        $this->numObj++;
1220
-        $this->o_action($this->numObj, 'new', $options['url']);
1221
-        $this->objects[$id]['info']['actionId'] = $this->numObj;
1222
-        break;
1223
-
1224
-      case  'ilink':
1225
-        // this is to a named internal link
1226
-        $label =  $options['label'];
1227
-        $this->objects[$id] = array('t'=>'annotation', 'info'=>$options);
1228
-        $this->numObj++;
1229
-        $this->o_action($this->numObj, 'new', array('type'=>'ilink', 'label'=>$label));
1230
-        $this->objects[$id]['info']['actionId'] = $this->numObj;
1231
-        break;
1232
-      }
1210
+        case  'new':
1211
+          // add the annotation to the current page
1212
+          $pageId =  $this->currentPage;
1213
+          $this->o_page($pageId, 'annot', $id);
1214
+
1215
+          // and add the action object which is going to be required
1216
+          switch ($options['type']) {
1217
+              case  'link':
1218
+                $this->objects[$id] = array('t'=>'annotation', 'info'=>$options);
1219
+                $this->numObj++;
1220
+                $this->o_action($this->numObj, 'new', $options['url']);
1221
+                $this->objects[$id]['info']['actionId'] = $this->numObj;
1222
+                break;
1223
+
1224
+              case  'ilink':
1225
+                // this is to a named internal link
1226
+                $label =  $options['label'];
1227
+                $this->objects[$id] = array('t'=>'annotation', 'info'=>$options);
1228
+                $this->numObj++;
1229
+                $this->o_action($this->numObj, 'new', array('type'=>'ilink', 'label'=>$label));
1230
+                $this->objects[$id]['info']['actionId'] = $this->numObj;
1231
+                break;
1232
+          }
1233 1233
       break;
1234 1234
 
1235
-    case  'out':
1236
-      $res = "\n".$id." 0 obj\n<< /Type /Annot";
1237
-      switch ($o['info']['type']) {
1238
-      case  'link':
1239
-      case  'ilink':
1240
-        $res.=  "\n/Subtype /Link";
1241
-        break;
1242
-      }
1235
+        case  'out':
1236
+          $res = "\n".$id." 0 obj\n<< /Type /Annot";
1237
+          switch ($o['info']['type']) {
1238
+              case  'link':
1239
+              case  'ilink':
1240
+                $res.=  "\n/Subtype /Link";
1241
+                break;
1242
+          }
1243 1243
       $res.= "\n/A ".$o['info']['actionId']." 0 R";
1244 1244
       $res.= "\n/Border [0 0 0]";
1245 1245
       $res.= "\n/H /I";
@@ -1265,77 +1265,77 @@  discard block
 block discarded – undo
1265 1265
     }
1266 1266
 
1267 1267
     switch  ($action) {
1268
-    case  'new':
1269
-      $this->numPages++;
1270
-      $this->objects[$id] = array('t'=>'page', 'info'=>array('parent'=>$this->currentNode, 'pageNum'=>$this->numPages));
1271
-
1272
-      if  (is_array($options)) {
1273
-        // then this must be a page insertion, array should contain 'rid','pos'=[before|after]
1274
-        $options['id'] = $id;
1275
-        $this->o_pages($this->currentNode, 'page', $options);
1276
-      } else {
1277
-        $this->o_pages($this->currentNode, 'page', $id);
1278
-      }
1268
+        case  'new':
1269
+          $this->numPages++;
1270
+          $this->objects[$id] = array('t'=>'page', 'info'=>array('parent'=>$this->currentNode, 'pageNum'=>$this->numPages));
1271
+
1272
+          if  (is_array($options)) {
1273
+            // then this must be a page insertion, array should contain 'rid','pos'=[before|after]
1274
+            $options['id'] = $id;
1275
+            $this->o_pages($this->currentNode, 'page', $options);
1276
+          } else {
1277
+            $this->o_pages($this->currentNode, 'page', $id);
1278
+          }
1279 1279
 
1280
-      $this->currentPage = $id;
1281
-      //make a contents object to go with this page
1282
-      $this->numObj++;
1283
-      $this->o_contents($this->numObj, 'new', $id);
1284
-      $this->currentContents = $this->numObj;
1285
-      $this->objects[$id]['info']['contents'] = array();
1286
-      $this->objects[$id]['info']['contents'][] = $this->numObj;
1287
-
1288
-      $match =  ($this->numPages%2 ?  'odd' :  'even');
1289
-      foreach($this->addLooseObjects as  $oId=>$target) {
1290
-        if  ($target === 'all' || $match === $target) {
1291
-          $this->objects[$id]['info']['contents'][] = $oId;
1292
-        }
1293
-      }
1294
-      break;
1280
+          $this->currentPage = $id;
1281
+          //make a contents object to go with this page
1282
+          $this->numObj++;
1283
+          $this->o_contents($this->numObj, 'new', $id);
1284
+          $this->currentContents = $this->numObj;
1285
+          $this->objects[$id]['info']['contents'] = array();
1286
+          $this->objects[$id]['info']['contents'][] = $this->numObj;
1287
+
1288
+          $match =  ($this->numPages%2 ?  'odd' :  'even');
1289
+          foreach($this->addLooseObjects as  $oId=>$target) {
1290
+            if  ($target === 'all' || $match === $target) {
1291
+              $this->objects[$id]['info']['contents'][] = $oId;
1292
+            }
1293
+          }
1294
+          break;
1295 1295
 
1296
-    case  'content':
1297
-      $o['info']['contents'][] = $options;
1298
-      break;
1296
+        case  'content':
1297
+          $o['info']['contents'][] = $options;
1298
+          break;
1299 1299
 
1300
-    case  'annot':
1301
-      // add an annotation to this page
1302
-      if  (!isset($o['info']['annot'])) {
1303
-        $o['info']['annot'] = array();
1304
-      }
1300
+        case  'annot':
1301
+          // add an annotation to this page
1302
+          if  (!isset($o['info']['annot'])) {
1303
+            $o['info']['annot'] = array();
1304
+          }
1305 1305
 
1306
-      // $options should contain the id of the annotation dictionary
1307
-      $o['info']['annot'][] = $options;
1308
-      break;
1306
+          // $options should contain the id of the annotation dictionary
1307
+          $o['info']['annot'][] = $options;
1308
+          break;
1309 1309
 
1310
-    case  'out':
1311
-      $res = "\n".$id." 0 obj\n<< /Type /Page";
1312
-      $res.= "\n/Parent ".$o['info']['parent']." 0 R";
1310
+        case  'out':
1311
+          $res = "\n".$id." 0 obj\n<< /Type /Page";
1312
+          $res.= "\n/Parent ".$o['info']['parent']." 0 R";
1313 1313
 
1314
-      if  (isset($o['info']['annot'])) {
1315
-        $res.= "\n/Annots [";
1316
-        foreach($o['info']['annot'] as  $aId) {
1317
-          $res.= " ".$aId." 0 R";
1318
-        }
1319
-        $res.= " ]";
1320
-      }
1314
+          if  (isset($o['info']['annot'])) {
1315
+            $res.= "\n/Annots [";
1316
+            foreach($o['info']['annot'] as  $aId) {
1317
+              $res.= " ".$aId." 0 R";
1318
+            }
1319
+            $res.= " ]";
1320
+          }
1321 1321
 
1322
-      $count =  count($o['info']['contents']);
1323
-      if  ($count == 1) {
1324
-        $res.= "\n/Contents ".$o['info']['contents'][0]." 0 R";
1325
-      } else  if  ($count>1) {
1326
-        $res.= "\n/Contents [\n";
1327
-
1328
-        // reverse the page contents so added objects are below normal content
1329
-        //foreach (array_reverse($o['info']['contents']) as  $cId) {
1330
-        // Back to normal now that I've got transparency working --Benj
1331
-        foreach ($o['info']['contents'] as  $cId) {
1332
-          $res.= $cId." 0 R\n";
1333
-        }
1334
-        $res.= "]";
1335
-      }
1322
+          $count =  count($o['info']['contents']);
1323
+          if  ($count == 1) {
1324
+            $res.= "\n/Contents ".$o['info']['contents'][0]." 0 R";
1325
+          } else  if  ($count>1) {
1326
+            $res.= "\n/Contents [\n";
1327
+
1328
+            // reverse the page contents so added objects are below normal content
1329
+            //foreach (array_reverse($o['info']['contents']) as  $cId) {
1330
+            // Back to normal now that I've got transparency working --Benj
1331
+            foreach ($o['info']['contents'] as  $cId) {
1332
+              $res.= $cId." 0 R\n";
1333
+            }
1334
+            $res.= "]";
1335
+          }
1336 1336
 
1337
-      $res.= "\n>>\nendobj";
1338
-      return  $res;
1337
+          $res.= "\n>>\nendobj";
1338
+          return  $res;
1339 1339
     }
1340 1340
   }
1341 1341
 
@@ -1349,51 +1349,51 @@  discard block
 block discarded – undo
1349 1349
     }
1350 1350
 
1351 1351
     switch  ($action) {
1352
-    case  'new':
1353
-      $this->objects[$id] = array('t'=>'contents', 'c'=>'', 'info'=>array());
1354
-      if  (mb_strlen($options, '8bit') &&  intval($options)) {
1355
-        // then this contents is the primary for a page
1356
-        $this->objects[$id]['onPage'] = $options;
1357
-      } else  if  ($options === 'raw') {
1358
-        // then this page contains some other type of system object
1359
-        $this->objects[$id]['raw'] = 1;
1360
-      }
1361
-      break;
1352
+        case  'new':
1353
+          $this->objects[$id] = array('t'=>'contents', 'c'=>'', 'info'=>array());
1354
+          if  (mb_strlen($options, '8bit') &&  intval($options)) {
1355
+            // then this contents is the primary for a page
1356
+            $this->objects[$id]['onPage'] = $options;
1357
+          } else  if  ($options === 'raw') {
1358
+            // then this page contains some other type of system object
1359
+            $this->objects[$id]['raw'] = 1;
1360
+          }
1361
+          break;
1362 1362
 
1363
-    case  'add':
1364
-      // add more options to the decleration
1365
-      foreach ($options as  $k=>$v) {
1366
-        $o['info'][$k] = $v;
1367
-      }
1363
+        case  'add':
1364
+          // add more options to the decleration
1365
+          foreach ($options as  $k=>$v) {
1366
+            $o['info'][$k] = $v;
1367
+          }
1368 1368
 
1369
-    case  'out':
1370
-      $tmp = $o['c'];
1371
-      $res =  "\n".$id." 0 obj\n";
1369
+        case  'out':
1370
+          $tmp = $o['c'];
1371
+          $res =  "\n".$id." 0 obj\n";
1372 1372
 
1373
-      if  (isset($this->objects[$id]['raw'])) {
1374
-        $res.= $tmp;
1375
-      } else {
1376
-        $res.=  "<<";
1377
-        if  (function_exists('gzcompress') &&  $this->options['compression']) {
1378
-          // then implement ZLIB based compression on this content stream
1379
-          $res.= " /Filter /FlateDecode";
1380
-          $tmp =  gzcompress($tmp,  6);
1381
-        }
1373
+          if  (isset($this->objects[$id]['raw'])) {
1374
+            $res.= $tmp;
1375
+          } else {
1376
+            $res.=  "<<";
1377
+            if  (function_exists('gzcompress') &&  $this->options['compression']) {
1378
+              // then implement ZLIB based compression on this content stream
1379
+              $res.= " /Filter /FlateDecode";
1380
+              $tmp =  gzcompress($tmp,  6);
1381
+            }
1382 1382
 
1383
-        if  ($this->encrypted) {
1384
-          $this->encryptInit($id);
1385
-          $tmp =  $this->ARC4($tmp);
1386
-        }
1383
+            if  ($this->encrypted) {
1384
+              $this->encryptInit($id);
1385
+              $tmp =  $this->ARC4($tmp);
1386
+            }
1387 1387
 
1388
-        foreach($o['info'] as  $k=>$v) {
1389
-          $res.=  "\n/".$k.' '.$v;
1390
-        }
1388
+            foreach($o['info'] as  $k=>$v) {
1389
+              $res.=  "\n/".$k.' '.$v;
1390
+            }
1391 1391
 
1392
-        $res.= "\n/Length ".mb_strlen($tmp, '8bit') ." >>\nstream\n".$tmp."\nendstream";
1393
-      }
1392
+            $res.= "\n/Length ".mb_strlen($tmp, '8bit') ." >>\nstream\n".$tmp."\nendstream";
1393
+          }
1394 1394
 
1395
-      $res.= "\nendobj";
1396
-      return  $res;
1395
+          $res.= "\nendobj";
1396
+          return  $res;
1397 1397
     }
1398 1398
   }
1399 1399
 
@@ -1403,19 +1403,19 @@  discard block
 block discarded – undo
1403 1403
     }
1404 1404
 
1405 1405
     switch  ($action) {
1406
-    case  'new':
1407
-      $this->objects[$id] = array('t'=>'embedjs', 'info'=>array(
1408
-        'Names' => '[(EmbeddedJS) '.($id+1).' 0 R]'
1409
-      ));
1410
-      break;
1406
+        case  'new':
1407
+          $this->objects[$id] = array('t'=>'embedjs', 'info'=>array(
1408
+            'Names' => '[(EmbeddedJS) '.($id+1).' 0 R]'
1409
+          ));
1410
+          break;
1411 1411
 
1412
-    case  'out':
1413
-      $res .= "\n".$id." 0 obj\n".'<< ';
1414
-      foreach($o['info'] as  $k=>$v) {
1415
-        $res.=  "\n/".$k.' '.$v;
1416
-      }
1417
-      $res.= "\n>>\nendobj";
1418
-      return  $res;
1412
+        case  'out':
1413
+          $res .= "\n".$id." 0 obj\n".'<< ';
1414
+          foreach($o['info'] as  $k=>$v) {
1415
+            $res.=  "\n/".$k.' '.$v;
1416
+          }
1417
+          $res.= "\n>>\nendobj";
1418
+          return  $res;
1419 1419
     }
1420 1420
   }
1421 1421
   
@@ -1425,20 +1425,20 @@  discard block
 block discarded – undo
1425 1425
     }
1426 1426
 
1427 1427
     switch  ($action) {
1428
-    case  'new':
1429
-      $this->objects[$id] = array('t'=>'javascript', 'info'=>array(
1430
-        'S' => '/JavaScript',
1431
-        'JS' => '('.$this->filterText($code).')',
1432
-      ));
1433
-      break;
1428
+        case  'new':
1429
+          $this->objects[$id] = array('t'=>'javascript', 'info'=>array(
1430
+            'S' => '/JavaScript',
1431
+            'JS' => '('.$this->filterText($code).')',
1432
+          ));
1433
+          break;
1434 1434
 
1435
-    case  'out':
1436
-      $res = "\n".$id." 0 obj\n".'<< ';
1437
-      foreach($o['info'] as  $k=>$v) {
1438
-        $res.=  "\n/".$k.' '.$v;
1439
-      }
1440
-      $res.= "\n>>\nendobj";
1441
-      return  $res;
1435
+        case  'out':
1436
+          $res = "\n".$id." 0 obj\n".'<< ';
1437
+          foreach($o['info'] as  $k=>$v) {
1438
+            $res.=  "\n/".$k.' '.$v;
1439
+          }
1440
+          $res.= "\n>>\nendobj";
1441
+          return  $res;
1442 1442
     }
1443 1443
   }
1444 1444
 
@@ -1451,28 +1451,28 @@  discard block
 block discarded – undo
1451 1451
     }
1452 1452
 
1453 1453
     switch ($action) {
1454
-    case  'new':
1455
-      // make the new object
1456
-      $this->objects[$id] = array('t'=>'image', 'data'=>&$options['data'], 'info'=>array());
1457
-      $this->objects[$id]['info']['Type'] = '/XObject';
1458
-      $this->objects[$id]['info']['Subtype'] = '/Image';
1459
-      $this->objects[$id]['info']['Width'] = $options['iw'];
1460
-      $this->objects[$id]['info']['Height'] = $options['ih'];
1461
-
1462
-      if  (!isset($options['type']) ||  $options['type'] === 'jpg') {
1463
-        if  (!isset($options['channels'])) {
1464
-          $options['channels'] = 3;
1465
-        }
1454
+        case  'new':
1455
+          // make the new object
1456
+          $this->objects[$id] = array('t'=>'image', 'data'=>&$options['data'], 'info'=>array());
1457
+          $this->objects[$id]['info']['Type'] = '/XObject';
1458
+          $this->objects[$id]['info']['Subtype'] = '/Image';
1459
+          $this->objects[$id]['info']['Width'] = $options['iw'];
1460
+          $this->objects[$id]['info']['Height'] = $options['ih'];
1461
+
1462
+          if  (!isset($options['type']) ||  $options['type'] === 'jpg') {
1463
+            if  (!isset($options['channels'])) {
1464
+              $options['channels'] = 3;
1465
+            }
1466 1466
 
1467
-        switch ($options['channels']) {
1468
-        case  1:
1469
-          $this->objects[$id]['info']['ColorSpace'] = '/DeviceGray';
1470
-          break;
1467
+            switch ($options['channels']) {
1468
+                case  1:
1469
+                  $this->objects[$id]['info']['ColorSpace'] = '/DeviceGray';
1470
+                  break;
1471 1471
 
1472
-        default:
1473
-          $this->objects[$id]['info']['ColorSpace'] = '/DeviceRGB';
1474
-          break;
1475
-        }
1472
+                default:
1473
+                  $this->objects[$id]['info']['ColorSpace'] = '/DeviceRGB';
1474
+                  break;
1475
+            }
1476 1476
 
1477 1477
         $this->objects[$id]['info']['Filter'] = '/DCTDecode';
1478 1478
         $this->objects[$id]['info']['BitsPerComponent'] = 8;
@@ -1490,39 +1490,39 @@  discard block
 block discarded – undo
1490 1490
           $this->objects[$id]['info']['ColorSpace'] =  $tmp;
1491 1491
           if  (isset($options['transparency'])) {
1492 1492
             switch ($options['transparency']['type']) {
1493
-            case  'indexed':
1494
-              $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] ';
1495
-              $this->objects[$id]['info']['Mask'] =  $tmp;
1496
-              break;
1497
-
1498
-            case 'color-key':
1499
-              $tmp = ' [ '.
1500
-                $options['transparency']['r'] . ' ' . $options['transparency']['r'] .
1501
-                $options['transparency']['g'] . ' ' . $options['transparency']['g'] .
1502
-                $options['transparency']['b'] . ' ' . $options['transparency']['b'] .
1503
-                ' ] ';
1504
-              $this->objects[$id]['info']['Mask'] = $tmp;
1505
-              pre_r($tmp);
1506
-              break;
1493
+                case  'indexed':
1494
+                  $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] ';
1495
+                  $this->objects[$id]['info']['Mask'] =  $tmp;
1496
+                  break;
1497
+
1498
+                case 'color-key':
1499
+                  $tmp = ' [ '.
1500
+                    $options['transparency']['r'] . ' ' . $options['transparency']['r'] .
1501
+                    $options['transparency']['g'] . ' ' . $options['transparency']['g'] .
1502
+                    $options['transparency']['b'] . ' ' . $options['transparency']['b'] .
1503
+                    ' ] ';
1504
+                  $this->objects[$id]['info']['Mask'] = $tmp;
1505
+                  pre_r($tmp);
1506
+                  break;
1507 1507
               
1508 1508
             }
1509 1509
           }
1510 1510
         } else {
1511 1511
           if  (isset($options['transparency'])) {
1512 1512
             switch ($options['transparency']['type']) {
1513
-            case  'indexed':
1514
-              $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] ';
1515
-              $this->objects[$id]['info']['Mask'] =  $tmp;
1516
-              break;
1517
-
1518
-            case 'color-key':
1519
-              $tmp = ' [ '.
1520
-                $options['transparency']['r'] . ' ' . $options['transparency']['r'] . ' ' .
1521
-                $options['transparency']['g'] . ' ' . $options['transparency']['g'] . ' ' .
1522
-                $options['transparency']['b'] . ' ' . $options['transparency']['b'] .
1523
-                ' ] ';
1524
-              $this->objects[$id]['info']['Mask'] = $tmp;
1525
-              break;              
1513
+                case  'indexed':
1514
+                  $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] ';
1515
+                  $this->objects[$id]['info']['Mask'] =  $tmp;
1516
+                  break;
1517
+
1518
+                case 'color-key':
1519
+                  $tmp = ' [ '.
1520
+                    $options['transparency']['r'] . ' ' . $options['transparency']['r'] . ' ' .
1521
+                    $options['transparency']['g'] . ' ' . $options['transparency']['g'] . ' ' .
1522
+                    $options['transparency']['b'] . ' ' . $options['transparency']['b'] .
1523
+                    ' ] ';
1524
+                  $this->objects[$id]['info']['Mask'] = $tmp;
1525
+                  break;              
1526 1526
             }
1527 1527
           }
1528 1528
           $this->objects[$id]['info']['ColorSpace'] = '/'.$options['color'];
@@ -1539,22 +1539,22 @@  discard block
 block discarded – undo
1539 1539
       $this->o_procset($this->procsetObjectId, 'add', 'ImageC');
1540 1540
       break;
1541 1541
 
1542
-    case  'out':
1543
-      $tmp = &$o['data'];
1544
-      $res =  "\n".$id." 0 obj\n<<";
1542
+        case  'out':
1543
+          $tmp = &$o['data'];
1544
+          $res =  "\n".$id." 0 obj\n<<";
1545 1545
 
1546
-      foreach($o['info'] as  $k=>$v) {
1547
-        $res.= "\n/".$k.' '.$v;
1548
-      }
1546
+          foreach($o['info'] as  $k=>$v) {
1547
+            $res.= "\n/".$k.' '.$v;
1548
+          }
1549 1549
 
1550
-      if  ($this->encrypted) {
1551
-        $this->encryptInit($id);
1552
-        $tmp =  $this->ARC4($tmp);
1553
-      }
1550
+          if  ($this->encrypted) {
1551
+            $this->encryptInit($id);
1552
+            $tmp =  $this->ARC4($tmp);
1553
+          }
1554 1554
 
1555
-      $res.= "\n/Length ".mb_strlen($tmp, '8bit') .">>\nstream\n".$tmp."\nendstream\nendobj";
1555
+          $res.= "\n/Length ".mb_strlen($tmp, '8bit') .">>\nstream\n".$tmp."\nendstream\nendobj";
1556 1556
 
1557
-      return  $res;
1557
+          return  $res;
1558 1558
     }
1559 1559
   }
1560 1560
 
@@ -1575,29 +1575,29 @@  discard block
 block discarded – undo
1575 1575
     }
1576 1576
 
1577 1577
     switch  ($action) {
1578
-    case  "new":
1579
-      $this->objects[$id] =  array('t' => 'extGState',  'info' => $options);
1578
+        case  "new":
1579
+          $this->objects[$id] =  array('t' => 'extGState',  'info' => $options);
1580 1580
 
1581
-      // Tell the pages about the new resource
1582
-      $this->numStates++;
1583
-      $this->o_pages($this->currentNode,  'extGState',  array("objNum" => $id,  "stateNum" => $this->numStates));
1584
-      break;
1581
+          // Tell the pages about the new resource
1582
+          $this->numStates++;
1583
+          $this->o_pages($this->currentNode,  'extGState',  array("objNum" => $id,  "stateNum" => $this->numStates));
1584
+          break;
1585 1585
 
1586
-    case  "out":
1587
-      $res =
1588
-        "\n" . $id . " 0 obj\n".
1589
-        "<< /Type /ExtGState\n";
1586
+        case  "out":
1587
+          $res =
1588
+            "\n" . $id . " 0 obj\n".
1589
+            "<< /Type /ExtGState\n";
1590 1590
 
1591
-      foreach ($o["info"] as  $parameter => $value) {
1592
-        if  ( !in_array($parameter,  $valid_params))
1593
-          continue;
1594
-        $res.=  "/$parameter $value\n";
1595
-      }
1591
+          foreach ($o["info"] as  $parameter => $value) {
1592
+            if  ( !in_array($parameter,  $valid_params))
1593
+              continue;
1594
+            $res.=  "/$parameter $value\n";
1595
+          }
1596 1596
 
1597
-      $res.=
1598
-        ">>\n".
1599
-        "endobj";
1600
-      return  $res;
1597
+          $res.=
1598
+            ">>\n".
1599
+            "endobj";
1600
+          return  $res;
1601 1601
     }
1602 1602
   }
1603 1603
 
@@ -1611,63 +1611,63 @@  discard block
 block discarded – undo
1611 1611
     }
1612 1612
 
1613 1613
     switch ($action) {
1614
-    case  'new':
1615
-      // make the new object
1616
-      $this->objects[$id] = array('t'=>'encryption', 'info'=>$options);
1617
-      $this->arc4_objnum = $id;
1618
-
1619
-      // figure out the additional paramaters required
1620
-      $pad =  chr(0x28) .chr(0xBF) .chr(0x4E) .chr(0x5E) .chr(0x4E) .chr(0x75) .chr(0x8A) .chr(0x41) .chr(0x64) .chr(0x00) .chr(0x4E) .chr(0x56) .chr(0xFF) .chr(0xFA) .chr(0x01) .chr(0x08) .chr(0x2E) .chr(0x2E) .chr(0x00) .chr(0xB6) .chr(0xD0) .chr(0x68) .chr(0x3E) .chr(0x80) .chr(0x2F) .chr(0x0C) .chr(0xA9) .chr(0xFE) .chr(0x64) .chr(0x53) .chr(0x69) .chr(0x7A);
1621
-      $len =  mb_strlen($options['owner'], '8bit');
1622
-
1623
-      if  ($len>32) {
1624
-        $owner =  substr($options['owner'], 0, 32);
1625
-      } else  if  ($len<32) {
1626
-        $owner =  $options['owner'].substr($pad, 0, 32-$len);
1627
-      } else {
1628
-        $owner =  $options['owner'];
1629
-      }
1614
+        case  'new':
1615
+          // make the new object
1616
+          $this->objects[$id] = array('t'=>'encryption', 'info'=>$options);
1617
+          $this->arc4_objnum = $id;
1618
+
1619
+          // figure out the additional paramaters required
1620
+          $pad =  chr(0x28) .chr(0xBF) .chr(0x4E) .chr(0x5E) .chr(0x4E) .chr(0x75) .chr(0x8A) .chr(0x41) .chr(0x64) .chr(0x00) .chr(0x4E) .chr(0x56) .chr(0xFF) .chr(0xFA) .chr(0x01) .chr(0x08) .chr(0x2E) .chr(0x2E) .chr(0x00) .chr(0xB6) .chr(0xD0) .chr(0x68) .chr(0x3E) .chr(0x80) .chr(0x2F) .chr(0x0C) .chr(0xA9) .chr(0xFE) .chr(0x64) .chr(0x53) .chr(0x69) .chr(0x7A);
1621
+          $len =  mb_strlen($options['owner'], '8bit');
1622
+
1623
+          if  ($len>32) {
1624
+            $owner =  substr($options['owner'], 0, 32);
1625
+          } else  if  ($len<32) {
1626
+            $owner =  $options['owner'].substr($pad, 0, 32-$len);
1627
+          } else {
1628
+            $owner =  $options['owner'];
1629
+          }
1630 1630
 
1631
-      $len =  mb_strlen($options['user'], '8bit');
1632
-      if  ($len>32) {
1633
-        $user =  substr($options['user'], 0, 32);
1634
-      } else  if  ($len<32) {
1635
-        $user =  $options['user'].substr($pad, 0, 32-$len);
1636
-      } else {
1637
-        $user =  $options['user'];
1638
-      }
1631
+          $len =  mb_strlen($options['user'], '8bit');
1632
+          if  ($len>32) {
1633
+            $user =  substr($options['user'], 0, 32);
1634
+          } else  if  ($len<32) {
1635
+            $user =  $options['user'].substr($pad, 0, 32-$len);
1636
+          } else {
1637
+            $user =  $options['user'];
1638
+          }
1639 1639
 
1640
-      $tmp =  $this->md5_16($owner);
1641
-      $okey =  substr($tmp, 0, 5);
1642
-      $this->ARC4_init($okey);
1643
-      $ovalue = $this->ARC4($user);
1644
-      $this->objects[$id]['info']['O'] = $ovalue;
1645
-
1646
-      // now make the u value, phew.
1647
-      $tmp =  $this->md5_16($user.$ovalue.chr($options['p']) .chr(255) .chr(255) .chr(255) .$this->fileIdentifier);
1648
-
1649
-      $ukey =  substr($tmp, 0, 5);
1650
-      $this->ARC4_init($ukey);
1651
-      $this->encryptionKey =  $ukey;
1652
-      $this->encrypted = 1;
1653
-      $uvalue = $this->ARC4($pad);
1654
-      $this->objects[$id]['info']['U'] = $uvalue;
1655
-      $this->encryptionKey = $ukey;
1656
-      // initialize the arc4 array
1657
-      break;
1640
+          $tmp =  $this->md5_16($owner);
1641
+          $okey =  substr($tmp, 0, 5);
1642
+          $this->ARC4_init($okey);
1643
+          $ovalue = $this->ARC4($user);
1644
+          $this->objects[$id]['info']['O'] = $ovalue;
1645
+
1646
+          // now make the u value, phew.
1647
+          $tmp =  $this->md5_16($user.$ovalue.chr($options['p']) .chr(255) .chr(255) .chr(255) .$this->fileIdentifier);
1648
+
1649
+          $ukey =  substr($tmp, 0, 5);
1650
+          $this->ARC4_init($ukey);
1651
+          $this->encryptionKey =  $ukey;
1652
+          $this->encrypted = 1;
1653
+          $uvalue = $this->ARC4($pad);
1654
+          $this->objects[$id]['info']['U'] = $uvalue;
1655
+          $this->encryptionKey = $ukey;
1656
+          // initialize the arc4 array
1657
+          break;
1658 1658
 
1659
-    case  'out':
1660
-      $res =  "\n".$id." 0 obj\n<<";
1661
-      $res.= "\n/Filter /Standard";
1662
-      $res.= "\n/V 1";
1663
-      $res.= "\n/R 2";
1664
-      $res.= "\n/O (".$this->filterText($o['info']['O']) .')';
1665
-      $res.= "\n/U (".$this->filterText($o['info']['U']) .')';
1666
-      // and the p-value needs to be converted to account for the twos-complement approach
1667
-      $o['info']['p'] =  (($o['info']['p']^255) +1) *-1;
1668
-      $res.= "\n/P ".($o['info']['p']);
1669
-      $res.= "\n>>\nendobj";
1670
-      return  $res;
1659
+        case  'out':
1660
+          $res =  "\n".$id." 0 obj\n<<";
1661
+          $res.= "\n/Filter /Standard";
1662
+          $res.= "\n/V 1";
1663
+          $res.= "\n/R 2";
1664
+          $res.= "\n/O (".$this->filterText($o['info']['O']) .')';
1665
+          $res.= "\n/U (".$this->filterText($o['info']['U']) .')';
1666
+          // and the p-value needs to be converted to account for the twos-complement approach
1667
+          $o['info']['p'] =  (($o['info']['p']^255) +1) *-1;
1668
+          $res.= "\n/P ".($o['info']['p']);
1669
+          $res.= "\n>>\nendobj";
1670
+          return  $res;
1671 1671
     }
1672 1672
   }
1673 1673
 
@@ -1999,112 +1999,112 @@  discard block
 block discarded – undo
1999 1999
           // then there must be some keyword
2000 2000
           $key =  substr($row, 0, $pos);
2001 2001
           switch  ($key) {
2002
-          case  'FontName':
2003
-          case  'FullName':
2004
-          case  'FamilyName':
2005
-          case  'Weight':
2006
-          case  'ItalicAngle':
2007
-          case  'IsFixedPitch':
2008
-          case  'CharacterSet':
2009
-          case  'UnderlinePosition':
2010
-          case  'UnderlineThickness':
2011
-          case  'Version':
2012
-          case  'EncodingScheme':
2013
-          case  'CapHeight':
2014
-          case  'XHeight':
2015
-          case  'Ascender':
2016
-          case  'Descender':
2017
-          case  'StdHW':
2018
-          case  'StdVW':
2019
-          case  'StartCharMetrics':
2020
-          case  'FontHeightOffset': // OAR - Added so we can offset the height calculation of a Windows font.  Otherwise it's too big.
2021
-            $data[$key] = trim(substr($row, $pos));
2022
-            break;
2023
-
2024
-          case  'FontBBox':
2025
-            $data[$key] = explode(' ', trim(substr($row, $pos)));
2026
-            break;
2027
-
2028
-          case  'C': // Found in AFM files
2029
-            //C 39 ; WX 222 ; N quoteright ; B 53 463 157 718 ;
2030
-            $bits = explode(';', trim($row));
2031
-            $dtmp = array();
2032
-
2033
-            foreach($bits as  $bit) {
2034
-              $bits2 =  explode(' ', trim($bit));
2035
-              if  (mb_strlen($bits2[0], '8bit')) {
2036
-                if  (count($bits2) >2) {
2037
-                  $dtmp[$bits2[0]] = array();
2038
-                  for  ($i = 1;$i<count($bits2);$i++) {
2039
-                    $dtmp[$bits2[0]][] = $bits2[$i];
2002
+              case  'FontName':
2003
+              case  'FullName':
2004
+              case  'FamilyName':
2005
+              case  'Weight':
2006
+              case  'ItalicAngle':
2007
+              case  'IsFixedPitch':
2008
+              case  'CharacterSet':
2009
+              case  'UnderlinePosition':
2010
+              case  'UnderlineThickness':
2011
+              case  'Version':
2012
+              case  'EncodingScheme':
2013
+              case  'CapHeight':
2014
+              case  'XHeight':
2015
+              case  'Ascender':
2016
+              case  'Descender':
2017
+              case  'StdHW':
2018
+              case  'StdVW':
2019
+              case  'StartCharMetrics':
2020
+              case  'FontHeightOffset': // OAR - Added so we can offset the height calculation of a Windows font.  Otherwise it's too big.
2021
+                $data[$key] = trim(substr($row, $pos));
2022
+                break;
2023
+
2024
+              case  'FontBBox':
2025
+                $data[$key] = explode(' ', trim(substr($row, $pos)));
2026
+                break;
2027
+
2028
+              case  'C': // Found in AFM files
2029
+                //C 39 ; WX 222 ; N quoteright ; B 53 463 157 718 ;
2030
+                $bits = explode(';', trim($row));
2031
+                $dtmp = array();
2032
+
2033
+                foreach($bits as  $bit) {
2034
+                  $bits2 =  explode(' ', trim($bit));
2035
+                  if  (mb_strlen($bits2[0], '8bit')) {
2036
+                    if  (count($bits2) >2) {
2037
+                      $dtmp[$bits2[0]] = array();
2038
+                      for  ($i = 1;$i<count($bits2);$i++) {
2039
+                        $dtmp[$bits2[0]][] = $bits2[$i];
2040
+                      }
2041
+                    } else  if  (count($bits2) == 2) {
2042
+                      $dtmp[$bits2[0]] = $bits2[1];
2043
+                    }
2040 2044
                   }
2041
-                } else  if  (count($bits2) == 2) {
2042
-                  $dtmp[$bits2[0]] = $bits2[1];
2043 2045
                 }
2044
-              }
2045
-            }
2046 2046
 
2047
-            $cc = (int)$dtmp['C'];
2048
-            if  ($cc >= 0) {
2049
-              $data['C'][$dtmp['C']] = $dtmp;
2050
-              $data['C'][$dtmp['N']] = $dtmp;
2051
-            } else {
2052
-              $data['C'][$dtmp['N']] = $dtmp;
2053
-            }
2047
+                $cc = (int)$dtmp['C'];
2048
+                if  ($cc >= 0) {
2049
+                  $data['C'][$dtmp['C']] = $dtmp;
2050
+                  $data['C'][$dtmp['N']] = $dtmp;
2051
+                } else {
2052
+                  $data['C'][$dtmp['N']] = $dtmp;
2053
+                }
2054 2054
 
2055
-            if  (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2056
-              $data['MissingWidth'] = $width;
2057
-            }
2055
+                if  (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2056
+                  $data['MissingWidth'] = $width;
2057
+                }
2058 2058
             
2059
-            break;
2060
-
2061
-          case  'U': // Found in UFM files
2062
-            if ($data['isUnicode']) {
2063
-              // U 827 ; WX 0 ; N squaresubnosp ; G 675 ;
2064
-              $bits = explode(';', trim($row));
2065
-              $dtmp = array();
2066
-
2067
-              foreach($bits as  $bit) {
2068
-                $bits2 =  explode(' ', trim($bit));
2069
-                if  (mb_strlen($bits2[0], '8bit')) {
2070
-                  if  (count($bits2) >2) {
2071
-                    $dtmp[$bits2[0]] = array();
2072
-                    for  ($i = 1;$i<count($bits2);$i++) {
2073
-                      $dtmp[$bits2[0]][] = $bits2[$i];
2059
+                break;
2060
+
2061
+              case  'U': // Found in UFM files
2062
+                if ($data['isUnicode']) {
2063
+                  // U 827 ; WX 0 ; N squaresubnosp ; G 675 ;
2064
+                  $bits = explode(';', trim($row));
2065
+                  $dtmp = array();
2066
+
2067
+                  foreach($bits as  $bit) {
2068
+                    $bits2 =  explode(' ', trim($bit));
2069
+                    if  (mb_strlen($bits2[0], '8bit')) {
2070
+                      if  (count($bits2) >2) {
2071
+                        $dtmp[$bits2[0]] = array();
2072
+                        for  ($i = 1;$i<count($bits2);$i++) {
2073
+                          $dtmp[$bits2[0]][] = $bits2[$i];
2074
+                        }
2075
+                      } else  if  (count($bits2) == 2) {
2076
+                        $dtmp[$bits2[0]] = $bits2[1];
2077
+                      }
2074 2078
                     }
2075
-                  } else  if  (count($bits2) == 2) {
2076
-                    $dtmp[$bits2[0]] = $bits2[1];
2077 2079
                   }
2078
-                }
2079
-              }
2080 2080
 
2081
-              $cc = (int)$dtmp['U'];
2082
-              $glyph = $dtmp['G'];
2083
-              $width = $dtmp['WX'];
2084
-              if  ($cc >= 0) {
2085
-                // Set values in CID to GID map
2086
-                if ($cc >= 0 && $cc < 0xFFFF && $glyph) {
2087
-                  $cidtogid[$cc*2] = chr($glyph >> 8);
2088
-                  $cidtogid[$cc*2 + 1] = chr($glyph & 0xFF);
2089
-                }
2081
+                  $cc = (int)$dtmp['U'];
2082
+                  $glyph = $dtmp['G'];
2083
+                  $width = $dtmp['WX'];
2084
+                  if  ($cc >= 0) {
2085
+                    // Set values in CID to GID map
2086
+                    if ($cc >= 0 && $cc < 0xFFFF && $glyph) {
2087
+                      $cidtogid[$cc*2] = chr($glyph >> 8);
2088
+                      $cidtogid[$cc*2 + 1] = chr($glyph & 0xFF);
2089
+                    }
2090 2090
 
2091
-                $data['C'][$dtmp['U']] = $dtmp;
2092
-                $data['C'][$dtmp['N']] = $dtmp;
2093
-              } else {
2094
-                $data['C'][$dtmp['N']] = $dtmp;
2095
-              }
2091
+                    $data['C'][$dtmp['U']] = $dtmp;
2092
+                    $data['C'][$dtmp['N']] = $dtmp;
2093
+                  } else {
2094
+                    $data['C'][$dtmp['N']] = $dtmp;
2095
+                  }
2096 2096
               
2097
-              if  (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2098
-                $data['MissingWidth'] = $width;
2099
-              }
2100
-            }
2101
-            break;
2097
+                  if  (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2098
+                    $data['MissingWidth'] = $width;
2099
+                  }
2100
+                }
2101
+                break;
2102 2102
 
2103
-          case  'KPX':
2104
-            //KPX Adieresis yacute -40
2105
-            $bits = explode(' ', trim($row));
2106
-            $data['KPX'][$bits[1]][$bits[2]] = $bits[3];
2107
-            break;
2103
+              case  'KPX':
2104
+                //KPX Adieresis yacute -40
2105
+                $bits = explode(' ', trim($row));
2106
+                $data['KPX'][$bits[1]][$bits[2]] = $bits[3];
2107
+                break;
2108 2108
           }
2109 2109
         }
2110 2110
       }
@@ -3108,163 +3108,163 @@  discard block
 block discarded – undo
3108 3108
     if  ($text[$j] === '<') {
3109 3109
       $j++;
3110 3110
       switch ($text[$j]) {
3111
-      case  '/':
3112
-        $j++;
3113
-        if  (mb_strlen($text) <=  $j) {
3114
-          return  $directive;
3115
-        }
3111
+          case  '/':
3112
+            $j++;
3113
+            if  (mb_strlen($text) <=  $j) {
3114
+              return  $directive;
3115
+            }
3116 3116
 
3117
-        switch ($text[$j]) {
3118
-        case  'b':
3119
-        case  'i':
3120
-          $j++;
3121
-          if  ($text[$j] === '>') {
3122
-            $p =  mb_strrpos($this->currentTextState, $text[$j-1]);
3117
+            switch ($text[$j]) {
3118
+                case  'b':
3119
+                case  'i':
3120
+                  $j++;
3121
+                  if  ($text[$j] === '>') {
3122
+                    $p =  mb_strrpos($this->currentTextState, $text[$j-1]);
3123 3123
 
3124
-            if  ($p !==  false) {
3125
-              // then there is one to remove
3126
-              $this->currentTextState =  mb_substr($this->currentTextState, 0, $p) .substr($this->currentTextState, $p+1);
3127
-            }
3124
+                    if  ($p !==  false) {
3125
+                      // then there is one to remove
3126
+                      $this->currentTextState =  mb_substr($this->currentTextState, 0, $p) .substr($this->currentTextState, $p+1);
3127
+                    }
3128 3128
 
3129
-            $directive =  $j-$i+1;
3130
-          }
3131
-          break;
3129
+                    $directive =  $j-$i+1;
3130
+                  }
3131
+                  break;
3132
+
3133
+                case  'c':
3134
+                  // this this might be a callback function
3135
+                  $j++;
3136
+                  $k =  mb_strpos($text, '>', $j);
3137
+
3138
+                  if  ($k !==  false &&  $text[$j] === ':') {
3139
+                    // then this will be treated as a callback directive
3140
+                    $directive =  $k-$i+1;
3141
+                    $f =  0;
3142
+                    // split the remainder on colons to get the function name and the paramater
3143
+                    $tmp =  mb_substr($text, $j+1, $k-$j-1);
3144
+                    $b1 =  mb_strpos($tmp, ':');
3145
+
3146
+                    if  ($b1 !==  false) {
3147
+                      $func =  mb_substr($tmp, 0, $b1);
3148
+                      $parm =  mb_substr($tmp, $b1+1);
3149
+                    } else {
3150
+                      $func =  $tmp;
3151
+                      $parm =  '';
3152
+                    }
3132 3153
 
3133
-        case  'c':
3134
-          // this this might be a callback function
3135
-          $j++;
3136
-          $k =  mb_strpos($text, '>', $j);
3137
-
3138
-          if  ($k !==  false &&  $text[$j] === ':') {
3139
-            // then this will be treated as a callback directive
3140
-            $directive =  $k-$i+1;
3141
-            $f =  0;
3142
-            // split the remainder on colons to get the function name and the paramater
3143
-            $tmp =  mb_substr($text, $j+1, $k-$j-1);
3144
-            $b1 =  mb_strpos($tmp, ':');
3145
-
3146
-            if  ($b1 !==  false) {
3147
-              $func =  mb_substr($tmp, 0, $b1);
3148
-              $parm =  mb_substr($tmp, $b1+1);
3149
-            } else {
3150
-              $func =  $tmp;
3151
-              $parm =  '';
3152
-            }
3154
+                    if  (!isset($func) ||  !mb_strlen(trim($func), '8bit')) {
3155
+                      $directive =  0;
3156
+                    } else {
3157
+                      // only call the function if this is the final call
3158
+                      if  ($final) {
3159
+                        // need to assess the text position, calculate the text width to this point
3160
+                        // can use getTextWidth to find the text width I think
3161
+                        $tmp =  $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
3162
+
3163
+                        $info =  array('x' => $tmp[0], 'y' => $tmp[1], 'angle' => $angle, 'status' => 'end', 'p' => $parm, 'nCallback' => $this->nCallback);
3164
+                        $x =  $tmp[0];
3165
+                        $y =  $tmp[1];
3166
+                        $ret =  $this->$func($info);
3167
+
3168
+                        if  (is_array($ret)) {
3169
+                          // then the return from the callback function could set the position, to start with, later will do font colour, and font
3170
+                          foreach($ret as  $rk => $rv) {
3171
+                            switch ($rk) {
3172
+                                case  'x':
3173
+                                case  'y':
3174
+                                  $$rk =  $rv;
3175
+                                  break;
3176
+                            }
3177
+                      }
3178
+                    }
3153 3179
 
3154
-            if  (!isset($func) ||  !mb_strlen(trim($func), '8bit')) {
3155
-              $directive =  0;
3156
-            } else {
3157
-              // only call the function if this is the final call
3158
-              if  ($final) {
3159
-                // need to assess the text position, calculate the text width to this point
3160
-                // can use getTextWidth to find the text width I think
3161
-                $tmp =  $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
3162
-
3163
-                $info =  array('x' => $tmp[0], 'y' => $tmp[1], 'angle' => $angle, 'status' => 'end', 'p' => $parm, 'nCallback' => $this->nCallback);
3164
-                $x =  $tmp[0];
3165
-                $y =  $tmp[1];
3166
-                $ret =  $this->$func($info);
3167
-
3168
-                if  (is_array($ret)) {
3169
-                  // then the return from the callback function could set the position, to start with, later will do font colour, and font
3170
-                  foreach($ret as  $rk => $rv) {
3171
-                    switch ($rk) {
3172
-                    case  'x':
3173
-                    case  'y':
3174
-                      $$rk =  $rv;
3175
-                      break;
3180
+                    // also remove from to the stack
3181
+                    // for simplicity, just take from the end, fix this another day
3182
+                    $this->nCallback--;
3183
+                    if  ($this->nCallback<0) {
3184
+                      $this->nCallBack =  0;
3176 3185
                     }
3177 3186
                   }
3178 3187
                 }
3179
-
3180
-                // also remove from to the stack
3181
-                // for simplicity, just take from the end, fix this another day
3182
-                $this->nCallback--;
3183
-                if  ($this->nCallback<0) {
3184
-                  $this->nCallBack =  0;
3185
-                }
3186 3188
               }
3187
-            }
3188
-          }
3189
-          break;
3189
+              break;
3190 3190
         }
3191 3191
         break;
3192 3192
 
3193
-      case  'b':
3194
-      case  'i':
3195
-        $j++;
3196
-        if  ($text[$j] === '>') {
3197
-          $this->currentTextState.=  $text[$j-1];
3198
-          $directive =  $j-$i+1;
3199
-        }
3200
-        break;
3193
+          case  'b':
3194
+          case  'i':
3195
+            $j++;
3196
+            if  ($text[$j] === '>') {
3197
+              $this->currentTextState.=  $text[$j-1];
3198
+              $directive =  $j-$i+1;
3199
+            }
3200
+            break;
3201 3201
 
3202
-      case  'C':
3203
-        $noClose =  1;
3204
-      case  'c':
3205
-        // this this might be a callback function
3206
-        $j++;
3207
-        $k =  mb_strpos($text, '>', $j);
3202
+          case  'C':
3203
+            $noClose =  1;
3204
+          case  'c':
3205
+            // this this might be a callback function
3206
+            $j++;
3207
+            $k =  mb_strpos($text, '>', $j);
3208 3208
 
3209
-        if  ($k !==  false &&  $text[$j] ===  ':') {
3210
-          // then this will be treated as a callback directive
3211
-          $directive =  $k-$i+1;
3209
+            if  ($k !==  false &&  $text[$j] ===  ':') {
3210
+              // then this will be treated as a callback directive
3211
+              $directive =  $k-$i+1;
3212 3212
 
3213
-          $f =  0;
3213
+              $f =  0;
3214 3214
 
3215
-          // split the remainder on colons to get the function name and the paramater
3216
-          //          $bits = explode(':',substr($text,$j+1,$k-$j-1));
3217
-          $tmp =  mb_substr($text, $j+1, $k-$j-1);
3218
-          $b1 =  mb_strpos($tmp, ':');
3215
+              // split the remainder on colons to get the function name and the paramater
3216
+              //          $bits = explode(':',substr($text,$j+1,$k-$j-1));
3217
+              $tmp =  mb_substr($text, $j+1, $k-$j-1);
3218
+              $b1 =  mb_strpos($tmp, ':');
3219 3219
 
3220
-          if  ($b1 !==  false) {
3221
-            $func =  mb_substr($tmp, 0, $b1);
3222
-            $parm =  mb_substr($tmp, $b1+1);
3223
-          } else {
3224
-            $func =  $tmp;
3225
-            $parm =  '';
3226
-          }
3227
-
3228
-          if  (!isset($func) ||  !mb_strlen(trim($func), '8bit')) {
3229
-            $directive =  0;
3230
-          } else {
3231
-            // only call the function if this is the final call, ie, the one actually doing printing, not measurement
3232
-            if  ($final) {
3233
-              // need to assess the text position, calculate the text width to this point
3234
-              // can use getTextWidth to find the text width I think
3235
-              // also add the text height and descender
3236
-              $tmp =  $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
3237
-
3238
-              $info =  array(
3239
-                'x' => $tmp[0], 
3240
-                'y' => $tmp[1], 
3241
-                'angle' => $angle, 
3242
-                'status' => 'start', 
3243
-                'p' => $parm, 
3244
-                'f' => $func, 
3245
-                'height' => $this->getFontHeight($size), 
3246
-                'descender' => $this->getFontDescender($size)
3247
-              );
3248
-              $x =  $tmp[0];
3249
-              $y =  $tmp[1];
3250
-
3251
-              if  (!isset($noClose) ||  !$noClose) {
3252
-                // only add to the stack if this is a small 'c', therefore is a start-stop pair
3253
-                $this->nCallback++;
3254
-                $info['nCallback'] =  $this->nCallback;
3255
-                $this->callback[$this->nCallback] =  $info;
3220
+              if  ($b1 !==  false) {
3221
+                $func =  mb_substr($tmp, 0, $b1);
3222
+                $parm =  mb_substr($tmp, $b1+1);
3223
+              } else {
3224
+                $func =  $tmp;
3225
+                $parm =  '';
3256 3226
               }
3257 3227
 
3258
-              $ret =  $this->$func($info);
3259
-              if  (is_array($ret)) {
3260
-                // then the return from the callback function could set the position, to start with, later will do font colour, and font
3261
-                foreach($ret as  $rk => $rv) {
3262
-                  switch ($rk) {
3263
-                  case  'x':
3264
-                  case  'y':
3265
-                    $$rk =  $rv;
3266
-                    break;
3228
+              if  (!isset($func) ||  !mb_strlen(trim($func), '8bit')) {
3229
+                $directive =  0;
3230
+              } else {
3231
+                // only call the function if this is the final call, ie, the one actually doing printing, not measurement
3232
+                if  ($final) {
3233
+                  // need to assess the text position, calculate the text width to this point
3234
+                  // can use getTextWidth to find the text width I think
3235
+                  // also add the text height and descender
3236
+                  $tmp =  $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
3237
+
3238
+                  $info =  array(
3239
+                    'x' => $tmp[0], 
3240
+                    'y' => $tmp[1], 
3241
+                    'angle' => $angle, 
3242
+                    'status' => 'start', 
3243
+                    'p' => $parm, 
3244
+                    'f' => $func, 
3245
+                    'height' => $this->getFontHeight($size), 
3246
+                    'descender' => $this->getFontDescender($size)
3247
+                  );
3248
+                  $x =  $tmp[0];
3249
+                  $y =  $tmp[1];
3250
+
3251
+                  if  (!isset($noClose) ||  !$noClose) {
3252
+                    // only add to the stack if this is a small 'c', therefore is a start-stop pair
3253
+                    $this->nCallback++;
3254
+                    $info['nCallback'] =  $this->nCallback;
3255
+                    $this->callback[$this->nCallback] =  $info;
3267 3256
                   }
3257
+
3258
+                  $ret =  $this->$func($info);
3259
+                  if  (is_array($ret)) {
3260
+                    // then the return from the callback function could set the position, to start with, later will do font colour, and font
3261
+                    foreach($ret as  $rk => $rv) {
3262
+                      switch ($rk) {
3263
+                          case  'x':
3264
+                          case  'y':
3265
+                            $$rk =  $rv;
3266
+                            break;
3267
+                      }
3268 3268
                 }
3269 3269
               }
3270 3270
             }
@@ -3471,29 +3471,29 @@  discard block
 block discarded – undo
3471 3471
    */
3472 3472
   function  PRVTadjustWrapText($text, $actual, $width, &$x, &$adjust, $justification) {
3473 3473
     switch  ($justification) {
3474
-    case  'left':
3475
-      return;
3474
+        case  'left':
3475
+          return;
3476 3476
 
3477
-    case  'right':
3478
-      $x+=  $width-$actual;
3479
-      break;
3477
+        case  'right':
3478
+          $x+=  $width-$actual;
3479
+          break;
3480 3480
 
3481
-    case  'center':
3482
-    case  'centre':
3483
-      $x+=  ($width-$actual) /2;
3484
-      break;
3481
+        case  'center':
3482
+        case  'centre':
3483
+          $x+=  ($width-$actual) /2;
3484
+          break;
3485 3485
 
3486
-    case  'full':
3487
-      // count the number of words
3488
-      $words =  explode(' ', $text);
3489
-      $nspaces =  count($words) -1;
3486
+        case  'full':
3487
+          // count the number of words
3488
+          $words =  explode(' ', $text);
3489
+          $nspaces =  count($words) -1;
3490 3490
 
3491
-      if  ($nspaces>0) {
3492
-        $adjust =  ($width-$actual) /$nspaces;
3493
-      } else {
3494
-        $adjust =  0;
3495
-      }
3496
-      break;
3491
+          if  ($nspaces>0) {
3492
+            $adjust =  ($width-$actual) /$nspaces;
3493
+          } else {
3494
+            $adjust =  0;
3495
+          }
3496
+          break;
3497 3497
     }
3498 3498
   }
3499 3499
 
@@ -3766,48 +3766,48 @@  discard block
 block discarded – undo
3766 3766
     if  (isset($this->looseObjects[$id]) &&  $this->currentContents !=  $id) {
3767 3767
       // then it is a valid object, and it is not being added to itself
3768 3768
       switch ($options) {
3769
-      case  'all':
3770
-        // then this object is to be added to this page (done in the next block) and
3771
-        // all future new pages.
3772
-        $this->addLooseObjects[$id] =  'all';
3773
-
3774
-      case  'add':
3775
-        if  (isset($this->objects[$this->currentContents]['onPage'])) {
3776
-          // then the destination contents is the primary for the page
3777
-          // (though this object is actually added to that page)
3778
-          $this->o_page($this->objects[$this->currentContents]['onPage'], 'content', $id);
3779
-        }
3780
-        break;
3769
+          case  'all':
3770
+            // then this object is to be added to this page (done in the next block) and
3771
+            // all future new pages.
3772
+            $this->addLooseObjects[$id] =  'all';
3773
+
3774
+          case  'add':
3775
+            if  (isset($this->objects[$this->currentContents]['onPage'])) {
3776
+              // then the destination contents is the primary for the page
3777
+              // (though this object is actually added to that page)
3778
+              $this->o_page($this->objects[$this->currentContents]['onPage'], 'content', $id);
3779
+            }
3780
+            break;
3781 3781
 
3782
-      case  'even':
3783
-        $this->addLooseObjects[$id] =  'even';
3784
-        $pageObjectId =  $this->objects[$this->currentContents]['onPage'];
3785
-        if  ($this->objects[$pageObjectId]['info']['pageNum']%2 ==  0) {
3786
-          $this->addObject($id);
3787
-          // hacky huh :)
3788
-        }
3789
-        break;
3782
+          case  'even':
3783
+            $this->addLooseObjects[$id] =  'even';
3784
+            $pageObjectId =  $this->objects[$this->currentContents]['onPage'];
3785
+            if  ($this->objects[$pageObjectId]['info']['pageNum']%2 ==  0) {
3786
+              $this->addObject($id);
3787
+              // hacky huh :)
3788
+            }
3789
+            break;
3790 3790
 
3791
-      case  'odd':
3792
-        $this->addLooseObjects[$id] =  'odd';
3793
-        $pageObjectId =  $this->objects[$this->currentContents]['onPage'];
3794
-        if  ($this->objects[$pageObjectId]['info']['pageNum']%2 ==  1) {
3795
-          $this->addObject($id);
3796
-          // hacky huh :)
3797
-        }
3798
-        break;
3791
+          case  'odd':
3792
+            $this->addLooseObjects[$id] =  'odd';
3793
+            $pageObjectId =  $this->objects[$this->currentContents]['onPage'];
3794
+            if  ($this->objects[$pageObjectId]['info']['pageNum']%2 ==  1) {
3795
+              $this->addObject($id);
3796
+              // hacky huh :)
3797
+            }
3798
+            break;
3799 3799
 
3800
-      case  'next':
3801
-        $this->addLooseObjects[$id] =  'all';
3802
-        break;
3800
+          case  'next':
3801
+            $this->addLooseObjects[$id] =  'all';
3802
+            break;
3803 3803
 
3804
-      case  'nexteven':
3805
-        $this->addLooseObjects[$id] =  'even';
3806
-        break;
3804
+          case  'nexteven':
3805
+            $this->addLooseObjects[$id] =  'even';
3806
+            break;
3807 3807
 
3808
-      case  'nextodd':
3809
-        $this->addLooseObjects[$id] =  'odd';
3810
-        break;
3808
+          case  'nextodd':
3809
+            $this->addLooseObjects[$id] =  'odd';
3810
+            break;
3811 3811
       }
3812 3812
     }
3813 3813
   }
@@ -4025,105 +4025,105 @@  discard block
 block discarded – undo
4025 4025
         $chunkType =  mb_substr($data, $p+4, 4, '8bit');
4026 4026
         //      echo $chunkType.' - '.$chunkLen.'<br>';
4027 4027
         switch ($chunkType) {
4028
-        case  'IHDR':
4029
-          // this is where all the file information comes from
4030
-          $info['width'] =  $this->PRVT_getBytes($data, $p+8, 4);
4031
-          $info['height'] =  $this->PRVT_getBytes($data, $p+12, 4);
4032
-          $info['bitDepth'] =  ord($data[$p+16]);
4033
-          $info['colorType'] =  ord($data[$p+17]);
4034
-          $info['compressionMethod'] =  ord($data[$p+18]);
4035
-          $info['filterMethod'] =  ord($data[$p+19]);
4036
-          $info['interlaceMethod'] =  ord($data[$p+20]);
4037
-
4038
-          //print_r($info);
4039
-          $haveHeader =  1;
4040
-          if  ($info['compressionMethod'] !=  0) {
4041
-            $error =  1;
4042
-
4043
-            //debugpng
4044
-            if (DEBUGPNG) print '[addPngFromFile unsupported compression method '.$file.']';
4045
-
4046
-            $errormsg =  'unsupported compression method';
4047
-          }
4028
+            case  'IHDR':
4029
+              // this is where all the file information comes from
4030
+              $info['width'] =  $this->PRVT_getBytes($data, $p+8, 4);
4031
+              $info['height'] =  $this->PRVT_getBytes($data, $p+12, 4);
4032
+              $info['bitDepth'] =  ord($data[$p+16]);
4033
+              $info['colorType'] =  ord($data[$p+17]);
4034
+              $info['compressionMethod'] =  ord($data[$p+18]);
4035
+              $info['filterMethod'] =  ord($data[$p+19]);
4036
+              $info['interlaceMethod'] =  ord($data[$p+20]);
4037
+
4038
+              //print_r($info);
4039
+              $haveHeader =  1;
4040
+              if  ($info['compressionMethod'] !=  0) {
4041
+                $error =  1;
4042
+
4043
+                //debugpng
4044
+                if (DEBUGPNG) print '[addPngFromFile unsupported compression method '.$file.']';
4045
+
4046
+                $errormsg =  'unsupported compression method';
4047
+              }
4048 4048
 
4049
-          if  ($info['filterMethod'] !=  0) {
4050
-            $error =  1;
4049
+              if  ($info['filterMethod'] !=  0) {
4050
+                $error =  1;
4051 4051
 
4052
-            //debugpng
4053
-            if (DEBUGPNG) print '[addPngFromFile unsupported filter method '.$file.']';
4052
+                //debugpng
4053
+                if (DEBUGPNG) print '[addPngFromFile unsupported filter method '.$file.']';
4054 4054
 
4055
-            $errormsg =  'unsupported filter method';
4056
-          }
4057
-          break;
4055
+                $errormsg =  'unsupported filter method';
4056
+              }
4057
+              break;
4058 4058
 
4059
-        case  'PLTE':
4060
-          $pdata.=  mb_substr($data, $p+8, $chunkLen, '8bit');
4061
-          break;
4059
+            case  'PLTE':
4060
+              $pdata.=  mb_substr($data, $p+8, $chunkLen, '8bit');
4061
+              break;
4062 4062
 
4063
-        case  'IDAT':
4064
-          $idata.=  mb_substr($data, $p+8, $chunkLen, '8bit');
4065
-          break;
4063
+            case  'IDAT':
4064
+              $idata.=  mb_substr($data, $p+8, $chunkLen, '8bit');
4065
+              break;
4066 4066
 
4067
-        case  'tRNS':
4068
-          //this chunk can only occur once and it must occur after the PLTE chunk and before IDAT chunk
4069
-          //print "tRNS found, color type = ".$info['colorType']."\n";
4070
-          $transparency =  array();
4067
+            case  'tRNS':
4068
+              //this chunk can only occur once and it must occur after the PLTE chunk and before IDAT chunk
4069
+              //print "tRNS found, color type = ".$info['colorType']."\n";
4070
+              $transparency =  array();
4071 4071
 
4072
-          if  ($info['colorType'] ==  3) {
4073
-            // indexed color, rbg
4074
-            /* corresponding to entries in the plte chunk
4072
+              if  ($info['colorType'] ==  3) {
4073
+                // indexed color, rbg
4074
+                /* corresponding to entries in the plte chunk
4075 4075
              Alpha for palette index 0: 1 byte
4076 4076
              Alpha for palette index 1: 1 byte
4077 4077
              ...etc...
4078 4078
             */
4079
-            // there will be one entry for each palette entry. up until the last non-opaque entry.
4080
-            // set up an array, stretching over all palette entries which will be o (opaque) or 1 (transparent)
4081
-            $transparency['type'] =  'indexed';
4082
-            $numPalette =  mb_strlen($pdata, '8bit')/3;
4083
-            $trans =  0;
4084
-
4085
-            for  ($i =  $chunkLen;$i >=  0;$i--) {
4086
-              if  (ord($data[$p+8+$i]) ==  0) {
4087
-                $trans =  $i;
4088
-              }
4089
-            }
4079
+                // there will be one entry for each palette entry. up until the last non-opaque entry.
4080
+                // set up an array, stretching over all palette entries which will be o (opaque) or 1 (transparent)
4081
+                $transparency['type'] =  'indexed';
4082
+                $numPalette =  mb_strlen($pdata, '8bit')/3;
4083
+                $trans =  0;
4084
+
4085
+                for  ($i =  $chunkLen;$i >=  0;$i--) {
4086
+                  if  (ord($data[$p+8+$i]) ==  0) {
4087
+                    $trans =  $i;
4088
+                  }
4089
+                }
4090 4090
 
4091
-            $transparency['data'] =  $trans;
4092
-          } elseif ($info['colorType'] ==  0) {
4093
-            // grayscale
4094
-            /* corresponding to entries in the plte chunk
4091
+                $transparency['data'] =  $trans;
4092
+              } elseif ($info['colorType'] ==  0) {
4093
+                // grayscale
4094
+                /* corresponding to entries in the plte chunk
4095 4095
              Gray: 2 bytes, range 0 .. (2^bitdepth)-1
4096 4096
             */
4097
-            //            $transparency['grayscale'] = $this->PRVT_getBytes($data,$p+8,2); // g = grayscale
4098
-            $transparency['type'] =  'indexed';
4097
+                //            $transparency['grayscale'] = $this->PRVT_getBytes($data,$p+8,2); // g = grayscale
4098
+                $transparency['type'] =  'indexed';
4099 4099
 
4100
-            $transparency['data'] =  ord($data[$p+8+1]);
4101
-          } elseif ($info['colorType'] ==  2) {
4102
-            // truecolor
4103
-            /* corresponding to entries in the plte chunk
4100
+                $transparency['data'] =  ord($data[$p+8+1]);
4101
+              } elseif ($info['colorType'] ==  2) {
4102
+                // truecolor
4103
+                /* corresponding to entries in the plte chunk
4104 4104
              Red: 2 bytes, range 0 .. (2^bitdepth)-1
4105 4105
              Green: 2 bytes, range 0 .. (2^bitdepth)-1
4106 4106
              Blue: 2 bytes, range 0 .. (2^bitdepth)-1
4107 4107
             */
4108
-            $transparency['r'] =  $this->PRVT_getBytes($data, $p+8, 2);
4109
-            // r from truecolor
4110
-            $transparency['g'] =  $this->PRVT_getBytes($data, $p+10, 2);
4111
-            // g from truecolor
4112
-            $transparency['b'] =  $this->PRVT_getBytes($data, $p+12, 2);
4113
-            // b from truecolor
4114
-
4115
-            $transparency['type'] = 'color-key';
4108
+                $transparency['r'] =  $this->PRVT_getBytes($data, $p+8, 2);
4109
+                // r from truecolor
4110
+                $transparency['g'] =  $this->PRVT_getBytes($data, $p+10, 2);
4111
+                // g from truecolor
4112
+                $transparency['b'] =  $this->PRVT_getBytes($data, $p+12, 2);
4113
+                // b from truecolor
4114
+
4115
+                $transparency['type'] = 'color-key';
4116 4116
             
4117
-          } else {
4118
-            //unsupported transparency type
4119
-            //debugpng
4120
-            if (DEBUGPNG) print '[addPngFromFile unsupported transparency type '.$file.']';
4121
-          }
4122
-          // KS End new code
4123
-          break;
4117
+              } else {
4118
+                //unsupported transparency type
4119
+                //debugpng
4120
+                if (DEBUGPNG) print '[addPngFromFile unsupported transparency type '.$file.']';
4121
+              }
4122
+              // KS End new code
4123
+              break;
4124 4124
 
4125
-        default:
4126
-          break;
4125
+            default:
4126
+              break;
4127 4127
         }
4128 4128
 
4129 4129
         $p+=  $chunkLen+12;
@@ -4168,20 +4168,20 @@  discard block
 block discarded – undo
4168 4168
         $errormsg =  'transparancey alpha channel not supported, transparency only supported for palette images.';
4169 4169
       } else {
4170 4170
         switch  ($info['colorType']) {
4171
-        case  3:
4172
-          $color =  'DeviceRGB';
4173
-          $ncolor =  1;
4174
-          break;
4171
+            case  3:
4172
+              $color =  'DeviceRGB';
4173
+              $ncolor =  1;
4174
+              break;
4175 4175
 
4176
-        case  2:
4177
-          $color =  'DeviceRGB';
4178
-          $ncolor =  3;
4179
-          break;
4176
+            case  2:
4177
+              $color =  'DeviceRGB';
4178
+              $ncolor =  3;
4179
+              break;
4180 4180
 
4181
-        case  0:
4182
-          $color =  'DeviceGray';
4183
-          $ncolor =  1;
4184
-          break;
4181
+            case  0:
4182
+              $color =  'DeviceGray';
4183
+              $ncolor =  1;
4184
+              break;
4185 4185
         }
4186 4186
       }
4187 4187
     }
@@ -4469,48 +4469,48 @@  discard block
 block discarded – undo
4469 4469
    */
4470 4470
   function  transaction($action) {
4471 4471
     switch  ($action) {
4472
-    case  'start':
4473
-      // store all the data away into the checkpoint variable
4474
-      $data =  get_object_vars($this);
4475
-      $this->checkpoint =  $data;
4476
-      unset($data);
4477
-      break;
4472
+        case  'start':
4473
+          // store all the data away into the checkpoint variable
4474
+          $data =  get_object_vars($this);
4475
+          $this->checkpoint =  $data;
4476
+          unset($data);
4477
+          break;
4478 4478
 
4479
-    case  'commit':
4480
-      if  (is_array($this->checkpoint) &&  isset($this->checkpoint['checkpoint'])) {
4481
-        $tmp =  $this->checkpoint['checkpoint'];
4482
-        $this->checkpoint =  $tmp;
4483
-        unset($tmp);
4484
-      } else {
4485
-        $this->checkpoint =  '';
4486
-      }
4487
-      break;
4479
+        case  'commit':
4480
+          if  (is_array($this->checkpoint) &&  isset($this->checkpoint['checkpoint'])) {
4481
+            $tmp =  $this->checkpoint['checkpoint'];
4482
+            $this->checkpoint =  $tmp;
4483
+            unset($tmp);
4484
+          } else {
4485
+            $this->checkpoint =  '';
4486
+          }
4487
+          break;
4488 4488
 
4489
-    case  'rewind':
4490
-      // do not destroy the current checkpoint, but move us back to the state then, so that we can try again
4491
-      if  (is_array($this->checkpoint)) {
4492
-        // can only abort if were inside a checkpoint
4493
-        $tmp =  $this->checkpoint;
4489
+        case  'rewind':
4490
+          // do not destroy the current checkpoint, but move us back to the state then, so that we can try again
4491
+          if  (is_array($this->checkpoint)) {
4492
+            // can only abort if were inside a checkpoint
4493
+            $tmp =  $this->checkpoint;
4494 4494
 
4495
-        foreach ($tmp as  $k => $v) {
4496
-          if  ($k !==  'checkpoint') {
4497
-            $this->$k =  $v;
4495
+            foreach ($tmp as  $k => $v) {
4496
+              if  ($k !==  'checkpoint') {
4497
+                $this->$k =  $v;
4498
+              }
4499
+            }
4500
+            unset($tmp);
4498 4501
           }
4499
-        }
4500
-        unset($tmp);
4501
-      }
4502
-      break;
4502
+          break;
4503 4503
 
4504
-    case  'abort':
4505
-      if  (is_array($this->checkpoint)) {
4506
-        // can only abort if were inside a checkpoint
4507
-        $tmp =  $this->checkpoint;
4508
-        foreach ($tmp as  $k => $v) {
4509
-          $this->$k =  $v;
4510
-        }
4511
-        unset($tmp);
4512
-      }
4513
-      break;
4504
+        case  'abort':
4505
+          if  (is_array($this->checkpoint)) {
4506
+            // can only abort if were inside a checkpoint
4507
+            $tmp =  $this->checkpoint;
4508
+            foreach ($tmp as  $k => $v) {
4509
+              $this->$k =  $v;
4510
+            }
4511
+            unset($tmp);
4512
+          }
4513
+          break;
4514 4514
     }
4515 4515
   }
4516 4516
 }
Please login to merge, or discard this patch.
Spacing   +1069 added lines, -1069 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
   /**
58 58
    * this array contains all of the pdf objects, ready for final assembly
59 59
    */
60
-  public  $objects =  array();
60
+  public  $objects = array();
61 61
 
62 62
   /**
63 63
    * the objectId (number within the objects array) of the document catalog
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
   /**
115 115
    * Number of graphic state resources used
116 116
    */
117
-  private  $numStates =  0;
117
+  private  $numStates = 0;
118 118
 
119 119
 
120 120
   /**
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
    * an array which is used to save the state of the document, mainly the colours and styles
147 147
    * it is used to temporarily change to another state, the change back to what it was before
148 148
    */
149
-  public  $stateStack =  array();
149
+  public  $stateStack = array();
150 150
 
151 151
   /**
152 152
    * number of elements within the state stack
153 153
    */
154
-  public  $nStateStack =  0;
154
+  public  $nStateStack = 0;
155 155
 
156 156
   /**
157 157
    * number of page objects within the document
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
    * this used so that the code knows which font is the bold version of another font, etc.
218 218
    * the value of this array is initialised in the constuctor function.
219 219
    */
220
-  public  $fontFamilies =  array();
220
+  public  $fontFamilies = array();
221 221
  
222 222
   /**
223 223
    * folder for php serialized formats of font metrics files.
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
   /**
246 246
    * track if the current font is bolded or italicised
247 247
    */
248
-  public  $currentTextState =  '';
248
+  public  $currentTextState = '';
249 249
 
250 250
   /**
251 251
    * messages are stored here during processing, these can be selected afterwards to give some useful debug information
@@ -280,25 +280,25 @@  discard block
 block discarded – undo
280 280
   /**
281 281
    * array which forms a stack to keep track of nested callback functions
282 282
    */
283
-  public  $callback =  array();
283
+  public  $callback = array();
284 284
 
285 285
   /**
286 286
    * the number of callback functions in the callback array
287 287
    */
288
-  public  $nCallback =  0;
288
+  public  $nCallback = 0;
289 289
 
290 290
   /**
291 291
    * store label->id pairs for named destinations, these will be used to replace internal links
292 292
    * done this way so that destinations can be defined after the location that links to them
293 293
    */
294
-  public  $destinations =  array();
294
+  public  $destinations = array();
295 295
 
296 296
   /**
297 297
    * store the stack for the transaction commands, each item in here is a record of the values of all the
298 298
    * publiciables within the class, so that the user can rollback at will (from each 'start' command)
299 299
    * note that this includes the objects array, so these can be large.
300 300
    */
301
-  public  $checkpoint =  '';
301
+  public  $checkpoint = '';
302 302
 
303 303
   /* Table of Image origin filenames and image labels which were already added with o_image().
304 304
    * Allows to merge identical images
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
    * @var array array of 4 numbers, defining the bottom left and upper right corner of the page. first two are normally zero.
319 319
    * @var boolean whether text will be treated as Unicode or not.
320 320
    */
321
-  function  Cpdf ($pageSize = array(0, 0, 612, 792), $isUnicode = false, $fontcache = '', $tmp = '') {
321
+  function  Cpdf($pageSize = array(0, 0, 612, 792), $isUnicode = false, $fontcache = '', $tmp = '') {
322 322
     $this->isUnicode = $isUnicode;
323 323
     $this->fontcache = $fontcache;
324 324
     $this->tmp = $tmp;
@@ -349,33 +349,33 @@  discard block
 block discarded – undo
349 349
    *destination object, used to specify the location for the user to jump to, presently on opening
350 350
    */
351 351
   protected function  o_destination($id, $action, $options = '') {
352
-    if  ($action !== 'new') {
352
+    if ($action !== 'new') {
353 353
       $o = & $this->objects[$id];
354 354
     }
355 355
 
356 356
     switch ($action) {
357 357
     case  'new':
358 358
       $this->objects[$id] = array('t'=>'destination', 'info'=>array());
359
-      $tmp =  '';
360
-      switch  ($options['type']) {
359
+      $tmp = '';
360
+      switch ($options['type']) {
361 361
       case  'XYZ':
362 362
       case  'FitR':
363
-        $tmp =   ' '.$options['p3'].$tmp;
363
+        $tmp = ' '.$options['p3'].$tmp;
364 364
       case  'FitH':
365 365
       case  'FitV':
366 366
       case  'FitBH':
367 367
       case  'FitBV':
368
-        $tmp =   ' '.$options['p1'].' '.$options['p2'].$tmp;
368
+        $tmp = ' '.$options['p1'].' '.$options['p2'].$tmp;
369 369
       case  'Fit':
370 370
       case  'FitB':
371
-        $tmp =   $options['type'].$tmp;
371
+        $tmp = $options['type'].$tmp;
372 372
         $this->objects[$id]['info']['string'] = $tmp;
373 373
         $this->objects[$id]['info']['page'] = $options['page'];
374 374
       }
375 375
       break;
376 376
 
377 377
     case  'out':
378
-      $tmp =  $o['info'];
378
+      $tmp = $o['info'];
379 379
       $res = "\n".$id." 0 obj\n".'['.$tmp['page'].' 0 R /'.$tmp['string']."]\nendobj";
380 380
       return  $res;
381 381
     }
@@ -386,18 +386,18 @@  discard block
 block discarded – undo
386 386
    * set the viewer preferences
387 387
    */
388 388
   protected function  o_viewerPreferences($id, $action, $options = '') {
389
-    if  ($action !== 'new') {
389
+    if ($action !== 'new') {
390 390
       $o = & $this->objects[$id];
391 391
     }
392 392
 
393
-    switch  ($action) {
393
+    switch ($action) {
394 394
     case  'new':
395 395
       $this->objects[$id] = array('t'=>'viewerPreferences', 'info'=>array());
396 396
       break;
397 397
 
398 398
     case  'add':
399
-      foreach($options as  $k=>$v) {
400
-        switch  ($k) {
399
+      foreach ($options as  $k=>$v) {
400
+        switch ($k) {
401 401
         case  'HideToolbar':
402 402
         case  'HideMenubar':
403 403
         case  'HideWindowUI':
@@ -413,10 +413,10 @@  discard block
 block discarded – undo
413 413
 
414 414
     case  'out':
415 415
       $res = "\n".$id." 0 obj\n".'<< ';
416
-      foreach($o['info'] as  $k=>$v) {
417
-        $res.= "\n/".$k.' '.$v;
416
+      foreach ($o['info'] as  $k=>$v) {
417
+        $res .= "\n/".$k.' '.$v;
418 418
       }
419
-      $res.= "\n>>\n";
419
+      $res .= "\n>>\n";
420 420
       return  $res;
421 421
     }
422 422
   }
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
    * define the document catalog, the overall controller for the document
427 427
    */
428 428
   protected function  o_catalog($id, $action, $options = '') {
429
-    if  ($action !== 'new') {
429
+    if ($action !== 'new') {
430 430
       $o = & $this->objects[$id];
431 431
     }
432 432
 
433
-    switch  ($action) {
433
+    switch ($action) {
434 434
     case  'new':
435 435
       $this->objects[$id] = array('t'=>'catalog', 'info'=>array());
436 436
       $this->catalogId = $id;
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
       break;
445 445
 
446 446
     case  'viewerPreferences':
447
-      if  (!isset($o['info']['viewerPreferences'])) {
447
+      if (!isset($o['info']['viewerPreferences'])) {
448 448
         $this->numObj++;
449 449
         $this->o_viewerPreferences($this->numObj, 'new');
450 450
         $o['info']['viewerPreferences'] = $this->numObj;
451 451
       }
452 452
 
453
-      $vp =  $o['info']['viewerPreferences'];
453
+      $vp = $o['info']['viewerPreferences'];
454 454
       $this->o_viewerPreferences($vp, 'add', $options);
455 455
 
456 456
       break;
@@ -458,31 +458,31 @@  discard block
 block discarded – undo
458 458
     case  'out':
459 459
       $res = "\n".$id." 0 obj\n".'<< /Type /Catalog';
460 460
 
461
-      foreach($o['info'] as  $k=>$v) {
461
+      foreach ($o['info'] as  $k=>$v) {
462 462
         switch ($k) {
463 463
         case  'outlines':
464
-          $res.= "\n".'/Outlines '.$v.' 0 R';
464
+          $res .= "\n".'/Outlines '.$v.' 0 R';
465 465
           break;
466 466
           
467 467
         case  'pages':
468
-          $res.= "\n".'/Pages '.$v.' 0 R';
468
+          $res .= "\n".'/Pages '.$v.' 0 R';
469 469
           break;
470 470
 
471 471
         case  'viewerPreferences':
472
-          $res.= "\n".'/ViewerPreferences '.$v.' 0 R';
472
+          $res .= "\n".'/ViewerPreferences '.$v.' 0 R';
473 473
           break;
474 474
 
475 475
         case  'openHere':
476
-          $res.= "\n".'/OpenAction '.$v.' 0 R';
476
+          $res .= "\n".'/OpenAction '.$v.' 0 R';
477 477
           break;
478 478
 
479 479
         case  'javascript':
480
-          $res.= "\n".'/Names <</JavaScript '.$v.' 0 R>>';
480
+          $res .= "\n".'/Names <</JavaScript '.$v.' 0 R>>';
481 481
           break;
482 482
         }
483 483
       }
484 484
 
485
-      $res.= " >>\nendobj";
485
+      $res .= " >>\nendobj";
486 486
       return  $res;
487 487
     }
488 488
   }
@@ -492,36 +492,36 @@  discard block
 block discarded – undo
492 492
    * object which is a parent to the pages in the document
493 493
    */
494 494
   protected function  o_pages($id, $action, $options = '') {
495
-    if  ($action !== 'new') {
495
+    if ($action !== 'new') {
496 496
       $o = & $this->objects[$id];
497 497
     }
498 498
 
499
-    switch  ($action) {
499
+    switch ($action) {
500 500
     case  'new':
501 501
       $this->objects[$id] = array('t'=>'pages', 'info'=>array());
502 502
       $this->o_catalog($this->catalogId, 'pages', $id);
503 503
       break;
504 504
 
505 505
     case  'page':
506
-      if  (!is_array($options)) {
506
+      if (!is_array($options)) {
507 507
         // then it will just be the id of the new page
508 508
         $o['info']['pages'][] = $options;
509 509
       } else {
510 510
         // then it should be an array having 'id','rid','pos', where rid=the page to which this one will be placed relative
511 511
         // and pos is either 'before' or 'after', saying where this page will fit.
512
-        if  (isset($options['id']) &&  isset($options['rid']) &&  isset($options['pos'])) {
513
-          $i =  array_search($options['rid'], $o['info']['pages']);
514
-          if  (isset($o['info']['pages'][$i]) &&  $o['info']['pages'][$i] == $options['rid']) {
512
+        if (isset($options['id']) && isset($options['rid']) && isset($options['pos'])) {
513
+          $i = array_search($options['rid'], $o['info']['pages']);
514
+          if (isset($o['info']['pages'][$i]) && $o['info']['pages'][$i] == $options['rid']) {
515 515
 
516 516
             // then there is a match
517 517
             // make a space
518
-            switch  ($options['pos']) {
518
+            switch ($options['pos']) {
519 519
             case  'before':
520
-              $k =  $i;
520
+              $k = $i;
521 521
               break;
522 522
 
523 523
             case  'after':
524
-              $k = $i+1;
524
+              $k = $i + 1;
525 525
               break;
526 526
 
527 527
             default:
@@ -529,9 +529,9 @@  discard block
 block discarded – undo
529 529
               break;
530 530
             }
531 531
 
532
-            if  ($k >= 0) {
533
-              for  ($j = count($o['info']['pages']) -1;$j >= $k;$j--) {
534
-                $o['info']['pages'][$j+1] = $o['info']['pages'][$j];
532
+            if ($k >= 0) {
533
+              for ($j = count($o['info']['pages']) - 1; $j >= $k; $j--) {
534
+                $o['info']['pages'][$j + 1] = $o['info']['pages'][$j];
535 535
               }
536 536
 
537 537
               $o['info']['pages'][$k] = $options['id'];
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
       break;
556 556
 
557 557
     case  'extGState':
558
-      $o['info']['extGStates'][] =  array('objNum' => $options['objNum'],  'stateNum' => $options['stateNum']);
558
+      $o['info']['extGStates'][] = array('objNum' => $options['objNum'], 'stateNum' => $options['stateNum']);
559 559
       break;
560 560
 
561 561
     case  'xObject':
@@ -563,55 +563,55 @@  discard block
 block discarded – undo
563 563
       break;
564 564
 
565 565
     case  'out':
566
-      if  (count($o['info']['pages'])) {
566
+      if (count($o['info']['pages'])) {
567 567
         $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Kids [";
568
-        foreach($o['info']['pages'] as  $k=>$v) {
569
-          $res.= $v." 0 R\n";
568
+        foreach ($o['info']['pages'] as  $k=>$v) {
569
+          $res .= $v." 0 R\n";
570 570
         }
571 571
 
572
-        $res.= "]\n/Count ".count($this->objects[$id]['info']['pages']);
572
+        $res .= "]\n/Count ".count($this->objects[$id]['info']['pages']);
573 573
 
574
-        if  ( (isset($o['info']['fonts']) &&  count($o['info']['fonts'])) ||
574
+        if ((isset($o['info']['fonts']) && count($o['info']['fonts'])) ||
575 575
               isset($o['info']['procset']) ||
576
-              (isset($o['info']['extGStates']) &&  count($o['info']['extGStates']))) {
577
-          $res.= "\n/Resources <<";
576
+              (isset($o['info']['extGStates']) && count($o['info']['extGStates']))) {
577
+          $res .= "\n/Resources <<";
578 578
 
579
-          if  (isset($o['info']['procset'])) {
580
-            $res.= "\n/ProcSet ".$o['info']['procset']." 0 R";
579
+          if (isset($o['info']['procset'])) {
580
+            $res .= "\n/ProcSet ".$o['info']['procset']." 0 R";
581 581
           }
582 582
 
583
-          if  (isset($o['info']['fonts']) &&  count($o['info']['fonts'])) {
584
-            $res.= "\n/Font << ";
585
-            foreach($o['info']['fonts'] as  $finfo) {
586
-              $res.= "\n/F".$finfo['fontNum']." ".$finfo['objNum']." 0 R";
583
+          if (isset($o['info']['fonts']) && count($o['info']['fonts'])) {
584
+            $res .= "\n/Font << ";
585
+            foreach ($o['info']['fonts'] as  $finfo) {
586
+              $res .= "\n/F".$finfo['fontNum']." ".$finfo['objNum']." 0 R";
587 587
             }
588
-            $res.= "\n>>";
588
+            $res .= "\n>>";
589 589
           }
590 590
 
591
-          if  (isset($o['info']['xObjects']) &&  count($o['info']['xObjects'])) {
592
-            $res.= "\n/XObject << ";
593
-            foreach($o['info']['xObjects'] as  $finfo) {
594
-              $res.= "\n/".$finfo['label']." ".$finfo['objNum']." 0 R";
591
+          if (isset($o['info']['xObjects']) && count($o['info']['xObjects'])) {
592
+            $res .= "\n/XObject << ";
593
+            foreach ($o['info']['xObjects'] as  $finfo) {
594
+              $res .= "\n/".$finfo['label']." ".$finfo['objNum']." 0 R";
595 595
             }
596
-            $res.= "\n>>";
596
+            $res .= "\n>>";
597 597
           }
598 598
 
599
-          if  ( isset($o['info']['extGStates']) &&  count($o['info']['extGStates'])) {
600
-            $res.=  "\n/ExtGState << ";
599
+          if (isset($o['info']['extGStates']) && count($o['info']['extGStates'])) {
600
+            $res .= "\n/ExtGState << ";
601 601
             foreach ($o['info']['extGStates'] as  $gstate) {
602
-              $res.=  "\n/GS" . $gstate['stateNum'] . " " . $gstate['objNum'] . " 0 R";
602
+              $res .= "\n/GS".$gstate['stateNum']." ".$gstate['objNum']." 0 R";
603 603
             }
604
-            $res.=  "\n>>";
604
+            $res .= "\n>>";
605 605
           }
606 606
 
607
-          $res.= "\n>>";
608
-          if  (isset($o['info']['mediaBox'])) {
607
+          $res .= "\n>>";
608
+          if (isset($o['info']['mediaBox'])) {
609 609
             $tmp = $o['info']['mediaBox'];
610
-            $res.= "\n/MediaBox [".sprintf('%.3F', $tmp[0]) .' '.sprintf('%.3F', $tmp[1]) .' '.sprintf('%.3F', $tmp[2]) .' '.sprintf('%.3F', $tmp[3]) .']';
610
+            $res .= "\n/MediaBox [".sprintf('%.3F', $tmp[0]).' '.sprintf('%.3F', $tmp[1]).' '.sprintf('%.3F', $tmp[2]).' '.sprintf('%.3F', $tmp[3]).']';
611 611
           }
612 612
         }
613 613
 
614
-        $res.= "\n >>\nendobj";
614
+        $res .= "\n >>\nendobj";
615 615
       } else {
616 616
         $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Count 0\n>>\nendobj";
617 617
       }
@@ -625,11 +625,11 @@  discard block
 block discarded – undo
625 625
    * define the outlines in the doc, empty for now
626 626
    */
627 627
   protected function  o_outlines($id, $action, $options = '') {
628
-    if  ($action !== 'new') {
628
+    if ($action !== 'new') {
629 629
       $o = & $this->objects[$id];
630 630
     }
631 631
 
632
-    switch  ($action) {
632
+    switch ($action) {
633 633
     case  'new':
634 634
       $this->objects[$id] = array('t'=>'outlines', 'info'=>array('outlines'=>array()));
635 635
       $this->o_catalog($this->catalogId, 'outlines', $id);
@@ -640,13 +640,13 @@  discard block
 block discarded – undo
640 640
       break;
641 641
 
642 642
     case  'out':
643
-      if  (count($o['info']['outlines'])) {
643
+      if (count($o['info']['outlines'])) {
644 644
         $res = "\n".$id." 0 obj\n<< /Type /Outlines /Kids [";
645
-        foreach($o['info']['outlines'] as  $k=>$v) {
646
-          $res.= $v." 0 R ";
645
+        foreach ($o['info']['outlines'] as  $k=>$v) {
646
+          $res .= $v." 0 R ";
647 647
         }
648 648
 
649
-        $res.= "] /Count ".count($o['info']['outlines']) ." >>\nendobj";
649
+        $res .= "] /Count ".count($o['info']['outlines'])." >>\nendobj";
650 650
       } else {
651 651
         $res = "\n".$id." 0 obj\n<< /Type /Outlines /Count 0 >>\nendobj";
652 652
       }
@@ -660,40 +660,40 @@  discard block
 block discarded – undo
660 660
    * an object to hold the font description
661 661
    */
662 662
   protected function  o_font($id, $action, $options = '') {
663
-    if  ($action !== 'new') {
663
+    if ($action !== 'new') {
664 664
       $o = & $this->objects[$id];
665 665
     }
666 666
 
667
-    switch  ($action) {
667
+    switch ($action) {
668 668
     case  'new':
669
-      $this->objects[$id] =  array('t' => 'font', 'info' => array('name' => $options['name'], 'fontFileName' => $options['fontFileName'], 'SubType' => 'Type1'));
670
-      $fontNum =  $this->numFonts;
671
-      $this->objects[$id]['info']['fontNum'] =  $fontNum;
669
+      $this->objects[$id] = array('t' => 'font', 'info' => array('name' => $options['name'], 'fontFileName' => $options['fontFileName'], 'SubType' => 'Type1'));
670
+      $fontNum = $this->numFonts;
671
+      $this->objects[$id]['info']['fontNum'] = $fontNum;
672 672
 
673 673
       // deal with the encoding and the differences
674
-      if  (isset($options['differences'])) {
674
+      if (isset($options['differences'])) {
675 675
         // then we'll need an encoding dictionary
676 676
         $this->numObj++;
677 677
         $this->o_fontEncoding($this->numObj, 'new', $options);
678
-        $this->objects[$id]['info']['encodingDictionary'] =  $this->numObj;
679
-      } else  if  (isset($options['encoding'])) {
678
+        $this->objects[$id]['info']['encodingDictionary'] = $this->numObj;
679
+      } else  if (isset($options['encoding'])) {
680 680
         // we can specify encoding here
681 681
         switch ($options['encoding']) {
682 682
         case  'WinAnsiEncoding':
683 683
         case  'MacRomanEncoding':
684 684
         case  'MacExpertEncoding':
685
-          $this->objects[$id]['info']['encoding'] =  $options['encoding'];
685
+          $this->objects[$id]['info']['encoding'] = $options['encoding'];
686 686
           break;
687 687
 
688 688
         case  'none':
689 689
           break;
690 690
 
691 691
         default:
692
-          $this->objects[$id]['info']['encoding'] =  'WinAnsiEncoding';
692
+          $this->objects[$id]['info']['encoding'] = 'WinAnsiEncoding';
693 693
           break;
694 694
         }
695 695
       } else {
696
-        $this->objects[$id]['info']['encoding'] =  'WinAnsiEncoding';
696
+        $this->objects[$id]['info']['encoding'] = 'WinAnsiEncoding';
697 697
       }
698 698
 
699 699
       if ($this->fonts[$options['fontFileName']]['isUnicode']) {
@@ -709,29 +709,29 @@  discard block
 block discarded – undo
709 709
         $this->o_contents($toUnicodeId, 'new', 'raw');
710 710
         $this->objects[$id]['info']['toUnicode'] = $toUnicodeId;
711 711
         
712
-        $stream =  "/CIDInit /ProcSet findresource begin\n";
713
-        $stream.=  "12 dict begin\n";
714
-        $stream.=  "begincmap\n";
715
-        $stream.=  "/CIDSystemInfo\n";
716
-        $stream.=  "<</Registry (Adobe)\n";
717
-        $stream.=  "/Ordering (UCS)\n";
718
-        $stream.=  "/Supplement 0\n";
719
-        $stream.=  ">> def\n";
720
-        $stream.=  "/CMapName /Adobe-Identity-UCS def\n";
721
-        $stream.=  "/CMapType 2 def\n";
722
-        $stream.=  "1 begincodespacerange\n";
723
-        $stream.=  "<0000> <FFFF>\n";
724
-        $stream.=  "endcodespacerange\n";
725
-        $stream.=  "1 beginbfrange\n";
726
-        $stream.=  "<0000> <FFFF> <0000>\n";
727
-        $stream.=  "endbfrange\n";
728
-        $stream.=  "endcmap\n";
729
-        $stream.=  "CMapName currentdict /CMap defineresource pop\n";
730
-        $stream.=  "end\n";
731
-        $stream.=  "end\n";
732
-
733
-        $res =   "<</Length " . mb_strlen($stream, '8bit') . " >>\n";
734
-        $res .=  "stream\n" . $stream . "endstream";
712
+        $stream = "/CIDInit /ProcSet findresource begin\n";
713
+        $stream .= "12 dict begin\n";
714
+        $stream .= "begincmap\n";
715
+        $stream .= "/CIDSystemInfo\n";
716
+        $stream .= "<</Registry (Adobe)\n";
717
+        $stream .= "/Ordering (UCS)\n";
718
+        $stream .= "/Supplement 0\n";
719
+        $stream .= ">> def\n";
720
+        $stream .= "/CMapName /Adobe-Identity-UCS def\n";
721
+        $stream .= "/CMapType 2 def\n";
722
+        $stream .= "1 begincodespacerange\n";
723
+        $stream .= "<0000> <FFFF>\n";
724
+        $stream .= "endcodespacerange\n";
725
+        $stream .= "1 beginbfrange\n";
726
+        $stream .= "<0000> <FFFF> <0000>\n";
727
+        $stream .= "endbfrange\n";
728
+        $stream .= "endcmap\n";
729
+        $stream .= "CMapName currentdict /CMap defineresource pop\n";
730
+        $stream .= "end\n";
731
+        $stream .= "end\n";
732
+
733
+        $res = "<</Length ".mb_strlen($stream, '8bit')." >>\n";
734
+        $res .= "stream\n".$stream."endstream";
735 735
 
736 736
         $this->objects[$toUnicodeId]['c'] = $res;
737 737
 
@@ -746,9 +746,9 @@  discard block
 block discarded – undo
746 746
 
747 747
     case  'add':
748 748
       foreach ($options as  $k => $v) {
749
-        switch  ($k) {
749
+        switch ($k) {
750 750
         case  'BaseFont':
751
-          $o['info']['name'] =  $v;
751
+          $o['info']['name'] = $v;
752 752
           break;
753 753
         case  'FirstChar':
754 754
         case  'LastChar':
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
         case  'FontDescriptor':
757 757
         case  'SubType':
758 758
           $this->addMessage('o_font '.$k." : ".$v);
759
-          $o['info'][$k] =  $v;
759
+          $o['info'][$k] = $v;
760 760
           break;
761 761
         }
762 762
       }
@@ -777,47 +777,47 @@  discard block
 block discarded – undo
777 777
         // All of this code is adapted from the excellent changes made to
778 778
         // transform FPDF to TCPDF (http://tcpdf.sourceforge.net/)
779 779
 
780
-        $res =  "\n".$id." 0 obj\n<</Type /Font\n/Subtype /Type0\n";
781
-        $res.=  "/BaseFont /".$o['info']['name']."\n";
780
+        $res = "\n".$id." 0 obj\n<</Type /Font\n/Subtype /Type0\n";
781
+        $res .= "/BaseFont /".$o['info']['name']."\n";
782 782
 
783 783
         // The horizontal identity mapping for 2-byte CIDs; may be used
784 784
         // with CIDFonts using any Registry, Ordering, and Supplement values.
785
-        $res.=  "/Encoding /Identity-H\n";
786
-        $res.=  "/DescendantFonts [".$o['info']['cidFont']." 0 R]\n";
787
-        $res.=  "/ToUnicode ".$o['info']['toUnicode']." 0 R\n";
788
-        $res.=  ">>\n";
789
-        $res.=  "endobj";
785
+        $res .= "/Encoding /Identity-H\n";
786
+        $res .= "/DescendantFonts [".$o['info']['cidFont']." 0 R]\n";
787
+        $res .= "/ToUnicode ".$o['info']['toUnicode']." 0 R\n";
788
+        $res .= ">>\n";
789
+        $res .= "endobj";
790 790
       } else {
791
-      $res =  "\n".$id." 0 obj\n<< /Type /Font\n/Subtype /".$o['info']['SubType']."\n";
792
-      $res.=  "/Name /F".$o['info']['fontNum']."\n";
793
-      $res.=  "/BaseFont /".$o['info']['name']."\n";
791
+      $res = "\n".$id." 0 obj\n<< /Type /Font\n/Subtype /".$o['info']['SubType']."\n";
792
+      $res .= "/Name /F".$o['info']['fontNum']."\n";
793
+      $res .= "/BaseFont /".$o['info']['name']."\n";
794 794
 
795
-      if  (isset($o['info']['encodingDictionary'])) {
795
+      if (isset($o['info']['encodingDictionary'])) {
796 796
         // then place a reference to the dictionary
797
-        $res.=  "/Encoding ".$o['info']['encodingDictionary']." 0 R\n";
798
-      } else  if  (isset($o['info']['encoding'])) {
797
+        $res .= "/Encoding ".$o['info']['encodingDictionary']." 0 R\n";
798
+      } else  if (isset($o['info']['encoding'])) {
799 799
         // use the specified encoding
800
-        $res.=  "/Encoding /".$o['info']['encoding']."\n";
800
+        $res .= "/Encoding /".$o['info']['encoding']."\n";
801 801
       }
802 802
 
803
-      if  (isset($o['info']['FirstChar'])) {
804
-        $res.=  "/FirstChar ".$o['info']['FirstChar']."\n";
803
+      if (isset($o['info']['FirstChar'])) {
804
+        $res .= "/FirstChar ".$o['info']['FirstChar']."\n";
805 805
       }
806 806
 
807
-      if  (isset($o['info']['LastChar'])) {
808
-        $res.=  "/LastChar ".$o['info']['LastChar']."\n";
807
+      if (isset($o['info']['LastChar'])) {
808
+        $res .= "/LastChar ".$o['info']['LastChar']."\n";
809 809
       }
810 810
 
811
-      if  (isset($o['info']['Widths'])) {
812
-        $res.=  "/Widths ".$o['info']['Widths']." 0 R\n";
811
+      if (isset($o['info']['Widths'])) {
812
+        $res .= "/Widths ".$o['info']['Widths']." 0 R\n";
813 813
       }
814 814
 
815
-      if  (isset($o['info']['FontDescriptor'])) {
816
-        $res.=  "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n";
815
+      if (isset($o['info']['FontDescriptor'])) {
816
+        $res .= "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n";
817 817
       }
818 818
 
819
-        $res.=  ">>\n";
820
-        $res.=  "endobj";
819
+        $res .= ">>\n";
820
+        $res .= "endobj";
821 821
       }
822 822
 
823 823
       return  $res;
@@ -829,11 +829,11 @@  discard block
 block discarded – undo
829 829
    * a font descriptor, needed for including additional fonts
830 830
    */
831 831
   protected function  o_fontDescriptor($id, $action, $options = '') {
832
-    if  ($action !== 'new') {
832
+    if ($action !== 'new') {
833 833
       $o = & $this->objects[$id];
834 834
     }
835 835
 
836
-    switch  ($action) {
836
+    switch ($action) {
837 837
     case  'new':
838 838
       $this->objects[$id] = array('t'=>'fontDescriptor', 'info'=>$options);
839 839
       break;
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
     case  'out':
842 842
       $res = "\n".$id." 0 obj\n<< /Type /FontDescriptor\n";
843 843
       foreach ($o['info'] as  $label => $value) {
844
-        switch  ($label) {
844
+        switch ($label) {
845 845
         case  'Ascent':
846 846
         case  'CapHeight':
847 847
         case  'Descent':
@@ -855,28 +855,28 @@  discard block
 block discarded – undo
855 855
         case  'StemH':
856 856
         case  'XHeight':
857 857
         case  'CharSet':
858
-          if  (mb_strlen($value, '8bit')) {
859
-            $res.= '/'.$label.' '.$value."\n";
858
+          if (mb_strlen($value, '8bit')) {
859
+            $res .= '/'.$label.' '.$value."\n";
860 860
           }
861 861
 
862 862
           break;
863 863
         case  'FontFile':
864 864
         case  'FontFile2':
865 865
         case  'FontFile3':
866
-          $res.= '/'.$label.' '.$value." 0 R\n";
866
+          $res .= '/'.$label.' '.$value." 0 R\n";
867 867
           break;
868 868
 
869 869
         case  'FontBBox':
870
-          $res.= '/'.$label.' ['.$value[0].' '.$value[1].' '.$value[2].' '.$value[3]."]\n";
870
+          $res .= '/'.$label.' ['.$value[0].' '.$value[1].' '.$value[2].' '.$value[3]."]\n";
871 871
           break;
872 872
 
873 873
         case  'FontName':
874
-          $res.= '/'.$label.' /'.$value."\n";
874
+          $res .= '/'.$label.' /'.$value."\n";
875 875
           break;
876 876
         }
877 877
       }
878 878
 
879
-      $res.= ">>\nendobj";
879
+      $res .= ">>\nendobj";
880 880
 
881 881
       return  $res;
882 882
     }
@@ -887,11 +887,11 @@  discard block
 block discarded – undo
887 887
    * the font encoding
888 888
    */
889 889
   protected function  o_fontEncoding($id, $action, $options = '') {
890
-    if  ($action !== 'new') {
890
+    if ($action !== 'new') {
891 891
       $o = & $this->objects[$id];
892 892
     }
893 893
 
894
-    switch  ($action) {
894
+    switch ($action) {
895 895
     case  'new':
896 896
       // the options array should contain 'differences' and maybe 'encoding'
897 897
       $this->objects[$id] = array('t'=>'fontEncoding', 'info'=>$options);
@@ -899,30 +899,30 @@  discard block
 block discarded – undo
899 899
 
900 900
     case  'out':
901 901
       $res = "\n".$id." 0 obj\n<< /Type /Encoding\n";
902
-      if  (!isset($o['info']['encoding'])) {
902
+      if (!isset($o['info']['encoding'])) {
903 903
         $o['info']['encoding'] = 'WinAnsiEncoding';
904 904
       }
905 905
 
906
-      if  ($o['info']['encoding'] !== 'none') {
907
-        $res.= "/BaseEncoding /".$o['info']['encoding']."\n";
906
+      if ($o['info']['encoding'] !== 'none') {
907
+        $res .= "/BaseEncoding /".$o['info']['encoding']."\n";
908 908
       }
909 909
 
910
-      $res.= "/Differences \n[";
910
+      $res .= "/Differences \n[";
911 911
 
912 912
       $onum = -100;
913 913
 
914
-      foreach($o['info']['differences'] as  $num=>$label) {
915
-        if  ($num != $onum+1) {
914
+      foreach ($o['info']['differences'] as  $num=>$label) {
915
+        if ($num != $onum + 1) {
916 916
           // we cannot make use of consecutive numbering
917
-          $res.=  "\n".$num." /".$label;
917
+          $res .= "\n".$num." /".$label;
918 918
         } else {
919
-          $res.=  " /".$label;
919
+          $res .= " /".$label;
920 920
         }
921 921
 
922 922
         $onum = $num;
923 923
       }
924 924
 
925
-      $res.= "\n]\n>>\nendobj";
925
+      $res .= "\n]\n>>\nendobj";
926 926
       return  $res;
927 927
     }
928 928
   }
@@ -932,22 +932,22 @@  discard block
 block discarded – undo
932 932
    * a descendent cid font,  needed for unicode fonts
933 933
    */
934 934
   protected function  o_fontDescendentCID($id, $action, $options = '') {
935
-    if  ($action !== 'new') {
935
+    if ($action !== 'new') {
936 936
       $o = & $this->objects[$id];
937 937
     }
938 938
 
939
-    switch  ($action) {
939
+    switch ($action) {
940 940
     case  'new':
941
-      $this->objects[$id] =  array('t'=>'fontDescendentCID', 'info'=>$options);
941
+      $this->objects[$id] = array('t'=>'fontDescendentCID', 'info'=>$options);
942 942
 
943 943
       // we need a CID system info section
944 944
       $cidSystemInfoId = ++$this->numObj;
945 945
       $this->o_contents($cidSystemInfoId, 'new', 'raw');
946 946
       $this->objects[$id]['info']['cidSystemInfo'] = $cidSystemInfoId;
947
-      $res=   "<</Registry (Adobe)\n"; // A string identifying an issuer of character collections
948
-      $res.=  "/Ordering (UCS)\n"; // A string that uniquely names a character collection issued by a specific registry
949
-      $res.=  "/Supplement 0\n"; // The supplement number of the character collection.
950
-      $res.=  ">>";
947
+      $res = "<</Registry (Adobe)\n"; // A string identifying an issuer of character collections
948
+      $res .= "/Ordering (UCS)\n"; // A string that uniquely names a character collection issued by a specific registry
949
+      $res .= "/Supplement 0\n"; // The supplement number of the character collection.
950
+      $res .= ">>";
951 951
       $this->objects[$cidSystemInfoId]['c'] = $res;
952 952
 
953 953
       // and a CID to GID map
@@ -958,9 +958,9 @@  discard block
 block discarded – undo
958 958
 
959 959
     case  'add':
960 960
       foreach ($options as  $k => $v) {
961
-        switch  ($k) {
961
+        switch ($k) {
962 962
         case  'BaseFont':
963
-          $o['info']['name'] =  $v;
963
+          $o['info']['name'] = $v;
964 964
           break;
965 965
 
966 966
         case  'FirstChar':
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
         case  'FontDescriptor':
970 970
         case  'SubType':
971 971
           $this->addMessage('o_fontDescendentCID '.$k." : ".$v);
972
-          $o['info'][$k] =  $v;
972
+          $o['info'][$k] = $v;
973 973
           break;
974 974
         }
975 975
       }
@@ -979,11 +979,11 @@  discard block
 block discarded – undo
979 979
       break;
980 980
 
981 981
     case  'out':
982
-      $res =  "\n".$id." 0 obj\n";
983
-      $res.=  "<</Type /Font\n";
984
-      $res.=  "/Subtype /CIDFontType2\n";
985
-      $res.=  "/BaseFont /".$o['info']['name']."\n";
986
-      $res.=  "/CIDSystemInfo ".$o['info']['cidSystemInfo']." 0 R\n";
982
+      $res = "\n".$id." 0 obj\n";
983
+      $res .= "<</Type /Font\n";
984
+      $res .= "/Subtype /CIDFontType2\n";
985
+      $res .= "/BaseFont /".$o['info']['name']."\n";
986
+      $res .= "/CIDSystemInfo ".$o['info']['cidSystemInfo']." 0 R\n";
987 987
 //      if  (isset($o['info']['FirstChar'])) {
988 988
 //        $res.=  "/FirstChar ".$o['info']['FirstChar']."\n";
989 989
 //      }
@@ -991,26 +991,26 @@  discard block
 block discarded – undo
991 991
 //      if  (isset($o['info']['LastChar'])) {
992 992
 //        $res.=  "/LastChar ".$o['info']['LastChar']."\n";
993 993
 //      }
994
-      if  (isset($o['info']['FontDescriptor'])) {
995
-        $res.=  "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n";
994
+      if (isset($o['info']['FontDescriptor'])) {
995
+        $res .= "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n";
996 996
       }
997 997
 
998
-      if  (isset($o['info']['MissingWidth'])) {
999
-        $res.=  "/DW ".$o['info']['MissingWidth']."\n";
998
+      if (isset($o['info']['MissingWidth'])) {
999
+        $res .= "/DW ".$o['info']['MissingWidth']."\n";
1000 1000
       }
1001 1001
 
1002
-      if  (isset($o['info']['fontFileName']) && isset($this->fonts[$o['info']['fontFileName']]['CIDWidths'])) {
1002
+      if (isset($o['info']['fontFileName']) && isset($this->fonts[$o['info']['fontFileName']]['CIDWidths'])) {
1003 1003
         $cid_widths = &$this->fonts[$o['info']['fontFileName']]['CIDWidths'];
1004 1004
         $w = '';
1005 1005
         foreach ($cid_widths as $cid => $width) {
1006 1006
           $w .= $cid.' ['.$width.'] ';
1007 1007
         }
1008
-        $res.=  "/W [".$w."]\n";
1008
+        $res .= "/W [".$w."]\n";
1009 1009
       }
1010 1010
 
1011
-      $res.=  "/CIDToGIDMap ".$o['info']['cidToGidMap']." 0 R\n";
1012
-      $res.=  ">>\n";
1013
-      $res.=  "endobj";
1011
+      $res .= "/CIDToGIDMap ".$o['info']['cidToGidMap']." 0 R\n";
1012
+      $res .= ">>\n";
1013
+      $res .= "endobj";
1014 1014
 
1015 1015
       return  $res;
1016 1016
     }
@@ -1021,13 +1021,13 @@  discard block
 block discarded – undo
1021 1021
    * a font glyph to character map,  needed for unicode fonts
1022 1022
    */
1023 1023
   protected function  o_fontGIDtoCIDMap($id, $action, $options = '') {
1024
-    if  ($action !== 'new') {
1024
+    if ($action !== 'new') {
1025 1025
       $o = & $this->objects[$id];
1026 1026
     }
1027 1027
 
1028
-    switch  ($action) {
1028
+    switch ($action) {
1029 1029
     case  'new':
1030
-      $this->objects[$id] =  array('t'=>'fontGIDtoCIDMap', 'info'=>$options);
1030
+      $this->objects[$id] = array('t'=>'fontGIDtoCIDMap', 'info'=>$options);
1031 1031
       break;
1032 1032
 
1033 1033
     case  'out':
@@ -1036,24 +1036,24 @@  discard block
 block discarded – undo
1036 1036
       $compressed = isset($this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed']) &&
1037 1037
                     $this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed'];
1038 1038
 
1039
-      if  (!$compressed && isset($o['raw'])) {
1040
-        $res.= $tmp;
1039
+      if (!$compressed && isset($o['raw'])) {
1040
+        $res .= $tmp;
1041 1041
       } else {
1042
-        $res.=  "<<";
1042
+        $res .= "<<";
1043 1043
 
1044
-        if  (!$compressed && function_exists('gzcompress') &&  $this->options['compression']) {
1044
+        if (!$compressed && function_exists('gzcompress') && $this->options['compression']) {
1045 1045
           // then implement ZLIB based compression on this content stream
1046 1046
           $compressed = true;
1047
-          $tmp =  gzcompress($tmp,  6);
1047
+          $tmp = gzcompress($tmp, 6);
1048 1048
         }
1049 1049
         if ($compressed) {
1050
-          $res.= "\n/Filter /FlateDecode";
1050
+          $res .= "\n/Filter /FlateDecode";
1051 1051
         }
1052 1052
 
1053
-        $res.= "\n/Length ".mb_strlen($tmp, '8bit') .">>\nstream\n".$tmp."\nendstream";
1053
+        $res .= "\n/Length ".mb_strlen($tmp, '8bit').">>\nstream\n".$tmp."\nendstream";
1054 1054
       }
1055 1055
 
1056
-      $res.= "\nendobj";
1056
+      $res .= "\nendobj";
1057 1057
       return  $res;
1058 1058
     }
1059 1059
   }
@@ -1063,11 +1063,11 @@  discard block
 block discarded – undo
1063 1063
    * the document procset, solves some problems with printing to old PS printers
1064 1064
    */
1065 1065
   protected function  o_procset($id, $action, $options = '') {
1066
-    if  ($action !== 'new') {
1066
+    if ($action !== 'new') {
1067 1067
       $o = & $this->objects[$id];
1068 1068
     }
1069 1069
 
1070
-    switch  ($action) {
1070
+    switch ($action) {
1071 1071
     case  'new':
1072 1072
       $this->objects[$id] = array('t'=>'procset', 'info'=>array('PDF'=>1, 'Text'=>1));
1073 1073
       $this->o_pages($this->currentNode, 'procset', $id);
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
     case  'add':
1078 1078
       // this is to add new items to the procset list, despite the fact that this is considered
1079 1079
       // obselete, the items are required for printing to some postscript printers
1080
-      switch  ($options) {
1080
+      switch ($options) {
1081 1081
       case  'ImageB':
1082 1082
       case  'ImageC':
1083 1083
       case  'ImageI':
@@ -1089,9 +1089,9 @@  discard block
 block discarded – undo
1089 1089
     case  'out':
1090 1090
       $res = "\n".$id." 0 obj\n[";
1091 1091
       foreach ($o['info'] as  $label=>$val) {
1092
-        $res.= '/'.$label.' ';
1092
+        $res .= '/'.$label.' ';
1093 1093
       }
1094
-      $res.= "]\nendobj";
1094
+      $res .= "]\nendobj";
1095 1095
       return  $res;
1096 1096
     }
1097 1097
   }
@@ -1101,11 +1101,11 @@  discard block
 block discarded – undo
1101 1101
    * define the document information
1102 1102
    */
1103 1103
   protected function  o_info($id, $action, $options = '') {
1104
-    if  ($action !== 'new') {
1104
+    if ($action !== 'new') {
1105 1105
       $o = & $this->objects[$id];
1106 1106
     }
1107 1107
 
1108
-    switch  ($action) {
1108
+    switch ($action) {
1109 1109
     case  'new':
1110 1110
       $this->infoObject = $id;
1111 1111
       $date = 'D:'.@date('Ymd');
@@ -1124,26 +1124,26 @@  discard block
 block discarded – undo
1124 1124
       break;
1125 1125
 
1126 1126
     case  'out':
1127
-      if  ($this->encrypted) {
1127
+      if ($this->encrypted) {
1128 1128
         $this->encryptInit($id);
1129 1129
       }
1130 1130
 
1131 1131
       $res = "\n".$id." 0 obj\n<<\n";
1132 1132
       foreach ($o['info'] as  $k=>$v) {
1133
-        $res.= '/'.$k.' (';
1133
+        $res .= '/'.$k.' (';
1134 1134
         // dates must be outputted as-is, without Unicode transformations
1135 1135
         $raw = ($k === 'CreationDate' || $k === 'ModDate');
1136 1136
         $c = $v;
1137 1137
 
1138
-        if  ($this->encrypted) {
1138
+        if ($this->encrypted) {
1139 1139
           $c = $this->ARC4($c);
1140 1140
         }
1141 1141
 
1142
-        $res.= ($raw) ? $c : $this->filterText($c);
1143
-        $res.= ")\n";
1142
+        $res .= ($raw) ? $c : $this->filterText($c);
1143
+        $res .= ")\n";
1144 1144
       }
1145 1145
 
1146
-      $res.= ">>\nendobj";
1146
+      $res .= ">>\nendobj";
1147 1147
       return  $res;
1148 1148
     }
1149 1149
   }
@@ -1153,13 +1153,13 @@  discard block
 block discarded – undo
1153 1153
    * an action object, used to link to URLS initially
1154 1154
    */
1155 1155
   protected function  o_action($id, $action, $options = '') {
1156
-    if  ($action !== 'new') {
1156
+    if ($action !== 'new') {
1157 1157
       $o = & $this->objects[$id];
1158 1158
     }
1159 1159
 
1160
-    switch  ($action) {
1160
+    switch ($action) {
1161 1161
     case  'new':
1162
-      if  (is_array($options)) {
1162
+      if (is_array($options)) {
1163 1163
         $this->objects[$id] = array('t'=>'action', 'info'=>$options, 'type'=>$options['type']);
1164 1164
       } else {
1165 1165
         // then assume a URI action
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
       break;
1169 1169
 
1170 1170
     case  'out':
1171
-      if  ($this->encrypted) {
1171
+      if ($this->encrypted) {
1172 1172
         $this->encryptInit($id);
1173 1173
       }
1174 1174
 
@@ -1176,22 +1176,22 @@  discard block
 block discarded – undo
1176 1176
       switch ($o['type']) {
1177 1177
       case  'ilink':
1178 1178
         // there will be an 'label' setting, this is the name of the destination
1179
-        $res.= "\n/S /GoTo\n/D ".$this->destinations[(string)$o['info']['label']]." 0 R";
1179
+        $res .= "\n/S /GoTo\n/D ".$this->destinations[(string) $o['info']['label']]." 0 R";
1180 1180
         break;
1181 1181
 
1182 1182
       case  'URI':
1183
-        $res.= "\n/S /URI\n/URI (";
1184
-        if  ($this->encrypted) {
1185
-          $res.= $this->filterText($this->ARC4($o['info']));
1183
+        $res .= "\n/S /URI\n/URI (";
1184
+        if ($this->encrypted) {
1185
+          $res .= $this->filterText($this->ARC4($o['info']));
1186 1186
         } else {
1187
-          $res.= $this->filterText($o['info']);
1187
+          $res .= $this->filterText($o['info']);
1188 1188
         }
1189 1189
 
1190
-        $res.= ")";
1190
+        $res .= ")";
1191 1191
         break;
1192 1192
       }
1193 1193
 
1194
-      $res.= "\n>>\nendobj";
1194
+      $res .= "\n>>\nendobj";
1195 1195
       return  $res;
1196 1196
     }
1197 1197
   }
@@ -1202,14 +1202,14 @@  discard block
 block discarded – undo
1202 1202
    * initially will support just link annotations
1203 1203
    */
1204 1204
   protected function  o_annotation($id, $action, $options = '') {
1205
-    if  ($action !== 'new') {
1205
+    if ($action !== 'new') {
1206 1206
       $o = & $this->objects[$id];
1207 1207
     }
1208 1208
 
1209
-    switch  ($action) {
1209
+    switch ($action) {
1210 1210
     case  'new':
1211 1211
       // add the annotation to the current page
1212
-      $pageId =  $this->currentPage;
1212
+      $pageId = $this->currentPage;
1213 1213
       $this->o_page($pageId, 'annot', $id);
1214 1214
 
1215 1215
       // and add the action object which is going to be required
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 
1224 1224
       case  'ilink':
1225 1225
         // this is to a named internal link
1226
-        $label =  $options['label'];
1226
+        $label = $options['label'];
1227 1227
         $this->objects[$id] = array('t'=>'annotation', 'info'=>$options);
1228 1228
         $this->numObj++;
1229 1229
         $this->o_action($this->numObj, 'new', array('type'=>'ilink', 'label'=>$label));
@@ -1237,20 +1237,20 @@  discard block
 block discarded – undo
1237 1237
       switch ($o['info']['type']) {
1238 1238
       case  'link':
1239 1239
       case  'ilink':
1240
-        $res.=  "\n/Subtype /Link";
1240
+        $res .= "\n/Subtype /Link";
1241 1241
         break;
1242 1242
       }
1243
-      $res.= "\n/A ".$o['info']['actionId']." 0 R";
1244
-      $res.= "\n/Border [0 0 0]";
1245
-      $res.= "\n/H /I";
1246
-      $res.= "\n/Rect [ ";
1243
+      $res .= "\n/A ".$o['info']['actionId']." 0 R";
1244
+      $res .= "\n/Border [0 0 0]";
1245
+      $res .= "\n/H /I";
1246
+      $res .= "\n/Rect [ ";
1247 1247
 
1248
-      foreach($o['info']['rect'] as  $v) {
1249
-        $res.=  sprintf("%.4F ", $v);
1248
+      foreach ($o['info']['rect'] as  $v) {
1249
+        $res .= sprintf("%.4F ", $v);
1250 1250
       }
1251 1251
 
1252
-      $res.= "]";
1253
-      $res.= "\n>>\nendobj";
1252
+      $res .= "]";
1253
+      $res .= "\n>>\nendobj";
1254 1254
       return  $res;
1255 1255
     }
1256 1256
   }
@@ -1260,16 +1260,16 @@  discard block
 block discarded – undo
1260 1260
    * a page object, it also creates a contents object to hold its contents
1261 1261
    */
1262 1262
   protected function  o_page($id, $action, $options = '') {
1263
-    if  ($action !== 'new') {
1263
+    if ($action !== 'new') {
1264 1264
       $o = & $this->objects[$id];
1265 1265
     }
1266 1266
 
1267
-    switch  ($action) {
1267
+    switch ($action) {
1268 1268
     case  'new':
1269 1269
       $this->numPages++;
1270 1270
       $this->objects[$id] = array('t'=>'page', 'info'=>array('parent'=>$this->currentNode, 'pageNum'=>$this->numPages));
1271 1271
 
1272
-      if  (is_array($options)) {
1272
+      if (is_array($options)) {
1273 1273
         // then this must be a page insertion, array should contain 'rid','pos'=[before|after]
1274 1274
         $options['id'] = $id;
1275 1275
         $this->o_pages($this->currentNode, 'page', $options);
@@ -1285,9 +1285,9 @@  discard block
 block discarded – undo
1285 1285
       $this->objects[$id]['info']['contents'] = array();
1286 1286
       $this->objects[$id]['info']['contents'][] = $this->numObj;
1287 1287
 
1288
-      $match =  ($this->numPages%2 ?  'odd' :  'even');
1289
-      foreach($this->addLooseObjects as  $oId=>$target) {
1290
-        if  ($target === 'all' || $match === $target) {
1288
+      $match = ($this->numPages % 2 ? 'odd' : 'even');
1289
+      foreach ($this->addLooseObjects as  $oId=>$target) {
1290
+        if ($target === 'all' || $match === $target) {
1291 1291
           $this->objects[$id]['info']['contents'][] = $oId;
1292 1292
         }
1293 1293
       }
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
 
1300 1300
     case  'annot':
1301 1301
       // add an annotation to this page
1302
-      if  (!isset($o['info']['annot'])) {
1302
+      if (!isset($o['info']['annot'])) {
1303 1303
         $o['info']['annot'] = array();
1304 1304
       }
1305 1305
 
@@ -1309,32 +1309,32 @@  discard block
 block discarded – undo
1309 1309
 
1310 1310
     case  'out':
1311 1311
       $res = "\n".$id." 0 obj\n<< /Type /Page";
1312
-      $res.= "\n/Parent ".$o['info']['parent']." 0 R";
1312
+      $res .= "\n/Parent ".$o['info']['parent']." 0 R";
1313 1313
 
1314
-      if  (isset($o['info']['annot'])) {
1315
-        $res.= "\n/Annots [";
1316
-        foreach($o['info']['annot'] as  $aId) {
1317
-          $res.= " ".$aId." 0 R";
1314
+      if (isset($o['info']['annot'])) {
1315
+        $res .= "\n/Annots [";
1316
+        foreach ($o['info']['annot'] as  $aId) {
1317
+          $res .= " ".$aId." 0 R";
1318 1318
         }
1319
-        $res.= " ]";
1319
+        $res .= " ]";
1320 1320
       }
1321 1321
 
1322
-      $count =  count($o['info']['contents']);
1323
-      if  ($count == 1) {
1324
-        $res.= "\n/Contents ".$o['info']['contents'][0]." 0 R";
1325
-      } else  if  ($count>1) {
1326
-        $res.= "\n/Contents [\n";
1322
+      $count = count($o['info']['contents']);
1323
+      if ($count == 1) {
1324
+        $res .= "\n/Contents ".$o['info']['contents'][0]." 0 R";
1325
+      } else  if ($count > 1) {
1326
+        $res .= "\n/Contents [\n";
1327 1327
 
1328 1328
         // reverse the page contents so added objects are below normal content
1329 1329
         //foreach (array_reverse($o['info']['contents']) as  $cId) {
1330 1330
         // Back to normal now that I've got transparency working --Benj
1331 1331
         foreach ($o['info']['contents'] as  $cId) {
1332
-          $res.= $cId." 0 R\n";
1332
+          $res .= $cId." 0 R\n";
1333 1333
         }
1334
-        $res.= "]";
1334
+        $res .= "]";
1335 1335
       }
1336 1336
 
1337
-      $res.= "\n>>\nendobj";
1337
+      $res .= "\n>>\nendobj";
1338 1338
       return  $res;
1339 1339
     }
1340 1340
   }
@@ -1344,17 +1344,17 @@  discard block
 block discarded – undo
1344 1344
    * the contents objects hold all of the content which appears on pages
1345 1345
    */
1346 1346
   protected function  o_contents($id, $action, $options = '') {
1347
-    if  ($action !== 'new') {
1347
+    if ($action !== 'new') {
1348 1348
       $o = & $this->objects[$id];
1349 1349
     }
1350 1350
 
1351
-    switch  ($action) {
1351
+    switch ($action) {
1352 1352
     case  'new':
1353 1353
       $this->objects[$id] = array('t'=>'contents', 'c'=>'', 'info'=>array());
1354
-      if  (mb_strlen($options, '8bit') &&  intval($options)) {
1354
+      if (mb_strlen($options, '8bit') && intval($options)) {
1355 1355
         // then this contents is the primary for a page
1356 1356
         $this->objects[$id]['onPage'] = $options;
1357
-      } else  if  ($options === 'raw') {
1357
+      } else  if ($options === 'raw') {
1358 1358
         // then this page contains some other type of system object
1359 1359
         $this->objects[$id]['raw'] = 1;
1360 1360
       }
@@ -1368,63 +1368,63 @@  discard block
 block discarded – undo
1368 1368
 
1369 1369
     case  'out':
1370 1370
       $tmp = $o['c'];
1371
-      $res =  "\n".$id." 0 obj\n";
1371
+      $res = "\n".$id." 0 obj\n";
1372 1372
 
1373
-      if  (isset($this->objects[$id]['raw'])) {
1374
-        $res.= $tmp;
1373
+      if (isset($this->objects[$id]['raw'])) {
1374
+        $res .= $tmp;
1375 1375
       } else {
1376
-        $res.=  "<<";
1377
-        if  (function_exists('gzcompress') &&  $this->options['compression']) {
1376
+        $res .= "<<";
1377
+        if (function_exists('gzcompress') && $this->options['compression']) {
1378 1378
           // then implement ZLIB based compression on this content stream
1379
-          $res.= " /Filter /FlateDecode";
1380
-          $tmp =  gzcompress($tmp,  6);
1379
+          $res .= " /Filter /FlateDecode";
1380
+          $tmp = gzcompress($tmp, 6);
1381 1381
         }
1382 1382
 
1383
-        if  ($this->encrypted) {
1383
+        if ($this->encrypted) {
1384 1384
           $this->encryptInit($id);
1385
-          $tmp =  $this->ARC4($tmp);
1385
+          $tmp = $this->ARC4($tmp);
1386 1386
         }
1387 1387
 
1388
-        foreach($o['info'] as  $k=>$v) {
1389
-          $res.=  "\n/".$k.' '.$v;
1388
+        foreach ($o['info'] as  $k=>$v) {
1389
+          $res .= "\n/".$k.' '.$v;
1390 1390
         }
1391 1391
 
1392
-        $res.= "\n/Length ".mb_strlen($tmp, '8bit') ." >>\nstream\n".$tmp."\nendstream";
1392
+        $res .= "\n/Length ".mb_strlen($tmp, '8bit')." >>\nstream\n".$tmp."\nendstream";
1393 1393
       }
1394 1394
 
1395
-      $res.= "\nendobj";
1395
+      $res .= "\nendobj";
1396 1396
       return  $res;
1397 1397
     }
1398 1398
   }
1399 1399
 
1400 1400
   protected function  o_embedjs($id, $action, $code = '') {
1401
-    if  ($action !== 'new') {
1401
+    if ($action !== 'new') {
1402 1402
       $o = & $this->objects[$id];
1403 1403
     }
1404 1404
 
1405
-    switch  ($action) {
1405
+    switch ($action) {
1406 1406
     case  'new':
1407 1407
       $this->objects[$id] = array('t'=>'embedjs', 'info'=>array(
1408
-        'Names' => '[(EmbeddedJS) '.($id+1).' 0 R]'
1408
+        'Names' => '[(EmbeddedJS) '.($id + 1).' 0 R]'
1409 1409
       ));
1410 1410
       break;
1411 1411
 
1412 1412
     case  'out':
1413 1413
       $res .= "\n".$id." 0 obj\n".'<< ';
1414
-      foreach($o['info'] as  $k=>$v) {
1415
-        $res.=  "\n/".$k.' '.$v;
1414
+      foreach ($o['info'] as  $k=>$v) {
1415
+        $res .= "\n/".$k.' '.$v;
1416 1416
       }
1417
-      $res.= "\n>>\nendobj";
1417
+      $res .= "\n>>\nendobj";
1418 1418
       return  $res;
1419 1419
     }
1420 1420
   }
1421 1421
   
1422 1422
   protected function  o_javascript($id, $action, $code = '') {
1423
-    if  ($action !== 'new') {
1423
+    if ($action !== 'new') {
1424 1424
       $o = & $this->objects[$id];
1425 1425
     }
1426 1426
 
1427
-    switch  ($action) {
1427
+    switch ($action) {
1428 1428
     case  'new':
1429 1429
       $this->objects[$id] = array('t'=>'javascript', 'info'=>array(
1430 1430
         'S' => '/JavaScript',
@@ -1434,10 +1434,10 @@  discard block
 block discarded – undo
1434 1434
 
1435 1435
     case  'out':
1436 1436
       $res = "\n".$id." 0 obj\n".'<< ';
1437
-      foreach($o['info'] as  $k=>$v) {
1438
-        $res.=  "\n/".$k.' '.$v;
1437
+      foreach ($o['info'] as  $k=>$v) {
1438
+        $res .= "\n/".$k.' '.$v;
1439 1439
       }
1440
-      $res.= "\n>>\nendobj";
1440
+      $res .= "\n>>\nendobj";
1441 1441
       return  $res;
1442 1442
     }
1443 1443
   }
@@ -1446,7 +1446,7 @@  discard block
 block discarded – undo
1446 1446
    * an image object, will be an XObject in the document, includes description and data
1447 1447
    */
1448 1448
   protected function  o_image($id, $action, $options = '') {
1449
-    if  ($action !== 'new') {
1449
+    if ($action !== 'new') {
1450 1450
       $o = & $this->objects[$id];
1451 1451
     }
1452 1452
 
@@ -1459,8 +1459,8 @@  discard block
 block discarded – undo
1459 1459
       $this->objects[$id]['info']['Width'] = $options['iw'];
1460 1460
       $this->objects[$id]['info']['Height'] = $options['ih'];
1461 1461
 
1462
-      if  (!isset($options['type']) ||  $options['type'] === 'jpg') {
1463
-        if  (!isset($options['channels'])) {
1462
+      if (!isset($options['type']) || $options['type'] === 'jpg') {
1463
+        if (!isset($options['channels'])) {
1464 1464
           $options['channels'] = 3;
1465 1465
         }
1466 1466
 
@@ -1476,30 +1476,30 @@  discard block
 block discarded – undo
1476 1476
 
1477 1477
         $this->objects[$id]['info']['Filter'] = '/DCTDecode';
1478 1478
         $this->objects[$id]['info']['BitsPerComponent'] = 8;
1479
-      } else  if  ($options['type'] === 'png') {
1479
+      } else  if ($options['type'] === 'png') {
1480 1480
         $this->objects[$id]['info']['Filter'] = '/FlateDecode';
1481 1481
         $this->objects[$id]['info']['DecodeParms'] = '<< /Predictor 15 /Colors '.$options['ncolor'].' /Columns '.$options['iw'].' /BitsPerComponent '.$options['bitsPerComponent'].'>>';
1482 1482
 
1483
-        if  (mb_strlen($options['pdata'], '8bit')) {
1484
-          $tmp =  ' [ /Indexed /DeviceRGB '.(mb_strlen($options['pdata'], '8bit') /3-1) .' ';
1483
+        if (mb_strlen($options['pdata'], '8bit')) {
1484
+          $tmp = ' [ /Indexed /DeviceRGB '.(mb_strlen($options['pdata'], '8bit') / 3 - 1).' ';
1485 1485
           $this->numObj++;
1486 1486
           $this->o_contents($this->numObj, 'new');
1487 1487
           $this->objects[$this->numObj]['c'] = $options['pdata'];
1488
-          $tmp.= $this->numObj.' 0 R';
1489
-          $tmp.= ' ]';
1490
-          $this->objects[$id]['info']['ColorSpace'] =  $tmp;
1491
-          if  (isset($options['transparency'])) {
1488
+          $tmp .= $this->numObj.' 0 R';
1489
+          $tmp .= ' ]';
1490
+          $this->objects[$id]['info']['ColorSpace'] = $tmp;
1491
+          if (isset($options['transparency'])) {
1492 1492
             switch ($options['transparency']['type']) {
1493 1493
             case  'indexed':
1494 1494
               $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] ';
1495
-              $this->objects[$id]['info']['Mask'] =  $tmp;
1495
+              $this->objects[$id]['info']['Mask'] = $tmp;
1496 1496
               break;
1497 1497
 
1498 1498
             case 'color-key':
1499 1499
               $tmp = ' [ '.
1500
-                $options['transparency']['r'] . ' ' . $options['transparency']['r'] .
1501
-                $options['transparency']['g'] . ' ' . $options['transparency']['g'] .
1502
-                $options['transparency']['b'] . ' ' . $options['transparency']['b'] .
1500
+                $options['transparency']['r'].' '.$options['transparency']['r'].
1501
+                $options['transparency']['g'].' '.$options['transparency']['g'].
1502
+                $options['transparency']['b'].' '.$options['transparency']['b'].
1503 1503
                 ' ] ';
1504 1504
               $this->objects[$id]['info']['Mask'] = $tmp;
1505 1505
               pre_r($tmp);
@@ -1508,18 +1508,18 @@  discard block
 block discarded – undo
1508 1508
             }
1509 1509
           }
1510 1510
         } else {
1511
-          if  (isset($options['transparency'])) {
1511
+          if (isset($options['transparency'])) {
1512 1512
             switch ($options['transparency']['type']) {
1513 1513
             case  'indexed':
1514 1514
               $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] ';
1515
-              $this->objects[$id]['info']['Mask'] =  $tmp;
1515
+              $this->objects[$id]['info']['Mask'] = $tmp;
1516 1516
               break;
1517 1517
 
1518 1518
             case 'color-key':
1519 1519
               $tmp = ' [ '.
1520
-                $options['transparency']['r'] . ' ' . $options['transparency']['r'] . ' ' .
1521
-                $options['transparency']['g'] . ' ' . $options['transparency']['g'] . ' ' .
1522
-                $options['transparency']['b'] . ' ' . $options['transparency']['b'] .
1520
+                $options['transparency']['r'].' '.$options['transparency']['r'].' '.
1521
+                $options['transparency']['g'].' '.$options['transparency']['g'].' '.
1522
+                $options['transparency']['b'].' '.$options['transparency']['b'].
1523 1523
                 ' ] ';
1524 1524
               $this->objects[$id]['info']['Mask'] = $tmp;
1525 1525
               break;              
@@ -1541,18 +1541,18 @@  discard block
 block discarded – undo
1541 1541
 
1542 1542
     case  'out':
1543 1543
       $tmp = &$o['data'];
1544
-      $res =  "\n".$id." 0 obj\n<<";
1544
+      $res = "\n".$id." 0 obj\n<<";
1545 1545
 
1546
-      foreach($o['info'] as  $k=>$v) {
1547
-        $res.= "\n/".$k.' '.$v;
1546
+      foreach ($o['info'] as  $k=>$v) {
1547
+        $res .= "\n/".$k.' '.$v;
1548 1548
       }
1549 1549
 
1550
-      if  ($this->encrypted) {
1550
+      if ($this->encrypted) {
1551 1551
         $this->encryptInit($id);
1552
-        $tmp =  $this->ARC4($tmp);
1552
+        $tmp = $this->ARC4($tmp);
1553 1553
       }
1554 1554
 
1555
-      $res.= "\n/Length ".mb_strlen($tmp, '8bit') .">>\nstream\n".$tmp."\nendstream\nendobj";
1555
+      $res .= "\n/Length ".mb_strlen($tmp, '8bit').">>\nstream\n".$tmp."\nendstream\nendobj";
1556 1556
 
1557 1557
       return  $res;
1558 1558
     }
@@ -1562,39 +1562,39 @@  discard block
 block discarded – undo
1562 1562
   /**
1563 1563
    * graphics state object
1564 1564
    */
1565
-  protected function  o_extGState($id,  $action,  $options = "") {
1566
-    static  $valid_params =  array("LW",  "LC",  "LC",  "LJ",  "ML",
1567
-                                   "D",  "RI",  "OP",  "op",  "OPM",
1568
-                                   "Font",  "BG",  "BG2",  "UCR",
1569
-                                   "TR",  "TR2",  "HT",  "FL",
1570
-                                   "SM",  "SA",  "BM",  "SMask",
1571
-                                   "CA",  "ca",  "AIS",  "TK");
1565
+  protected function  o_extGState($id, $action, $options = "") {
1566
+    static  $valid_params = array("LW", "LC", "LC", "LJ", "ML",
1567
+                                   "D", "RI", "OP", "op", "OPM",
1568
+                                   "Font", "BG", "BG2", "UCR",
1569
+                                   "TR", "TR2", "HT", "FL",
1570
+                                   "SM", "SA", "BM", "SMask",
1571
+                                   "CA", "ca", "AIS", "TK");
1572 1572
 
1573
-    if  ($action !==  "new") {
1573
+    if ($action !== "new") {
1574 1574
       $o = & $this->objects[$id];
1575 1575
     }
1576 1576
 
1577
-    switch  ($action) {
1577
+    switch ($action) {
1578 1578
     case  "new":
1579
-      $this->objects[$id] =  array('t' => 'extGState',  'info' => $options);
1579
+      $this->objects[$id] = array('t' => 'extGState', 'info' => $options);
1580 1580
 
1581 1581
       // Tell the pages about the new resource
1582 1582
       $this->numStates++;
1583
-      $this->o_pages($this->currentNode,  'extGState',  array("objNum" => $id,  "stateNum" => $this->numStates));
1583
+      $this->o_pages($this->currentNode, 'extGState', array("objNum" => $id, "stateNum" => $this->numStates));
1584 1584
       break;
1585 1585
 
1586 1586
     case  "out":
1587 1587
       $res =
1588
-        "\n" . $id . " 0 obj\n".
1588
+        "\n".$id." 0 obj\n".
1589 1589
         "<< /Type /ExtGState\n";
1590 1590
 
1591 1591
       foreach ($o["info"] as  $parameter => $value) {
1592
-        if  ( !in_array($parameter,  $valid_params))
1592
+        if (!in_array($parameter, $valid_params))
1593 1593
           continue;
1594
-        $res.=  "/$parameter $value\n";
1594
+        $res .= "/$parameter $value\n";
1595 1595
       }
1596 1596
 
1597
-      $res.=
1597
+      $res .=
1598 1598
         ">>\n".
1599 1599
         "endobj";
1600 1600
       return  $res;
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
    * encryption object.
1607 1607
    */
1608 1608
   protected function  o_encryption($id, $action, $options = '') {
1609
-    if  ($action !== 'new') {
1609
+    if ($action !== 'new') {
1610 1610
       $o = & $this->objects[$id];
1611 1611
     }
1612 1612
 
@@ -1617,38 +1617,38 @@  discard block
 block discarded – undo
1617 1617
       $this->arc4_objnum = $id;
1618 1618
 
1619 1619
       // figure out the additional paramaters required
1620
-      $pad =  chr(0x28) .chr(0xBF) .chr(0x4E) .chr(0x5E) .chr(0x4E) .chr(0x75) .chr(0x8A) .chr(0x41) .chr(0x64) .chr(0x00) .chr(0x4E) .chr(0x56) .chr(0xFF) .chr(0xFA) .chr(0x01) .chr(0x08) .chr(0x2E) .chr(0x2E) .chr(0x00) .chr(0xB6) .chr(0xD0) .chr(0x68) .chr(0x3E) .chr(0x80) .chr(0x2F) .chr(0x0C) .chr(0xA9) .chr(0xFE) .chr(0x64) .chr(0x53) .chr(0x69) .chr(0x7A);
1621
-      $len =  mb_strlen($options['owner'], '8bit');
1620
+      $pad = chr(0x28).chr(0xBF).chr(0x4E).chr(0x5E).chr(0x4E).chr(0x75).chr(0x8A).chr(0x41).chr(0x64).chr(0x00).chr(0x4E).chr(0x56).chr(0xFF).chr(0xFA).chr(0x01).chr(0x08).chr(0x2E).chr(0x2E).chr(0x00).chr(0xB6).chr(0xD0).chr(0x68).chr(0x3E).chr(0x80).chr(0x2F).chr(0x0C).chr(0xA9).chr(0xFE).chr(0x64).chr(0x53).chr(0x69).chr(0x7A);
1621
+      $len = mb_strlen($options['owner'], '8bit');
1622 1622
 
1623
-      if  ($len>32) {
1624
-        $owner =  substr($options['owner'], 0, 32);
1625
-      } else  if  ($len<32) {
1626
-        $owner =  $options['owner'].substr($pad, 0, 32-$len);
1623
+      if ($len > 32) {
1624
+        $owner = substr($options['owner'], 0, 32);
1625
+      } else  if ($len < 32) {
1626
+        $owner = $options['owner'].substr($pad, 0, 32 - $len);
1627 1627
       } else {
1628
-        $owner =  $options['owner'];
1628
+        $owner = $options['owner'];
1629 1629
       }
1630 1630
 
1631
-      $len =  mb_strlen($options['user'], '8bit');
1632
-      if  ($len>32) {
1633
-        $user =  substr($options['user'], 0, 32);
1634
-      } else  if  ($len<32) {
1635
-        $user =  $options['user'].substr($pad, 0, 32-$len);
1631
+      $len = mb_strlen($options['user'], '8bit');
1632
+      if ($len > 32) {
1633
+        $user = substr($options['user'], 0, 32);
1634
+      } else  if ($len < 32) {
1635
+        $user = $options['user'].substr($pad, 0, 32 - $len);
1636 1636
       } else {
1637
-        $user =  $options['user'];
1637
+        $user = $options['user'];
1638 1638
       }
1639 1639
 
1640
-      $tmp =  $this->md5_16($owner);
1641
-      $okey =  substr($tmp, 0, 5);
1640
+      $tmp = $this->md5_16($owner);
1641
+      $okey = substr($tmp, 0, 5);
1642 1642
       $this->ARC4_init($okey);
1643 1643
       $ovalue = $this->ARC4($user);
1644 1644
       $this->objects[$id]['info']['O'] = $ovalue;
1645 1645
 
1646 1646
       // now make the u value, phew.
1647
-      $tmp =  $this->md5_16($user.$ovalue.chr($options['p']) .chr(255) .chr(255) .chr(255) .$this->fileIdentifier);
1647
+      $tmp = $this->md5_16($user.$ovalue.chr($options['p']).chr(255).chr(255).chr(255).$this->fileIdentifier);
1648 1648
 
1649
-      $ukey =  substr($tmp, 0, 5);
1649
+      $ukey = substr($tmp, 0, 5);
1650 1650
       $this->ARC4_init($ukey);
1651
-      $this->encryptionKey =  $ukey;
1651
+      $this->encryptionKey = $ukey;
1652 1652
       $this->encrypted = 1;
1653 1653
       $uvalue = $this->ARC4($pad);
1654 1654
       $this->objects[$id]['info']['U'] = $uvalue;
@@ -1657,16 +1657,16 @@  discard block
 block discarded – undo
1657 1657
       break;
1658 1658
 
1659 1659
     case  'out':
1660
-      $res =  "\n".$id." 0 obj\n<<";
1661
-      $res.= "\n/Filter /Standard";
1662
-      $res.= "\n/V 1";
1663
-      $res.= "\n/R 2";
1664
-      $res.= "\n/O (".$this->filterText($o['info']['O']) .')';
1665
-      $res.= "\n/U (".$this->filterText($o['info']['U']) .')';
1660
+      $res = "\n".$id." 0 obj\n<<";
1661
+      $res .= "\n/Filter /Standard";
1662
+      $res .= "\n/V 1";
1663
+      $res .= "\n/R 2";
1664
+      $res .= "\n/O (".$this->filterText($o['info']['O']).')';
1665
+      $res .= "\n/U (".$this->filterText($o['info']['U']).')';
1666 1666
       // and the p-value needs to be converted to account for the twos-complement approach
1667
-      $o['info']['p'] =  (($o['info']['p']^255) +1) *-1;
1668
-      $res.= "\n/P ".($o['info']['p']);
1669
-      $res.= "\n>>\nendobj";
1667
+      $o['info']['p'] = (($o['info']['p'] ^ 255) + 1) * -1;
1668
+      $res .= "\n/P ".($o['info']['p']);
1669
+      $res .= "\n>>\nendobj";
1670 1670
       return  $res;
1671 1671
     }
1672 1672
   }
@@ -1681,10 +1681,10 @@  discard block
 block discarded – undo
1681 1681
    * calculate the 16 byte version of the 128 bit md5 digest of the string
1682 1682
    */
1683 1683
   function  md5_16($string) {
1684
-    $tmp =  md5($string);
1684
+    $tmp = md5($string);
1685 1685
     $out = '';
1686
-    for  ($i = 0;$i <= 30;$i = $i+2) {
1687
-      $out.= chr(hexdec(substr($tmp, $i, 2)));
1686
+    for ($i = 0; $i <= 30; $i = $i + 2) {
1687
+      $out .= chr(hexdec(substr($tmp, $i, 2)));
1688 1688
     }
1689 1689
     return  $out;
1690 1690
   }
@@ -1694,13 +1694,13 @@  discard block
 block discarded – undo
1694 1694
    * initialize the encryption for processing a particular object
1695 1695
    */
1696 1696
   function  encryptInit($id) {
1697
-    $tmp =  $this->encryptionKey;
1698
-    $hex =  dechex($id);
1699
-    if  (mb_strlen($hex, '8bit') <6) {
1700
-      $hex =  substr('000000', 0, 6-mb_strlen($hex, '8bit')) .$hex;
1697
+    $tmp = $this->encryptionKey;
1698
+    $hex = dechex($id);
1699
+    if (mb_strlen($hex, '8bit') < 6) {
1700
+      $hex = substr('000000', 0, 6 - mb_strlen($hex, '8bit')).$hex;
1701 1701
     }
1702
-    $tmp.=  chr(hexdec(substr($hex, 4, 2))) .chr(hexdec(substr($hex, 2, 2))) .chr(hexdec(substr($hex, 0, 2))) .chr(0) .chr(0);
1703
-    $key =  $this->md5_16($tmp);
1702
+    $tmp .= chr(hexdec(substr($hex, 4, 2))).chr(hexdec(substr($hex, 2, 2))).chr(hexdec(substr($hex, 0, 2))).chr(0).chr(0);
1703
+    $key = $this->md5_16($tmp);
1704 1704
     $this->ARC4_init(substr($key, 0, 10));
1705 1705
   }
1706 1706
 
@@ -1709,28 +1709,28 @@  discard block
 block discarded – undo
1709 1709
    * initialize the ARC4 encryption
1710 1710
    */
1711 1711
   function  ARC4_init($key = '') {
1712
-    $this->arc4 =  '';
1712
+    $this->arc4 = '';
1713 1713
 
1714 1714
     // setup the control array
1715
-    if  (mb_strlen($key, '8bit') == 0) {
1715
+    if (mb_strlen($key, '8bit') == 0) {
1716 1716
       return;
1717 1717
     }
1718 1718
 
1719
-    $k =  '';
1720
-    while (mb_strlen($k, '8bit') <256) {
1721
-      $k.= $key;
1719
+    $k = '';
1720
+    while (mb_strlen($k, '8bit') < 256) {
1721
+      $k .= $key;
1722 1722
     }
1723 1723
 
1724 1724
     $k = substr($k, 0, 256);
1725
-    for  ($i = 0;$i<256;$i++) {
1726
-      $this->arc4.=  chr($i);
1725
+    for ($i = 0; $i < 256; $i++) {
1726
+      $this->arc4 .= chr($i);
1727 1727
     }
1728 1728
 
1729 1729
     $j = 0;
1730 1730
 
1731
-    for  ($i = 0;$i<256;$i++) {
1732
-      $t =  $this->arc4[$i];
1733
-      $j =  ($j + ord($t)  + ord($k[$i])) %256;
1731
+    for ($i = 0; $i < 256; $i++) {
1732
+      $t = $this->arc4[$i];
1733
+      $j = ($j + ord($t) + ord($k[$i])) % 256;
1734 1734
       $this->arc4[$i] = $this->arc4[$j];
1735 1735
       $this->arc4[$j] = $t;
1736 1736
     }
@@ -1744,16 +1744,16 @@  discard block
 block discarded – undo
1744 1744
     $len = mb_strlen($text, '8bit');
1745 1745
     $a = 0;
1746 1746
     $b = 0;
1747
-    $c =  $this->arc4;
1747
+    $c = $this->arc4;
1748 1748
     $out = '';
1749
-    for  ($i = 0;$i<$len;$i++) {
1750
-      $a =  ($a+1) %256;
1751
-      $t =  $c[$a];
1752
-      $b =  ($b+ord($t)) %256;
1749
+    for ($i = 0; $i < $len; $i++) {
1750
+      $a = ($a + 1) % 256;
1751
+      $t = $c[$a];
1752
+      $b = ($b + ord($t)) % 256;
1753 1753
       $c[$a] = $c[$b];
1754 1754
       $c[$b] = $t;
1755
-      $k =  ord($c[(ord($c[$a]) +ord($c[$b])) %256]);
1756
-      $out.= chr(ord($text[$i])  ^ $k);
1755
+      $k = ord($c[(ord($c[$a]) + ord($c[$b])) % 256]);
1756
+      $out .= chr(ord($text[$i]) ^ $k);
1757 1757
     }
1758 1758
     return  $out;
1759 1759
   }
@@ -1768,7 +1768,7 @@  discard block
 block discarded – undo
1768 1768
    */
1769 1769
   function  addLink($url, $x0, $y0, $x1, $y1) {
1770 1770
     $this->numObj++;
1771
-    $info =  array('type'=>'link', 'url'=>$url, 'rect'=>array($x0, $y0, $x1, $y1));
1771
+    $info = array('type'=>'link', 'url'=>$url, 'rect'=>array($x0, $y0, $x1, $y1));
1772 1772
     $this->o_annotation($this->numObj, 'new', $info);
1773 1773
   }
1774 1774
 
@@ -1778,7 +1778,7 @@  discard block
 block discarded – undo
1778 1778
    */
1779 1779
   function  addInternalLink($label, $x0, $y0, $x1, $y1) {
1780 1780
     $this->numObj++;
1781
-    $info =  array('type'=>'ilink', 'label'=>$label, 'rect'=>array($x0, $y0, $x1, $y1));
1781
+    $info = array('type'=>'ilink', 'label'=>$label, 'rect'=>array($x0, $y0, $x1, $y1));
1782 1782
     $this->o_annotation($this->numObj, 'new', $info);
1783 1783
   }
1784 1784
 
@@ -1791,21 +1791,21 @@  discard block
 block discarded – undo
1791 1791
   function  setEncryption($userPass = '', $ownerPass = '', $pc = array()) {
1792 1792
     $p = bindec(11000000);
1793 1793
 
1794
-    $options =  array('print'=>4, 'modify'=>8, 'copy'=>16, 'add'=>32);
1794
+    $options = array('print'=>4, 'modify'=>8, 'copy'=>16, 'add'=>32);
1795 1795
 
1796
-    foreach($pc as  $k=>$v) {
1797
-      if  ($v &&  isset($options[$k])) {
1798
-        $p+= $options[$k];
1799
-      } else  if  (isset($options[$v])) {
1800
-        $p+= $options[$v];
1796
+    foreach ($pc as  $k=>$v) {
1797
+      if ($v && isset($options[$k])) {
1798
+        $p += $options[$k];
1799
+      } else  if (isset($options[$v])) {
1800
+        $p += $options[$v];
1801 1801
       }
1802 1802
     }
1803 1803
 
1804 1804
     // implement encryption on the document
1805
-    if  ($this->arc4_objnum ==  0) {
1805
+    if ($this->arc4_objnum == 0) {
1806 1806
       // then the block does not exist already, add it.
1807 1807
       $this->numObj++;
1808
-      if  (mb_strlen($ownerPass) == 0) {
1808
+      if (mb_strlen($ownerPass) == 0) {
1809 1809
         $ownerPass = $userPass;
1810 1810
       }
1811 1811
 
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
    * return the pdf stream as a string returned from the function
1826 1826
    */
1827 1827
   function  output($debug = false) {
1828
-    if  ($debug) {
1828
+    if ($debug) {
1829 1829
       // turn compression off
1830 1830
       $this->options['compression'] = 0;
1831 1831
     }
@@ -1837,12 +1837,12 @@  discard block
 block discarded – undo
1837 1837
       $this->o_embedjs($js_id, 'new');
1838 1838
       $this->o_javascript(++$this->numObj, 'new', $this->javascript);
1839 1839
       
1840
-      $id =  $this->catalogId;
1840
+      $id = $this->catalogId;
1841 1841
       
1842 1842
       $this->o_catalog($id, 'javascript', $js_id);
1843 1843
     }
1844 1844
 
1845
-    if  ($this->arc4_objnum) {
1845
+    if ($this->arc4_objnum) {
1846 1846
       $this->ARC4_init($this->encryptionKey);
1847 1847
     }
1848 1848
 
@@ -1853,32 +1853,32 @@  discard block
 block discarded – undo
1853 1853
     $content = '%PDF-1.3';
1854 1854
     $pos = mb_strlen($content, '8bit');
1855 1855
 
1856
-    foreach($this->objects as  $k=>$v) {
1856
+    foreach ($this->objects as  $k=>$v) {
1857 1857
       $tmp = 'o_'.$v['t'];
1858 1858
       $cont = $this->$tmp($k, 'out');
1859
-      $content.= $cont;
1859
+      $content .= $cont;
1860 1860
       $xref[] = $pos;
1861
-      $pos+= mb_strlen($cont, '8bit');
1861
+      $pos += mb_strlen($cont, '8bit');
1862 1862
     }
1863 1863
 
1864
-    $content.= "\nxref\n0 ".(count($xref) +1) ."\n0000000000 65535 f \n";
1864
+    $content .= "\nxref\n0 ".(count($xref) + 1)."\n0000000000 65535 f \n";
1865 1865
 
1866
-    foreach($xref as  $p) {
1867
-      $content.= str_pad($p,  10,  "0",  STR_PAD_LEFT)  . " 00000 n \n";
1866
+    foreach ($xref as  $p) {
1867
+      $content .= str_pad($p, 10, "0", STR_PAD_LEFT)." 00000 n \n";
1868 1868
     }
1869 1869
 
1870
-    $content.= "trailer\n<<\n/Size ".(count($xref) +1) ."\n/Root 1 0 R\n/Info ".$this->infoObject." 0 R\n";
1870
+    $content .= "trailer\n<<\n/Size ".(count($xref) + 1)."\n/Root 1 0 R\n/Info ".$this->infoObject." 0 R\n";
1871 1871
 
1872 1872
     // if encryption has been applied to this document then add the marker for this dictionary
1873
-    if  ($this->arc4_objnum > 0) {
1874
-      $content.=  "/Encrypt ".$this->arc4_objnum." 0 R\n";
1873
+    if ($this->arc4_objnum > 0) {
1874
+      $content .= "/Encrypt ".$this->arc4_objnum." 0 R\n";
1875 1875
     }
1876 1876
 
1877
-    if  (mb_strlen($this->fileIdentifier, '8bit')) {
1878
-      $content.=  "/ID[<".$this->fileIdentifier."><".$this->fileIdentifier.">]\n";
1877
+    if (mb_strlen($this->fileIdentifier, '8bit')) {
1878
+      $content .= "/ID[<".$this->fileIdentifier."><".$this->fileIdentifier.">]\n";
1879 1879
     }
1880 1880
 
1881
-    $content.=  ">>\nstartxref\n".$pos."\n%%EOF\n";
1881
+    $content .= ">>\nstartxref\n".$pos."\n%%EOF\n";
1882 1882
 
1883 1883
     return  $content;
1884 1884
   }
@@ -1892,7 +1892,7 @@  discard block
 block discarded – undo
1892 1892
    */
1893 1893
   function  newDocument($pageSize = array(0, 0, 612, 792)) {
1894 1894
     $this->numObj = 0;
1895
-    $this->objects =  array();
1895
+    $this->objects = array();
1896 1896
 
1897 1897
     $this->numObj++;
1898 1898
     $this->o_catalog($this->numObj, 'new');
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
     $this->o_pages($this->numObj, 'new');
1905 1905
 
1906 1906
     $this->o_pages($this->numObj, 'mediaBox', $pageSize);
1907
-    $this->currentNode =  3;
1907
+    $this->currentNode = 3;
1908 1908
 
1909 1909
     $this->numObj++;
1910 1910
     $this->o_procset($this->numObj, 'new');
@@ -1917,7 +1917,7 @@  discard block
 block discarded – undo
1917 1917
 
1918 1918
     // need to store the first page id as there is no way to get it to the user during
1919 1919
     // startup
1920
-    $this->firstPageId =  $this->currentContents;
1920
+    $this->firstPageId = $this->currentContents;
1921 1921
   }
1922 1922
 
1923 1923
   /**
@@ -1933,12 +1933,12 @@  discard block
 block discarded – undo
1933 1933
     // assume that $font contains the path and file but not the extension
1934 1934
     $pos = strrpos($font, '/');
1935 1935
 
1936
-    if  ($pos === false) {
1937
-      $dir =  './';
1938
-      $name =  $font;
1936
+    if ($pos === false) {
1937
+      $dir = './';
1938
+      $name = $font;
1939 1939
     } else {
1940
-      $dir = substr($font, 0, $pos+1);
1941
-      $name = substr($font, $pos+1);
1940
+      $dir = substr($font, 0, $pos + 1);
1941
+      $name = substr($font, $pos + 1);
1942 1942
     }
1943 1943
     
1944 1944
     $fontcache = $this->fontcache;
@@ -1954,31 +1954,31 @@  discard block
 block discarded – undo
1954 1954
     
1955 1955
     $this->addMessage('openFont: '.$font.' - '.$name);
1956 1956
 
1957
-    $metrics_name = $name . (($this->isUnicode) ? '.ufm' : '.afm');
1957
+    $metrics_name = $name.(($this->isUnicode) ? '.ufm' : '.afm');
1958 1958
     
1959 1959
     // Core fonts don't currently work with composite fonts (for Unicode support).
1960 1960
     // The .ufm files have been removed so we need to check whether or not to use the
1961 1961
     // .ufm or .afm.
1962
-    if ($this->isUnicode && !file_exists($dir . '/' . $metrics_name)) { $metrics_name = $name . '.afm'; }
1962
+    if ($this->isUnicode && !file_exists($dir.'/'.$metrics_name)) { $metrics_name = $name.'.afm'; }
1963 1963
     
1964
-    $cache_name = 'php_' . $metrics_name;
1964
+    $cache_name = 'php_'.$metrics_name;
1965 1965
     $this->addMessage('metrics: '.$metrics_name.', cache: '.$cache_name);
1966
-    if  (file_exists($fontcache . $cache_name)) {
1967
-      $this->addMessage('openFont: php file exists ' . $fontcache . $cache_name);
1968
-      $tmp =  file_get_contents($fontcache . $cache_name);
1966
+    if (file_exists($fontcache.$cache_name)) {
1967
+      $this->addMessage('openFont: php file exists '.$fontcache.$cache_name);
1968
+      $tmp = file_get_contents($fontcache.$cache_name);
1969 1969
       eval($tmp);
1970 1970
 
1971
-      if  (!isset($this->fonts[$font]['_version_']) ||  $this->fonts[$font]['_version_'] != $this->fontcacheVersion) {
1971
+      if (!isset($this->fonts[$font]['_version_']) || $this->fonts[$font]['_version_'] != $this->fontcacheVersion) {
1972 1972
         // if the font file is old, then clear it out and prepare for re-creation
1973 1973
         $this->addMessage('openFont: clear out, make way for new version.');
1974 1974
         unset($this->fonts[$font]);
1975 1975
       }
1976 1976
     }
1977 1977
 
1978
-    if  (!isset($this->fonts[$font]) &&  file_exists($dir . $metrics_name)) {
1978
+    if (!isset($this->fonts[$font]) && file_exists($dir.$metrics_name)) {
1979 1979
       // then rebuild the php_<font>.afm file from the <font>.afm file
1980
-      $this->addMessage('openFont: build php file from ' . $dir . $metrics_name);
1981
-      $data =  array();
1980
+      $this->addMessage('openFont: build php file from '.$dir.$metrics_name);
1981
+      $data = array();
1982 1982
       
1983 1983
       // Since we're not going to enable Unicode for the core fonts we need to use a font-based
1984 1984
       // setting for Unicode support rather than a global setting.
@@ -1986,19 +1986,19 @@  discard block
 block discarded – undo
1986 1986
       
1987 1987
       $cidtogid = '';
1988 1988
       if ($data['isUnicode']) {
1989
-        $cidtogid = str_pad('', 256*256*2, "\x00");
1989
+        $cidtogid = str_pad('', 256 * 256 * 2, "\x00");
1990 1990
       }
1991 1991
 
1992
-      $file =  file($dir . $metrics_name);
1992
+      $file = file($dir.$metrics_name);
1993 1993
 
1994 1994
       foreach ($file as  $rowA) {
1995 1995
         $row = trim($rowA);
1996 1996
         $pos = strpos($row, ' ');
1997 1997
 
1998
-        if  ($pos) {
1998
+        if ($pos) {
1999 1999
           // then there must be some keyword
2000
-          $key =  substr($row, 0, $pos);
2001
-          switch  ($key) {
2000
+          $key = substr($row, 0, $pos);
2001
+          switch ($key) {
2002 2002
           case  'FontName':
2003 2003
           case  'FullName':
2004 2004
           case  'FamilyName':
@@ -2030,29 +2030,29 @@  discard block
 block discarded – undo
2030 2030
             $bits = explode(';', trim($row));
2031 2031
             $dtmp = array();
2032 2032
 
2033
-            foreach($bits as  $bit) {
2034
-              $bits2 =  explode(' ', trim($bit));
2035
-              if  (mb_strlen($bits2[0], '8bit')) {
2036
-                if  (count($bits2) >2) {
2033
+            foreach ($bits as  $bit) {
2034
+              $bits2 = explode(' ', trim($bit));
2035
+              if (mb_strlen($bits2[0], '8bit')) {
2036
+                if (count($bits2) > 2) {
2037 2037
                   $dtmp[$bits2[0]] = array();
2038
-                  for  ($i = 1;$i<count($bits2);$i++) {
2038
+                  for ($i = 1; $i < count($bits2); $i++) {
2039 2039
                     $dtmp[$bits2[0]][] = $bits2[$i];
2040 2040
                   }
2041
-                } else  if  (count($bits2) == 2) {
2041
+                } else  if (count($bits2) == 2) {
2042 2042
                   $dtmp[$bits2[0]] = $bits2[1];
2043 2043
                 }
2044 2044
               }
2045 2045
             }
2046 2046
 
2047
-            $cc = (int)$dtmp['C'];
2048
-            if  ($cc >= 0) {
2047
+            $cc = (int) $dtmp['C'];
2048
+            if ($cc >= 0) {
2049 2049
               $data['C'][$dtmp['C']] = $dtmp;
2050 2050
               $data['C'][$dtmp['N']] = $dtmp;
2051 2051
             } else {
2052 2052
               $data['C'][$dtmp['N']] = $dtmp;
2053 2053
             }
2054 2054
 
2055
-            if  (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2055
+            if (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2056 2056
               $data['MissingWidth'] = $width;
2057 2057
             }
2058 2058
             
@@ -2064,28 +2064,28 @@  discard block
 block discarded – undo
2064 2064
               $bits = explode(';', trim($row));
2065 2065
               $dtmp = array();
2066 2066
 
2067
-              foreach($bits as  $bit) {
2068
-                $bits2 =  explode(' ', trim($bit));
2069
-                if  (mb_strlen($bits2[0], '8bit')) {
2070
-                  if  (count($bits2) >2) {
2067
+              foreach ($bits as  $bit) {
2068
+                $bits2 = explode(' ', trim($bit));
2069
+                if (mb_strlen($bits2[0], '8bit')) {
2070
+                  if (count($bits2) > 2) {
2071 2071
                     $dtmp[$bits2[0]] = array();
2072
-                    for  ($i = 1;$i<count($bits2);$i++) {
2072
+                    for ($i = 1; $i < count($bits2); $i++) {
2073 2073
                       $dtmp[$bits2[0]][] = $bits2[$i];
2074 2074
                     }
2075
-                  } else  if  (count($bits2) == 2) {
2075
+                  } else  if (count($bits2) == 2) {
2076 2076
                     $dtmp[$bits2[0]] = $bits2[1];
2077 2077
                   }
2078 2078
                 }
2079 2079
               }
2080 2080
 
2081
-              $cc = (int)$dtmp['U'];
2081
+              $cc = (int) $dtmp['U'];
2082 2082
               $glyph = $dtmp['G'];
2083 2083
               $width = $dtmp['WX'];
2084
-              if  ($cc >= 0) {
2084
+              if ($cc >= 0) {
2085 2085
                 // Set values in CID to GID map
2086 2086
                 if ($cc >= 0 && $cc < 0xFFFF && $glyph) {
2087
-                  $cidtogid[$cc*2] = chr($glyph >> 8);
2088
-                  $cidtogid[$cc*2 + 1] = chr($glyph & 0xFF);
2087
+                  $cidtogid[$cc * 2] = chr($glyph >> 8);
2088
+                  $cidtogid[$cc * 2 + 1] = chr($glyph & 0xFF);
2089 2089
                 }
2090 2090
 
2091 2091
                 $data['C'][$dtmp['U']] = $dtmp;
@@ -2094,7 +2094,7 @@  discard block
 block discarded – undo
2094 2094
                 $data['C'][$dtmp['N']] = $dtmp;
2095 2095
               }
2096 2096
               
2097
-              if  (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2097
+              if (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2098 2098
                 $data['MissingWidth'] = $width;
2099 2099
               }
2100 2100
             }
@@ -2110,10 +2110,10 @@  discard block
 block discarded – undo
2110 2110
       }
2111 2111
 
2112 2112
       //    echo $cidtogid; die("CIDtoGID Displayed!");
2113
-      if  (function_exists('gzcompress') &&  $this->options['compression']) {
2113
+      if (function_exists('gzcompress') && $this->options['compression']) {
2114 2114
         // then implement ZLIB based compression on CIDtoGID string
2115 2115
         $data['CIDtoGID_Compressed'] = true;
2116
-        $cidtogid =  gzcompress($cidtogid,  6);
2116
+        $cidtogid = gzcompress($cidtogid, 6);
2117 2117
       }
2118 2118
       $data['CIDtoGID'] = base64_encode($cidtogid);
2119 2119
       $data['_version_'] = $this->fontcacheVersion;
@@ -2121,12 +2121,12 @@  discard block
 block discarded – undo
2121 2121
 
2122 2122
       //Because of potential trouble with php safe mode, expect that the folder already exists.
2123 2123
       //If not existing, this will hit performance because of missing cached results.
2124
-      if ( is_dir(substr($fontcache,0,-1)) ) {
2125
-        file_put_contents($fontcache . $cache_name,  '$this->fonts[$font]=' . var_export($data,  true)  . ';');
2124
+      if (is_dir(substr($fontcache, 0, -1))) {
2125
+        file_put_contents($fontcache.$cache_name, '$this->fonts[$font]='.var_export($data, true).';');
2126 2126
       }
2127 2127
     }
2128 2128
     
2129
-    if  (!isset($this->fonts[$font])) {
2129
+    if (!isset($this->fonts[$font])) {
2130 2130
       $this->addMessage("openFont: no font file found for $font.  Do you need to run load_font.php?");
2131 2131
       //echo 'Font not Found '.$font;
2132 2132
     }
@@ -2142,59 +2142,59 @@  discard block
 block discarded – undo
2142 2142
    * and 'differences' => an array of mappings between numbers 0->255 and character names.
2143 2143
    *
2144 2144
    */
2145
-  function  selectFont($fontName, $encoding =  '', $set =  true) {
2145
+  function  selectFont($fontName, $encoding = '', $set = true) {
2146 2146
     $ext = substr($fontName, -4);
2147
-    if  ($ext === '.afm' || $ext === '.ufm') {
2148
-      $fontName = substr($fontName, 0, mb_strlen($fontName)-4);
2147
+    if ($ext === '.afm' || $ext === '.ufm') {
2148
+      $fontName = substr($fontName, 0, mb_strlen($fontName) - 4);
2149 2149
     }
2150 2150
 
2151
-    if  (!isset($this->fonts[$fontName])) {
2151
+    if (!isset($this->fonts[$fontName])) {
2152 2152
       $this->addMessage("selectFont: selecting - $fontName - $encoding, $set");
2153 2153
 
2154 2154
       // load the file
2155 2155
       $this->openFont($fontName);
2156 2156
 
2157
-      if  (isset($this->fonts[$fontName])) {
2157
+      if (isset($this->fonts[$fontName])) {
2158 2158
         $this->numObj++;
2159 2159
         $this->numFonts++;
2160 2160
 
2161 2161
         //$this->numFonts = md5($fontName);
2162
-        $pos =  strrpos($fontName, '/');
2162
+        $pos = strrpos($fontName, '/');
2163 2163
         //      $dir = substr($fontName,0,$pos+1);
2164
-        $name =  substr($fontName, $pos+1);
2165
-        $options =  array('name' => $name, 'fontFileName' => $fontName);
2164
+        $name = substr($fontName, $pos + 1);
2165
+        $options = array('name' => $name, 'fontFileName' => $fontName);
2166 2166
 
2167
-        if  (is_array($encoding)) {
2167
+        if (is_array($encoding)) {
2168 2168
           // then encoding and differences might be set
2169
-          if  (isset($encoding['encoding'])) {
2170
-            $options['encoding'] =  $encoding['encoding'];
2169
+          if (isset($encoding['encoding'])) {
2170
+            $options['encoding'] = $encoding['encoding'];
2171 2171
           }
2172 2172
 
2173
-          if  (isset($encoding['differences'])) {
2174
-            $options['differences'] =  $encoding['differences'];
2173
+          if (isset($encoding['differences'])) {
2174
+            $options['differences'] = $encoding['differences'];
2175 2175
           }
2176
-        } else  if  (mb_strlen($encoding, '8bit')) {
2176
+        } else  if (mb_strlen($encoding, '8bit')) {
2177 2177
           // then perhaps only the encoding has been set
2178
-          $options['encoding'] =  $encoding;
2178
+          $options['encoding'] = $encoding;
2179 2179
         }
2180 2180
 
2181
-        $fontObj =  $this->numObj;
2181
+        $fontObj = $this->numObj;
2182 2182
         $this->o_font($this->numObj, 'new', $options);
2183
-        $this->fonts[$fontName]['fontNum'] =  $this->numFonts;
2183
+        $this->fonts[$fontName]['fontNum'] = $this->numFonts;
2184 2184
 
2185 2185
         // if this is a '.afm' font, and there is a '.pfa' file to go with it ( as there
2186 2186
         // should be for all non-basic fonts), then load it into an object and put the
2187 2187
         // references into the font object
2188
-        $basefile =  $fontName;
2189
-        if  (file_exists($basefile.'.pfb')) {
2190
-          $fbtype =  'pfb';
2191
-        } else  if  (file_exists($basefile.'.ttf')) {
2192
-          $fbtype =  'ttf';
2188
+        $basefile = $fontName;
2189
+        if (file_exists($basefile.'.pfb')) {
2190
+          $fbtype = 'pfb';
2191
+        } else  if (file_exists($basefile.'.ttf')) {
2192
+          $fbtype = 'ttf';
2193 2193
         } else {
2194
-          $fbtype =  '';
2194
+          $fbtype = '';
2195 2195
         }
2196 2196
 
2197
-        $fbfile =  $basefile.'.'.$fbtype;
2197
+        $fbfile = $basefile.'.'.$fbtype;
2198 2198
 
2199 2199
         //      $pfbfile = substr($fontName,0,strlen($fontName)-4).'.pfb';
2200 2200
         //      $ttffile = substr($fontName,0,strlen($fontName)-4).'.ttf';
@@ -2202,60 +2202,60 @@  discard block
 block discarded – undo
2202 2202
 
2203 2203
         // OAR - I don't understand this old check
2204 2204
         // if  (substr($fontName, -4) ===  '.afm' &&  strlen($fbtype)) {
2205
-        if  (mb_strlen($fbtype, '8bit')) {
2206
-          $adobeFontName =  $this->fonts[$fontName]['FontName'];
2205
+        if (mb_strlen($fbtype, '8bit')) {
2206
+          $adobeFontName = $this->fonts[$fontName]['FontName'];
2207 2207
           //        $fontObj = $this->numObj;
2208 2208
           $this->addMessage('selectFont: adding font file - '.$fbfile.' - '.$adobeFontName);
2209 2209
 
2210 2210
           // find the array of font widths, and put that into an object.
2211
-          $firstChar =  -1;
2212
-          $lastChar =  0;
2213
-          $widths =  array();
2211
+          $firstChar = -1;
2212
+          $lastChar = 0;
2213
+          $widths = array();
2214 2214
           $cid_widths = array();
2215 2215
 
2216 2216
           foreach ($this->fonts[$fontName]['C'] as  $num => $d) {
2217
-            if  (intval($num) >0 ||  $num ==  '0') {
2217
+            if (intval($num) > 0 || $num == '0') {
2218 2218
               if (!$this->fonts[$fontName]['isUnicode']) {
2219 2219
                 // With Unicode, widths array isn't used
2220
-                if  ($lastChar>0 &&  $num>$lastChar+1) {
2221
-                  for ($i =  $lastChar+1;$i<$num;$i++) {
2222
-                    $widths[] =  0;
2220
+                if ($lastChar > 0 && $num > $lastChar + 1) {
2221
+                  for ($i = $lastChar + 1; $i < $num; $i++) {
2222
+                    $widths[] = 0;
2223 2223
                   }
2224 2224
                 }
2225 2225
               }
2226 2226
 
2227
-              $widths[] =  $d['WX'];
2227
+              $widths[] = $d['WX'];
2228 2228
 
2229 2229
               if ($this->fonts[$fontName]['isUnicode']) {
2230
-                $cid_widths[$num] =  $d['WX'];
2230
+                $cid_widths[$num] = $d['WX'];
2231 2231
               }
2232 2232
 
2233
-              if  ($firstChar ==  -1) {
2234
-                $firstChar =  $num;
2233
+              if ($firstChar == -1) {
2234
+                $firstChar = $num;
2235 2235
               }
2236 2236
 
2237
-              $lastChar =  $num;
2237
+              $lastChar = $num;
2238 2238
             }
2239 2239
           }
2240 2240
 
2241 2241
           // also need to adjust the widths for the differences array
2242
-          if  (isset($options['differences'])) {
2243
-            foreach($options['differences'] as  $charNum => $charName) {
2244
-              if  ($charNum > $lastChar) {
2242
+          if (isset($options['differences'])) {
2243
+            foreach ($options['differences'] as  $charNum => $charName) {
2244
+              if ($charNum > $lastChar) {
2245 2245
                 if (!$this->fonts[$fontName]['isUnicode']) {
2246 2246
                   // With Unicode, widths array isn't used
2247
-                  for ($i =  $lastChar + 1; $i <=  $charNum; $i++) {
2248
-                    $widths[] =  0;
2247
+                  for ($i = $lastChar + 1; $i <= $charNum; $i++) {
2248
+                    $widths[] = 0;
2249 2249
                   }
2250 2250
                 }
2251 2251
 
2252
-                $lastChar =  $charNum;
2252
+                $lastChar = $charNum;
2253 2253
               }
2254 2254
 
2255
-              if  (isset($this->fonts[$fontName]['C'][$charName])) {
2256
-                $widths[$charNum-$firstChar] =  $this->fonts[$fontName]['C'][$charName]['WX'];
2255
+              if (isset($this->fonts[$fontName]['C'][$charName])) {
2256
+                $widths[$charNum - $firstChar] = $this->fonts[$fontName]['C'][$charName]['WX'];
2257 2257
                 if ($this->fonts[$fontName]['isUnicode']) {
2258
-                  $cid_widths[$charName] =  $this->fonts[$fontName]['C'][$charName]['WX'];
2258
+                  $cid_widths[$charName] = $this->fonts[$fontName]['C'][$charName]['WX'];
2259 2259
                 }
2260 2260
               }
2261 2261
             }
@@ -2275,21 +2275,21 @@  discard block
 block discarded – undo
2275 2275
 
2276 2276
             $this->numObj++;
2277 2277
             $this->o_contents($this->numObj, 'new', 'raw');
2278
-            $this->objects[$this->numObj]['c'].=  '[';
2278
+            $this->objects[$this->numObj]['c'] .= '[';
2279 2279
 
2280
-            foreach($widths as  $width) {
2281
-              $this->objects[$this->numObj]['c'].=  ' '.$width;
2280
+            foreach ($widths as  $width) {
2281
+              $this->objects[$this->numObj]['c'] .= ' '.$width;
2282 2282
             }
2283 2283
 
2284
-            $this->objects[$this->numObj]['c'].=  ' ]';
2285
-            $widthid =  $this->numObj;
2284
+            $this->objects[$this->numObj]['c'] .= ' ]';
2285
+            $widthid = $this->numObj;
2286 2286
           }
2287 2287
 
2288 2288
           $missing_width = 500;
2289 2289
           $stemV = 70;
2290 2290
 
2291 2291
           if (isset($this->fonts[$fontName]['MissingWidth'])) {
2292
-            $missing_width =  $this->fonts[$fontName]['MissingWidth'];
2292
+            $missing_width = $this->fonts[$fontName]['MissingWidth'];
2293 2293
           }
2294 2294
           if (isset($this->fonts[$fontName]['StdVW'])) {
2295 2295
             $stemV = $this->fonts[$fontName]['StdVW'];
@@ -2300,28 +2300,28 @@  discard block
 block discarded – undo
2300 2300
           // load the pfb file, and put that into an object too.
2301 2301
           // note that pdf supports only binary format type 1 font files, though there is a
2302 2302
           // simple utility to convert them from pfa to pfb.
2303
-          $data =  file_get_contents($fbfile);
2303
+          $data = file_get_contents($fbfile);
2304 2304
 
2305 2305
           // create the font descriptor
2306 2306
           $this->numObj++;
2307
-          $fontDescriptorId =  $this->numObj;
2307
+          $fontDescriptorId = $this->numObj;
2308 2308
 
2309 2309
           $this->numObj++;
2310
-          $pfbid =  $this->numObj;
2310
+          $pfbid = $this->numObj;
2311 2311
 
2312 2312
           // determine flags (more than a little flakey, hopefully will not matter much)
2313
-          $flags =  0;
2313
+          $flags = 0;
2314 2314
 
2315
-          if  ($this->fonts[$fontName]['ItalicAngle'] !=  0) {
2316
-            $flags+=  pow(2, 6);
2315
+          if ($this->fonts[$fontName]['ItalicAngle'] != 0) {
2316
+            $flags += pow(2, 6);
2317 2317
           }
2318 2318
 
2319
-          if  ($this->fonts[$fontName]['IsFixedPitch'] === 'true') {
2320
-            $flags+=  1;
2319
+          if ($this->fonts[$fontName]['IsFixedPitch'] === 'true') {
2320
+            $flags += 1;
2321 2321
           }
2322 2322
 
2323
-          $flags+=  pow(2, 5); // assume non-sybolic
2324
-          $list =  array(
2323
+          $flags += pow(2, 5); // assume non-sybolic
2324
+          $list = array(
2325 2325
             'Ascent' => 'Ascender', 
2326 2326
             'CapHeight' => 'CapHeight', 
2327 2327
             'MissingWidth' => 'MissingWidth', 
@@ -2329,51 +2329,51 @@  discard block
 block discarded – undo
2329 2329
             'FontBBox' => 'FontBBox', 
2330 2330
             'ItalicAngle' => 'ItalicAngle'
2331 2331
           );
2332
-          $fdopt =  array(
2332
+          $fdopt = array(
2333 2333
             'Flags' => $flags, 
2334 2334
             'FontName' => $adobeFontName, 
2335 2335
             'StemV' => $stemV
2336 2336
           );
2337 2337
 
2338
-          foreach($list as  $k => $v) {
2339
-            if  (isset($this->fonts[$fontName][$v])) {
2340
-              $fdopt[$k] =  $this->fonts[$fontName][$v];
2338
+          foreach ($list as  $k => $v) {
2339
+            if (isset($this->fonts[$fontName][$v])) {
2340
+              $fdopt[$k] = $this->fonts[$fontName][$v];
2341 2341
             }
2342 2342
           }
2343 2343
 
2344
-          if  ($fbtype === 'pfb') {
2345
-            $fdopt['FontFile'] =  $pfbid;
2346
-          } else  if  ($fbtype === 'ttf') {
2347
-            $fdopt['FontFile2'] =  $pfbid;
2344
+          if ($fbtype === 'pfb') {
2345
+            $fdopt['FontFile'] = $pfbid;
2346
+          } else  if ($fbtype === 'ttf') {
2347
+            $fdopt['FontFile2'] = $pfbid;
2348 2348
           }
2349 2349
 
2350 2350
           $this->o_fontDescriptor($fontDescriptorId, 'new', $fdopt);
2351 2351
 
2352 2352
           // embed the font program
2353 2353
           $this->o_contents($this->numObj, 'new');
2354
-          $this->objects[$pfbid]['c'].=  $data;
2354
+          $this->objects[$pfbid]['c'] .= $data;
2355 2355
 
2356 2356
           // determine the cruicial lengths within this file
2357
-          if  ($fbtype === 'pfb') {
2358
-            $l1 =  strpos($data, 'eexec') +6;
2359
-            $l2 =  strpos($data, '00000000') -$l1;
2360
-            $l3 =  mb_strlen($data, '8bit') -$l2-$l1;
2357
+          if ($fbtype === 'pfb') {
2358
+            $l1 = strpos($data, 'eexec') + 6;
2359
+            $l2 = strpos($data, '00000000') - $l1;
2360
+            $l3 = mb_strlen($data, '8bit') - $l2 - $l1;
2361 2361
             $this->o_contents($this->numObj, 'add', array('Length1' => $l1, 'Length2' => $l2, 'Length3' => $l3));
2362
-          } else  if  ($fbtype == 'ttf') {
2363
-            $l1 =  mb_strlen($data, '8bit');
2362
+          } else  if ($fbtype == 'ttf') {
2363
+            $l1 = mb_strlen($data, '8bit');
2364 2364
             $this->o_contents($this->numObj, 'add', array('Length1' => $l1));
2365 2365
           }
2366 2366
 
2367 2367
           // tell the font object about all this new stuff
2368
-          $tmp =  array('BaseFont' => $adobeFontName, 'MissingWidth' => $missing_width, 'Widths' => $widthid, 'FirstChar' => $firstChar, 'LastChar' => $lastChar, 'FontDescriptor' => $fontDescriptorId);
2368
+          $tmp = array('BaseFont' => $adobeFontName, 'MissingWidth' => $missing_width, 'Widths' => $widthid, 'FirstChar' => $firstChar, 'LastChar' => $lastChar, 'FontDescriptor' => $fontDescriptorId);
2369 2369
 
2370
-          if  ($fbtype === 'ttf') {
2371
-            $tmp['SubType'] =  'TrueType';
2370
+          if ($fbtype === 'ttf') {
2371
+            $tmp['SubType'] = 'TrueType';
2372 2372
           }
2373 2373
 
2374 2374
           $this->addMessage('adding extra info to font.('.$fontObj.')');
2375 2375
 
2376
-          foreach($tmp as  $fk => $fv) {
2376
+          foreach ($tmp as  $fk => $fv) {
2377 2377
             $this->addMessage($fk." : ".$fv);
2378 2378
           }
2379 2379
 
@@ -2384,20 +2384,20 @@  discard block
 block discarded – undo
2384 2384
 
2385 2385
         // also set the differences here, note that this means that these will take effect only the
2386 2386
         //first time that a font is selected, else they are ignored
2387
-        if  (isset($options['differences'])) {
2388
-          $this->fonts[$fontName]['differences'] =  $options['differences'];
2387
+        if (isset($options['differences'])) {
2388
+          $this->fonts[$fontName]['differences'] = $options['differences'];
2389 2389
         }
2390 2390
       }
2391 2391
     }
2392 2392
 
2393
-    if  ($set &&  isset($this->fonts[$fontName])) {
2393
+    if ($set && isset($this->fonts[$fontName])) {
2394 2394
       // so if for some reason the font was not set in the last one then it will not be selected
2395
-      $this->currentBaseFont =  $fontName;
2395
+      $this->currentBaseFont = $fontName;
2396 2396
 
2397 2397
       // the next lines mean that if a new font is selected, then the current text state will be
2398 2398
       // applied to it as well.
2399
-      $this->currentFont =  $this->currentBaseFont;
2400
-      $this->currentFontNum =  $this->fonts[$this->currentFont]['fontNum'];
2399
+      $this->currentFont = $this->currentBaseFont;
2400
+      $this->currentFontNum = $this->fonts[$this->currentFont]['fontNum'];
2401 2401
 
2402 2402
       //$this->setCurrentFont();
2403 2403
     }
@@ -2437,8 +2437,8 @@  discard block
 block discarded – undo
2437 2437
     //   } else {
2438 2438
     //     // the this font must not have the right family member for the current state
2439 2439
     //     // simply assume the base font
2440
-    $this->currentFont =  $this->currentBaseFont;
2441
-    $this->currentFontNum =  $this->fonts[$this->currentFont]['fontNum'];
2440
+    $this->currentFont = $this->currentBaseFont;
2441
+    $this->currentFontNum = $this->fonts[$this->currentFont]['fontNum'];
2442 2442
     //  }
2443 2443
   }
2444 2444
 
@@ -2458,17 +2458,17 @@  discard block
 block discarded – undo
2458 2458
    * @access private
2459 2459
    */
2460 2460
   function  addContent($content) {
2461
-    $this->objects[$this->currentContents]['c'].=  $content;
2461
+    $this->objects[$this->currentContents]['c'] .= $content;
2462 2462
   }
2463 2463
 
2464 2464
 
2465 2465
   /**
2466 2466
    * sets the colour for fill operations
2467 2467
    */
2468
-  function  setColor($r, $g, $b, $force =  0) {
2469
-    if  ($r >=  0 &&  ($force ||  $r !=  $this->currentColour['r'] ||  $g !=  $this->currentColour['g'] ||  $b !=  $this->currentColour['b'])) {
2470
-      $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $r) .' '.sprintf('%.3F', $g) .' '.sprintf('%.3F', $b) .' rg';
2471
-      $this->currentColour =  array('r' => $r, 'g' => $g, 'b' => $b);
2468
+  function  setColor($r, $g, $b, $force = 0) {
2469
+    if ($r >= 0 && ($force || $r != $this->currentColour['r'] || $g != $this->currentColour['g'] || $b != $this->currentColour['b'])) {
2470
+      $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $r).' '.sprintf('%.3F', $g).' '.sprintf('%.3F', $b).' rg';
2471
+      $this->currentColour = array('r' => $r, 'g' => $g, 'b' => $b);
2472 2472
     }
2473 2473
   }
2474 2474
 
@@ -2476,10 +2476,10 @@  discard block
 block discarded – undo
2476 2476
   /**
2477 2477
    * sets the colour for stroke operations
2478 2478
    */
2479
-  function  setStrokeColor($r, $g, $b, $force =  0) {
2480
-    if  ($r >=  0 &&  ($force ||  $r !=  $this->currentStrokeColour['r'] ||  $g !=  $this->currentStrokeColour['g'] ||  $b !=  $this->currentStrokeColour['b'])) {
2481
-      $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $r) .' '.sprintf('%.3F', $g) .' '.sprintf('%.3F', $b) .' RG';
2482
-      $this->currentStrokeColour =  array('r' => $r, 'g' => $g, 'b' => $b);
2479
+  function  setStrokeColor($r, $g, $b, $force = 0) {
2480
+    if ($r >= 0 && ($force || $r != $this->currentStrokeColour['r'] || $g != $this->currentStrokeColour['g'] || $b != $this->currentStrokeColour['b'])) {
2481
+      $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $r).' '.sprintf('%.3F', $g).' '.sprintf('%.3F', $b).' RG';
2482
+      $this->currentStrokeColour = array('r' => $r, 'g' => $g, 'b' => $b);
2483 2483
     }
2484 2484
   }
2485 2485
 
@@ -2491,8 +2491,8 @@  discard block
 block discarded – undo
2491 2491
     // Create a new graphics state object
2492 2492
     // FIXME: should actually keep track of states that have already been created...
2493 2493
     $this->numObj++;
2494
-    $this->o_extGState($this->numObj,  'new',  $parameters);
2495
-    $this->objects[ $this->currentContents ]['c'].=  "\n/GS" . $this->numStates . " gs";
2494
+    $this->o_extGState($this->numObj, 'new', $parameters);
2495
+    $this->objects[$this->currentContents]['c'] .= "\n/GS".$this->numStates." gs";
2496 2496
   }
2497 2497
 
2498 2498
 
@@ -2514,16 +2514,16 @@  discard block
 block discarded – undo
2514 2514
                                 "ColorDogde", "ColorBurn", "HardLight",
2515 2515
                                 "SoftLight", "Difference", "Exclusion");
2516 2516
 
2517
-    if ( !in_array($mode, $blend_modes) )
2517
+    if (!in_array($mode, $blend_modes))
2518 2518
       $mode = "Normal";
2519 2519
     
2520 2520
     // Only create a new graphics state if required
2521
-    if ( $mode == $this->currentLineTransparency["mode"]  &&
2522
-         $opacity == $this->currentLineTransparency["opacity"] )
2521
+    if ($mode == $this->currentLineTransparency["mode"] &&
2522
+         $opacity == $this->currentLineTransparency["opacity"])
2523 2523
       return;
2524 2524
 
2525 2525
     $options = array("BM" => "/$mode",
2526
-                     "CA" => (float)$opacity);
2526
+                     "CA" => (float) $opacity);
2527 2527
 
2528 2528
     $this->setGraphicsState($options);
2529 2529
   }
@@ -2546,15 +2546,15 @@  discard block
 block discarded – undo
2546 2546
                                 "ColorDogde", "ColorBurn", "HardLight",
2547 2547
                                 "SoftLight", "Difference", "Exclusion");
2548 2548
 
2549
-    if ( !in_array($mode, $blend_modes) )
2549
+    if (!in_array($mode, $blend_modes))
2550 2550
       $mode = "Normal";
2551 2551
 
2552
-    if ( $mode == $this->currentFillTransparency["mode"]  &&
2553
-         $opacity == $this->currentFillTransparency["opacity"] )
2552
+    if ($mode == $this->currentFillTransparency["mode"] &&
2553
+         $opacity == $this->currentFillTransparency["opacity"])
2554 2554
       return;
2555 2555
 
2556 2556
     $options = array("BM" => "/$mode",
2557
-                     "ca" => (float)$opacity);
2557
+                     "ca" => (float) $opacity);
2558 2558
     
2559 2559
     $this->setGraphicsState($options);
2560 2560
   }
@@ -2564,7 +2564,7 @@  discard block
 block discarded – undo
2564 2564
    */
2565 2565
   function  line($x1, $y1, $x2, $y2) {
2566 2566
     $this->objects[$this->currentContents]['c'] .=
2567
-      "\n".sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1) .' m '.sprintf('%.3F', $x2) .' '.sprintf('%.3F', $y2) .' l S';
2567
+      "\n".sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1).' m '.sprintf('%.3F', $x2).' '.sprintf('%.3F', $y2).' l S';
2568 2568
   }
2569 2569
 
2570 2570
 
@@ -2575,17 +2575,17 @@  discard block
 block discarded – undo
2575 2575
     // in the current line style, draw a bezier curve from (x0,y0) to (x3,y3) using the other two points
2576 2576
     // as the control points for the curve.
2577 2577
     $this->objects[$this->currentContents]['c'] .=
2578
-      "\n".sprintf('%.3F', $x0) .' '.sprintf('%.3F', $y0) .' m '.sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1);
2578
+      "\n".sprintf('%.3F', $x0).' '.sprintf('%.3F', $y0).' m '.sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1);
2579 2579
 
2580 2580
     $this->objects[$this->currentContents]['c'] .=
2581
-      ' '.sprintf('%.3F', $x2) .' '.sprintf('%.3F', $y2) .' '.sprintf('%.3F', $x3) .' '.sprintf('%.3F', $y3) .' c S';
2581
+      ' '.sprintf('%.3F', $x2).' '.sprintf('%.3F', $y2).' '.sprintf('%.3F', $x3).' '.sprintf('%.3F', $y3).' c S';
2582 2582
   }
2583 2583
 
2584 2584
 
2585 2585
   /**
2586 2586
    * draw a part of an ellipse
2587 2587
    */
2588
-  function  partEllipse($x0, $y0, $astart, $afinish, $r1, $r2 =  0, $angle =  0, $nSeg =  8) {
2588
+  function  partEllipse($x0, $y0, $astart, $afinish, $r1, $r2 = 0, $angle = 0, $nSeg = 8) {
2589 2589
     $this->ellipse($x0, $y0, $r1, $r2, $angle, $nSeg, $astart, $afinish, 0);
2590 2590
   }
2591 2591
 
@@ -2593,8 +2593,8 @@  discard block
 block discarded – undo
2593 2593
   /**
2594 2594
    * draw a filled ellipse
2595 2595
    */
2596
-  function  filledEllipse($x0, $y0, $r1, $r2 =  0, $angle =  0, $nSeg =  8, $astart =  0, $afinish =  360) {
2597
-    return  $this->ellipse($x0, $y0, $r1, $r2 =  0, $angle, $nSeg, $astart, $afinish, 1, 1);
2596
+  function  filledEllipse($x0, $y0, $r1, $r2 = 0, $angle = 0, $nSeg = 8, $astart = 0, $afinish = 360) {
2597
+    return  $this->ellipse($x0, $y0, $r1, $r2 = 0, $angle, $nSeg, $astart, $afinish, 1, 1);
2598 2598
   }
2599 2599
 
2600 2600
 
@@ -2608,78 +2608,78 @@  discard block
 block discarded – undo
2608 2608
    * nSeg is not allowed to be less than 2, as this will simply draw a line (and will even draw a
2609 2609
    * pretty crappy shape at 2, as we are approximating with bezier curves.
2610 2610
    */
2611
-  function  ellipse($x0, $y0, $r1, $r2 =  0, $angle =  0, $nSeg =  8, $astart =  0, $afinish =  360, $close =  1, $fill =  0) {
2612
-    if  ($r1 ==  0) {
2611
+  function  ellipse($x0, $y0, $r1, $r2 = 0, $angle = 0, $nSeg = 8, $astart = 0, $afinish = 360, $close = 1, $fill = 0) {
2612
+    if ($r1 == 0) {
2613 2613
       return;
2614 2614
     }
2615 2615
 
2616
-    if  ($r2 ==  0) {
2617
-      $r2 =  $r1;
2616
+    if ($r2 == 0) {
2617
+      $r2 = $r1;
2618 2618
     }
2619 2619
 
2620
-    if  ($nSeg < 2) {
2621
-      $nSeg =  2;
2620
+    if ($nSeg < 2) {
2621
+      $nSeg = 2;
2622 2622
     }
2623 2623
 
2624
-    $astart =  deg2rad((float)$astart);
2625
-    $afinish =  deg2rad((float)$afinish);
2626
-    $totalAngle = $afinish-$astart;
2624
+    $astart = deg2rad((float) $astart);
2625
+    $afinish = deg2rad((float) $afinish);
2626
+    $totalAngle = $afinish - $astart;
2627 2627
 
2628
-    $dt =  $totalAngle/$nSeg;
2629
-    $dtm =  $dt/3;
2628
+    $dt = $totalAngle / $nSeg;
2629
+    $dtm = $dt / 3;
2630 2630
 
2631
-    if  ($angle !=  0) {
2632
-      $a =  -1*deg2rad((float)$angle);
2631
+    if ($angle != 0) {
2632
+      $a = -1 * deg2rad((float) $angle);
2633 2633
 
2634
-      $tmp  =  "\n q ";
2635
-      $tmp .=  sprintf('%.3F', cos($a)) .' '.sprintf('%.3F', (-1.0*sin($a))) .' '.sprintf('%.3F', sin($a)) .' '.sprintf('%.3F', cos($a)) .' ';
2636
-      $tmp .=  sprintf('%.3F', $x0) .' '.sprintf('%.3F', $y0) .' cm';
2634
+      $tmp  = "\n q ";
2635
+      $tmp .= sprintf('%.3F', cos($a)).' '.sprintf('%.3F', (-1.0 * sin($a))).' '.sprintf('%.3F', sin($a)).' '.sprintf('%.3F', cos($a)).' ';
2636
+      $tmp .= sprintf('%.3F', $x0).' '.sprintf('%.3F', $y0).' cm';
2637 2637
 
2638
-      $this->objects[$this->currentContents]['c'].=  $tmp;
2638
+      $this->objects[$this->currentContents]['c'] .= $tmp;
2639 2639
 
2640
-      $x0 =  0;
2641
-      $y0 =  0;
2640
+      $x0 = 0;
2641
+      $y0 = 0;
2642 2642
     }
2643 2643
 
2644
-    $t1 =  $astart;
2645
-    $a0 =  $x0 + $r1*cos($t1);
2646
-    $b0 =  $y0 + $r2*sin($t1);
2647
-    $c0 =  -$r1 * sin($t1);
2648
-    $d0 =  $r2 * cos($t1);
2644
+    $t1 = $astart;
2645
+    $a0 = $x0 + $r1 * cos($t1);
2646
+    $b0 = $y0 + $r2 * sin($t1);
2647
+    $c0 = -$r1 * sin($t1);
2648
+    $d0 = $r2 * cos($t1);
2649 2649
 
2650
-    $this->objects[$this->currentContents]['c'] .=  "\n".sprintf('%.3F', $a0) .' '.sprintf('%.3F', $b0) .' m ';
2650
+    $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $a0).' '.sprintf('%.3F', $b0).' m ';
2651 2651
 
2652
-    for  ($i = 1; $i <=  $nSeg; $i++) {
2652
+    for ($i = 1; $i <= $nSeg; $i++) {
2653 2653
       // draw this bit of the total curve
2654
-      $t1 =  $i * $dt + $astart;
2655
-      $a1 =  $x0 + $r1 * cos($t1);
2656
-      $b1 =  $y0 + $r2 * sin($t1);
2654
+      $t1 = $i * $dt + $astart;
2655
+      $a1 = $x0 + $r1 * cos($t1);
2656
+      $b1 = $y0 + $r2 * sin($t1);
2657 2657
       $c1 = -$r1 * sin($t1);
2658
-      $d1 =  $r2 * cos($t1);
2658
+      $d1 = $r2 * cos($t1);
2659 2659
 
2660 2660
       $this->objects[$this->currentContents]['c']
2661
-        .=  "\n".sprintf('%.3F', ($a0+$c0*$dtm)) .' '.sprintf('%.3F', ($b0 + $d0 * $dtm));
2661
+        .=  "\n".sprintf('%.3F', ($a0 + $c0 * $dtm)).' '.sprintf('%.3F', ($b0 + $d0 * $dtm));
2662 2662
 
2663 2663
       $this->objects[$this->currentContents]['c'] .=
2664
-        ' '.sprintf('%.3F', ($a1-$c1*$dtm)) .' '.sprintf('%.3F', ($b1-$d1*$dtm)) .' '.sprintf('%.3F', $a1) .' '.sprintf('%.3F', $b1) .' c';
2664
+        ' '.sprintf('%.3F', ($a1 - $c1 * $dtm)).' '.sprintf('%.3F', ($b1 - $d1 * $dtm)).' '.sprintf('%.3F', $a1).' '.sprintf('%.3F', $b1).' c';
2665 2665
 
2666
-      $a0 =  $a1;
2667
-      $b0 =  $b1;
2668
-      $c0 =  $c1;
2669
-      $d0 =  $d1;
2666
+      $a0 = $a1;
2667
+      $b0 = $b1;
2668
+      $c0 = $c1;
2669
+      $d0 = $d1;
2670 2670
     }
2671 2671
 
2672
-    if  ($fill) {
2673
-      $this->objects[$this->currentContents]['c'].=  ' f';
2672
+    if ($fill) {
2673
+      $this->objects[$this->currentContents]['c'] .= ' f';
2674 2674
     } else if ($close) {
2675
-        $this->objects[$this->currentContents]['c'].=  ' s';
2675
+        $this->objects[$this->currentContents]['c'] .= ' s';
2676 2676
         // small 's' signifies closing the path as well
2677 2677
     } else {
2678
-      $this->objects[$this->currentContents]['c'].=  ' S';
2678
+      $this->objects[$this->currentContents]['c'] .= ' S';
2679 2679
     }
2680 2680
 
2681
-    if  ($angle !=  0) {
2682
-      $this->objects[$this->currentContents]['c'].=  ' Q';
2681
+    if ($angle != 0) {
2682
+      $this->objects[$this->currentContents]['c'] .= ' Q';
2683 2683
     }
2684 2684
   }
2685 2685
 
@@ -2697,38 +2697,38 @@  discard block
 block discarded – undo
2697 2697
    *   (2,1) is 2 on, 1 off, 2 on, 1 off.. etc
2698 2698
    * phase is a modifier on the dash pattern which is used to shift the point at which the pattern starts.
2699 2699
    */
2700
-  function  setLineStyle($width =  1, $cap =  '', $join =  '', $dash =  '', $phase =  0) {
2700
+  function  setLineStyle($width = 1, $cap = '', $join = '', $dash = '', $phase = 0) {
2701 2701
     // this is quite inefficient in that it sets all the parameters whenever 1 is changed, but will fix another day
2702
-    $string =  '';
2702
+    $string = '';
2703 2703
 
2704
-    if  ($width>0) {
2705
-      $string.=  $width.' w';
2704
+    if ($width > 0) {
2705
+      $string .= $width.' w';
2706 2706
     }
2707 2707
 
2708
-    $ca =  array('butt' => 0, 'round' => 1, 'square' => 2);
2708
+    $ca = array('butt' => 0, 'round' => 1, 'square' => 2);
2709 2709
 
2710
-    if  (isset($ca[$cap])) {
2711
-      $string.=  ' '.$ca[$cap].' J';
2710
+    if (isset($ca[$cap])) {
2711
+      $string .= ' '.$ca[$cap].' J';
2712 2712
     }
2713 2713
 
2714
-    $ja =  array('miter' => 0, 'round' => 1, 'bevel' => 2);
2714
+    $ja = array('miter' => 0, 'round' => 1, 'bevel' => 2);
2715 2715
 
2716
-    if  (isset($ja[$join])) {
2717
-      $string.=  ' '.$ja[$join].' j';
2716
+    if (isset($ja[$join])) {
2717
+      $string .= ' '.$ja[$join].' j';
2718 2718
     }
2719 2719
 
2720
-    if  (is_array($dash)) {
2721
-      $string.=  ' [';
2720
+    if (is_array($dash)) {
2721
+      $string .= ' [';
2722 2722
 
2723 2723
       foreach ($dash as  $len) {
2724
-        $string.=  ' '.$len;
2724
+        $string .= ' '.$len;
2725 2725
       }
2726 2726
 
2727
-      $string.=  ' ] '.$phase.' d';
2727
+      $string .= ' ] '.$phase.' d';
2728 2728
     }
2729 2729
 
2730
-    $this->currentLineStyle =  $string;
2731
-    $this->objects[$this->currentContents]['c'].=  "\n".$string;
2730
+    $this->currentLineStyle = $string;
2731
+    $this->objects[$this->currentContents]['c'] .= "\n".$string;
2732 2732
   }
2733 2733
 
2734 2734
 
@@ -2736,18 +2736,18 @@  discard block
 block discarded – undo
2736 2736
   /**
2737 2737
    * draw a polygon, the syntax for this is similar to the GD polygon command
2738 2738
    */
2739
-  function  polygon($p, $np, $f =  0) {
2740
-    $this->objects[$this->currentContents]['c'].=  "\n";
2741
-    $this->objects[$this->currentContents]['c'].=  sprintf('%.3F', $p[0]) .' '.sprintf('%.3F', $p[1]) .' m ';
2739
+  function  polygon($p, $np, $f = 0) {
2740
+    $this->objects[$this->currentContents]['c'] .= "\n";
2741
+    $this->objects[$this->currentContents]['c'] .= sprintf('%.3F', $p[0]).' '.sprintf('%.3F', $p[1]).' m ';
2742 2742
 
2743
-    for  ($i =  2; $i < $np * 2; $i =  $i + 2) {
2744
-      $this->objects[$this->currentContents]['c'].=  sprintf('%.3F', $p[$i]) .' '.sprintf('%.3F', $p[$i+1]) .' l ';
2743
+    for ($i = 2; $i < $np * 2; $i = $i + 2) {
2744
+      $this->objects[$this->currentContents]['c'] .= sprintf('%.3F', $p[$i]).' '.sprintf('%.3F', $p[$i + 1]).' l ';
2745 2745
     }
2746 2746
 
2747
-    if  ($f ==  1) {
2748
-      $this->objects[$this->currentContents]['c'].=  ' f';
2747
+    if ($f == 1) {
2748
+      $this->objects[$this->currentContents]['c'] .= ' f';
2749 2749
     } else {
2750
-      $this->objects[$this->currentContents]['c'].=  ' S';
2750
+      $this->objects[$this->currentContents]['c'] .= ' S';
2751 2751
     }
2752 2752
   }
2753 2753
 
@@ -2757,7 +2757,7 @@  discard block
 block discarded – undo
2757 2757
    * the coordinates of the upper-right corner
2758 2758
    */
2759 2759
   function  filledRectangle($x1, $y1, $width, $height) {
2760
-    $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1) .' '.sprintf('%.3F', $width) .' '.sprintf('%.3F', $height) .' re f';
2760
+    $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1).' '.sprintf('%.3F', $width).' '.sprintf('%.3F', $height).' re f';
2761 2761
   }
2762 2762
 
2763 2763
 
@@ -2766,7 +2766,7 @@  discard block
 block discarded – undo
2766 2766
    * the coordinates of the upper-right corner
2767 2767
    */
2768 2768
   function  rectangle($x1, $y1, $width, $height) {
2769
-    $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1) .' '.sprintf('%.3F', $width) .' '.sprintf('%.3F', $height) .' re S';
2769
+    $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1).' '.sprintf('%.3F', $width).' '.sprintf('%.3F', $height).' re S';
2770 2770
   }
2771 2771
 
2772 2772
 
@@ -2774,47 +2774,47 @@  discard block
 block discarded – undo
2774 2774
    * add a new page to the document
2775 2775
    * this also makes the new page the current active object
2776 2776
    */
2777
-  function  newPage($insert =  0, $id =  0, $pos =  'after') {
2777
+  function  newPage($insert = 0, $id = 0, $pos = 'after') {
2778 2778
     // if there is a state saved, then go up the stack closing them
2779 2779
     // then on the new page, re-open them with the right setings
2780 2780
 
2781
-    if  ($this->nStateStack) {
2782
-      for  ($i =  $this->nStateStack;$i >=  1;$i--) {
2781
+    if ($this->nStateStack) {
2782
+      for ($i = $this->nStateStack; $i >= 1; $i--) {
2783 2783
         $this->restoreState($i);
2784 2784
       }
2785 2785
     }
2786 2786
 
2787 2787
     $this->numObj++;
2788 2788
 
2789
-    if  ($insert) {
2789
+    if ($insert) {
2790 2790
       // the id from the ezPdf class is the id of the contents of the page, not the page object itself
2791 2791
       // query that object to find the parent
2792
-      $rid =  $this->objects[$id]['onPage'];
2793
-      $opt =  array('rid' => $rid, 'pos' => $pos);
2792
+      $rid = $this->objects[$id]['onPage'];
2793
+      $opt = array('rid' => $rid, 'pos' => $pos);
2794 2794
       $this->o_page($this->numObj, 'new', $opt);
2795 2795
     } else {
2796 2796
       $this->o_page($this->numObj, 'new');
2797 2797
     }
2798 2798
 
2799 2799
     // if there is a stack saved, then put that onto the page
2800
-    if  ($this->nStateStack) {
2801
-      for  ($i =  1;$i <=  $this->nStateStack;$i++) {
2800
+    if ($this->nStateStack) {
2801
+      for ($i = 1; $i <= $this->nStateStack; $i++) {
2802 2802
         $this->saveState($i);
2803 2803
       }
2804 2804
     }
2805 2805
 
2806 2806
     // and if there has been a stroke or fill colour set, then transfer them
2807
-    if  ($this->currentColour['r'] >=  0) {
2807
+    if ($this->currentColour['r'] >= 0) {
2808 2808
       $this->setColor($this->currentColour['r'], $this->currentColour['g'], $this->currentColour['b'], 1);
2809 2809
     }
2810 2810
 
2811
-    if  ($this->currentStrokeColour['r'] >=  0) {
2811
+    if ($this->currentStrokeColour['r'] >= 0) {
2812 2812
       $this->setStrokeColor($this->currentStrokeColour['r'], $this->currentStrokeColour['g'], $this->currentStrokeColour['b'], 1);
2813 2813
     }
2814 2814
 
2815 2815
     // if there is a line style set, then put this in too
2816
-    if  (mb_strlen($this->currentLineStyle, '8bit')) {
2817
-      $this->objects[$this->currentContents]['c'].=  "\n".$this->currentLineStyle;
2816
+    if (mb_strlen($this->currentLineStyle, '8bit')) {
2817
+      $this->objects[$this->currentContents]['c'] .= "\n".$this->currentLineStyle;
2818 2818
     }
2819 2819
 
2820 2820
     // the call to the o_page object set currentContents to the present page, so this can be returned as the page id
@@ -2826,7 +2826,7 @@  discard block
 block discarded – undo
2826 2826
    * output the pdf code, streaming it to the browser
2827 2827
    * the relevant headers are set so that hopefully the browser will recognise it
2828 2828
    */
2829
-  function  stream($options =  '') {
2829
+  function  stream($options = '') {
2830 2830
     // setting the options allows the adjustment of the headers
2831 2831
     // values at the moment are:
2832 2832
     // 'Content-Disposition' => 'filename'  - sets the filename, though not too sure how well this will
@@ -2836,36 +2836,36 @@  discard block
 block discarded – undo
2836 2836
     //    them, so I am leaving it off by default.
2837 2837
     // 'compress' = > 1 or 0 - apply content stream compression, this is on (1) by default
2838 2838
     // 'Attachment' => 1 or 0 - if 1, force the browser to open a download dialog
2839
-    if  (!is_array($options)) {
2840
-      $options =  array();
2839
+    if (!is_array($options)) {
2840
+      $options = array();
2841 2841
     }
2842 2842
 
2843
-    if  ( headers_sent())
2843
+    if (headers_sent())
2844 2844
       die("Unable to stream pdf: headers already sent");
2845 2845
 
2846
-    if  ( isset($options['compress']) &&  $options['compress'] ==  0) {
2847
-      $tmp =  ltrim($this->output(1));
2846
+    if (isset($options['compress']) && $options['compress'] == 0) {
2847
+      $tmp = ltrim($this->output(1));
2848 2848
     } else {
2849
-      $tmp =  ltrim($this->output());
2849
+      $tmp = ltrim($this->output());
2850 2850
     }
2851 2851
 
2852 2852
     header("Cache-Control: private");
2853 2853
     header("Content-type: application/pdf");
2854 2854
 
2855 2855
     //FIXME: I don't know that this is sufficient for determining content length (i.e. what about transport compression?)
2856
-    header("Content-Length: " . mb_strlen($tmp, '8bit'));
2857
-    $fileName =  (isset($options['Content-Disposition']) ?  $options['Content-Disposition'] :  'file.pdf');
2856
+    header("Content-Length: ".mb_strlen($tmp, '8bit'));
2857
+    $fileName = (isset($options['Content-Disposition']) ? $options['Content-Disposition'] : 'file.pdf');
2858 2858
 
2859
-    if  ( !isset($options["Attachment"]))
2860
-      $options["Attachment"] =  true;
2859
+    if (!isset($options["Attachment"]))
2860
+      $options["Attachment"] = true;
2861 2861
 
2862
-    $attachment =  $options["Attachment"] ?  "attachment" :  "inline";
2862
+    $attachment = $options["Attachment"] ? "attachment" : "inline";
2863 2863
 
2864 2864
     header("Content-Disposition: $attachment; filename=\"$fileName\"");
2865 2865
 
2866
-    if  (isset($options['Accept-Ranges']) &&  $options['Accept-Ranges'] ==  1) {
2866
+    if (isset($options['Accept-Ranges']) && $options['Accept-Ranges'] == 1) {
2867 2867
       //FIXME: Is this the correct value ... spec says 1#range-unit
2868
-      header("Accept-Ranges: " . mb_strlen($tmp, '8bit'));
2868
+      header("Accept-Ranges: ".mb_strlen($tmp, '8bit'));
2869 2869
     }
2870 2870
 
2871 2871
     echo  $tmp;
@@ -2877,12 +2877,12 @@  discard block
 block discarded – undo
2877 2877
    * return the height in units of the current font in the given size
2878 2878
    */
2879 2879
   function  getFontHeight($size) {
2880
-    if  (!$this->numFonts) {
2880
+    if (!$this->numFonts) {
2881 2881
       $this->selectFont($this->defaultFont);
2882 2882
     }
2883 2883
     
2884 2884
     // for the current font, and the given size, what is the height of the font in user units
2885
-    $h =  $this->fonts[$this->currentFont]['FontBBox'][3]-$this->fonts[$this->currentFont]['FontBBox'][1];
2885
+    $h = $this->fonts[$this->currentFont]['FontBBox'][3] - $this->fonts[$this->currentFont]['FontBBox'][1];
2886 2886
 
2887 2887
     // have to adjust by a font offset for Windows fonts.  unfortunately it looks like
2888 2888
     // the bounding box calculations are wrong and I don't know why.
@@ -2894,10 +2894,10 @@  discard block
 block discarded – undo
2894 2894
       // Courier font.
2895 2895
       //
2896 2896
       // Both have been added manually to the .afm and .ufm files.
2897
-      $h += (int)$this->fonts[$this->currentFont]['FontHeightOffset'];
2897
+      $h += (int) $this->fonts[$this->currentFont]['FontHeightOffset'];
2898 2898
     }
2899 2899
 
2900
-    return  $size*$h/1000;
2900
+    return  $size * $h / 1000;
2901 2901
   }
2902 2902
 
2903 2903
 
@@ -2908,14 +2908,14 @@  discard block
 block discarded – undo
2908 2908
    */
2909 2909
   function  getFontDescender($size) {
2910 2910
     // note that this will most likely return a negative value
2911
-    if  (!$this->numFonts) {
2911
+    if (!$this->numFonts) {
2912 2912
       $this->selectFont($this->defaultFont);
2913 2913
     }
2914 2914
 
2915 2915
     //$h = $this->fonts[$this->currentFont]['FontBBox'][1];
2916 2916
     $h = $this->fonts[$this->currentFont]['Descender'];
2917 2917
 
2918
-    return  $size*$h/1000;
2918
+    return  $size * $h / 1000;
2919 2919
   }
2920 2920
 
2921 2921
 
@@ -2933,7 +2933,7 @@  discard block
 block discarded – undo
2933 2933
   	$cf = $this->currentFont;
2934 2934
     if ($this->fonts[$cf]['isUnicode']) {
2935 2935
       $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
2936
-      $text =  $this->utf8toUtf16BE($text, $bom);
2936
+      $text = $this->utf8toUtf16BE($text, $bom);
2937 2937
     } else {
2938 2938
       if (in_array('Windows-1252', mb_list_encodings())) {
2939 2939
         $text = mb_convert_encoding($text, 'Windows-1252', 'UTF-8');
@@ -3034,7 +3034,7 @@  discard block
 block discarded – undo
3034 3034
    * @return string UTF-16 result string
3035 3035
    */
3036 3036
   function  utf8toUtf16BE(&$text, $bom = true) {
3037
-    $cf =  $this->currentFont;
3037
+    $cf = $this->currentFont;
3038 3038
     if (!$this->fonts[$cf]['isUnicode']) return $text;
3039 3039
     $out = $bom ? "\xFE\xFF" : '';
3040 3040
     
@@ -3067,15 +3067,15 @@  discard block
 block discarded – undo
3067 3067
    */
3068 3068
   function  PRVTgetTextPosition($x, $y, $angle, $size, $wa, $text) {
3069 3069
     // given this information return an array containing x and y for the end position as elements 0 and 1
3070
-    $w =  $this->getTextWidth($size, $text);
3070
+    $w = $this->getTextWidth($size, $text);
3071 3071
 
3072 3072
     // need to adjust for the number of spaces in this text
3073
-    $words =  explode(' ', $text);
3074
-    $nspaces =  count($words) -1;
3075
-    $w+=  $wa*$nspaces;
3076
-    $a =  deg2rad((float)$angle);
3073
+    $words = explode(' ', $text);
3074
+    $nspaces = count($words) - 1;
3075
+    $w += $wa * $nspaces;
3076
+    $a = deg2rad((float) $angle);
3077 3077
 
3078
-    return  array(cos($a) *$w+$x, -sin($a) *$w+$y);
3078
+    return  array(cos($a) * $w + $x, -sin($a) * $w + $y);
3079 3079
   }
3080 3080
 
3081 3081
 
@@ -3086,8 +3086,8 @@  discard block
 block discarded – undo
3086 3086
    */
3087 3087
   function  PRVTcheckTextDirective(&$text, $i, &$f) {
3088 3088
     return  0;
3089
-    $x =  0;
3090
-    $y =  0;
3089
+    $x = 0;
3090
+    $y = 0;
3091 3091
     return  $this->PRVTcheckTextDirective1($text, $i, $f, 0, $x, $y);
3092 3092
   }
3093 3093
 
@@ -3101,16 +3101,16 @@  discard block
 block discarded – undo
3101 3101
    *
3102 3102
    * @access private
3103 3103
    */
3104
-  function  PRVTcheckTextDirective1(&$text, $i, &$f, $final, &$x, &$y, $size =  0, $angle =  0, $wordSpaceAdjust =  0) {
3104
+  function  PRVTcheckTextDirective1(&$text, $i, &$f, $final, &$x, &$y, $size = 0, $angle = 0, $wordSpaceAdjust = 0) {
3105 3105
     return  0;
3106
-    $directive =  0;
3107
-    $j =  $i;
3108
-    if  ($text[$j] === '<') {
3106
+    $directive = 0;
3107
+    $j = $i;
3108
+    if ($text[$j] === '<') {
3109 3109
       $j++;
3110 3110
       switch ($text[$j]) {
3111 3111
       case  '/':
3112 3112
         $j++;
3113
-        if  (mb_strlen($text) <=  $j) {
3113
+        if (mb_strlen($text) <= $j) {
3114 3114
           return  $directive;
3115 3115
         }
3116 3116
 
@@ -3118,60 +3118,60 @@  discard block
 block discarded – undo
3118 3118
         case  'b':
3119 3119
         case  'i':
3120 3120
           $j++;
3121
-          if  ($text[$j] === '>') {
3122
-            $p =  mb_strrpos($this->currentTextState, $text[$j-1]);
3121
+          if ($text[$j] === '>') {
3122
+            $p = mb_strrpos($this->currentTextState, $text[$j - 1]);
3123 3123
 
3124
-            if  ($p !==  false) {
3124
+            if ($p !== false) {
3125 3125
               // then there is one to remove
3126
-              $this->currentTextState =  mb_substr($this->currentTextState, 0, $p) .substr($this->currentTextState, $p+1);
3126
+              $this->currentTextState = mb_substr($this->currentTextState, 0, $p).substr($this->currentTextState, $p + 1);
3127 3127
             }
3128 3128
 
3129
-            $directive =  $j-$i+1;
3129
+            $directive = $j - $i + 1;
3130 3130
           }
3131 3131
           break;
3132 3132
 
3133 3133
         case  'c':
3134 3134
           // this this might be a callback function
3135 3135
           $j++;
3136
-          $k =  mb_strpos($text, '>', $j);
3136
+          $k = mb_strpos($text, '>', $j);
3137 3137
 
3138
-          if  ($k !==  false &&  $text[$j] === ':') {
3138
+          if ($k !== false && $text[$j] === ':') {
3139 3139
             // then this will be treated as a callback directive
3140
-            $directive =  $k-$i+1;
3141
-            $f =  0;
3140
+            $directive = $k - $i + 1;
3141
+            $f = 0;
3142 3142
             // split the remainder on colons to get the function name and the paramater
3143
-            $tmp =  mb_substr($text, $j+1, $k-$j-1);
3144
-            $b1 =  mb_strpos($tmp, ':');
3143
+            $tmp = mb_substr($text, $j + 1, $k - $j - 1);
3144
+            $b1 = mb_strpos($tmp, ':');
3145 3145
 
3146
-            if  ($b1 !==  false) {
3147
-              $func =  mb_substr($tmp, 0, $b1);
3148
-              $parm =  mb_substr($tmp, $b1+1);
3146
+            if ($b1 !== false) {
3147
+              $func = mb_substr($tmp, 0, $b1);
3148
+              $parm = mb_substr($tmp, $b1 + 1);
3149 3149
             } else {
3150
-              $func =  $tmp;
3151
-              $parm =  '';
3150
+              $func = $tmp;
3151
+              $parm = '';
3152 3152
             }
3153 3153
 
3154
-            if  (!isset($func) ||  !mb_strlen(trim($func), '8bit')) {
3155
-              $directive =  0;
3154
+            if (!isset($func) || !mb_strlen(trim($func), '8bit')) {
3155
+              $directive = 0;
3156 3156
             } else {
3157 3157
               // only call the function if this is the final call
3158
-              if  ($final) {
3158
+              if ($final) {
3159 3159
                 // need to assess the text position, calculate the text width to this point
3160 3160
                 // can use getTextWidth to find the text width I think
3161
-                $tmp =  $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
3161
+                $tmp = $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
3162 3162
 
3163
-                $info =  array('x' => $tmp[0], 'y' => $tmp[1], 'angle' => $angle, 'status' => 'end', 'p' => $parm, 'nCallback' => $this->nCallback);
3164
-                $x =  $tmp[0];
3165
-                $y =  $tmp[1];
3166
-                $ret =  $this->$func($info);
3163
+                $info = array('x' => $tmp[0], 'y' => $tmp[1], 'angle' => $angle, 'status' => 'end', 'p' => $parm, 'nCallback' => $this->nCallback);
3164
+                $x = $tmp[0];
3165
+                $y = $tmp[1];
3166
+                $ret = $this->$func($info);
3167 3167
 
3168
-                if  (is_array($ret)) {
3168
+                if (is_array($ret)) {
3169 3169
                   // then the return from the callback function could set the position, to start with, later will do font colour, and font
3170
-                  foreach($ret as  $rk => $rv) {
3170
+                  foreach ($ret as  $rk => $rv) {
3171 3171
                     switch ($rk) {
3172 3172
                     case  'x':
3173 3173
                     case  'y':
3174
-                      $$rk =  $rv;
3174
+                      $$rk = $rv;
3175 3175
                       break;
3176 3176
                     }
3177 3177
                   }
@@ -3180,8 +3180,8 @@  discard block
 block discarded – undo
3180 3180
                 // also remove from to the stack
3181 3181
                 // for simplicity, just take from the end, fix this another day
3182 3182
                 $this->nCallback--;
3183
-                if  ($this->nCallback<0) {
3184
-                  $this->nCallBack =  0;
3183
+                if ($this->nCallback < 0) {
3184
+                  $this->nCallBack = 0;
3185 3185
                 }
3186 3186
               }
3187 3187
             }
@@ -3193,49 +3193,49 @@  discard block
 block discarded – undo
3193 3193
       case  'b':
3194 3194
       case  'i':
3195 3195
         $j++;
3196
-        if  ($text[$j] === '>') {
3197
-          $this->currentTextState.=  $text[$j-1];
3198
-          $directive =  $j-$i+1;
3196
+        if ($text[$j] === '>') {
3197
+          $this->currentTextState .= $text[$j - 1];
3198
+          $directive = $j - $i + 1;
3199 3199
         }
3200 3200
         break;
3201 3201
 
3202 3202
       case  'C':
3203
-        $noClose =  1;
3203
+        $noClose = 1;
3204 3204
       case  'c':
3205 3205
         // this this might be a callback function
3206 3206
         $j++;
3207
-        $k =  mb_strpos($text, '>', $j);
3207
+        $k = mb_strpos($text, '>', $j);
3208 3208
 
3209
-        if  ($k !==  false &&  $text[$j] ===  ':') {
3209
+        if ($k !== false && $text[$j] === ':') {
3210 3210
           // then this will be treated as a callback directive
3211
-          $directive =  $k-$i+1;
3211
+          $directive = $k - $i + 1;
3212 3212
 
3213
-          $f =  0;
3213
+          $f = 0;
3214 3214
 
3215 3215
           // split the remainder on colons to get the function name and the paramater
3216 3216
           //          $bits = explode(':',substr($text,$j+1,$k-$j-1));
3217
-          $tmp =  mb_substr($text, $j+1, $k-$j-1);
3218
-          $b1 =  mb_strpos($tmp, ':');
3217
+          $tmp = mb_substr($text, $j + 1, $k - $j - 1);
3218
+          $b1 = mb_strpos($tmp, ':');
3219 3219
 
3220
-          if  ($b1 !==  false) {
3221
-            $func =  mb_substr($tmp, 0, $b1);
3222
-            $parm =  mb_substr($tmp, $b1+1);
3220
+          if ($b1 !== false) {
3221
+            $func = mb_substr($tmp, 0, $b1);
3222
+            $parm = mb_substr($tmp, $b1 + 1);
3223 3223
           } else {
3224
-            $func =  $tmp;
3225
-            $parm =  '';
3224
+            $func = $tmp;
3225
+            $parm = '';
3226 3226
           }
3227 3227
 
3228
-          if  (!isset($func) ||  !mb_strlen(trim($func), '8bit')) {
3229
-            $directive =  0;
3228
+          if (!isset($func) || !mb_strlen(trim($func), '8bit')) {
3229
+            $directive = 0;
3230 3230
           } else {
3231 3231
             // only call the function if this is the final call, ie, the one actually doing printing, not measurement
3232
-            if  ($final) {
3232
+            if ($final) {
3233 3233
               // need to assess the text position, calculate the text width to this point
3234 3234
               // can use getTextWidth to find the text width I think
3235 3235
               // also add the text height and descender
3236
-              $tmp =  $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
3236
+              $tmp = $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
3237 3237
 
3238
-              $info =  array(
3238
+              $info = array(
3239 3239
                 'x' => $tmp[0], 
3240 3240
                 'y' => $tmp[1], 
3241 3241
                 'angle' => $angle, 
@@ -3245,24 +3245,24 @@  discard block
 block discarded – undo
3245 3245
                 'height' => $this->getFontHeight($size), 
3246 3246
                 'descender' => $this->getFontDescender($size)
3247 3247
               );
3248
-              $x =  $tmp[0];
3249
-              $y =  $tmp[1];
3248
+              $x = $tmp[0];
3249
+              $y = $tmp[1];
3250 3250
 
3251
-              if  (!isset($noClose) ||  !$noClose) {
3251
+              if (!isset($noClose) || !$noClose) {
3252 3252
                 // only add to the stack if this is a small 'c', therefore is a start-stop pair
3253 3253
                 $this->nCallback++;
3254
-                $info['nCallback'] =  $this->nCallback;
3255
-                $this->callback[$this->nCallback] =  $info;
3254
+                $info['nCallback'] = $this->nCallback;
3255
+                $this->callback[$this->nCallback] = $info;
3256 3256
               }
3257 3257
 
3258
-              $ret =  $this->$func($info);
3259
-              if  (is_array($ret)) {
3258
+              $ret = $this->$func($info);
3259
+              if (is_array($ret)) {
3260 3260
                 // then the return from the callback function could set the position, to start with, later will do font colour, and font
3261
-                foreach($ret as  $rk => $rv) {
3261
+                foreach ($ret as  $rk => $rv) {
3262 3262
                   switch ($rk) {
3263 3263
                   case  'x':
3264 3264
                   case  'y':
3265
-                    $$rk =  $rv;
3265
+                    $$rk = $rv;
3266 3266
                     break;
3267 3267
                   }
3268 3268
                 }
@@ -3281,16 +3281,16 @@  discard block
 block discarded – undo
3281 3281
   /**
3282 3282
    * add text to the document, at a specified location, size and angle on the page
3283 3283
    */
3284
-  function  addText($x, $y, $size, $text, $angle =  0, $wordSpaceAdjust =  0) {
3285
-    if  (!$this->numFonts) {
3284
+  function  addText($x, $y, $size, $text, $angle = 0, $wordSpaceAdjust = 0) {
3285
+    if (!$this->numFonts) {
3286 3286
       $this->selectFont($this->defaultFont);
3287 3287
     }
3288 3288
 
3289 3289
     // if there are any open callbacks, then they should be called, to show the start of the line
3290
-    if  ($this->nCallback>0) {
3291
-      for  ($i =  $this->nCallback;$i>0;$i--) {
3290
+    if ($this->nCallback > 0) {
3291
+      for ($i = $this->nCallback; $i > 0; $i--) {
3292 3292
         // call each function
3293
-        $info =  array('x' => $x,
3293
+        $info = array('x' => $x,
3294 3294
                        'y' => $y,
3295 3295
                        'angle' => $angle,
3296 3296
                        'status' => 'sol',
@@ -3299,28 +3299,28 @@  discard block
 block discarded – undo
3299 3299
                        'height' => $this->callback[$i]['height'],
3300 3300
                        'descender' => $this->callback[$i]['descender']);
3301 3301
 
3302
-        $func =  $this->callback[$i]['f'];
3302
+        $func = $this->callback[$i]['f'];
3303 3303
         $this->$func($info);
3304 3304
       }
3305 3305
     }
3306 3306
 
3307
-    if  ($angle ==  0) {
3308
-      $this->objects[$this->currentContents]['c'].=  "\n".'BT '.sprintf('%.3F', $x) .' '.sprintf('%.3F', $y) .' Td';
3307
+    if ($angle == 0) {
3308
+      $this->objects[$this->currentContents]['c'] .= "\n".'BT '.sprintf('%.3F', $x).' '.sprintf('%.3F', $y).' Td';
3309 3309
     } else {
3310
-      $a =  deg2rad((float)$angle);
3311
-      $tmp =  "\n".'BT ';
3312
-      $tmp.=  sprintf('%.3F', cos($a)) .' '.sprintf('%.3F', (-1.0*sin($a))) .' '.sprintf('%.3F', sin($a)) .' '.sprintf('%.3F', cos($a)) .' ';
3313
-      $tmp.=  sprintf('%.3F', $x) .' '.sprintf('%.3F', $y) .' Tm';
3314
-      $this->objects[$this->currentContents]['c'].=  $tmp;
3310
+      $a = deg2rad((float) $angle);
3311
+      $tmp = "\n".'BT ';
3312
+      $tmp .= sprintf('%.3F', cos($a)).' '.sprintf('%.3F', (-1.0 * sin($a))).' '.sprintf('%.3F', sin($a)).' '.sprintf('%.3F', cos($a)).' ';
3313
+      $tmp .= sprintf('%.3F', $x).' '.sprintf('%.3F', $y).' Tm';
3314
+      $this->objects[$this->currentContents]['c'] .= $tmp;
3315 3315
     }
3316 3316
 
3317
-    if  ($wordSpaceAdjust !=  0 ||  $wordSpaceAdjust !=  $this->wordSpaceAdjust) {
3318
-      $this->wordSpaceAdjust =  $wordSpaceAdjust;
3319
-      $this->objects[$this->currentContents]['c'].=  ' '.sprintf('%.3F', $wordSpaceAdjust) .' Tw';
3317
+    if ($wordSpaceAdjust != 0 || $wordSpaceAdjust != $this->wordSpaceAdjust) {
3318
+      $this->wordSpaceAdjust = $wordSpaceAdjust;
3319
+      $this->objects[$this->currentContents]['c'] .= ' '.sprintf('%.3F', $wordSpaceAdjust).' Tw';
3320 3320
     }
3321 3321
 
3322
-    $len =  mb_strlen($text);
3323
-    $start =  0;
3322
+    $len = mb_strlen($text);
3323
+    $start = 0;
3324 3324
 
3325 3325
     /*
3326 3326
      for ($i = 0;$i<$len;$i++){
@@ -3365,20 +3365,20 @@  discard block
 block discarded – undo
3365 3365
 
3366 3366
      }
3367 3367
     */
3368
-    if  ($start < $len) {
3369
-      $part =  $text; // OAR - Don't need this anymore, given that $start always equals zero.  substr($text, $start);
3370
-      $this->objects[$this->currentContents]['c'].=  ' /F'.$this->currentFontNum.' '.sprintf('%.1F', $size) .' Tf ';
3371
-      $this->objects[$this->currentContents]['c'].=  ' ('.$this->filterText($part, false) .') Tj';
3368
+    if ($start < $len) {
3369
+      $part = $text; // OAR - Don't need this anymore, given that $start always equals zero.  substr($text, $start);
3370
+      $this->objects[$this->currentContents]['c'] .= ' /F'.$this->currentFontNum.' '.sprintf('%.1F', $size).' Tf ';
3371
+      $this->objects[$this->currentContents]['c'] .= ' ('.$this->filterText($part, false).') Tj';
3372 3372
     }
3373 3373
 
3374
-    $this->objects[$this->currentContents]['c'].=  ' ET';
3374
+    $this->objects[$this->currentContents]['c'] .= ' ET';
3375 3375
 
3376 3376
     // if there are any open callbacks, then they should be called, to show the end of the line
3377
-    if  ($this->nCallback>0) {
3378
-      for  ($i =  $this->nCallback;$i>0;$i--) {
3377
+    if ($this->nCallback > 0) {
3378
+      for ($i = $this->nCallback; $i > 0; $i--) {
3379 3379
         // call each function
3380
-        $tmp =  $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, $text);
3381
-        $info =  array(
3380
+        $tmp = $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, $text);
3381
+        $info = array(
3382 3382
           'x' => $tmp[0], 
3383 3383
           'y' => $tmp[1], 
3384 3384
           'angle' => $angle,
@@ -3388,7 +3388,7 @@  discard block
 block discarded – undo
3388 3388
           'height' => $this->callback[$i]['height'], 
3389 3389
           'descender' => $this->callback[$i]['descender']
3390 3390
         );
3391
-        $func =  $this->callback[$i]['f'];
3391
+        $func = $this->callback[$i]['f'];
3392 3392
         $this->$func($info);
3393 3393
       }
3394 3394
     }
@@ -3399,68 +3399,68 @@  discard block
 block discarded – undo
3399 3399
    * calculate how wide a given text string will be on a page, at a given size.
3400 3400
    * this can be called externally, but is alse used by the other class functions
3401 3401
    */
3402
-  function  getTextWidth($size, $text, $spacing =  0) {
3402
+  function  getTextWidth($size, $text, $spacing = 0) {
3403 3403
     // this function should not change any of the settings, though it will need to
3404 3404
     // track any directives which change during calculation, so copy them at the start
3405 3405
     // and put them back at the end.
3406
-    $store_currentTextState =  $this->currentTextState;
3406
+    $store_currentTextState = $this->currentTextState;
3407 3407
 
3408
-    if  (!$this->numFonts) {
3408
+    if (!$this->numFonts) {
3409 3409
       $this->selectFont($this->defaultFont);
3410 3410
     }
3411 3411
 
3412 3412
     // converts a number or a float to a string so it can get the width
3413
-    $text =  "$text";
3413
+    $text = "$text";
3414 3414
 
3415 3415
     // hmm, this is where it all starts to get tricky - use the font information to
3416 3416
     // calculate the width of each character, add them up and convert to user units
3417
-    $w =  0;
3418
-    $cf =  $this->currentFont;
3419
-    $space_scale =  1000 / $size;
3420
-    if ( $this->fonts[$cf]['isUnicode']) {
3417
+    $w = 0;
3418
+    $cf = $this->currentFont;
3419
+    $space_scale = 1000 / $size;
3420
+    if ($this->fonts[$cf]['isUnicode']) {
3421 3421
       // for Unicode, use the code points array to calculate width rather
3422 3422
       // than just the string itself
3423
-      $unicode =  $this->utf8toCodePointsArray($text);
3423
+      $unicode = $this->utf8toCodePointsArray($text);
3424 3424
 
3425 3425
       foreach ($unicode as $char) {
3426 3426
         // check if we have to replace character
3427
-      if  ( isset($this->fonts[$cf]['differences'][$char])) {
3428
-          $char =  $this->fonts[$cf]['differences'][$char];
3427
+      if (isset($this->fonts[$cf]['differences'][$char])) {
3428
+          $char = $this->fonts[$cf]['differences'][$char];
3429 3429
         }
3430 3430
         // add the character width
3431
-        if  ( isset($this->fonts[$cf]['C'][$char]['WX'])) {
3432
-          $w+=  $this->fonts[$cf]['C'][$char]['WX'];
3431
+        if (isset($this->fonts[$cf]['C'][$char]['WX'])) {
3432
+          $w += $this->fonts[$cf]['C'][$char]['WX'];
3433 3433
         }
3434 3434
         // add additional padding for space
3435
-        if  ( $char ==  32) {  // Space
3436
-          $w+=  $spacing * $space_scale;
3435
+        if ($char == 32) {  // Space
3436
+          $w += $spacing * $space_scale;
3437 3437
         }
3438 3438
       }
3439 3439
 
3440 3440
     } else {
3441
-      $len =  mb_strlen($text, 'Windows-1252');
3441
+      $len = mb_strlen($text, 'Windows-1252');
3442 3442
 
3443
-      for  ($i =  0; $i < $len; $i++) {
3444
-        $char =  ord($text[$i]);
3443
+      for ($i = 0; $i < $len; $i++) {
3444
+        $char = ord($text[$i]);
3445 3445
         // check if we have to replace character
3446
-        if  ( isset($this->fonts[$cf]['differences'][$char])) {
3447
-          $char =  $this->fonts[$cf]['differences'][$char];
3446
+        if (isset($this->fonts[$cf]['differences'][$char])) {
3447
+          $char = $this->fonts[$cf]['differences'][$char];
3448 3448
         }
3449 3449
         // add the character width
3450
-        if  ( isset($this->fonts[$cf]['C'][$char]['WX'])) {
3451
-        $w+=  $this->fonts[$cf]['C'][$char]['WX'];
3450
+        if (isset($this->fonts[$cf]['C'][$char]['WX'])) {
3451
+        $w += $this->fonts[$cf]['C'][$char]['WX'];
3452 3452
         }
3453 3453
         // add additional padding for space
3454
-        if  ( $char ==  32) {  // Space
3455
-          $w+=  $spacing * $space_scale;
3454
+        if ($char == 32) {  // Space
3455
+          $w += $spacing * $space_scale;
3456 3456
         }
3457 3457
       }
3458 3458
     }
3459 3459
 
3460
-    $this->currentTextState =  $store_currentTextState;
3460
+    $this->currentTextState = $store_currentTextState;
3461 3461
     $this->setCurrentFont();
3462 3462
 
3463
-    return  $w*$size/1000;
3463
+    return  $w * $size / 1000;
3464 3464
   }
3465 3465
 
3466 3466
 
@@ -3470,28 +3470,28 @@  discard block
 block discarded – undo
3470 3470
    * @access private
3471 3471
    */
3472 3472
   function  PRVTadjustWrapText($text, $actual, $width, &$x, &$adjust, $justification) {
3473
-    switch  ($justification) {
3473
+    switch ($justification) {
3474 3474
     case  'left':
3475 3475
       return;
3476 3476
 
3477 3477
     case  'right':
3478
-      $x+=  $width-$actual;
3478
+      $x += $width - $actual;
3479 3479
       break;
3480 3480
 
3481 3481
     case  'center':
3482 3482
     case  'centre':
3483
-      $x+=  ($width-$actual) /2;
3483
+      $x += ($width - $actual) / 2;
3484 3484
       break;
3485 3485
 
3486 3486
     case  'full':
3487 3487
       // count the number of words
3488
-      $words =  explode(' ', $text);
3489
-      $nspaces =  count($words) -1;
3488
+      $words = explode(' ', $text);
3489
+      $nspaces = count($words) - 1;
3490 3490
 
3491
-      if  ($nspaces>0) {
3492
-        $adjust =  ($width-$actual) /$nspaces;
3491
+      if ($nspaces > 0) {
3492
+        $adjust = ($width - $actual) / $nspaces;
3493 3493
       } else {
3494
-        $adjust =  0;
3494
+        $adjust = 0;
3495 3495
       }
3496 3496
       break;
3497 3497
     }
@@ -3504,9 +3504,9 @@  discard block
 block discarded – undo
3504 3504
    * and return the remainder.
3505 3505
    * justification and angle can also be specified for the text
3506 3506
    */
3507
-  function  addTextWrap($x, $y, $width, $size, $text, $justification =  'left', $angle =  0, $test =  0) {
3507
+  function  addTextWrap($x, $y, $width, $size, $text, $justification = 'left', $angle = 0, $test = 0) {
3508 3508
   	// TODO - need to support Unicode
3509
-    $cf =  $this->currentFont;
3509
+    $cf = $this->currentFont;
3510 3510
     if ($this->fonts[$cf]['isUnicode']) {
3511 3511
         die("addTextWrap does not support Unicode yet!");
3512 3512
     }
@@ -3518,89 +3518,89 @@  discard block
 block discarded – undo
3518 3518
 
3519 3519
     // need to store the initial text state, as this will change during the width calculation
3520 3520
     // but will need to be re-set before printing, so that the chars work out right
3521
-    $store_currentTextState =  $this->currentTextState;
3521
+    $store_currentTextState = $this->currentTextState;
3522 3522
 
3523
-    if  (!$this->numFonts) {
3523
+    if (!$this->numFonts) {
3524 3524
       $this->selectFont($this->defaultFont);
3525 3525
     }
3526 3526
 
3527
-    if  ($width <=  0) {
3527
+    if ($width <= 0) {
3528 3528
       // error, pretend it printed ok, otherwise risking a loop
3529 3529
       return  '';
3530 3530
     }
3531 3531
 
3532
-    $w =  0;
3533
-    $break =  0;
3534
-    $breakWidth =  0;
3535
-    $len =  mb_strlen($text);
3536
-    $cf =  $this->currentFont;
3537
-    $tw =  $width/$size*1000;
3532
+    $w = 0;
3533
+    $break = 0;
3534
+    $breakWidth = 0;
3535
+    $len = mb_strlen($text);
3536
+    $cf = $this->currentFont;
3537
+    $tw = $width / $size * 1000;
3538 3538
 
3539
-    for  ($i =  0;$i<$len;$i++) {
3540
-      $f =  1;
3541
-      $directive =  0;
3539
+    for ($i = 0; $i < $len; $i++) {
3540
+      $f = 1;
3541
+      $directive = 0;
3542 3542
       //$this->PRVTcheckTextDirective($text,$i,$f);
3543
-      if  ($directive) {
3544
-        if  ($f) {
3543
+      if ($directive) {
3544
+        if ($f) {
3545 3545
           $this->setCurrentFont();
3546
-          $cf =  $this->currentFont;
3546
+          $cf = $this->currentFont;
3547 3547
         }
3548 3548
 
3549
-        $i =  $i+$directive-1;
3549
+        $i = $i + $directive - 1;
3550 3550
       } else {
3551
-        $cOrd =  ord($text[$i]);
3551
+        $cOrd = ord($text[$i]);
3552 3552
 
3553
-        if  (isset($this->fonts[$cf]['differences'][$cOrd])) {
3553
+        if (isset($this->fonts[$cf]['differences'][$cOrd])) {
3554 3554
           // then this character is being replaced by another
3555
-          $cOrd2 =  $this->fonts[$cf]['differences'][$cOrd];
3555
+          $cOrd2 = $this->fonts[$cf]['differences'][$cOrd];
3556 3556
         } else {
3557
-          $cOrd2 =  $cOrd;
3557
+          $cOrd2 = $cOrd;
3558 3558
         }
3559 3559
 
3560
-        if  (isset($this->fonts[$cf]['C'][$cOrd2]['WX'])) {
3561
-          $w+=  $this->fonts[$cf]['C'][$cOrd2]['WX'];
3560
+        if (isset($this->fonts[$cf]['C'][$cOrd2]['WX'])) {
3561
+          $w += $this->fonts[$cf]['C'][$cOrd2]['WX'];
3562 3562
         }
3563 3563
 
3564
-        if  ($w>$tw) {
3564
+        if ($w > $tw) {
3565 3565
           // then we need to truncate this line
3566
-          if  ($break>0) {
3566
+          if ($break > 0) {
3567 3567
             // then we have somewhere that we can split :)
3568
-            if  ($text[$break] ===  ' ') {
3569
-              $tmp =  mb_substr($text, 0, $break);
3568
+            if ($text[$break] === ' ') {
3569
+              $tmp = mb_substr($text, 0, $break);
3570 3570
             } else {
3571
-              $tmp =  mb_substr($text, 0, $break+1);
3571
+              $tmp = mb_substr($text, 0, $break + 1);
3572 3572
             }
3573 3573
 
3574
-            $adjust =  0;
3574
+            $adjust = 0;
3575 3575
             $this->PRVTadjustWrapText($tmp, $breakWidth, $width, $x, $adjust, $justification);
3576 3576
 
3577 3577
             // reset the text state
3578
-            $this->currentTextState =  $store_currentTextState;
3578
+            $this->currentTextState = $store_currentTextState;
3579 3579
             $this->setCurrentFont();
3580 3580
 
3581
-            if  (!$test) {
3581
+            if (!$test) {
3582 3582
               $this->addText($x, $y, $size, $tmp, $angle, $adjust);
3583 3583
             }
3584 3584
 
3585
-            return  mb_substr($text, $break+1);
3585
+            return  mb_substr($text, $break + 1);
3586 3586
           } else {
3587 3587
             // just split before the current character
3588
-            $tmp =  mb_substr($text, 0, $i);
3589
-            $adjust =  0;
3590
-            $ctmp =  ord($text[$i]);
3588
+            $tmp = mb_substr($text, 0, $i);
3589
+            $adjust = 0;
3590
+            $ctmp = ord($text[$i]);
3591 3591
 
3592
-            if  (isset($this->fonts[$cf]['differences'][$ctmp])) {
3593
-              $ctmp =  $this->fonts[$cf]['differences'][$ctmp];
3592
+            if (isset($this->fonts[$cf]['differences'][$ctmp])) {
3593
+              $ctmp = $this->fonts[$cf]['differences'][$ctmp];
3594 3594
             }
3595 3595
 
3596
-            $tmpw =  ($w-$this->fonts[$cf]['C'][$ctmp]['WX']) *$size/1000;
3596
+            $tmpw = ($w - $this->fonts[$cf]['C'][$ctmp]['WX']) * $size / 1000;
3597 3597
             $this->PRVTadjustWrapText($tmp, $tmpw, $width, $x, $adjust, $justification);
3598 3598
 
3599 3599
             // reset the text state
3600
-            $this->currentTextState =  $store_currentTextState;
3600
+            $this->currentTextState = $store_currentTextState;
3601 3601
             $this->setCurrentFont();
3602 3602
 
3603
-            if  (!$test) {
3603
+            if (!$test) {
3604 3604
               $this->addText($x, $y, $size, $tmp, $angle, $adjust);
3605 3605
             }
3606 3606
 
@@ -3608,39 +3608,39 @@  discard block
 block discarded – undo
3608 3608
           }
3609 3609
         }
3610 3610
 
3611
-        if  ($text[$i] ===  '-') {
3612
-          $break =  $i;
3613
-          $breakWidth =  $w*$size/1000;
3611
+        if ($text[$i] === '-') {
3612
+          $break = $i;
3613
+          $breakWidth = $w * $size / 1000;
3614 3614
         }
3615 3615
 
3616
-        if  ($text[$i] ===  ' ') {
3617
-          $break =  $i;
3618
-          $ctmp =  ord($text[$i]);
3616
+        if ($text[$i] === ' ') {
3617
+          $break = $i;
3618
+          $ctmp = ord($text[$i]);
3619 3619
 
3620
-          if  (isset($this->fonts[$cf]['differences'][$ctmp])) {
3621
-            $ctmp =  $this->fonts[$cf]['differences'][$ctmp];
3620
+          if (isset($this->fonts[$cf]['differences'][$ctmp])) {
3621
+            $ctmp = $this->fonts[$cf]['differences'][$ctmp];
3622 3622
           }
3623 3623
 
3624
-          $breakWidth =  ($w-$this->fonts[$cf]['C'][$ctmp]['WX']) *$size/1000;
3624
+          $breakWidth = ($w - $this->fonts[$cf]['C'][$ctmp]['WX']) * $size / 1000;
3625 3625
         }
3626 3626
       }
3627 3627
     }
3628 3628
 
3629 3629
     // then there was no need to break this line
3630
-    if  ($justification ===  'full') {
3631
-      $justification =  'left';
3630
+    if ($justification === 'full') {
3631
+      $justification = 'left';
3632 3632
     }
3633 3633
 
3634
-    $adjust =  0;
3635
-    $tmpw =  $w*$size/1000;
3634
+    $adjust = 0;
3635
+    $tmpw = $w * $size / 1000;
3636 3636
 
3637 3637
     $this->PRVTadjustWrapText($text, $tmpw, $width, $x, $adjust, $justification);
3638 3638
 
3639 3639
     // reset the text state
3640
-    $this->currentTextState =  $store_currentTextState;
3640
+    $this->currentTextState = $store_currentTextState;
3641 3641
     $this->setCurrentFont();
3642 3642
 
3643
-    if  (!$test) {
3643
+    if (!$test) {
3644 3644
       $this->addText($x, $y, $size, $text, $angle, $adjust, $angle);
3645 3645
     }
3646 3646
 
@@ -3654,45 +3654,45 @@  discard block
 block discarded – undo
3654 3654
    * This is to get around not being able to have open 'q' across pages
3655 3655
    *
3656 3656
    */
3657
-  function  saveState($pageEnd =  0) {
3658
-    if  ($pageEnd) {
3657
+  function  saveState($pageEnd = 0) {
3658
+    if ($pageEnd) {
3659 3659
       // this will be called at a new page to return the state to what it was on the
3660 3660
       // end of the previous page, before the stack was closed down
3661 3661
       // This is to get around not being able to have open 'q' across pages
3662
-      $opt =  $this->stateStack[$pageEnd];
3662
+      $opt = $this->stateStack[$pageEnd];
3663 3663
       // ok to use this as stack starts numbering at 1
3664 3664
       $this->setColor($opt['col']['r'], $opt['col']['g'], $opt['col']['b'], 1);
3665 3665
       $this->setStrokeColor($opt['str']['r'], $opt['str']['g'], $opt['str']['b'], 1);
3666
-      $this->objects[$this->currentContents]['c'].=  "\n".$opt['lin'];
3666
+      $this->objects[$this->currentContents]['c'] .= "\n".$opt['lin'];
3667 3667
       //    $this->currentLineStyle = $opt['lin'];
3668 3668
     } else {
3669 3669
       $this->nStateStack++;
3670
-      $this->stateStack[$this->nStateStack] =  array(
3670
+      $this->stateStack[$this->nStateStack] = array(
3671 3671
         'col' => $this->currentColour, 
3672 3672
         'str' => $this->currentStrokeColour, 
3673 3673
         'lin' => $this->currentLineStyle
3674 3674
       );
3675 3675
     }
3676 3676
 
3677
-    $this->objects[$this->currentContents]['c'].=  "\nq";
3677
+    $this->objects[$this->currentContents]['c'] .= "\nq";
3678 3678
   }
3679 3679
 
3680 3680
 
3681 3681
   /**
3682 3682
    * restore a previously saved state
3683 3683
    */
3684
-  function  restoreState($pageEnd =  0) {
3685
-    if  (!$pageEnd) {
3686
-      $n =  $this->nStateStack;
3687
-      $this->currentColour =  $this->stateStack[$n]['col'];
3688
-      $this->currentStrokeColour =  $this->stateStack[$n]['str'];
3689
-      $this->objects[$this->currentContents]['c'].=  "\n".$this->stateStack[$n]['lin'];
3690
-      $this->currentLineStyle =  $this->stateStack[$n]['lin'];
3684
+  function  restoreState($pageEnd = 0) {
3685
+    if (!$pageEnd) {
3686
+      $n = $this->nStateStack;
3687
+      $this->currentColour = $this->stateStack[$n]['col'];
3688
+      $this->currentStrokeColour = $this->stateStack[$n]['str'];
3689
+      $this->objects[$this->currentContents]['c'] .= "\n".$this->stateStack[$n]['lin'];
3690
+      $this->currentLineStyle = $this->stateStack[$n]['lin'];
3691 3691
       unset($this->stateStack[$n]);
3692 3692
       $this->nStateStack--;
3693 3693
     }
3694 3694
     
3695
-    $this->objects[$this->currentContents]['c'].=  "\nQ";
3695
+    $this->objects[$this->currentContents]['c'] .= "\nQ";
3696 3696
   }
3697 3697
 
3698 3698
 
@@ -3704,12 +3704,12 @@  discard block
 block discarded – undo
3704 3704
    */
3705 3705
   function  openObject() {
3706 3706
     $this->nStack++;
3707
-    $this->stack[$this->nStack] =  array('c' => $this->currentContents, 'p' => $this->currentPage);
3707
+    $this->stack[$this->nStack] = array('c' => $this->currentContents, 'p' => $this->currentPage);
3708 3708
     // add a new object of the content type, to hold the data flow
3709 3709
     $this->numObj++;
3710 3710
     $this->o_contents($this->numObj, 'new');
3711
-    $this->currentContents =  $this->numObj;
3712
-    $this->looseObjects[$this->numObj] =  1;
3711
+    $this->currentContents = $this->numObj;
3712
+    $this->looseObjects[$this->numObj] = 1;
3713 3713
 
3714 3714
     return  $this->numObj;
3715 3715
   }
@@ -3720,12 +3720,12 @@  discard block
 block discarded – undo
3720 3720
    */
3721 3721
   function  reopenObject($id) {
3722 3722
     $this->nStack++;
3723
-    $this->stack[$this->nStack] =  array('c' => $this->currentContents, 'p' => $this->currentPage);
3724
-    $this->currentContents =  $id;
3723
+    $this->stack[$this->nStack] = array('c' => $this->currentContents, 'p' => $this->currentPage);
3724
+    $this->currentContents = $id;
3725 3725
 
3726 3726
     // also if this object is the primary contents for a page, then set the current page to its parent
3727
-    if  (isset($this->objects[$id]['onPage'])) {
3728
-      $this->currentPage =  $this->objects[$id]['onPage'];
3727
+    if (isset($this->objects[$id]['onPage'])) {
3728
+      $this->currentPage = $this->objects[$id]['onPage'];
3729 3729
     }
3730 3730
   }
3731 3731
 
@@ -3736,9 +3736,9 @@  discard block
 block discarded – undo
3736 3736
   function  closeObject() {
3737 3737
     // close the object, as long as there was one open in the first place, which will be indicated by
3738 3738
     // an objectId on the stack.
3739
-    if  ($this->nStack>0) {
3740
-      $this->currentContents =  $this->stack[$this->nStack]['c'];
3741
-      $this->currentPage =  $this->stack[$this->nStack]['p'];
3739
+    if ($this->nStack > 0) {
3740
+      $this->currentContents = $this->stack[$this->nStack]['c'];
3741
+      $this->currentPage = $this->stack[$this->nStack]['p'];
3742 3742
       $this->nStack--;
3743 3743
       // easier to probably not worry about removing the old entries, they will be overwritten
3744 3744
       // if there are new ones.
@@ -3752,8 +3752,8 @@  discard block
 block discarded – undo
3752 3752
   function  stopObject($id) {
3753 3753
     // if an object has been appearing on pages up to now, then stop it, this page will
3754 3754
     // be the last one that could contian it.
3755
-    if  (isset($this->addLooseObjects[$id])) {
3756
-      $this->addLooseObjects[$id] =  '';
3755
+    if (isset($this->addLooseObjects[$id])) {
3756
+      $this->addLooseObjects[$id] = '';
3757 3757
     }
3758 3758
   }
3759 3759
 
@@ -3761,18 +3761,18 @@  discard block
 block discarded – undo
3761 3761
   /**
3762 3762
    * after an object has been created, it wil only show if it has been added, using this function.
3763 3763
    */
3764
-  function  addObject($id, $options =  'add') {
3764
+  function  addObject($id, $options = 'add') {
3765 3765
     // add the specified object to the page
3766
-    if  (isset($this->looseObjects[$id]) &&  $this->currentContents !=  $id) {
3766
+    if (isset($this->looseObjects[$id]) && $this->currentContents != $id) {
3767 3767
       // then it is a valid object, and it is not being added to itself
3768 3768
       switch ($options) {
3769 3769
       case  'all':
3770 3770
         // then this object is to be added to this page (done in the next block) and
3771 3771
         // all future new pages.
3772
-        $this->addLooseObjects[$id] =  'all';
3772
+        $this->addLooseObjects[$id] = 'all';
3773 3773
 
3774 3774
       case  'add':
3775
-        if  (isset($this->objects[$this->currentContents]['onPage'])) {
3775
+        if (isset($this->objects[$this->currentContents]['onPage'])) {
3776 3776
           // then the destination contents is the primary for the page
3777 3777
           // (though this object is actually added to that page)
3778 3778
           $this->o_page($this->objects[$this->currentContents]['onPage'], 'content', $id);
@@ -3780,33 +3780,33 @@  discard block
 block discarded – undo
3780 3780
         break;
3781 3781
 
3782 3782
       case  'even':
3783
-        $this->addLooseObjects[$id] =  'even';
3784
-        $pageObjectId =  $this->objects[$this->currentContents]['onPage'];
3785
-        if  ($this->objects[$pageObjectId]['info']['pageNum']%2 ==  0) {
3783
+        $this->addLooseObjects[$id] = 'even';
3784
+        $pageObjectId = $this->objects[$this->currentContents]['onPage'];
3785
+        if ($this->objects[$pageObjectId]['info']['pageNum'] % 2 == 0) {
3786 3786
           $this->addObject($id);
3787 3787
           // hacky huh :)
3788 3788
         }
3789 3789
         break;
3790 3790
 
3791 3791
       case  'odd':
3792
-        $this->addLooseObjects[$id] =  'odd';
3793
-        $pageObjectId =  $this->objects[$this->currentContents]['onPage'];
3794
-        if  ($this->objects[$pageObjectId]['info']['pageNum']%2 ==  1) {
3792
+        $this->addLooseObjects[$id] = 'odd';
3793
+        $pageObjectId = $this->objects[$this->currentContents]['onPage'];
3794
+        if ($this->objects[$pageObjectId]['info']['pageNum'] % 2 == 1) {
3795 3795
           $this->addObject($id);
3796 3796
           // hacky huh :)
3797 3797
         }
3798 3798
         break;
3799 3799
 
3800 3800
       case  'next':
3801
-        $this->addLooseObjects[$id] =  'all';
3801
+        $this->addLooseObjects[$id] = 'all';
3802 3802
         break;
3803 3803
 
3804 3804
       case  'nexteven':
3805
-        $this->addLooseObjects[$id] =  'even';
3805
+        $this->addLooseObjects[$id] = 'even';
3806 3806
         break;
3807 3807
 
3808 3808
       case  'nextodd':
3809
-        $this->addLooseObjects[$id] =  'odd';
3809
+        $this->addLooseObjects[$id] = 'odd';
3810 3810
         break;
3811 3811
       }
3812 3812
     }
@@ -3817,8 +3817,8 @@  discard block
 block discarded – undo
3817 3817
    * return a storable representation of a specific object
3818 3818
    */
3819 3819
   function  serializeObject($id) {
3820
-    if  ( array_key_exists($id,  $this->objects))
3821
-      return  var_export($this->objects[$id],  true);
3820
+    if (array_key_exists($id, $this->objects))
3821
+      return  var_export($this->objects[$id], true);
3822 3822
   }
3823 3823
 
3824 3824
 
@@ -3826,8 +3826,8 @@  discard block
 block discarded – undo
3826 3826
    * restore an object from its stored representation.  returns its new object id.
3827 3827
    */
3828 3828
   function  restoreSerializedObject($obj) {
3829
-    $obj_id =  $this->openObject();
3830
-    eval('$this->objects[$obj_id] = ' . $obj . ';');
3829
+    $obj_id = $this->openObject();
3830
+    eval('$this->objects[$obj_id] = '.$obj.';');
3831 3831
     $this->closeObject();
3832 3832
     return  $obj_id;
3833 3833
   }
@@ -3836,12 +3836,12 @@  discard block
 block discarded – undo
3836 3836
   /**
3837 3837
    * add content to the documents info object
3838 3838
    */
3839
-  function  addInfo($label, $value =  0) {
3839
+  function  addInfo($label, $value = 0) {
3840 3840
     // this will only work if the label is one of the valid ones.
3841 3841
     // modify this so that arrays can be passed as well.
3842 3842
     // if $label is an array then assume that it is key => value pairs
3843 3843
     // else assume that they are both scalar, anything else will probably error
3844
-    if  (is_array($label)) {
3844
+    if (is_array($label)) {
3845 3845
       foreach ($label as  $l => $v) {
3846 3846
         $this->o_info($this->infoObject, $l, $v);
3847 3847
       }
@@ -3854,9 +3854,9 @@  discard block
 block discarded – undo
3854 3854
   /**
3855 3855
    * set the viewer preferences of the document, it is up to the browser to obey these.
3856 3856
    */
3857
-  function  setPreferences($label, $value =  0) {
3857
+  function  setPreferences($label, $value = 0) {
3858 3858
     // this will only work if the label is one of the valid ones.
3859
-    if  (is_array($label)) {
3859
+    if (is_array($label)) {
3860 3860
       foreach ($label as  $l => $v) {
3861 3861
         $this->o_catalog($this->catalogId, 'viewerPreferences', array($l => $v));
3862 3862
       }
@@ -3873,10 +3873,10 @@  discard block
 block discarded – undo
3873 3873
    */
3874 3874
   function  PRVT_getBytes(&$data, $pos, $num) {
3875 3875
     // return the integer represented by $num bytes from $pos within $data
3876
-    $ret =  0;
3877
-    for  ($i =  0;$i<$num;$i++) {
3878
-      $ret =  $ret*256;
3879
-      $ret+=  ord($data[$pos+$i]);
3876
+    $ret = 0;
3877
+    for ($i = 0; $i < $num; $i++) {
3878
+      $ret = $ret * 256;
3879
+      $ret += ord($data[$pos + $i]);
3880 3880
     }
3881 3881
 
3882 3882
     return  $ret;
@@ -3887,9 +3887,9 @@  discard block
 block discarded – undo
3887 3887
    * add a PNG image into the document, from a GD object
3888 3888
    * this should work with remote files
3889 3889
    */
3890
-  function addImagePng($file, $x, $y, $w =  0, $h =  0, &$img) {
3890
+  function addImagePng($file, $x, $y, $w = 0, $h = 0, &$img) {
3891 3891
     //if already cached, need not to read again
3892
-	if ( isset($this->imagelist[$file]) ) {
3892
+	if (isset($this->imagelist[$file])) {
3893 3893
 	  $data = null;
3894 3894
 	} else {
3895 3895
   	  // Example for transparency handling on new image. Retain for current image
@@ -3905,7 +3905,7 @@  discard block
 block discarded – undo
3905 3905
 	  //default, but explicitely set to ensure pdf compatibility
3906 3906
       imagesavealpha($img, false);
3907 3907
       
3908
-      $error =  0;
3908
+      $error = 0;
3909 3909
       //DEBUG_IMG_TEMP
3910 3910
       //debugpng
3911 3911
       if (DEBUGPNG) print '[addImagePng '.$file.']';
@@ -3923,7 +3923,7 @@  discard block
 block discarded – undo
3923 3923
         if (DEBUGPNG) print 'trouble writing file from GD';
3924 3924
 	  }
3925 3925
 
3926
-      if  ($error) {
3926
+      if ($error) {
3927 3927
         $this->addMessage('PNG error - ('.$file.') '.$errormsg);
3928 3928
         return;
3929 3929
       }
@@ -3937,9 +3937,9 @@  discard block
 block discarded – undo
3937 3937
    * add a PNG image into the document, from a file
3938 3938
    * this should work with remote files
3939 3939
    */
3940
-  function  addPngFromFile($file, $x, $y, $w =  0, $h =  0) {
3940
+  function  addPngFromFile($file, $x, $y, $w = 0, $h = 0) {
3941 3941
     //if already cached, need not to read again
3942
-	if ( isset($this->imagelist[$file]) ) {
3942
+	if (isset($this->imagelist[$file])) {
3943 3943
 	  $img = null;
3944 3944
 	} else {
3945 3945
       //png files typically contain an alpha channel.
@@ -3958,18 +3958,18 @@  discard block
 block discarded – undo
3958 3958
       }
3959 3959
       $sx = imagesx($imgtmp);
3960 3960
       $sy = imagesy($imgtmp);
3961
-      $img = imagecreatetruecolor($sx,$sy);
3961
+      $img = imagecreatetruecolor($sx, $sy);
3962 3962
       imagealphablending($img, true);
3963 3963
   	  $ti = imagecolortransparent($imgtmp);
3964 3964
 	  if ($ti >= 0) {
3965
-	    $tc = imagecolorsforindex($imgtmp,$ti);
3966
-        $ti = imagecolorallocate($img,$tc['red'],$tc['green'],$tc['blue']);
3967
-        imagefill($img,0,0,$ti);
3965
+	    $tc = imagecolorsforindex($imgtmp, $ti);
3966
+        $ti = imagecolorallocate($img, $tc['red'], $tc['green'], $tc['blue']);
3967
+        imagefill($img, 0, 0, $ti);
3968 3968
         imagecolortransparent($img, $ti);
3969 3969
       } else {
3970
-        imagefill($img,1,1,imagecolorallocate($img,255,255,255));
3970
+        imagefill($img, 1, 1, imagecolorallocate($img, 255, 255, 255));
3971 3971
       }
3972
-      imagecopy($img,$imgtmp,0,0,0,0,$sx,$sy);
3972
+      imagecopy($img, $imgtmp, 0, 0, 0, 0, $sx, $sy);
3973 3973
       imagedestroy($imgtmp);
3974 3974
     }
3975 3975
     $this->addImagePng($file, $x, $y, $w, $h, $img);
@@ -3979,8 +3979,8 @@  discard block
 block discarded – undo
3979 3979
   /**
3980 3980
    * add a PNG image into the document, from a memory buffer of the file
3981 3981
    */
3982
-  function  addPngFromBuf($file, $x, $y, $w =  0, $h =  0, &$data) {
3983
-	if ( isset($this->imagelist[$file]) ) {
3982
+  function  addPngFromBuf($file, $x, $y, $w = 0, $h = 0, &$data) {
3983
+	if (isset($this->imagelist[$file])) {
3984 3984
       //debugpng
3985 3985
       //if (DEBUGPNG) print '[addPngFromBuf Duplicate '.$file.']';
3986 3986
 	  $data = null;
@@ -3995,81 +3995,81 @@  discard block
 block discarded – undo
3995 3995
       }
3996 3996
       //debugpng
3997 3997
       //if (DEBUGPNG) print '[addPngFromBuf file='.$file.']';
3998
-    $error =  0;
3998
+    $error = 0;
3999 3999
 
4000
-    if  (!$error) {
4001
-      $header =  chr(137) .chr(80) .chr(78) .chr(71) .chr(13) .chr(10) .chr(26) .chr(10);
4002
-      if  (mb_substr($data, 0, 8, '8bit') !=  $header) {
4003
-        $error =  1;
4000
+    if (!$error) {
4001
+      $header = chr(137).chr(80).chr(78).chr(71).chr(13).chr(10).chr(26).chr(10);
4002
+      if (mb_substr($data, 0, 8, '8bit') != $header) {
4003
+        $error = 1;
4004 4004
         //debugpng
4005 4005
         if (DEBUGPNG) print '[addPngFromFile this file does not have a valid header '.$file.']';
4006 4006
 
4007
-        $errormsg =  'this file does not have a valid header';
4007
+        $errormsg = 'this file does not have a valid header';
4008 4008
       }
4009 4009
     }
4010 4010
 
4011 4011
 
4012
-    if  (!$error) {
4012
+    if (!$error) {
4013 4013
       // set pointer
4014
-      $p =  8;
4015
-      $len =  mb_strlen($data, '8bit');
4014
+      $p = 8;
4015
+      $len = mb_strlen($data, '8bit');
4016 4016
 
4017 4017
       // cycle through the file, identifying chunks
4018
-      $haveHeader =  0;
4019
-      $info =  array();
4020
-      $idata =  '';
4021
-      $pdata =  '';
4022
-
4023
-      while  ($p < $len) {
4024
-        $chunkLen =  $this->PRVT_getBytes($data, $p, 4);
4025
-        $chunkType =  mb_substr($data, $p+4, 4, '8bit');
4018
+      $haveHeader = 0;
4019
+      $info = array();
4020
+      $idata = '';
4021
+      $pdata = '';
4022
+
4023
+      while ($p < $len) {
4024
+        $chunkLen = $this->PRVT_getBytes($data, $p, 4);
4025
+        $chunkType = mb_substr($data, $p + 4, 4, '8bit');
4026 4026
         //      echo $chunkType.' - '.$chunkLen.'<br>';
4027 4027
         switch ($chunkType) {
4028 4028
         case  'IHDR':
4029 4029
           // this is where all the file information comes from
4030
-          $info['width'] =  $this->PRVT_getBytes($data, $p+8, 4);
4031
-          $info['height'] =  $this->PRVT_getBytes($data, $p+12, 4);
4032
-          $info['bitDepth'] =  ord($data[$p+16]);
4033
-          $info['colorType'] =  ord($data[$p+17]);
4034
-          $info['compressionMethod'] =  ord($data[$p+18]);
4035
-          $info['filterMethod'] =  ord($data[$p+19]);
4036
-          $info['interlaceMethod'] =  ord($data[$p+20]);
4030
+          $info['width'] = $this->PRVT_getBytes($data, $p + 8, 4);
4031
+          $info['height'] = $this->PRVT_getBytes($data, $p + 12, 4);
4032
+          $info['bitDepth'] = ord($data[$p + 16]);
4033
+          $info['colorType'] = ord($data[$p + 17]);
4034
+          $info['compressionMethod'] = ord($data[$p + 18]);
4035
+          $info['filterMethod'] = ord($data[$p + 19]);
4036
+          $info['interlaceMethod'] = ord($data[$p + 20]);
4037 4037
 
4038 4038
           //print_r($info);
4039
-          $haveHeader =  1;
4040
-          if  ($info['compressionMethod'] !=  0) {
4041
-            $error =  1;
4039
+          $haveHeader = 1;
4040
+          if ($info['compressionMethod'] != 0) {
4041
+            $error = 1;
4042 4042
 
4043 4043
             //debugpng
4044 4044
             if (DEBUGPNG) print '[addPngFromFile unsupported compression method '.$file.']';
4045 4045
 
4046
-            $errormsg =  'unsupported compression method';
4046
+            $errormsg = 'unsupported compression method';
4047 4047
           }
4048 4048
 
4049
-          if  ($info['filterMethod'] !=  0) {
4050
-            $error =  1;
4049
+          if ($info['filterMethod'] != 0) {
4050
+            $error = 1;
4051 4051
 
4052 4052
             //debugpng
4053 4053
             if (DEBUGPNG) print '[addPngFromFile unsupported filter method '.$file.']';
4054 4054
 
4055
-            $errormsg =  'unsupported filter method';
4055
+            $errormsg = 'unsupported filter method';
4056 4056
           }
4057 4057
           break;
4058 4058
 
4059 4059
         case  'PLTE':
4060
-          $pdata.=  mb_substr($data, $p+8, $chunkLen, '8bit');
4060
+          $pdata .= mb_substr($data, $p + 8, $chunkLen, '8bit');
4061 4061
           break;
4062 4062
 
4063 4063
         case  'IDAT':
4064
-          $idata.=  mb_substr($data, $p+8, $chunkLen, '8bit');
4064
+          $idata .= mb_substr($data, $p + 8, $chunkLen, '8bit');
4065 4065
           break;
4066 4066
 
4067 4067
         case  'tRNS':
4068 4068
           //this chunk can only occur once and it must occur after the PLTE chunk and before IDAT chunk
4069 4069
           //print "tRNS found, color type = ".$info['colorType']."\n";
4070
-          $transparency =  array();
4070
+          $transparency = array();
4071 4071
 
4072
-          if  ($info['colorType'] ==  3) {
4072
+          if ($info['colorType'] == 3) {
4073 4073
             // indexed color, rbg
4074 4074
             /* corresponding to entries in the plte chunk
4075 4075
              Alpha for palette index 0: 1 byte
@@ -4078,38 +4078,38 @@  discard block
 block discarded – undo
4078 4078
             */
4079 4079
             // there will be one entry for each palette entry. up until the last non-opaque entry.
4080 4080
             // set up an array, stretching over all palette entries which will be o (opaque) or 1 (transparent)
4081
-            $transparency['type'] =  'indexed';
4082
-            $numPalette =  mb_strlen($pdata, '8bit')/3;
4083
-            $trans =  0;
4081
+            $transparency['type'] = 'indexed';
4082
+            $numPalette = mb_strlen($pdata, '8bit') / 3;
4083
+            $trans = 0;
4084 4084
 
4085
-            for  ($i =  $chunkLen;$i >=  0;$i--) {
4086
-              if  (ord($data[$p+8+$i]) ==  0) {
4087
-                $trans =  $i;
4085
+            for ($i = $chunkLen; $i >= 0; $i--) {
4086
+              if (ord($data[$p + 8 + $i]) == 0) {
4087
+                $trans = $i;
4088 4088
               }
4089 4089
             }
4090 4090
 
4091
-            $transparency['data'] =  $trans;
4092
-          } elseif ($info['colorType'] ==  0) {
4091
+            $transparency['data'] = $trans;
4092
+          } elseif ($info['colorType'] == 0) {
4093 4093
             // grayscale
4094 4094
             /* corresponding to entries in the plte chunk
4095 4095
              Gray: 2 bytes, range 0 .. (2^bitdepth)-1
4096 4096
             */
4097 4097
             //            $transparency['grayscale'] = $this->PRVT_getBytes($data,$p+8,2); // g = grayscale
4098
-            $transparency['type'] =  'indexed';
4098
+            $transparency['type'] = 'indexed';
4099 4099
 
4100
-            $transparency['data'] =  ord($data[$p+8+1]);
4101
-          } elseif ($info['colorType'] ==  2) {
4100
+            $transparency['data'] = ord($data[$p + 8 + 1]);
4101
+          } elseif ($info['colorType'] == 2) {
4102 4102
             // truecolor
4103 4103
             /* corresponding to entries in the plte chunk
4104 4104
              Red: 2 bytes, range 0 .. (2^bitdepth)-1
4105 4105
              Green: 2 bytes, range 0 .. (2^bitdepth)-1
4106 4106
              Blue: 2 bytes, range 0 .. (2^bitdepth)-1
4107 4107
             */
4108
-            $transparency['r'] =  $this->PRVT_getBytes($data, $p+8, 2);
4108
+            $transparency['r'] = $this->PRVT_getBytes($data, $p + 8, 2);
4109 4109
             // r from truecolor
4110
-            $transparency['g'] =  $this->PRVT_getBytes($data, $p+10, 2);
4110
+            $transparency['g'] = $this->PRVT_getBytes($data, $p + 10, 2);
4111 4111
             // g from truecolor
4112
-            $transparency['b'] =  $this->PRVT_getBytes($data, $p+12, 2);
4112
+            $transparency['b'] = $this->PRVT_getBytes($data, $p + 12, 2);
4113 4113
             // b from truecolor
4114 4114
 
4115 4115
             $transparency['type'] = 'color-key';
@@ -4126,67 +4126,67 @@  discard block
 block discarded – undo
4126 4126
           break;
4127 4127
         }
4128 4128
 
4129
-        $p+=  $chunkLen+12;
4129
+        $p += $chunkLen + 12;
4130 4130
       }
4131 4131
 
4132 4132
 
4133 4133
       if (!$haveHeader) {
4134
-        $error =  1;
4134
+        $error = 1;
4135 4135
 
4136 4136
         //debugpng
4137 4137
         if (DEBUGPNG) print '[addPngFromFile information header is missing '.$file.']';
4138 4138
 
4139
-        $errormsg =  'information header is missing';
4139
+        $errormsg = 'information header is missing';
4140 4140
       }
4141 4141
 
4142
-      if  (isset($info['interlaceMethod']) &&  $info['interlaceMethod']) {
4143
-        $error =  1;
4142
+      if (isset($info['interlaceMethod']) && $info['interlaceMethod']) {
4143
+        $error = 1;
4144 4144
 
4145 4145
         //debugpng
4146 4146
         if (DEBUGPNG) print '[addPngFromFile no support for interlaced images in pdf '.$file.']';
4147 4147
 
4148
-        $errormsg =  'There appears to be no support for interlaced images in pdf.';
4148
+        $errormsg = 'There appears to be no support for interlaced images in pdf.';
4149 4149
       }
4150 4150
     }
4151 4151
 
4152
-    if  (!$error &&  $info['bitDepth'] > 8) {
4153
-      $error =  1;
4152
+    if (!$error && $info['bitDepth'] > 8) {
4153
+      $error = 1;
4154 4154
 
4155 4155
       //debugpng
4156 4156
       if (DEBUGPNG) print '[addPngFromFile bit depth of 8 or less is supported '.$file.']';
4157 4157
 
4158
-      $errormsg =  'only bit depth of 8 or less is supported';
4158
+      $errormsg = 'only bit depth of 8 or less is supported';
4159 4159
     }
4160 4160
 
4161
-    if  (!$error) {
4162
-      if  ($info['colorType'] !=  2 &&  $info['colorType'] !=  0 &&  $info['colorType'] !=  3) {
4163
-        $error =  1;
4161
+    if (!$error) {
4162
+      if ($info['colorType'] != 2 && $info['colorType'] != 0 && $info['colorType'] != 3) {
4163
+        $error = 1;
4164 4164
 
4165 4165
         //debugpng
4166 4166
         if (DEBUGPNG) print '[addPngFromFile alpha channel not supported: '.$info['colorType'].' '.$file.']';
4167 4167
 
4168
-        $errormsg =  'transparancey alpha channel not supported, transparency only supported for palette images.';
4168
+        $errormsg = 'transparancey alpha channel not supported, transparency only supported for palette images.';
4169 4169
       } else {
4170
-        switch  ($info['colorType']) {
4170
+        switch ($info['colorType']) {
4171 4171
         case  3:
4172
-          $color =  'DeviceRGB';
4173
-          $ncolor =  1;
4172
+          $color = 'DeviceRGB';
4173
+          $ncolor = 1;
4174 4174
           break;
4175 4175
 
4176 4176
         case  2:
4177
-          $color =  'DeviceRGB';
4178
-          $ncolor =  3;
4177
+          $color = 'DeviceRGB';
4178
+          $ncolor = 3;
4179 4179
           break;
4180 4180
 
4181 4181
         case  0:
4182
-          $color =  'DeviceGray';
4183
-          $ncolor =  1;
4182
+          $color = 'DeviceGray';
4183
+          $ncolor = 1;
4184 4184
           break;
4185 4185
         }
4186 4186
       }
4187 4187
     }
4188 4188
 
4189
-    if  ($error) {
4189
+    if ($error) {
4190 4190
       $this->addMessage('PNG error - ('.$file.') '.$errormsg);
4191 4191
       return;
4192 4192
     }
@@ -4194,84 +4194,84 @@  discard block
 block discarded – undo
4194 4194
       //print_r($info);
4195 4195
       // so this image is ok... add it in.
4196 4196
       $this->numImages++;
4197
-      $im =  $this->numImages;
4198
-      $label =  'I'.$im;
4197
+      $im = $this->numImages;
4198
+      $label = 'I'.$im;
4199 4199
       $this->numObj++;
4200 4200
 
4201 4201
       //  $this->o_image($this->numObj,'new',array('label' => $label,'data' => $idata,'iw' => $w,'ih' => $h,'type' => 'png','ic' => $info['width']));
4202
-      $options =  array('label' => $label, 'data' => $idata, 'bitsPerComponent' => $info['bitDepth'], 'pdata' => $pdata, 'iw' => $info['width'], 'ih' => $info['height'], 'type' => 'png', 'color' => $color, 'ncolor' => $ncolor);
4202
+      $options = array('label' => $label, 'data' => $idata, 'bitsPerComponent' => $info['bitDepth'], 'pdata' => $pdata, 'iw' => $info['width'], 'ih' => $info['height'], 'type' => 'png', 'color' => $color, 'ncolor' => $ncolor);
4203 4203
 
4204
-      if  (isset($transparency)) {
4205
-        $options['transparency'] =  $transparency;
4204
+      if (isset($transparency)) {
4205
+        $options['transparency'] = $transparency;
4206 4206
       }
4207 4207
 
4208 4208
       $this->o_image($this->numObj, 'new', $options);
4209 4209
       $this->imagelist[$file] = array('label' =>$label, 'w' => $info['width'], 'h' => $info['height']);
4210 4210
     }
4211 4211
 
4212
-    if  ($w <=  0 && $h <=  0) {
4213
-      $w =  $info['width'];
4214
-      $h =  $info['height'];
4212
+    if ($w <= 0 && $h <= 0) {
4213
+      $w = $info['width'];
4214
+      $h = $info['height'];
4215 4215
     }
4216 4216
 
4217
-    if  ($w <=  0) {
4218
-      $w =  $h/$info['height']*$info['width'];
4217
+    if ($w <= 0) {
4218
+      $w = $h / $info['height'] * $info['width'];
4219 4219
     }
4220 4220
 
4221
-    if  ($h <=  0) {
4222
-      $h =  $w*$info['height']/$info['width'];
4221
+    if ($h <= 0) {
4222
+      $h = $w * $info['height'] / $info['width'];
4223 4223
     }
4224 4224
 
4225
-    $this->objects[$this->currentContents]['c'].=  "\nq";
4226
-    $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $w) ." 0 0 ".sprintf('%.3F', $h) ." ".sprintf('%.3F', $x) ." ".sprintf('%.3F', $y) ." cm";
4227
-    $this->objects[$this->currentContents]['c'].=  "\n/".$label.' Do';
4228
-    $this->objects[$this->currentContents]['c'].=  "\nQ";
4225
+    $this->objects[$this->currentContents]['c'] .= "\nq";
4226
+    $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $w)." 0 0 ".sprintf('%.3F', $h)." ".sprintf('%.3F', $x)." ".sprintf('%.3F', $y)." cm";
4227
+    $this->objects[$this->currentContents]['c'] .= "\n/".$label.' Do';
4228
+    $this->objects[$this->currentContents]['c'] .= "\nQ";
4229 4229
   }
4230 4230
 
4231 4231
 
4232 4232
   /**
4233 4233
    * add a JPEG image into the document, from a file
4234 4234
    */
4235
-  function  addJpegFromFile($img, $x, $y, $w =  0, $h =  0) {
4235
+  function  addJpegFromFile($img, $x, $y, $w = 0, $h = 0) {
4236 4236
     // attempt to add a jpeg image straight from a file, using no GD commands
4237 4237
     // note that this function is unable to operate on a remote file.
4238 4238
 
4239
-    if  (!file_exists($img)) {
4239
+    if (!file_exists($img)) {
4240 4240
       return;
4241 4241
     }
4242 4242
 
4243
-	if ( isset($this->imagelist[$img]) ) {
4243
+	if (isset($this->imagelist[$img])) {
4244 4244
 	  $data = null;
4245 4245
       $imageWidth = $this->imagelist[$img]['w'];
4246 4246
       $imageHeight = $this->imagelist[$img]['h'];
4247
-      $channels =  $this->imagelist[$img]['c'];
4247
+      $channels = $this->imagelist[$img]['c'];
4248 4248
 	} else {
4249
-      $tmp =  getimagesize($img);
4250
-      $imageWidth =  $tmp[0];
4251
-      $imageHeight =  $tmp[1];
4249
+      $tmp = getimagesize($img);
4250
+      $imageWidth = $tmp[0];
4251
+      $imageHeight = $tmp[1];
4252 4252
 
4253
-      if  (isset($tmp['channels'])) {
4254
-        $channels =  $tmp['channels'];
4253
+      if (isset($tmp['channels'])) {
4254
+        $channels = $tmp['channels'];
4255 4255
       } else {
4256
-        $channels =  3;
4256
+        $channels = 3;
4257 4257
       }
4258 4258
 
4259 4259
       //$fp = fopen($img,'rb');
4260
-      $data =  file_get_contents($img);
4260
+      $data = file_get_contents($img);
4261 4261
       //fread($fp,filesize($img));
4262 4262
       //fclose($fp);
4263 4263
     }
4264 4264
 
4265
-    if  ($w <=  0 &&  $h <=  0) {
4266
-      $w =  $imageWidth;
4265
+    if ($w <= 0 && $h <= 0) {
4266
+      $w = $imageWidth;
4267 4267
     }
4268 4268
 
4269
-    if  ($w ==  0) {
4270
-      $w =  $h/$imageHeight*$imageWidth;
4269
+    if ($w == 0) {
4270
+      $w = $h / $imageHeight * $imageWidth;
4271 4271
     }
4272 4272
 
4273
-    if  ($h ==  0) {
4274
-      $h =  $w*$imageHeight/$imageWidth;
4273
+    if ($h == 0) {
4274
+      $h = $w * $imageHeight / $imageWidth;
4275 4275
     }
4276 4276
 
4277 4277
     $this->addJpegImage_common($data, $x, $y, $w, $h, $imageWidth, $imageHeight, $channels, $img);
@@ -4283,7 +4283,7 @@  discard block
 block discarded – undo
4283 4283
    * this function is not all that reliable, and I would probably encourage people to use
4284 4284
    * the file based functions
4285 4285
    */
4286
-  function  addImage(&$img, $x, $y, $w =  0, $h =  0, $quality =  75) {
4286
+  function  addImage(&$img, $x, $y, $w = 0, $h = 0, $quality = 75) {
4287 4287
     /* Todo:
4288 4288
      * Pass in original filename as $imgname
4289 4289
      * If already cached like image_iscached(), allow empty $img
@@ -4302,25 +4302,25 @@  discard block
 block discarded – undo
4302 4302
 
4303 4303
     // there seems to be some problem here in that images that have quality set above 75 do not appear
4304 4304
     // not too sure why this is, but in the meantime I have restricted this to 75.
4305
-    if  ($quality>75) {
4306
-      $quality =  75;
4305
+    if ($quality > 75) {
4306
+      $quality = 75;
4307 4307
     }
4308 4308
 
4309 4309
     // if the width or height are set to zero, then set the other one based on keeping the image
4310 4310
     // height/width ratio the same, if they are both zero, then give up :)
4311
-    $imageWidth =  imagesx($img);
4312
-    $imageHeight =  imagesy($img);
4311
+    $imageWidth = imagesx($img);
4312
+    $imageHeight = imagesy($img);
4313 4313
 
4314
-    if  ($w <=  0 &&  $h <=  0) {
4314
+    if ($w <= 0 && $h <= 0) {
4315 4315
       return;
4316 4316
     }
4317 4317
 
4318
-    if  ($w ==  0) {
4319
-      $w =  $h/$imageHeight*$imageWidth;
4318
+    if ($w == 0) {
4319
+      $w = $h / $imageHeight * $imageWidth;
4320 4320
     }
4321 4321
 
4322
-    if  ($h ==  0) {
4323
-      $h =  $w*$imageHeight/$imageWidth;
4322
+    if ($h == 0) {
4323
+      $h = $w * $imageHeight / $imageWidth;
4324 4324
     }
4325 4325
 
4326 4326
     // gotta get the data out of the img..
@@ -4346,8 +4346,8 @@  discard block
 block discarded – undo
4346 4346
    *
4347 4347
    * @access private
4348 4348
    */
4349
-  function  addJpegImage_common(&$data, $x, $y, $w =  0, $h =  0, $imageWidth, $imageHeight, $channels =  3, $imgname) {
4350
-    if ( isset($this->imagelist[$imgname]) ) {
4349
+  function  addJpegImage_common(&$data, $x, $y, $w = 0, $h = 0, $imageWidth, $imageHeight, $channels = 3, $imgname) {
4350
+    if (isset($this->imagelist[$imgname])) {
4351 4351
       $label = $this->imagelist[$imgname]['label'];
4352 4352
       //debugpng
4353 4353
       //if (DEBUGPNG) print '[addJpegImage_common Duplicate '.$imgname.']';
@@ -4361,24 +4361,24 @@  discard block
 block discarded – undo
4361 4361
       // note that this function is not to be called externally
4362 4362
       // it is just the common code between the GD and the file options
4363 4363
       $this->numImages++;
4364
-      $im =  $this->numImages;
4365
-      $label =  'I'.$im;
4364
+      $im = $this->numImages;
4365
+      $label = 'I'.$im;
4366 4366
       $this->numObj++;
4367 4367
       $this->o_image($this->numObj, 'new', array('label' => $label, 'data' => &$data, 'iw' => $imageWidth, 'ih' => $imageHeight, 'channels' => $channels));
4368
-      $this->imagelist[$imgname] = array('label' =>$label, 'w' => $imageWidth, 'h' => $imageHeight, 'c'=> $channels );
4368
+      $this->imagelist[$imgname] = array('label' =>$label, 'w' => $imageWidth, 'h' => $imageHeight, 'c'=> $channels);
4369 4369
     }
4370 4370
 
4371
-    $this->objects[$this->currentContents]['c'].=  "\nq";
4372
-    $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $w) ." 0 0 ".sprintf('%.3F', $h) ." ".sprintf('%.3F', $x) ." ".sprintf('%.3F', $y) ." cm";
4373
-    $this->objects[$this->currentContents]['c'].=  "\n/".$label.' Do';
4374
-    $this->objects[$this->currentContents]['c'].=  "\nQ";
4371
+    $this->objects[$this->currentContents]['c'] .= "\nq";
4372
+    $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $w)." 0 0 ".sprintf('%.3F', $h)." ".sprintf('%.3F', $x)." ".sprintf('%.3F', $y)." cm";
4373
+    $this->objects[$this->currentContents]['c'] .= "\n/".$label.' Do';
4374
+    $this->objects[$this->currentContents]['c'] .= "\nQ";
4375 4375
   }
4376 4376
 
4377 4377
 
4378 4378
   /**
4379 4379
    * specify where the document should open when it first starts
4380 4380
    */
4381
-  function  openHere($style, $a =  0, $b =  0, $c =  0) {
4381
+  function  openHere($style, $a = 0, $b = 0, $c = 0) {
4382 4382
     // this function will open the document at a specified page, in a specified style
4383 4383
     // the values for style, and the required paramters are:
4384 4384
     // 'XYZ'  left, top, zoom
@@ -4391,7 +4391,7 @@  discard block
 block discarded – undo
4391 4391
     // 'FitBV' left
4392 4392
     $this->numObj++;
4393 4393
     $this->o_destination($this->numObj, 'new', array('page' => $this->currentPage, 'type' => $style, 'p1' => $a, 'p2' => $b, 'p3' => $c));
4394
-    $id =  $this->catalogId;
4394
+    $id = $this->catalogId;
4395 4395
     $this->o_catalog($id, 'openHere', $this->numObj);
4396 4396
   }
4397 4397
   
@@ -4403,16 +4403,16 @@  discard block
 block discarded – undo
4403 4403
   /**
4404 4404
    * create a labelled destination within the document
4405 4405
    */
4406
-  function  addDestination($label, $style, $a =  0, $b =  0, $c =  0) {
4406
+  function  addDestination($label, $style, $a = 0, $b = 0, $c = 0) {
4407 4407
     // associates the given label with the destination, it is done this way so that a destination can be specified after
4408 4408
     // it has been linked to
4409 4409
     // styles are the same as the 'openHere' function
4410 4410
     $this->numObj++;
4411 4411
     $this->o_destination($this->numObj, 'new', array('page' => $this->currentPage, 'type' => $style, 'p1' => $a, 'p2' => $b, 'p3' => $c));
4412
-    $id =  $this->numObj;
4412
+    $id = $this->numObj;
4413 4413
 
4414 4414
     // store the label->idf relationship, note that this means that labels can be used only once
4415
-    $this->destinations["$label"] =  $id;
4415
+    $this->destinations["$label"] = $id;
4416 4416
   }
4417 4417
 
4418 4418
 
@@ -4421,9 +4421,9 @@  discard block
 block discarded – undo
4421 4421
    * and for the user to add new ones for their fonts. The default bahavious can be overridden should
4422 4422
    * that be desired.
4423 4423
    */
4424
-  function  setFontFamily($family, $options =  '') {
4425
-    if  (!is_array($options)) {
4426
-      if  ($family ===  'init') {
4424
+  function  setFontFamily($family, $options = '') {
4425
+    if (!is_array($options)) {
4426
+      if ($family === 'init') {
4427 4427
         // set the known family groups
4428 4428
         // these font families will be used to enable bold and italic markers to be included
4429 4429
         // within text streams. html forms will be used... <b></b> <i></i>
@@ -4449,8 +4449,8 @@  discard block
 block discarded – undo
4449 4449
 
4450 4450
       // the user is trying to set a font family
4451 4451
       // note that this can also be used to set the base ones to something else
4452
-      if  (mb_strlen($family)) {
4453
-        $this->fontFamilies[$family] =  $options;
4452
+      if (mb_strlen($family)) {
4453
+        $this->fontFamilies[$family] = $options;
4454 4454
       }
4455 4455
     }
4456 4456
   }
@@ -4460,7 +4460,7 @@  discard block
 block discarded – undo
4460 4460
    * used to add messages for use in debugging
4461 4461
    */
4462 4462
   function  addMessage($message) {
4463
-    $this->messages.=  $message."\n";
4463
+    $this->messages .= $message."\n";
4464 4464
   }
4465 4465
 
4466 4466
 
@@ -4468,33 +4468,33 @@  discard block
 block discarded – undo
4468 4468
    * a few functions which should allow the document to be treated transactionally.
4469 4469
    */
4470 4470
   function  transaction($action) {
4471
-    switch  ($action) {
4471
+    switch ($action) {
4472 4472
     case  'start':
4473 4473
       // store all the data away into the checkpoint variable
4474
-      $data =  get_object_vars($this);
4475
-      $this->checkpoint =  $data;
4474
+      $data = get_object_vars($this);
4475
+      $this->checkpoint = $data;
4476 4476
       unset($data);
4477 4477
       break;
4478 4478
 
4479 4479
     case  'commit':
4480
-      if  (is_array($this->checkpoint) &&  isset($this->checkpoint['checkpoint'])) {
4481
-        $tmp =  $this->checkpoint['checkpoint'];
4482
-        $this->checkpoint =  $tmp;
4480
+      if (is_array($this->checkpoint) && isset($this->checkpoint['checkpoint'])) {
4481
+        $tmp = $this->checkpoint['checkpoint'];
4482
+        $this->checkpoint = $tmp;
4483 4483
         unset($tmp);
4484 4484
       } else {
4485
-        $this->checkpoint =  '';
4485
+        $this->checkpoint = '';
4486 4486
       }
4487 4487
       break;
4488 4488
 
4489 4489
     case  'rewind':
4490 4490
       // do not destroy the current checkpoint, but move us back to the state then, so that we can try again
4491
-      if  (is_array($this->checkpoint)) {
4491
+      if (is_array($this->checkpoint)) {
4492 4492
         // can only abort if were inside a checkpoint
4493
-        $tmp =  $this->checkpoint;
4493
+        $tmp = $this->checkpoint;
4494 4494
 
4495 4495
         foreach ($tmp as  $k => $v) {
4496
-          if  ($k !==  'checkpoint') {
4497
-            $this->$k =  $v;
4496
+          if ($k !== 'checkpoint') {
4497
+            $this->$k = $v;
4498 4498
           }
4499 4499
         }
4500 4500
         unset($tmp);
@@ -4502,11 +4502,11 @@  discard block
 block discarded – undo
4502 4502
       break;
4503 4503
 
4504 4504
     case  'abort':
4505
-      if  (is_array($this->checkpoint)) {
4505
+      if (is_array($this->checkpoint)) {
4506 4506
         // can only abort if were inside a checkpoint
4507
-        $tmp =  $this->checkpoint;
4507
+        $tmp = $this->checkpoint;
4508 4508
         foreach ($tmp as  $k => $v) {
4509
-          $this->$k =  $v;
4509
+          $this->$k = $v;
4510 4510
         }
4511 4511
         unset($tmp);
4512 4512
       }
Please login to merge, or discard this patch.
Braces   +57 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1589,8 +1589,9 @@  discard block
 block discarded – undo
1589 1589
         "<< /Type /ExtGState\n";
1590 1590
 
1591 1591
       foreach ($o["info"] as  $parameter => $value) {
1592
-        if  ( !in_array($parameter,  $valid_params))
1593
-          continue;
1592
+        if  ( !in_array($parameter,  $valid_params)) {
1593
+                  continue;
1594
+        }
1594 1595
         $res.=  "/$parameter $value\n";
1595 1596
       }
1596 1597
 
@@ -2514,13 +2515,15 @@  discard block
 block discarded – undo
2514 2515
                                 "ColorDogde", "ColorBurn", "HardLight",
2515 2516
                                 "SoftLight", "Difference", "Exclusion");
2516 2517
 
2517
-    if ( !in_array($mode, $blend_modes) )
2518
-      $mode = "Normal";
2518
+    if ( !in_array($mode, $blend_modes) ) {
2519
+          $mode = "Normal";
2520
+    }
2519 2521
     
2520 2522
     // Only create a new graphics state if required
2521 2523
     if ( $mode == $this->currentLineTransparency["mode"]  &&
2522
-         $opacity == $this->currentLineTransparency["opacity"] )
2523
-      return;
2524
+         $opacity == $this->currentLineTransparency["opacity"] ) {
2525
+          return;
2526
+    }
2524 2527
 
2525 2528
     $options = array("BM" => "/$mode",
2526 2529
                      "CA" => (float)$opacity);
@@ -2546,12 +2549,14 @@  discard block
 block discarded – undo
2546 2549
                                 "ColorDogde", "ColorBurn", "HardLight",
2547 2550
                                 "SoftLight", "Difference", "Exclusion");
2548 2551
 
2549
-    if ( !in_array($mode, $blend_modes) )
2550
-      $mode = "Normal";
2552
+    if ( !in_array($mode, $blend_modes) ) {
2553
+          $mode = "Normal";
2554
+    }
2551 2555
 
2552 2556
     if ( $mode == $this->currentFillTransparency["mode"]  &&
2553
-         $opacity == $this->currentFillTransparency["opacity"] )
2554
-      return;
2557
+         $opacity == $this->currentFillTransparency["opacity"] ) {
2558
+          return;
2559
+    }
2555 2560
 
2556 2561
     $options = array("BM" => "/$mode",
2557 2562
                      "ca" => (float)$opacity);
@@ -2840,8 +2845,9 @@  discard block
 block discarded – undo
2840 2845
       $options =  array();
2841 2846
     }
2842 2847
 
2843
-    if  ( headers_sent())
2844
-      die("Unable to stream pdf: headers already sent");
2848
+    if  ( headers_sent()) {
2849
+          die("Unable to stream pdf: headers already sent");
2850
+    }
2845 2851
 
2846 2852
     if  ( isset($options['compress']) &&  $options['compress'] ==  0) {
2847 2853
       $tmp =  ltrim($this->output(1));
@@ -2856,8 +2862,9 @@  discard block
 block discarded – undo
2856 2862
     header("Content-Length: " . mb_strlen($tmp, '8bit'));
2857 2863
     $fileName =  (isset($options['Content-Disposition']) ?  $options['Content-Disposition'] :  'file.pdf');
2858 2864
 
2859
-    if  ( !isset($options["Attachment"]))
2860
-      $options["Attachment"] =  true;
2865
+    if  ( !isset($options["Attachment"])) {
2866
+          $options["Attachment"] =  true;
2867
+    }
2861 2868
 
2862 2869
     $attachment =  $options["Attachment"] ?  "attachment" :  "inline";
2863 2870
 
@@ -3035,7 +3042,9 @@  discard block
 block discarded – undo
3035 3042
    */
3036 3043
   function  utf8toUtf16BE(&$text, $bom = true) {
3037 3044
     $cf =  $this->currentFont;
3038
-    if (!$this->fonts[$cf]['isUnicode']) return $text;
3045
+    if (!$this->fonts[$cf]['isUnicode']) {
3046
+        return $text;
3047
+    }
3039 3048
     $out = $bom ? "\xFE\xFF" : '';
3040 3049
     
3041 3050
     $unicode = $this->utf8toCodePointsArray($text);
@@ -3817,8 +3826,9 @@  discard block
 block discarded – undo
3817 3826
    * return a storable representation of a specific object
3818 3827
    */
3819 3828
   function  serializeObject($id) {
3820
-    if  ( array_key_exists($id,  $this->objects))
3821
-      return  var_export($this->objects[$id],  true);
3829
+    if  ( array_key_exists($id,  $this->objects)) {
3830
+          return  var_export($this->objects[$id],  true);
3831
+    }
3822 3832
   }
3823 3833
 
3824 3834
 
@@ -3908,7 +3918,9 @@  discard block
 block discarded – undo
3908 3918
       $error =  0;
3909 3919
       //DEBUG_IMG_TEMP
3910 3920
       //debugpng
3911
-      if (DEBUGPNG) print '[addImagePng '.$file.']';
3921
+      if (DEBUGPNG) {
3922
+          print '[addImagePng '.$file.']';
3923
+      }
3912 3924
 
3913 3925
       ob_start();
3914 3926
       @imagepng($img);
@@ -3920,7 +3932,9 @@  discard block
 block discarded – undo
3920 3932
         $errormsg = 'trouble writing file from GD';
3921 3933
         //DEBUG_IMG_TEMP
3922 3934
         //debugpng
3923
-        if (DEBUGPNG) print 'trouble writing file from GD';
3935
+        if (DEBUGPNG) {
3936
+            print 'trouble writing file from GD';
3937
+        }
3924 3938
 	  }
3925 3939
 
3926 3940
       if  ($error) {
@@ -4002,7 +4016,9 @@  discard block
 block discarded – undo
4002 4016
       if  (mb_substr($data, 0, 8, '8bit') !=  $header) {
4003 4017
         $error =  1;
4004 4018
         //debugpng
4005
-        if (DEBUGPNG) print '[addPngFromFile this file does not have a valid header '.$file.']';
4019
+        if (DEBUGPNG) {
4020
+            print '[addPngFromFile this file does not have a valid header '.$file.']';
4021
+        }
4006 4022
 
4007 4023
         $errormsg =  'this file does not have a valid header';
4008 4024
       }
@@ -4041,7 +4057,9 @@  discard block
 block discarded – undo
4041 4057
             $error =  1;
4042 4058
 
4043 4059
             //debugpng
4044
-            if (DEBUGPNG) print '[addPngFromFile unsupported compression method '.$file.']';
4060
+            if (DEBUGPNG) {
4061
+                print '[addPngFromFile unsupported compression method '.$file.']';
4062
+            }
4045 4063
 
4046 4064
             $errormsg =  'unsupported compression method';
4047 4065
           }
@@ -4050,7 +4068,9 @@  discard block
 block discarded – undo
4050 4068
             $error =  1;
4051 4069
 
4052 4070
             //debugpng
4053
-            if (DEBUGPNG) print '[addPngFromFile unsupported filter method '.$file.']';
4071
+            if (DEBUGPNG) {
4072
+                print '[addPngFromFile unsupported filter method '.$file.']';
4073
+            }
4054 4074
 
4055 4075
             $errormsg =  'unsupported filter method';
4056 4076
           }
@@ -4117,7 +4137,9 @@  discard block
 block discarded – undo
4117 4137
           } else {
4118 4138
             //unsupported transparency type
4119 4139
             //debugpng
4120
-            if (DEBUGPNG) print '[addPngFromFile unsupported transparency type '.$file.']';
4140
+            if (DEBUGPNG) {
4141
+                print '[addPngFromFile unsupported transparency type '.$file.']';
4142
+            }
4121 4143
           }
4122 4144
           // KS End new code
4123 4145
           break;
@@ -4134,7 +4156,9 @@  discard block
 block discarded – undo
4134 4156
         $error =  1;
4135 4157
 
4136 4158
         //debugpng
4137
-        if (DEBUGPNG) print '[addPngFromFile information header is missing '.$file.']';
4159
+        if (DEBUGPNG) {
4160
+            print '[addPngFromFile information header is missing '.$file.']';
4161
+        }
4138 4162
 
4139 4163
         $errormsg =  'information header is missing';
4140 4164
       }
@@ -4143,7 +4167,9 @@  discard block
 block discarded – undo
4143 4167
         $error =  1;
4144 4168
 
4145 4169
         //debugpng
4146
-        if (DEBUGPNG) print '[addPngFromFile no support for interlaced images in pdf '.$file.']';
4170
+        if (DEBUGPNG) {
4171
+            print '[addPngFromFile no support for interlaced images in pdf '.$file.']';
4172
+        }
4147 4173
 
4148 4174
         $errormsg =  'There appears to be no support for interlaced images in pdf.';
4149 4175
       }
@@ -4153,7 +4179,9 @@  discard block
 block discarded – undo
4153 4179
       $error =  1;
4154 4180
 
4155 4181
       //debugpng
4156
-      if (DEBUGPNG) print '[addPngFromFile bit depth of 8 or less is supported '.$file.']';
4182
+      if (DEBUGPNG) {
4183
+          print '[addPngFromFile bit depth of 8 or less is supported '.$file.']';
4184
+      }
4157 4185
 
4158 4186
       $errormsg =  'only bit depth of 8 or less is supported';
4159 4187
     }
@@ -4163,7 +4191,9 @@  discard block
 block discarded – undo
4163 4191
         $error =  1;
4164 4192
 
4165 4193
         //debugpng
4166
-        if (DEBUGPNG) print '[addPngFromFile alpha channel not supported: '.$info['colorType'].' '.$file.']';
4194
+        if (DEBUGPNG) {
4195
+            print '[addPngFromFile alpha channel not supported: '.$info['colorType'].' '.$file.']';
4196
+        }
4167 4197
 
4168 4198
         $errormsg =  'transparancey alpha channel not supported, transparency only supported for palette images.';
4169 4199
       } else {
Please login to merge, or discard this patch.
main/inc/lib/phpmailer/class.phpmailer.php 4 patches
Doc Comments   +15 added lines, -3 removed lines patch added patch discarded remove patch
@@ -891,6 +891,7 @@  discard block
 block discarded – undo
891 891
   /**
892 892
    * Creates recipient headers.
893 893
    * @access public
894
+   * @param string $type
894 895
    * @return string
895 896
    */
896 897
   public function AddrAppend($type, $addr) {
@@ -1258,6 +1259,9 @@  discard block
 block discarded – undo
1258 1259
   /**
1259 1260
    * Returns the start of a message boundary.
1260 1261
    * @access private
1262
+   * @param string $charSet
1263
+   * @param string $contentType
1264
+   * @param string $encoding
1261 1265
    */
1262 1266
   private function GetBoundary($boundary, $charSet, $contentType, $encoding) {
1263 1267
     $result = '';
@@ -1311,6 +1315,7 @@  discard block
 block discarded – undo
1311 1315
   /**
1312 1316
    *  Returns a formatted header line.
1313 1317
    * @access public
1318
+   * @param string $name
1314 1319
    * @return string
1315 1320
    */
1316 1321
   public function HeaderLine($name, $value) {
@@ -1320,6 +1325,7 @@  discard block
 block discarded – undo
1320 1325
   /**
1321 1326
    * Returns a formatted mail line.
1322 1327
    * @access public
1328
+   * @param string $value
1323 1329
    * @return string
1324 1330
    */
1325 1331
   public function TextLine($value) {
@@ -1521,6 +1527,7 @@  discard block
 block discarded – undo
1521 1527
   /**
1522 1528
    * Encode a header string to best (shortest) of Q, B, quoted or none.
1523 1529
    * @access public
1530
+   * @param string $str
1524 1531
    * @return string
1525 1532
    */
1526 1533
   public function EncodeHeader($str, $position = 'text') {
@@ -1647,7 +1654,6 @@  discard block
 block discarded – undo
1647 1654
   * Encode string to quoted-printable.
1648 1655
   * Only uses standard PHP, slow, but will always work
1649 1656
   * @access public
1650
-  * @param string $string the text to encode
1651 1657
   * @param integer $line_max Number of chars allowed on a line before wrapping
1652 1658
   * @return string
1653 1659
   */
@@ -1917,6 +1923,7 @@  discard block
 block discarded – undo
1917 1923
   /**
1918 1924
    * Adds the error message to the error container.
1919 1925
    * @access protected
1926
+   * @param string $msg
1920 1927
    * @return void
1921 1928
    */
1922 1929
   protected function SetError($msg) {
@@ -1966,6 +1973,7 @@  discard block
 block discarded – undo
1966 1973
   /**
1967 1974
    * Returns a message in the appropriate language.
1968 1975
    * @access private
1976
+   * @param string $key
1969 1977
    * @return string
1970 1978
    */
1971 1979
   private function Lang($key) {
@@ -1992,6 +2000,7 @@  discard block
 block discarded – undo
1992 2000
   /**
1993 2001
    * Changes every end of line from CR or LF to CRLF.
1994 2002
    * @access private
2003
+   * @param string $str
1995 2004
    * @return string
1996 2005
    */
1997 2006
   private function FixEOL($str) {
@@ -2203,8 +2212,6 @@  discard block
 block discarded – undo
2203 2212
    * Set the private key file and password to sign the message.
2204 2213
    *
2205 2214
    * @access public
2206
-   * @param string $key_filename Parameter File Name
2207
-   * @param string $key_pass Password for private key
2208 2215
    */
2209 2216
   public function DKIM_QP($txt) {
2210 2217
     $tmp="";
@@ -2318,6 +2325,11 @@  discard block
 block discarded – undo
2318 2325
     return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n";
2319 2326
   }
2320 2327
 
2328
+  /**
2329
+   * @param integer $isSent
2330
+   * @param string $subject
2331
+   * @param string $body
2332
+   */
2321 2333
   protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body) {
2322 2334
     if (!empty($this->action_function) && function_exists($this->action_function)) {
2323 2335
       $params = array($isSent,$to,$cc,$bcc,$subject,$body);
Please login to merge, or discard this patch.
Indentation   +1454 added lines, -1454 removed lines patch added patch discarded remove patch
@@ -42,441 +42,441 @@  discard block
 block discarded – undo
42 42
 
43 43
 class PHPMailer {
44 44
 
45
-  /////////////////////////////////////////////////
46
-  // PROPERTIES, PUBLIC
47
-  /////////////////////////////////////////////////
48
-
49
-  /**
50
-   * Email priority (1 = High, 3 = Normal, 5 = low).
51
-   * @var int
52
-   */
53
-  public $Priority          = 3;
54
-
55
-  /**
56
-   * Sets the CharSet of the message.
57
-   * @var string
58
-   */
59
-  public $CharSet           = 'iso-8859-1';
60
-
61
-  /**
62
-   * Sets the Content-type of the message.
63
-   * @var string
64
-   */
65
-  public $ContentType       = 'text/plain';
66
-
67
-  /**
68
-   * Sets the Encoding of the message. Options for this are
69
-   *  "8bit", "7bit", "binary", "base64", and "quoted-printable".
70
-   * @var string
71
-   */
72
-  public $Encoding          = '8bit';
73
-
74
-  /**
75
-   * Holds the most recent mailer error message.
76
-   * @var string
77
-   */
78
-  public $ErrorInfo         = '';
79
-
80
-  /**
81
-   * Sets the From email address for the message.
82
-   * @var string
83
-   */
84
-  public $From              = 'root@localhost';
85
-
86
-  /**
87
-   * Sets the From name of the message.
88
-   * @var string
89
-   */
90
-  public $FromName          = 'Root User';
91
-
92
-  /**
93
-   * Sets the Sender email (Return-Path) of the message.  If not empty,
94
-   * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
95
-   * @var string
96
-   */
97
-  public $Sender            = '';
98
-
99
-  /**
100
-   * Sets the Subject of the message.
101
-   * @var string
102
-   */
103
-  public $Subject           = '';
104
-
105
-  /**
106
-   * Sets the Body of the message.  This can be either an HTML or text body.
107
-   * If HTML then run IsHTML(true).
108
-   * @var string
109
-   */
110
-  public $Body              = '';
111
-
112
-  /**
113
-   * Sets the text-only body of the message.  This automatically sets the
114
-   * email to multipart/alternative.  This body can be read by mail
115
-   * clients that do not have HTML email capability such as mutt. Clients
116
-   * that can read HTML will view the normal Body.
117
-   * @var string
118
-   */
119
-  public $AltBody           = '';
120
-
121
-  /**
122
-   * Sets word wrapping on the body of the message to a given number of
123
-   * characters.
124
-   * @var int
125
-   */
126
-  public $WordWrap          = 0;
127
-
128
-  /**
129
-   * Method to send mail: ("mail", "sendmail", or "smtp").
130
-   * @var string
131
-   */
132
-  public $Mailer            = 'mail';
133
-
134
-  /**
135
-   * Sets the path of the sendmail program.
136
-   * @var string
137
-   */
138
-  public $Sendmail          = '/usr/sbin/sendmail';
139
-
140
-  /**
141
-   * Path to PHPMailer plugins.  Useful if the SMTP class
142
-   * is in a different directory than the PHP include path.
143
-   * @var string
144
-   */
145
-  public $PluginDir         = '';
146
-
147
-  /**
148
-   * Sets the email address that a reading confirmation will be sent.
149
-   * @var string
150
-   */
151
-  public $ConfirmReadingTo  = '';
152
-
153
-  /**
154
-   * Sets the hostname to use in Message-Id and Received headers
155
-   * and as default HELO string. If empty, the value returned
156
-   * by SERVER_NAME is used or 'localhost.localdomain'.
157
-   * @var string
158
-   */
159
-  public $Hostname          = '';
160
-
161
-  /**
162
-   * Sets the message ID to be used in the Message-Id header.
163
-   * If empty, a unique id will be generated.
164
-   * @var string
165
-   */
166
-  public $MessageID         = '';
167
-
168
-  /////////////////////////////////////////////////
169
-  // PROPERTIES FOR SMTP
170
-  /////////////////////////////////////////////////
171
-
172
-  /**
173
-   * Sets the SMTP hosts.  All hosts must be separated by a
174
-   * semicolon.  You can also specify a different port
175
-   * for each host by using this format: [hostname:port]
176
-   * (e.g. "smtp1.example.com:25;smtp2.example.com").
177
-   * Hosts will be tried in order.
178
-   * @var string
179
-   */
180
-  public $Host          = 'localhost';
181
-
182
-  /**
183
-   * Sets the default SMTP server port.
184
-   * @var int
185
-   */
186
-  public $Port          = 25;
187
-
188
-  /**
189
-   * Sets the SMTP HELO of the message (Default is $Hostname).
190
-   * @var string
191
-   */
192
-  public $Helo          = '';
193
-
194
-  /**
195
-   * Sets connection prefix.
196
-   * Options are "", "ssl" or "tls"
197
-   * @var string
198
-   */
199
-  public $SMTPSecure    = '';
200
-
201
-  /**
202
-   * Sets SMTP authentication. Utilizes the Username and Password variables.
203
-   * @var bool
204
-   */
205
-  public $SMTPAuth      = false;
206
-
207
-  /**
208
-   * Sets SMTP username.
209
-   * @var string
210
-   */
211
-  public $Username      = '';
212
-
213
-  /**
214
-   * Sets SMTP password.
215
-   * @var string
216
-   */
217
-  public $Password      = '';
218
-
219
-  /**
220
-   * Sets the SMTP server timeout in seconds.
221
-   * This function will not work with the win32 version.
222
-   * @var int
223
-   */
224
-  public $Timeout       = 10;
225
-
226
-  /**
227
-   * Sets SMTP class debugging on or off.
228
-   * @var bool
229
-   */
230
-  public $SMTPDebug     = false;
231
-
232
-  /**
233
-   * Prevents the SMTP connection from being closed after each mail
234
-   * sending.  If this is set to true then to close the connection
235
-   * requires an explicit call to SmtpClose().
236
-   * @var bool
237
-   */
238
-  public $SMTPKeepAlive = false;
239
-
240
-  /**
241
-   * Provides the ability to have the TO field process individual
242
-   * emails, instead of sending to entire TO addresses
243
-   * @var bool
244
-   */
245
-  public $SingleTo      = false;
246
-
247
-   /**
248
-   * If SingleTo is true, this provides the array to hold the email addresses
249
-   * @var bool
250
-   */
251
-  public $SingleToArray = array();
252
-
253
- /**
254
-   * Provides the ability to change the line ending
255
-   * @var string
256
-   */
257
-  public $LE              = "\n";
258
-
259
-  /**
260
-   * Used with DKIM DNS Resource Record
261
-   * @var string
262
-   */
263
-  public $DKIM_selector   = 'phpmailer';
264
-
265
-  /**
266
-   * Used with DKIM DNS Resource Record
267
-   * optional, in format of email address '[email protected]'
268
-   * @var string
269
-   */
270
-  public $DKIM_identity   = '';
271
-
272
-  /**
273
-   * Used with DKIM DNS Resource Record
274
-   * optional, in format of email address '[email protected]'
275
-   * @var string
276
-   */
277
-  public $DKIM_domain     = '';
278
-
279
-  /**
280
-   * Used with DKIM DNS Resource Record
281
-   * optional, in format of email address '[email protected]'
282
-   * @var string
283
-   */
284
-  public $DKIM_private    = '';
285
-
286
-  /**
287
-   * Callback Action function name
288
-   * the function that handles the result of the send email action. Parameters:
289
-   *   bool    $result        result of the send action
290
-   *   string  $to            email address of the recipient
291
-   *   string  $cc            cc email addresses
292
-   *   string  $bcc           bcc email addresses
293
-   *   string  $subject       the subject
294
-   *   string  $body          the email body
295
-   * @var string
296
-   */
297
-  public $action_function = ''; //'callbackAction';
298
-
299
-  /**
300
-   * Sets the PHPMailer Version number
301
-   * @var string
302
-   */
303
-  public $Version         = '5.1';
304
-
305
-  /////////////////////////////////////////////////
306
-  // PROPERTIES, PRIVATE AND PROTECTED
307
-  /////////////////////////////////////////////////
308
-
309
-  private   $smtp           = NULL;
310
-  private   $to             = array();
311
-  private   $cc             = array();
312
-  private   $bcc            = array();
313
-  private   $ReplyTo        = array();
314
-  private   $all_recipients = array();
315
-  private   $attachment     = array();
316
-  private   $CustomHeader   = array();
317
-  private   $message_type   = '';
318
-  private   $boundary       = array();
319
-  protected $language       = array();
320
-  private   $error_count    = 0;
321
-  private   $sign_cert_file = "";
322
-  private   $sign_key_file  = "";
323
-  private   $sign_key_pass  = "";
324
-  private   $exceptions     = false;
325
-
326
-  /////////////////////////////////////////////////
327
-  // CONSTANTS
328
-  /////////////////////////////////////////////////
329
-
330
-  const STOP_MESSAGE  = 0; // message only, continue processing
331
-  const STOP_CONTINUE = 1; // message?, likely ok to continue processing
332
-  const STOP_CRITICAL = 2; // message, plus full stop, critical error reached
333
-
334
-  /////////////////////////////////////////////////
335
-  // METHODS, VARIABLES
336
-  /////////////////////////////////////////////////
337
-
338
-  /**
339
-   * Constructor
340
-   * @param boolean $exceptions Should we throw external exceptions?
341
-   */
342
-  public function __construct($exceptions = false) {
45
+    /////////////////////////////////////////////////
46
+    // PROPERTIES, PUBLIC
47
+    /////////////////////////////////////////////////
48
+
49
+    /**
50
+     * Email priority (1 = High, 3 = Normal, 5 = low).
51
+     * @var int
52
+     */
53
+    public $Priority          = 3;
54
+
55
+    /**
56
+     * Sets the CharSet of the message.
57
+     * @var string
58
+     */
59
+    public $CharSet           = 'iso-8859-1';
60
+
61
+    /**
62
+     * Sets the Content-type of the message.
63
+     * @var string
64
+     */
65
+    public $ContentType       = 'text/plain';
66
+
67
+    /**
68
+     * Sets the Encoding of the message. Options for this are
69
+     *  "8bit", "7bit", "binary", "base64", and "quoted-printable".
70
+     * @var string
71
+     */
72
+    public $Encoding          = '8bit';
73
+
74
+    /**
75
+     * Holds the most recent mailer error message.
76
+     * @var string
77
+     */
78
+    public $ErrorInfo         = '';
79
+
80
+    /**
81
+     * Sets the From email address for the message.
82
+     * @var string
83
+     */
84
+    public $From              = 'root@localhost';
85
+
86
+    /**
87
+     * Sets the From name of the message.
88
+     * @var string
89
+     */
90
+    public $FromName          = 'Root User';
91
+
92
+    /**
93
+     * Sets the Sender email (Return-Path) of the message.  If not empty,
94
+     * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
95
+     * @var string
96
+     */
97
+    public $Sender            = '';
98
+
99
+    /**
100
+     * Sets the Subject of the message.
101
+     * @var string
102
+     */
103
+    public $Subject           = '';
104
+
105
+    /**
106
+     * Sets the Body of the message.  This can be either an HTML or text body.
107
+     * If HTML then run IsHTML(true).
108
+     * @var string
109
+     */
110
+    public $Body              = '';
111
+
112
+    /**
113
+     * Sets the text-only body of the message.  This automatically sets the
114
+     * email to multipart/alternative.  This body can be read by mail
115
+     * clients that do not have HTML email capability such as mutt. Clients
116
+     * that can read HTML will view the normal Body.
117
+     * @var string
118
+     */
119
+    public $AltBody           = '';
120
+
121
+    /**
122
+     * Sets word wrapping on the body of the message to a given number of
123
+     * characters.
124
+     * @var int
125
+     */
126
+    public $WordWrap          = 0;
127
+
128
+    /**
129
+     * Method to send mail: ("mail", "sendmail", or "smtp").
130
+     * @var string
131
+     */
132
+    public $Mailer            = 'mail';
133
+
134
+    /**
135
+     * Sets the path of the sendmail program.
136
+     * @var string
137
+     */
138
+    public $Sendmail          = '/usr/sbin/sendmail';
139
+
140
+    /**
141
+     * Path to PHPMailer plugins.  Useful if the SMTP class
142
+     * is in a different directory than the PHP include path.
143
+     * @var string
144
+     */
145
+    public $PluginDir         = '';
146
+
147
+    /**
148
+     * Sets the email address that a reading confirmation will be sent.
149
+     * @var string
150
+     */
151
+    public $ConfirmReadingTo  = '';
152
+
153
+    /**
154
+     * Sets the hostname to use in Message-Id and Received headers
155
+     * and as default HELO string. If empty, the value returned
156
+     * by SERVER_NAME is used or 'localhost.localdomain'.
157
+     * @var string
158
+     */
159
+    public $Hostname          = '';
160
+
161
+    /**
162
+     * Sets the message ID to be used in the Message-Id header.
163
+     * If empty, a unique id will be generated.
164
+     * @var string
165
+     */
166
+    public $MessageID         = '';
167
+
168
+    /////////////////////////////////////////////////
169
+    // PROPERTIES FOR SMTP
170
+    /////////////////////////////////////////////////
171
+
172
+    /**
173
+     * Sets the SMTP hosts.  All hosts must be separated by a
174
+     * semicolon.  You can also specify a different port
175
+     * for each host by using this format: [hostname:port]
176
+     * (e.g. "smtp1.example.com:25;smtp2.example.com").
177
+     * Hosts will be tried in order.
178
+     * @var string
179
+     */
180
+    public $Host          = 'localhost';
181
+
182
+    /**
183
+     * Sets the default SMTP server port.
184
+     * @var int
185
+     */
186
+    public $Port          = 25;
187
+
188
+    /**
189
+     * Sets the SMTP HELO of the message (Default is $Hostname).
190
+     * @var string
191
+     */
192
+    public $Helo          = '';
193
+
194
+    /**
195
+     * Sets connection prefix.
196
+     * Options are "", "ssl" or "tls"
197
+     * @var string
198
+     */
199
+    public $SMTPSecure    = '';
200
+
201
+    /**
202
+     * Sets SMTP authentication. Utilizes the Username and Password variables.
203
+     * @var bool
204
+     */
205
+    public $SMTPAuth      = false;
206
+
207
+    /**
208
+     * Sets SMTP username.
209
+     * @var string
210
+     */
211
+    public $Username      = '';
212
+
213
+    /**
214
+     * Sets SMTP password.
215
+     * @var string
216
+     */
217
+    public $Password      = '';
218
+
219
+    /**
220
+     * Sets the SMTP server timeout in seconds.
221
+     * This function will not work with the win32 version.
222
+     * @var int
223
+     */
224
+    public $Timeout       = 10;
225
+
226
+    /**
227
+     * Sets SMTP class debugging on or off.
228
+     * @var bool
229
+     */
230
+    public $SMTPDebug     = false;
231
+
232
+    /**
233
+     * Prevents the SMTP connection from being closed after each mail
234
+     * sending.  If this is set to true then to close the connection
235
+     * requires an explicit call to SmtpClose().
236
+     * @var bool
237
+     */
238
+    public $SMTPKeepAlive = false;
239
+
240
+    /**
241
+     * Provides the ability to have the TO field process individual
242
+     * emails, instead of sending to entire TO addresses
243
+     * @var bool
244
+     */
245
+    public $SingleTo      = false;
246
+
247
+    /**
248
+     * If SingleTo is true, this provides the array to hold the email addresses
249
+     * @var bool
250
+     */
251
+    public $SingleToArray = array();
252
+
253
+    /**
254
+     * Provides the ability to change the line ending
255
+     * @var string
256
+     */
257
+    public $LE              = "\n";
258
+
259
+    /**
260
+     * Used with DKIM DNS Resource Record
261
+     * @var string
262
+     */
263
+    public $DKIM_selector   = 'phpmailer';
264
+
265
+    /**
266
+     * Used with DKIM DNS Resource Record
267
+     * optional, in format of email address '[email protected]'
268
+     * @var string
269
+     */
270
+    public $DKIM_identity   = '';
271
+
272
+    /**
273
+     * Used with DKIM DNS Resource Record
274
+     * optional, in format of email address '[email protected]'
275
+     * @var string
276
+     */
277
+    public $DKIM_domain     = '';
278
+
279
+    /**
280
+     * Used with DKIM DNS Resource Record
281
+     * optional, in format of email address '[email protected]'
282
+     * @var string
283
+     */
284
+    public $DKIM_private    = '';
285
+
286
+    /**
287
+     * Callback Action function name
288
+     * the function that handles the result of the send email action. Parameters:
289
+     *   bool    $result        result of the send action
290
+     *   string  $to            email address of the recipient
291
+     *   string  $cc            cc email addresses
292
+     *   string  $bcc           bcc email addresses
293
+     *   string  $subject       the subject
294
+     *   string  $body          the email body
295
+     * @var string
296
+     */
297
+    public $action_function = ''; //'callbackAction';
298
+
299
+    /**
300
+     * Sets the PHPMailer Version number
301
+     * @var string
302
+     */
303
+    public $Version         = '5.1';
304
+
305
+    /////////////////////////////////////////////////
306
+    // PROPERTIES, PRIVATE AND PROTECTED
307
+    /////////////////////////////////////////////////
308
+
309
+    private   $smtp           = NULL;
310
+    private   $to             = array();
311
+    private   $cc             = array();
312
+    private   $bcc            = array();
313
+    private   $ReplyTo        = array();
314
+    private   $all_recipients = array();
315
+    private   $attachment     = array();
316
+    private   $CustomHeader   = array();
317
+    private   $message_type   = '';
318
+    private   $boundary       = array();
319
+    protected $language       = array();
320
+    private   $error_count    = 0;
321
+    private   $sign_cert_file = "";
322
+    private   $sign_key_file  = "";
323
+    private   $sign_key_pass  = "";
324
+    private   $exceptions     = false;
325
+
326
+    /////////////////////////////////////////////////
327
+    // CONSTANTS
328
+    /////////////////////////////////////////////////
329
+
330
+    const STOP_MESSAGE  = 0; // message only, continue processing
331
+    const STOP_CONTINUE = 1; // message?, likely ok to continue processing
332
+    const STOP_CRITICAL = 2; // message, plus full stop, critical error reached
333
+
334
+    /////////////////////////////////////////////////
335
+    // METHODS, VARIABLES
336
+    /////////////////////////////////////////////////
337
+
338
+    /**
339
+     * Constructor
340
+     * @param boolean $exceptions Should we throw external exceptions?
341
+     */
342
+    public function __construct($exceptions = false) {
343 343
     $this->exceptions = ($exceptions == true);
344
-  }
345
-
346
-  /**
347
-   * Sets message type to HTML.
348
-   * @param bool $ishtml
349
-   * @return void
350
-   */
351
-  public function IsHTML($ishtml = true) {
344
+    }
345
+
346
+    /**
347
+     * Sets message type to HTML.
348
+     * @param bool $ishtml
349
+     * @return void
350
+     */
351
+    public function IsHTML($ishtml = true) {
352 352
     if ($ishtml) {
353
-      $this->ContentType = 'text/html';
353
+        $this->ContentType = 'text/html';
354 354
     } else {
355
-      $this->ContentType = 'text/plain';
355
+        $this->ContentType = 'text/plain';
356
+    }
356 357
     }
357
-  }
358 358
 
359
-  /**
360
-   * Sets Mailer to send message using SMTP.
361
-   * @return void
362
-   */
363
-  public function IsSMTP() {
359
+    /**
360
+     * Sets Mailer to send message using SMTP.
361
+     * @return void
362
+     */
363
+    public function IsSMTP() {
364 364
     $this->Mailer = 'smtp';
365
-  }
365
+    }
366 366
 
367
-  /**
368
-   * Sets Mailer to send message using PHP mail() function.
369
-   * @return void
370
-   */
371
-  public function IsMail() {
367
+    /**
368
+     * Sets Mailer to send message using PHP mail() function.
369
+     * @return void
370
+     */
371
+    public function IsMail() {
372 372
     $this->Mailer = 'mail';
373
-  }
373
+    }
374 374
 
375
-  /**
376
-   * Sets Mailer to send message using the $Sendmail program.
377
-   * @return void
378
-   */
379
-  public function IsSendmail() {
375
+    /**
376
+     * Sets Mailer to send message using the $Sendmail program.
377
+     * @return void
378
+     */
379
+    public function IsSendmail() {
380 380
     if (!stristr(ini_get('sendmail_path'), 'sendmail')) {
381
-      $this->Sendmail = '/var/qmail/bin/sendmail';
381
+        $this->Sendmail = '/var/qmail/bin/sendmail';
382 382
     }
383 383
     $this->Mailer = 'sendmail';
384
-  }
384
+    }
385 385
 
386
-  /**
387
-   * Sets Mailer to send message using the qmail MTA.
388
-   * @return void
389
-   */
390
-  public function IsQmail() {
386
+    /**
387
+     * Sets Mailer to send message using the qmail MTA.
388
+     * @return void
389
+     */
390
+    public function IsQmail() {
391 391
     if (stristr(ini_get('sendmail_path'), 'qmail')) {
392
-      $this->Sendmail = '/var/qmail/bin/sendmail';
392
+        $this->Sendmail = '/var/qmail/bin/sendmail';
393 393
     }
394 394
     $this->Mailer = 'sendmail';
395
-  }
396
-
397
-  /////////////////////////////////////////////////
398
-  // METHODS, RECIPIENTS
399
-  /////////////////////////////////////////////////
400
-
401
-  /**
402
-   * Adds a "To" address.
403
-   * @param string $address
404
-   * @param string $name
405
-   * @return boolean true on success, false if address already used
406
-   */
407
-  public function AddAddress($address, $name = '') {
395
+    }
396
+
397
+    /////////////////////////////////////////////////
398
+    // METHODS, RECIPIENTS
399
+    /////////////////////////////////////////////////
400
+
401
+    /**
402
+     * Adds a "To" address.
403
+     * @param string $address
404
+     * @param string $name
405
+     * @return boolean true on success, false if address already used
406
+     */
407
+    public function AddAddress($address, $name = '') {
408 408
     return $this->AddAnAddress('to', $address, $name);
409
-  }
410
-
411
-  /**
412
-   * Adds a "Cc" address.
413
-   * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
414
-   * @param string $address
415
-   * @param string $name
416
-   * @return boolean true on success, false if address already used
417
-   */
418
-  public function AddCC($address, $name = '') {
409
+    }
410
+
411
+    /**
412
+     * Adds a "Cc" address.
413
+     * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
414
+     * @param string $address
415
+     * @param string $name
416
+     * @return boolean true on success, false if address already used
417
+     */
418
+    public function AddCC($address, $name = '') {
419 419
     return $this->AddAnAddress('cc', $address, $name);
420
-  }
421
-
422
-  /**
423
-   * Adds a "Bcc" address.
424
-   * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
425
-   * @param string $address
426
-   * @param string $name
427
-   * @return boolean true on success, false if address already used
428
-   */
429
-  public function AddBCC($address, $name = '') {
420
+    }
421
+
422
+    /**
423
+     * Adds a "Bcc" address.
424
+     * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
425
+     * @param string $address
426
+     * @param string $name
427
+     * @return boolean true on success, false if address already used
428
+     */
429
+    public function AddBCC($address, $name = '') {
430 430
     return $this->AddAnAddress('bcc', $address, $name);
431
-  }
432
-
433
-  /**
434
-   * Adds a "Reply-to" address.
435
-   * @param string $address
436
-   * @param string $name
437
-   * @return boolean
438
-   */
439
-  public function AddReplyTo($address, $name = '') {
431
+    }
432
+
433
+    /**
434
+     * Adds a "Reply-to" address.
435
+     * @param string $address
436
+     * @param string $name
437
+     * @return boolean
438
+     */
439
+    public function AddReplyTo($address, $name = '') {
440 440
     return $this->AddAnAddress('ReplyTo', $address, $name);
441
-  }
442
-
443
-  /**
444
-   * Adds an address to one of the recipient arrays
445
-   * Addresses that have been added already return false, but do not throw exceptions
446
-   * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo'
447
-   * @param string $address The email address to send to
448
-   * @param string $name
449
-   * @return boolean true on success, false if address already used or invalid in some way
450
-   * @access private
451
-   */
452
-  private function AddAnAddress($kind, $address, $name = '') {
441
+    }
442
+
443
+    /**
444
+     * Adds an address to one of the recipient arrays
445
+     * Addresses that have been added already return false, but do not throw exceptions
446
+     * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo'
447
+     * @param string $address The email address to send to
448
+     * @param string $name
449
+     * @return boolean true on success, false if address already used or invalid in some way
450
+     * @access private
451
+     */
452
+    private function AddAnAddress($kind, $address, $name = '') {
453 453
     if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) {
454
-      error_log('Invalid recipient array: ' . $kind);
455
-      return false;
454
+        error_log('Invalid recipient array: ' . $kind);
455
+        return false;
456 456
     }
457 457
     $address = trim($address);
458 458
     $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
459 459
     if (!self::ValidateAddress($address)) {
460
-      $this->SetError($this->Lang('invalid_address').': '. $address);
461
-      if ($this->exceptions) {
460
+        $this->SetError($this->Lang('invalid_address').': '. $address);
461
+        if ($this->exceptions) {
462 462
         throw new phpmailerException($this->Lang('invalid_address').': '.$address);
463
-      }
464
-      error_log($this->Lang('invalid_address').': '.$address);
465
-      return false;
463
+        }
464
+        error_log($this->Lang('invalid_address').': '.$address);
465
+        return false;
466 466
     }
467 467
     if ($kind != 'ReplyTo') {
468
-      if (!isset($this->all_recipients[strtolower($address)])) {
468
+        if (!isset($this->all_recipients[strtolower($address)])) {
469 469
         array_push($this->$kind, array($address, $name));
470 470
         $this->all_recipients[strtolower($address)] = true;
471 471
         return true;
472
-      }
472
+        }
473 473
     } else {
474
-      if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
474
+        if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
475 475
         $this->ReplyTo[strtolower($address)] = array($address, $name);
476
-      return true;
476
+        return true;
477
+    }
477 478
     }
478
-  }
479
-  return false;
479
+    return false;
480 480
 }
481 481
 
482 482
 /**
@@ -485,125 +485,125 @@  discard block
 block discarded – undo
485 485
  * @param string $name
486 486
  * @return boolean
487 487
  */
488
-  public function SetFrom($address, $name = '',$auto=1) {
488
+    public function SetFrom($address, $name = '',$auto=1) {
489 489
     $address = trim($address);
490 490
     $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
491 491
     if (!self::ValidateAddress($address)) {
492
-      $this->SetError($this->Lang('invalid_address').': '. $address);
493
-      if ($this->exceptions) {
492
+        $this->SetError($this->Lang('invalid_address').': '. $address);
493
+        if ($this->exceptions) {
494 494
         throw new phpmailerException($this->Lang('invalid_address').': '.$address);
495
-      }
496
-      error_log($this->Lang('invalid_address').': '.$address);
497
-      return false;
495
+        }
496
+        error_log($this->Lang('invalid_address').': '.$address);
497
+        return false;
498 498
     }
499 499
     $this->From = $address;
500 500
     $this->FromName = $name;
501 501
     if ($auto) {
502
-      if (empty($this->ReplyTo)) {
502
+        if (empty($this->ReplyTo)) {
503 503
         $this->AddAnAddress('ReplyTo', $address, $name);
504
-      }
505
-      if (empty($this->Sender)) {
504
+        }
505
+        if (empty($this->Sender)) {
506 506
         $this->Sender = $address;
507
-      }
507
+        }
508 508
     }
509 509
     return true;
510
-  }
511
-
512
-  /**
513
-   * Check that a string looks roughly like an email address should
514
-   * Static so it can be used without instantiation
515
-   * Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator
516
-   * Conforms approximately to RFC2822
517
-   * @link http://www.hexillion.com/samples/#Regex Original pattern found here
518
-   * @param string $address The email address to check
519
-   * @return boolean
520
-   * @static
521
-   * @access public
522
-   */
523
-  public static function ValidateAddress($address) {
510
+    }
511
+
512
+    /**
513
+     * Check that a string looks roughly like an email address should
514
+     * Static so it can be used without instantiation
515
+     * Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator
516
+     * Conforms approximately to RFC2822
517
+     * @link http://www.hexillion.com/samples/#Regex Original pattern found here
518
+     * @param string $address The email address to check
519
+     * @return boolean
520
+     * @static
521
+     * @access public
522
+     */
523
+    public static function ValidateAddress($address) {
524 524
     if (function_exists('filter_var')) { //Introduced in PHP 5.2
525
-      if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
525
+        if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
526 526
         return false;
527
-      } else {
527
+        } else {
528 528
         return true;
529
-      }
529
+        }
530 530
     } else {
531
-      return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
531
+        return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
532
+    }
532 533
     }
533
-  }
534 534
 
535
-  /////////////////////////////////////////////////
536
-  // METHODS, MAIL SENDING
537
-  /////////////////////////////////////////////////
535
+    /////////////////////////////////////////////////
536
+    // METHODS, MAIL SENDING
537
+    /////////////////////////////////////////////////
538 538
 
539
-  /**
540
-   * Creates message and assigns Mailer. If the message is
541
-   * not sent successfully then it returns false.  Use the ErrorInfo
542
-   * variable to view description of the error.
543
-   * @return bool
544
-   */
545
-  public function Send() {
539
+    /**
540
+     * Creates message and assigns Mailer. If the message is
541
+     * not sent successfully then it returns false.  Use the ErrorInfo
542
+     * variable to view description of the error.
543
+     * @return bool
544
+     */
545
+    public function Send() {
546 546
     try {
547
-      if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
547
+        if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
548 548
         throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL);
549
-      }
549
+        }
550 550
 
551
-      // Set whether the message is multipart/alternative
552
-      if(!empty($this->AltBody)) {
551
+        // Set whether the message is multipart/alternative
552
+        if(!empty($this->AltBody)) {
553 553
         $this->ContentType = 'multipart/alternative';
554
-      }
554
+        }
555 555
 
556
-      $this->error_count = 0; // reset errors
557
-      $this->SetMessageType();
558
-      $header = $this->CreateHeader();
559
-      $body = $this->CreateBody();
556
+        $this->error_count = 0; // reset errors
557
+        $this->SetMessageType();
558
+        $header = $this->CreateHeader();
559
+        $body = $this->CreateBody();
560 560
 
561
-      if (empty($this->Body)) {
561
+        if (empty($this->Body)) {
562 562
         throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL);
563
-      }
563
+        }
564 564
 
565
-      // digitally sign with DKIM if enabled
566
-      if ($this->DKIM_domain && $this->DKIM_private) {
565
+        // digitally sign with DKIM if enabled
566
+        if ($this->DKIM_domain && $this->DKIM_private) {
567 567
         $header_dkim = $this->DKIM_Add($header,$this->Subject,$body);
568 568
         $header = str_replace("\r\n","\n",$header_dkim) . $header;
569
-      }
569
+        }
570 570
 
571
-      // Choose the mailer and send through it
572
-      switch($this->Mailer) {
571
+        // Choose the mailer and send through it
572
+        switch($this->Mailer) {
573 573
         case 'sendmail':
574 574
           return $this->SendmailSend($header, $body);
575 575
         case 'smtp':
576 576
           return $this->SmtpSend($header, $body);
577 577
         default:
578 578
           return $this->MailSend($header, $body);
579
-      }
579
+        }
580 580
 
581 581
     } catch (phpmailerException $e) {
582
-      $this->SetError($e->getMessage());
583
-      if ($this->exceptions) {
582
+        $this->SetError($e->getMessage());
583
+        if ($this->exceptions) {
584 584
         throw $e;
585
-      }
586
-      return false;
587
-    }
588
-  }
589
-
590
-  /**
591
-   * Sends mail using the $Sendmail program.
592
-   * @param string $header The message headers
593
-   * @param string $body The message body
594
-   * @access protected
595
-   * @return bool
596
-   */
597
-  protected function SendmailSend($header, $body) {
585
+        }
586
+        return false;
587
+    }
588
+    }
589
+
590
+    /**
591
+     * Sends mail using the $Sendmail program.
592
+     * @param string $header The message headers
593
+     * @param string $body The message body
594
+     * @access protected
595
+     * @return bool
596
+     */
597
+    protected function SendmailSend($header, $body) {
598 598
     if ($this->Sender != '') {
599
-      $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
599
+        $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
600 600
     } else {
601
-      $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
601
+        $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
602 602
     }
603 603
     if ($this->SingleTo === true) {
604
-      foreach ($this->SingleToArray as $key => $val) {
604
+        foreach ($this->SingleToArray as $key => $val) {
605 605
         if(!@$mail = popen($sendmail, 'w')) {
606
-          throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
606
+            throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
607 607
         }
608 608
         fputs($mail, "To: " . $val . "\n");
609 609
         fputs($mail, $header);
@@ -613,164 +613,164 @@  discard block
 block discarded – undo
613 613
         $isSent = ($result == 0) ? 1 : 0;
614 614
         $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
615 615
         if($result != 0) {
616
-          throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
616
+            throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
617
+        }
617 618
         }
618
-      }
619 619
     } else {
620
-      if(!@$mail = popen($sendmail, 'w')) {
620
+        if(!@$mail = popen($sendmail, 'w')) {
621 621
         throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
622
-      }
623
-      fputs($mail, $header);
624
-      fputs($mail, $body);
625
-      $result = pclose($mail);
626
-      // implement call back function if it exists
627
-      $isSent = ($result == 0) ? 1 : 0;
628
-      $this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body);
629
-      if($result != 0) {
622
+        }
623
+        fputs($mail, $header);
624
+        fputs($mail, $body);
625
+        $result = pclose($mail);
626
+        // implement call back function if it exists
627
+        $isSent = ($result == 0) ? 1 : 0;
628
+        $this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body);
629
+        if($result != 0) {
630 630
         throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
631
-      }
631
+        }
632 632
     }
633 633
     return true;
634
-  }
635
-
636
-  /**
637
-   * Sends mail using the PHP mail() function.
638
-   * @param string $header The message headers
639
-   * @param string $body The message body
640
-   * @access protected
641
-   * @return bool
642
-   */
643
-  protected function MailSend($header, $body) {
634
+    }
635
+
636
+    /**
637
+     * Sends mail using the PHP mail() function.
638
+     * @param string $header The message headers
639
+     * @param string $body The message body
640
+     * @access protected
641
+     * @return bool
642
+     */
643
+    protected function MailSend($header, $body) {
644 644
     $toArr = array();
645 645
     foreach($this->to as $t) {
646
-      $toArr[] = $this->AddrFormat($t);
646
+        $toArr[] = $this->AddrFormat($t);
647 647
     }
648 648
     $to = implode(', ', $toArr);
649 649
 
650 650
     $params = sprintf("-oi -f %s", $this->Sender);
651 651
     if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) {
652
-      $old_from = ini_get('sendmail_from');
653
-      ini_set('sendmail_from', $this->Sender);
654
-      if ($this->SingleTo === true && count($toArr) > 1) {
652
+        $old_from = ini_get('sendmail_from');
653
+        ini_set('sendmail_from', $this->Sender);
654
+        if ($this->SingleTo === true && count($toArr) > 1) {
655 655
         foreach ($toArr as $key => $val) {
656
-          $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
657
-          // implement call back function if it exists
658
-          $isSent = ($rt == 1) ? 1 : 0;
659
-          $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
656
+            $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
657
+            // implement call back function if it exists
658
+            $isSent = ($rt == 1) ? 1 : 0;
659
+            $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
660 660
         }
661
-      } else {
661
+        } else {
662 662
         $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
663 663
         // implement call back function if it exists
664 664
         $isSent = ($rt == 1) ? 1 : 0;
665 665
         $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
666
-      }
666
+        }
667 667
     } else {
668
-      if ($this->SingleTo === true && count($toArr) > 1) {
668
+        if ($this->SingleTo === true && count($toArr) > 1) {
669 669
         foreach ($toArr as $key => $val) {
670
-          $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
671
-          // implement call back function if it exists
672
-          $isSent = ($rt == 1) ? 1 : 0;
673
-          $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
670
+            $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
671
+            // implement call back function if it exists
672
+            $isSent = ($rt == 1) ? 1 : 0;
673
+            $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
674 674
         }
675
-      } else {
675
+        } else {
676 676
         $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
677 677
         // implement call back function if it exists
678 678
         $isSent = ($rt == 1) ? 1 : 0;
679 679
         $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
680
-      }
680
+        }
681 681
     }
682 682
     if (isset($old_from)) {
683
-      ini_set('sendmail_from', $old_from);
683
+        ini_set('sendmail_from', $old_from);
684 684
     }
685 685
     if(!$rt) {
686
-      throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL);
686
+        throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL);
687 687
     }
688 688
     return true;
689
-  }
690
-
691
-  /**
692
-   * Sends mail via SMTP using PhpSMTP
693
-   * Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
694
-   * @param string $header The message headers
695
-   * @param string $body The message body
696
-   * @uses SMTP
697
-   * @access protected
698
-   * @return bool
699
-   */
700
-  protected function SmtpSend($header, $body) {
689
+    }
690
+
691
+    /**
692
+     * Sends mail via SMTP using PhpSMTP
693
+     * Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
694
+     * @param string $header The message headers
695
+     * @param string $body The message body
696
+     * @uses SMTP
697
+     * @access protected
698
+     * @return bool
699
+     */
700
+    protected function SmtpSend($header, $body) {
701 701
     require_once $this->PluginDir . 'class.smtp.php';
702 702
     $bad_rcpt = array();
703 703
 
704 704
     if(!$this->SmtpConnect()) {
705
-      throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
705
+        throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
706 706
     }
707 707
     $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
708 708
     if(!$this->smtp->Mail($smtp_from)) {
709
-      throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
709
+        throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
710 710
     }
711 711
 
712 712
     // Attempt to send attach all recipients
713 713
     foreach($this->to as $to) {
714
-      if (!$this->smtp->Recipient($to[0])) {
714
+        if (!$this->smtp->Recipient($to[0])) {
715 715
         $bad_rcpt[] = $to[0];
716 716
         // implement call back function if it exists
717 717
         $isSent = 0;
718 718
         $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
719
-      } else {
719
+        } else {
720 720
         // implement call back function if it exists
721 721
         $isSent = 1;
722 722
         $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
723
-      }
723
+        }
724 724
     }
725 725
     foreach($this->cc as $cc) {
726
-      if (!$this->smtp->Recipient($cc[0])) {
726
+        if (!$this->smtp->Recipient($cc[0])) {
727 727
         $bad_rcpt[] = $cc[0];
728 728
         // implement call back function if it exists
729 729
         $isSent = 0;
730 730
         $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
731
-      } else {
731
+        } else {
732 732
         // implement call back function if it exists
733 733
         $isSent = 1;
734 734
         $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
735
-      }
735
+        }
736 736
     }
737 737
     foreach($this->bcc as $bcc) {
738
-      if (!$this->smtp->Recipient($bcc[0])) {
738
+        if (!$this->smtp->Recipient($bcc[0])) {
739 739
         $bad_rcpt[] = $bcc[0];
740 740
         // implement call back function if it exists
741 741
         $isSent = 0;
742 742
         $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
743
-      } else {
743
+        } else {
744 744
         // implement call back function if it exists
745 745
         $isSent = 1;
746 746
         $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
747
-      }
747
+        }
748 748
     }
749 749
 
750 750
 
751 751
     if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
752
-      $badaddresses = implode(', ', $bad_rcpt);
753
-      throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
752
+        $badaddresses = implode(', ', $bad_rcpt);
753
+        throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
754 754
     }
755 755
     if(!$this->smtp->Data($header . $body)) {
756
-      throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
756
+        throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
757 757
     }
758 758
     if($this->SMTPKeepAlive == true) {
759
-      $this->smtp->Reset();
759
+        $this->smtp->Reset();
760 760
     }
761 761
     return true;
762
-  }
763
-
764
-  /**
765
-   * Initiates a connection to an SMTP server.
766
-   * Returns false if the operation failed.
767
-   * @uses SMTP
768
-   * @access public
769
-   * @return bool
770
-   */
771
-  public function SmtpConnect() {
762
+    }
763
+
764
+    /**
765
+     * Initiates a connection to an SMTP server.
766
+     * Returns false if the operation failed.
767
+     * @uses SMTP
768
+     * @access public
769
+     * @return bool
770
+     */
771
+    public function SmtpConnect() {
772 772
     if(is_null($this->smtp)) {
773
-      $this->smtp = new SMTP();
773
+        $this->smtp = new SMTP();
774 774
     }
775 775
 
776 776
     $this->smtp->do_debug = $this->SMTPDebug;
@@ -780,14 +780,14 @@  discard block
 block discarded – undo
780 780
 
781 781
     // Retry while there is no connection
782 782
     try {
783
-      while($index < count($hosts) && !$connection) {
783
+        while($index < count($hosts) && !$connection) {
784 784
         $hostinfo = array();
785 785
         if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) {
786
-          $host = $hostinfo[1];
787
-          $port = $hostinfo[2];
786
+            $host = $hostinfo[1];
787
+            $port = $hostinfo[2];
788 788
         } else {
789
-          $host = $hosts[$index];
790
-          $port = $this->Port;
789
+            $host = $hosts[$index];
790
+            $port = $this->Port;
791 791
         }
792 792
 
793 793
         $tls = ($this->SMTPSecure == 'tls');
@@ -795,140 +795,140 @@  discard block
 block discarded – undo
795 795
 
796 796
         if ($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) {
797 797
 
798
-          $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname());
799
-          $this->smtp->Hello($hello);
798
+            $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname());
799
+            $this->smtp->Hello($hello);
800 800
 
801
-          if ($tls) {
801
+            if ($tls) {
802 802
             if (!$this->smtp->StartTLS()) {
803
-              throw new phpmailerException($this->Lang('tls'));
803
+                throw new phpmailerException($this->Lang('tls'));
804 804
             }
805 805
 
806 806
             //We must resend HELO after tls negotiation
807 807
             $this->smtp->Hello($hello);
808
-          }
808
+            }
809 809
 
810
-          $connection = true;
811
-          if ($this->SMTPAuth) {
810
+            $connection = true;
811
+            if ($this->SMTPAuth) {
812 812
             if (!$this->smtp->Authenticate($this->Username, $this->Password)) {
813
-              throw new phpmailerException($this->Lang('authenticate'));
813
+                throw new phpmailerException($this->Lang('authenticate'));
814
+            }
814 815
             }
815
-          }
816 816
         }
817 817
         $index++;
818 818
         if (!$connection) {
819
-          throw new phpmailerException($this->Lang('connect_host'));
819
+            throw new phpmailerException($this->Lang('connect_host'));
820
+        }
820 821
         }
821
-      }
822 822
     } catch (phpmailerException $e) {
823
-      $this->smtp->Reset();
824
-      throw $e;
823
+        $this->smtp->Reset();
824
+        throw $e;
825 825
     }
826 826
     return true;
827
-  }
827
+    }
828 828
 
829
-  /**
830
-   * Closes the active SMTP session if one exists.
831
-   * @return void
832
-   */
833
-  public function SmtpClose() {
829
+    /**
830
+     * Closes the active SMTP session if one exists.
831
+     * @return void
832
+     */
833
+    public function SmtpClose() {
834 834
     if(!is_null($this->smtp)) {
835
-      if($this->smtp->Connected()) {
835
+        if($this->smtp->Connected()) {
836 836
         $this->smtp->Quit();
837 837
         $this->smtp->Close();
838
-      }
839
-    }
840
-  }
841
-
842
-  /**
843
-  * Sets the language for all class error messages.
844
-  * Returns false if it cannot load the language file.  The default language is English.
845
-  * @param string $langcode ISO 639-1 2-character language code (e.g. Portuguese: "br")
846
-  * @param string $lang_path Path to the language file directory
847
-  * @access public
848
-  */
849
-  function SetLanguage($langcode = 'en', $lang_path = 'language/') {
838
+        }
839
+    }
840
+    }
841
+
842
+    /**
843
+     * Sets the language for all class error messages.
844
+     * Returns false if it cannot load the language file.  The default language is English.
845
+     * @param string $langcode ISO 639-1 2-character language code (e.g. Portuguese: "br")
846
+     * @param string $lang_path Path to the language file directory
847
+     * @access public
848
+     */
849
+    function SetLanguage($langcode = 'en', $lang_path = 'language/') {
850 850
     //Define full set of translatable strings
851 851
     $PHPMAILER_LANG = array(
852
-      'provide_address' => 'You must provide at least one recipient email address.',
853
-      'mailer_not_supported' => ' mailer is not supported.',
854
-      'execute' => 'Could not execute: ',
855
-      'instantiate' => 'Could not instantiate mail function.',
856
-      'authenticate' => 'SMTP Error: Could not authenticate.',
857
-      'from_failed' => 'The following From address failed: ',
858
-      'recipients_failed' => 'SMTP Error: The following recipients failed: ',
859
-      'data_not_accepted' => 'SMTP Error: Data not accepted.',
860
-      'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
861
-      'file_access' => 'Could not access file: ',
862
-      'file_open' => 'File Error: Could not open file: ',
863
-      'encoding' => 'Unknown encoding: ',
864
-      'signing' => 'Signing Error: ',
865
-      'smtp_error' => 'SMTP server error: ',
866
-      'empty_message' => 'Message body empty',
867
-      'invalid_address' => 'Invalid address',
868
-      'variable_set' => 'Cannot set or reset variable: '
852
+        'provide_address' => 'You must provide at least one recipient email address.',
853
+        'mailer_not_supported' => ' mailer is not supported.',
854
+        'execute' => 'Could not execute: ',
855
+        'instantiate' => 'Could not instantiate mail function.',
856
+        'authenticate' => 'SMTP Error: Could not authenticate.',
857
+        'from_failed' => 'The following From address failed: ',
858
+        'recipients_failed' => 'SMTP Error: The following recipients failed: ',
859
+        'data_not_accepted' => 'SMTP Error: Data not accepted.',
860
+        'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
861
+        'file_access' => 'Could not access file: ',
862
+        'file_open' => 'File Error: Could not open file: ',
863
+        'encoding' => 'Unknown encoding: ',
864
+        'signing' => 'Signing Error: ',
865
+        'smtp_error' => 'SMTP server error: ',
866
+        'empty_message' => 'Message body empty',
867
+        'invalid_address' => 'Invalid address',
868
+        'variable_set' => 'Cannot set or reset variable: '
869 869
     );
870 870
     //Overwrite language-specific strings. This way we'll never have missing translations - no more "language string failed to load"!
871 871
     $l = true;
872 872
     if ($langcode != 'en') { //There is no English translation file
873
-      $l = @include $lang_path.'phpmailer.lang-'.$langcode.'.php';
873
+        $l = @include $lang_path.'phpmailer.lang-'.$langcode.'.php';
874 874
     }
875 875
     $this->language = $PHPMAILER_LANG;
876 876
     return ($l == true); //Returns false if language not found
877
-  }
877
+    }
878 878
 
879
-  /**
880
-  * Return the current array of language strings
881
-  * @return array
882
-  */
883
-  public function GetTranslations() {
879
+    /**
880
+     * Return the current array of language strings
881
+     * @return array
882
+     */
883
+    public function GetTranslations() {
884 884
     return $this->language;
885
-  }
886
-
887
-  /////////////////////////////////////////////////
888
-  // METHODS, MESSAGE CREATION
889
-  /////////////////////////////////////////////////
890
-
891
-  /**
892
-   * Creates recipient headers.
893
-   * @access public
894
-   * @return string
895
-   */
896
-  public function AddrAppend($type, $addr) {
885
+    }
886
+
887
+    /////////////////////////////////////////////////
888
+    // METHODS, MESSAGE CREATION
889
+    /////////////////////////////////////////////////
890
+
891
+    /**
892
+     * Creates recipient headers.
893
+     * @access public
894
+     * @return string
895
+     */
896
+    public function AddrAppend($type, $addr) {
897 897
     $addr_str = $type . ': ';
898 898
     $addresses = array();
899 899
     foreach ($addr as $a) {
900
-      $addresses[] = $this->AddrFormat($a);
900
+        $addresses[] = $this->AddrFormat($a);
901 901
     }
902 902
     $addr_str .= implode(', ', $addresses);
903 903
     $addr_str .= $this->LE;
904 904
 
905 905
     return $addr_str;
906
-  }
907
-
908
-  /**
909
-   * Formats an address correctly.
910
-   * @access public
911
-   * @return string
912
-   */
913
-  public function AddrFormat($addr) {
906
+    }
907
+
908
+    /**
909
+     * Formats an address correctly.
910
+     * @access public
911
+     * @return string
912
+     */
913
+    public function AddrFormat($addr) {
914 914
     if (empty($addr[1])) {
915
-      return $this->SecureHeader($addr[0]);
915
+        return $this->SecureHeader($addr[0]);
916 916
     } else {
917
-      return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
918
-    }
919
-  }
920
-
921
-  /**
922
-   * Wraps message for use with mailers that do not
923
-   * automatically perform wrapping and for quoted-printable.
924
-   * Original written by philippe.
925
-   * @param string $message The message to wrap
926
-   * @param integer $length The line length to wrap to
927
-   * @param boolean $qp_mode Whether to run in Quoted-Printable mode
928
-   * @access public
929
-   * @return string
930
-   */
931
-  public function WrapText($message, $length, $qp_mode = false) {
917
+        return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
918
+    }
919
+    }
920
+
921
+    /**
922
+     * Wraps message for use with mailers that do not
923
+     * automatically perform wrapping and for quoted-printable.
924
+     * Original written by philippe.
925
+     * @param string $message The message to wrap
926
+     * @param integer $length The line length to wrap to
927
+     * @param boolean $qp_mode Whether to run in Quoted-Printable mode
928
+     * @access public
929
+     * @return string
930
+     */
931
+    public function WrapText($message, $length, $qp_mode = false) {
932 932
     $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
933 933
     // If utf-8 encoding is used, we will need to make sure we don't
934 934
     // split multibyte characters when we wrap
@@ -936,140 +936,140 @@  discard block
 block discarded – undo
936 936
 
937 937
     $message = $this->FixEOL($message);
938 938
     if (substr($message, -1) == $this->LE) {
939
-      $message = substr($message, 0, -1);
939
+        $message = substr($message, 0, -1);
940 940
     }
941 941
 
942 942
     $line = explode($this->LE, $message);
943 943
     $message = '';
944 944
     for ($i=0 ;$i < count($line); $i++) {
945
-      $line_part = explode(' ', $line[$i]);
946
-      $buf = '';
947
-      for ($e = 0; $e<count($line_part); $e++) {
945
+        $line_part = explode(' ', $line[$i]);
946
+        $buf = '';
947
+        for ($e = 0; $e<count($line_part); $e++) {
948 948
         $word = $line_part[$e];
949 949
         if ($qp_mode and (strlen($word) > $length)) {
950
-          $space_left = $length - strlen($buf) - 1;
951
-          if ($e != 0) {
950
+            $space_left = $length - strlen($buf) - 1;
951
+            if ($e != 0) {
952 952
             if ($space_left > 20) {
953
-              $len = $space_left;
954
-              if ($is_utf8) {
953
+                $len = $space_left;
954
+                if ($is_utf8) {
955 955
                 $len = $this->UTF8CharBoundary($word, $len);
956
-              } elseif (substr($word, $len - 1, 1) == "=") {
956
+                } elseif (substr($word, $len - 1, 1) == "=") {
957 957
                 $len--;
958
-              } elseif (substr($word, $len - 2, 1) == "=") {
958
+                } elseif (substr($word, $len - 2, 1) == "=") {
959 959
                 $len -= 2;
960
-              }
961
-              $part = substr($word, 0, $len);
962
-              $word = substr($word, $len);
963
-              $buf .= ' ' . $part;
964
-              $message .= $buf . sprintf("=%s", $this->LE);
960
+                }
961
+                $part = substr($word, 0, $len);
962
+                $word = substr($word, $len);
963
+                $buf .= ' ' . $part;
964
+                $message .= $buf . sprintf("=%s", $this->LE);
965 965
             } else {
966
-              $message .= $buf . $soft_break;
966
+                $message .= $buf . $soft_break;
967 967
             }
968 968
             $buf = '';
969
-          }
970
-          while (strlen($word) > 0) {
969
+            }
970
+            while (strlen($word) > 0) {
971 971
             $len = $length;
972 972
             if ($is_utf8) {
973
-              $len = $this->UTF8CharBoundary($word, $len);
973
+                $len = $this->UTF8CharBoundary($word, $len);
974 974
             } elseif (substr($word, $len - 1, 1) == "=") {
975
-              $len--;
975
+                $len--;
976 976
             } elseif (substr($word, $len - 2, 1) == "=") {
977
-              $len -= 2;
977
+                $len -= 2;
978 978
             }
979 979
             $part = substr($word, 0, $len);
980 980
             $word = substr($word, $len);
981 981
 
982 982
             if (strlen($word) > 0) {
983
-              $message .= $part . sprintf("=%s", $this->LE);
983
+                $message .= $part . sprintf("=%s", $this->LE);
984 984
             } else {
985
-              $buf = $part;
985
+                $buf = $part;
986
+            }
986 987
             }
987
-          }
988 988
         } else {
989
-          $buf_o = $buf;
990
-          $buf .= ($e == 0) ? $word : (' ' . $word);
989
+            $buf_o = $buf;
990
+            $buf .= ($e == 0) ? $word : (' ' . $word);
991 991
 
992
-          if (strlen($buf) > $length and $buf_o != '') {
992
+            if (strlen($buf) > $length and $buf_o != '') {
993 993
             $message .= $buf_o . $soft_break;
994 994
             $buf = $word;
995
-          }
995
+            }
996
+        }
996 997
         }
997
-      }
998
-      $message .= $buf . $this->LE;
998
+        $message .= $buf . $this->LE;
999 999
     }
1000 1000
 
1001 1001
     return $message;
1002
-  }
1003
-
1004
-  /**
1005
-   * Finds last character boundary prior to maxLength in a utf-8
1006
-   * quoted (printable) encoded string.
1007
-   * Original written by Colin Brown.
1008
-   * @access public
1009
-   * @param string $encodedText utf-8 QP text
1010
-   * @param int    $maxLength   find last character boundary prior to this length
1011
-   * @return int
1012
-   */
1013
-  public function UTF8CharBoundary($encodedText, $maxLength) {
1002
+    }
1003
+
1004
+    /**
1005
+     * Finds last character boundary prior to maxLength in a utf-8
1006
+     * quoted (printable) encoded string.
1007
+     * Original written by Colin Brown.
1008
+     * @access public
1009
+     * @param string $encodedText utf-8 QP text
1010
+     * @param int    $maxLength   find last character boundary prior to this length
1011
+     * @return int
1012
+     */
1013
+    public function UTF8CharBoundary($encodedText, $maxLength) {
1014 1014
     $foundSplitPos = false;
1015 1015
     $lookBack = 3;
1016 1016
     while (!$foundSplitPos) {
1017
-      $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
1018
-      $encodedCharPos = strpos($lastChunk, "=");
1019
-      if ($encodedCharPos !== false) {
1017
+        $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
1018
+        $encodedCharPos = strpos($lastChunk, "=");
1019
+        if ($encodedCharPos !== false) {
1020 1020
         // Found start of encoded character byte within $lookBack block.
1021 1021
         // Check the encoded byte value (the 2 chars after the '=')
1022 1022
         $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
1023 1023
         $dec = hexdec($hex);
1024 1024
         if ($dec < 128) { // Single byte character.
1025
-          // If the encoded char was found at pos 0, it will fit
1026
-          // otherwise reduce maxLength to start of the encoded char
1027
-          $maxLength = ($encodedCharPos == 0) ? $maxLength :
1025
+            // If the encoded char was found at pos 0, it will fit
1026
+            // otherwise reduce maxLength to start of the encoded char
1027
+            $maxLength = ($encodedCharPos == 0) ? $maxLength :
1028 1028
           $maxLength - ($lookBack - $encodedCharPos);
1029
-          $foundSplitPos = true;
1029
+            $foundSplitPos = true;
1030 1030
         } elseif ($dec >= 192) { // First byte of a multi byte character
1031
-          // Reduce maxLength to split at start of character
1032
-          $maxLength = $maxLength - ($lookBack - $encodedCharPos);
1033
-          $foundSplitPos = true;
1031
+            // Reduce maxLength to split at start of character
1032
+            $maxLength = $maxLength - ($lookBack - $encodedCharPos);
1033
+            $foundSplitPos = true;
1034 1034
         } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
1035
-          $lookBack += 3;
1035
+            $lookBack += 3;
1036 1036
         }
1037
-      } else {
1037
+        } else {
1038 1038
         // No encoded character found
1039 1039
         $foundSplitPos = true;
1040
-      }
1040
+        }
1041 1041
     }
1042 1042
     return $maxLength;
1043
-  }
1043
+    }
1044 1044
 
1045 1045
 
1046
-  /**
1047
-   * Set the body wrapping.
1048
-   * @access public
1049
-   * @return void
1050
-   */
1051
-  public function SetWordWrap() {
1046
+    /**
1047
+     * Set the body wrapping.
1048
+     * @access public
1049
+     * @return void
1050
+     */
1051
+    public function SetWordWrap() {
1052 1052
     if($this->WordWrap < 1) {
1053
-      return;
1053
+        return;
1054 1054
     }
1055 1055
 
1056 1056
     switch($this->message_type) {
1057
-      case 'alt':
1057
+        case 'alt':
1058 1058
       case 'alt_attachments':
1059 1059
         $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
1060 1060
         break;
1061
-      default:
1061
+        default:
1062 1062
         $this->Body = $this->WrapText($this->Body, $this->WordWrap);
1063 1063
         break;
1064 1064
     }
1065
-  }
1065
+    }
1066 1066
 
1067
-  /**
1068
-   * Assembles message header.
1069
-   * @access public
1070
-   * @return string The assembled header
1071
-   */
1072
-  public function CreateHeader() {
1067
+    /**
1068
+     * Assembles message header.
1069
+     * @access public
1070
+     * @return string The assembled header
1071
+     */
1072
+    public function CreateHeader() {
1073 1073
     $result = '';
1074 1074
 
1075 1075
     // Set the boundaries
@@ -1079,24 +1079,24 @@  discard block
 block discarded – undo
1079 1079
 
1080 1080
     $result .= $this->HeaderLine('Date', self::RFCDate());
1081 1081
     if($this->Sender == '') {
1082
-      $result .= $this->HeaderLine('Return-Path', trim($this->From));
1082
+        $result .= $this->HeaderLine('Return-Path', trim($this->From));
1083 1083
     } else {
1084
-      $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
1084
+        $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
1085 1085
     }
1086 1086
 
1087 1087
     // To be created automatically by mail()
1088 1088
     if($this->Mailer != 'mail') {
1089
-      if ($this->SingleTo === true) {
1089
+        if ($this->SingleTo === true) {
1090 1090
         foreach($this->to as $t) {
1091
-          $this->SingleToArray[] = $this->AddrFormat($t);
1091
+            $this->SingleToArray[] = $this->AddrFormat($t);
1092 1092
         }
1093
-      } else {
1093
+        } else {
1094 1094
         if(count($this->to) > 0) {
1095
-          $result .= $this->AddrAppend('To', $this->to);
1095
+            $result .= $this->AddrAppend('To', $this->to);
1096 1096
         } elseif (count($this->cc) == 0) {
1097
-          $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
1097
+            $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
1098
+        }
1098 1099
         }
1099
-      }
1100 1100
     }
1101 1101
 
1102 1102
     $from = array();
@@ -1106,97 +1106,97 @@  discard block
 block discarded – undo
1106 1106
 
1107 1107
     // sendmail and mail() extract Cc from the header before sending
1108 1108
     if(count($this->cc) > 0) {
1109
-      $result .= $this->AddrAppend('Cc', $this->cc);
1109
+        $result .= $this->AddrAppend('Cc', $this->cc);
1110 1110
     }
1111 1111
 
1112 1112
     // sendmail and mail() extract Bcc from the header before sending
1113 1113
     if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
1114
-      $result .= $this->AddrAppend('Bcc', $this->bcc);
1114
+        $result .= $this->AddrAppend('Bcc', $this->bcc);
1115 1115
     }
1116 1116
 
1117 1117
     if(count($this->ReplyTo) > 0) {
1118
-      $result .= $this->AddrAppend('Reply-to', $this->ReplyTo);
1118
+        $result .= $this->AddrAppend('Reply-to', $this->ReplyTo);
1119 1119
     }
1120 1120
 
1121 1121
     // mail() sets the subject itself
1122 1122
     if($this->Mailer != 'mail') {
1123
-      $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
1123
+        $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
1124 1124
     }
1125 1125
 
1126 1126
     if($this->MessageID != '') {
1127
-      $result .= $this->HeaderLine('Message-ID',$this->MessageID);
1127
+        $result .= $this->HeaderLine('Message-ID',$this->MessageID);
1128 1128
     } else {
1129
-      $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
1129
+        $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
1130 1130
     }
1131 1131
     $result .= $this->HeaderLine('X-Priority', $this->Priority);
1132 1132
     $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)');
1133 1133
 
1134 1134
     if($this->ConfirmReadingTo != '') {
1135
-      $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
1135
+        $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
1136 1136
     }
1137 1137
 
1138 1138
     // Add custom headers
1139 1139
     for($index = 0; $index < count($this->CustomHeader); $index++) {
1140
-      $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
1140
+        $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
1141 1141
     }
1142 1142
     if (!$this->sign_key_file) {
1143
-      $result .= $this->HeaderLine('MIME-Version', '1.0');
1144
-      $result .= $this->GetMailMIME();
1143
+        $result .= $this->HeaderLine('MIME-Version', '1.0');
1144
+        $result .= $this->GetMailMIME();
1145 1145
     }
1146 1146
 
1147 1147
     return $result;
1148
-  }
1149
-
1150
-  /**
1151
-   * Returns the message MIME.
1152
-   * @access public
1153
-   * @return string
1154
-   */
1155
-  public function GetMailMIME() {
1148
+    }
1149
+
1150
+    /**
1151
+     * Returns the message MIME.
1152
+     * @access public
1153
+     * @return string
1154
+     */
1155
+    public function GetMailMIME() {
1156 1156
     $result = '';
1157 1157
     switch($this->message_type) {
1158
-      case 'plain':
1158
+        case 'plain':
1159 1159
         $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
1160 1160
         $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
1161 1161
         break;
1162
-      case 'attachments':
1162
+        case 'attachments':
1163 1163
       case 'alt_attachments':
1164 1164
         if($this->InlineImageExists()){
1165
-          $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
1165
+            $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
1166 1166
         } else {
1167
-          $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
1168
-          $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1167
+            $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
1168
+            $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1169 1169
         }
1170 1170
         break;
1171
-      case 'alt':
1171
+        case 'alt':
1172 1172
         $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
1173 1173
         $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1174 1174
         break;
1175 1175
     }
1176 1176
 
1177 1177
     if($this->Mailer != 'mail') {
1178
-      $result .= $this->LE.$this->LE;
1178
+        $result .= $this->LE.$this->LE;
1179 1179
     }
1180 1180
 
1181 1181
     return $result;
1182
-  }
1183
-
1184
-  /**
1185
-   * Assembles the message body.  Returns an empty string on failure.
1186
-   * @access public
1187
-   * @return string The assembled message body
1188
-   */
1189
-  public function CreateBody() {
1182
+    }
1183
+
1184
+    /**
1185
+     * Assembles the message body.  Returns an empty string on failure.
1186
+     * @access public
1187
+     * @return string The assembled message body
1188
+     */
1189
+    public function CreateBody() {
1190 1190
     $body = '';
1191 1191
 
1192 1192
     if ($this->sign_key_file) {
1193
-      $body .= $this->GetMailMIME();
1193
+        $body .= $this->GetMailMIME();
1194 1194
     }
1195 1195
 
1196 1196
     $this->SetWordWrap();
1197 1197
 
1198 1198
     switch($this->message_type) {
1199
-      case 'alt':
1199
+        case 'alt':
1200 1200
         $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
1201 1201
         $body .= $this->EncodeString($this->AltBody, $this->Encoding);
1202 1202
         $body .= $this->LE.$this->LE;
@@ -1205,16 +1205,16 @@  discard block
 block discarded – undo
1205 1205
         $body .= $this->LE.$this->LE;
1206 1206
         $body .= $this->EndBoundary($this->boundary[1]);
1207 1207
         break;
1208
-      case 'plain':
1208
+        case 'plain':
1209 1209
         $body .= $this->EncodeString($this->Body, $this->Encoding);
1210 1210
         break;
1211
-      case 'attachments':
1211
+        case 'attachments':
1212 1212
         $body .= $this->GetBoundary($this->boundary[1], '', '', '');
1213 1213
         $body .= $this->EncodeString($this->Body, $this->Encoding);
1214 1214
         $body .= $this->LE;
1215 1215
         $body .= $this->AttachAll();
1216 1216
         break;
1217
-      case 'alt_attachments':
1217
+        case 'alt_attachments':
1218 1218
         $body .= sprintf("--%s%s", $this->boundary[1], $this->LE);
1219 1219
         $body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
1220 1220
         $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
@@ -1229,46 +1229,46 @@  discard block
 block discarded – undo
1229 1229
     }
1230 1230
 
1231 1231
     if ($this->IsError()) {
1232
-      $body = '';
1232
+        $body = '';
1233 1233
     } elseif ($this->sign_key_file) {
1234
-      try {
1234
+        try {
1235 1235
         $file = tempnam('', 'mail');
1236 1236
         file_put_contents($file, $body); //TODO check this worked
1237 1237
         $signed = tempnam("", "signed");
1238 1238
         if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) {
1239
-          @unlink($file);
1240
-          @unlink($signed);
1241
-          $body = file_get_contents($signed);
1239
+            @unlink($file);
1240
+            @unlink($signed);
1241
+            $body = file_get_contents($signed);
1242 1242
         } else {
1243
-          @unlink($file);
1244
-          @unlink($signed);
1245
-          throw new phpmailerException($this->Lang("signing").openssl_error_string());
1243
+            @unlink($file);
1244
+            @unlink($signed);
1245
+            throw new phpmailerException($this->Lang("signing").openssl_error_string());
1246 1246
         }
1247
-      } catch (phpmailerException $e) {
1247
+        } catch (phpmailerException $e) {
1248 1248
         $body = '';
1249 1249
         if ($this->exceptions) {
1250
-          throw $e;
1250
+            throw $e;
1251
+        }
1251 1252
         }
1252
-      }
1253 1253
     }
1254 1254
 
1255 1255
     return $body;
1256
-  }
1256
+    }
1257 1257
 
1258
-  /**
1259
-   * Returns the start of a message boundary.
1260
-   * @access private
1261
-   */
1262
-  private function GetBoundary($boundary, $charSet, $contentType, $encoding) {
1258
+    /**
1259
+     * Returns the start of a message boundary.
1260
+     * @access private
1261
+     */
1262
+    private function GetBoundary($boundary, $charSet, $contentType, $encoding) {
1263 1263
     $result = '';
1264 1264
     if($charSet == '') {
1265
-      $charSet = $this->CharSet;
1265
+        $charSet = $this->CharSet;
1266 1266
     }
1267 1267
     if($contentType == '') {
1268
-      $contentType = $this->ContentType;
1268
+        $contentType = $this->ContentType;
1269 1269
     }
1270 1270
     if($encoding == '') {
1271
-      $encoding = $this->Encoding;
1271
+        $encoding = $this->Encoding;
1272 1272
     }
1273 1273
     $result .= $this->TextLine('--' . $boundary);
1274 1274
     $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);
@@ -1277,80 +1277,80 @@  discard block
 block discarded – undo
1277 1277
     $result .= $this->LE;
1278 1278
 
1279 1279
     return $result;
1280
-  }
1280
+    }
1281 1281
 
1282
-  /**
1283
-   * Returns the end of a message boundary.
1284
-   * @access private
1285
-   */
1286
-  private function EndBoundary($boundary) {
1282
+    /**
1283
+     * Returns the end of a message boundary.
1284
+     * @access private
1285
+     */
1286
+    private function EndBoundary($boundary) {
1287 1287
     return $this->LE . '--' . $boundary . '--' . $this->LE;
1288
-  }
1289
-
1290
-  /**
1291
-   * Sets the message type.
1292
-   * @access private
1293
-   * @return void
1294
-   */
1295
-  private function SetMessageType() {
1288
+    }
1289
+
1290
+    /**
1291
+     * Sets the message type.
1292
+     * @access private
1293
+     * @return void
1294
+     */
1295
+    private function SetMessageType() {
1296 1296
     if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
1297
-      $this->message_type = 'plain';
1297
+        $this->message_type = 'plain';
1298 1298
     } else {
1299
-      if(count($this->attachment) > 0) {
1299
+        if(count($this->attachment) > 0) {
1300 1300
         $this->message_type = 'attachments';
1301
-      }
1302
-      if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
1301
+        }
1302
+        if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
1303 1303
         $this->message_type = 'alt';
1304
-      }
1305
-      if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
1304
+        }
1305
+        if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
1306 1306
         $this->message_type = 'alt_attachments';
1307
-      }
1307
+        }
1308
+    }
1308 1309
     }
1309
-  }
1310 1310
 
1311
-  /**
1312
-   *  Returns a formatted header line.
1313
-   * @access public
1314
-   * @return string
1315
-   */
1316
-  public function HeaderLine($name, $value) {
1311
+    /**
1312
+     *  Returns a formatted header line.
1313
+     * @access public
1314
+     * @return string
1315
+     */
1316
+    public function HeaderLine($name, $value) {
1317 1317
     return $name . ': ' . $value . $this->LE;
1318
-  }
1319
-
1320
-  /**
1321
-   * Returns a formatted mail line.
1322
-   * @access public
1323
-   * @return string
1324
-   */
1325
-  public function TextLine($value) {
1318
+    }
1319
+
1320
+    /**
1321
+     * Returns a formatted mail line.
1322
+     * @access public
1323
+     * @return string
1324
+     */
1325
+    public function TextLine($value) {
1326 1326
     return $value . $this->LE;
1327
-  }
1328
-
1329
-  /////////////////////////////////////////////////
1330
-  // CLASS METHODS, ATTACHMENTS
1331
-  /////////////////////////////////////////////////
1332
-
1333
-  /**
1334
-   * Adds an attachment from a path on the filesystem.
1335
-   * Returns false if the file could not be found
1336
-   * or accessed.
1337
-   * @param string $path Path to the attachment.
1338
-   * @param string $name Overrides the attachment name.
1339
-   * @param string $encoding File encoding (see $Encoding).
1340
-   * @param string $type File extension (MIME) type.
1341
-   * @return bool
1342
-   */
1343
-  public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1327
+    }
1328
+
1329
+    /////////////////////////////////////////////////
1330
+    // CLASS METHODS, ATTACHMENTS
1331
+    /////////////////////////////////////////////////
1332
+
1333
+    /**
1334
+     * Adds an attachment from a path on the filesystem.
1335
+     * Returns false if the file could not be found
1336
+     * or accessed.
1337
+     * @param string $path Path to the attachment.
1338
+     * @param string $name Overrides the attachment name.
1339
+     * @param string $encoding File encoding (see $Encoding).
1340
+     * @param string $type File extension (MIME) type.
1341
+     * @return bool
1342
+     */
1343
+    public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1344 1344
     try {
1345
-      if ( !@is_file($path) ) {
1345
+        if ( !@is_file($path) ) {
1346 1346
         throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
1347
-      }
1348
-      $filename = basename($path);
1349
-      if ( $name == '' ) {
1347
+        }
1348
+        $filename = basename($path);
1349
+        if ( $name == '' ) {
1350 1350
         $name = $filename;
1351
-      }
1351
+        }
1352 1352
 
1353
-      $this->attachment[] = array(
1353
+        $this->attachment[] = array(
1354 1354
         0 => $path,
1355 1355
         1 => $filename,
1356 1356
         2 => $name,
@@ -1359,36 +1359,36 @@  discard block
 block discarded – undo
1359 1359
         5 => false,  // isStringAttachment
1360 1360
         6 => 'attachment',
1361 1361
         7 => 0
1362
-      );
1362
+        );
1363 1363
 
1364 1364
     } catch (phpmailerException $e) {
1365
-      $this->SetError($e->getMessage());
1366
-      if ($this->exceptions) {
1365
+        $this->SetError($e->getMessage());
1366
+        if ($this->exceptions) {
1367 1367
         throw $e;
1368
-      }
1369
-      error_log($e->getMessage()."\n");
1370
-      if ( $e->getCode() == self::STOP_CRITICAL ) {
1368
+        }
1369
+        error_log($e->getMessage()."\n");
1370
+        if ( $e->getCode() == self::STOP_CRITICAL ) {
1371 1371
         return false;
1372
-      }
1372
+        }
1373 1373
     }
1374 1374
     return true;
1375
-  }
1375
+    }
1376 1376
 
1377
-  /**
1378
-  * Return the current array of attachments
1379
-  * @return array
1380
-  */
1381
-  public function GetAttachments() {
1377
+    /**
1378
+     * Return the current array of attachments
1379
+     * @return array
1380
+     */
1381
+    public function GetAttachments() {
1382 1382
     return $this->attachment;
1383
-  }
1384
-
1385
-  /**
1386
-   * Attaches all fs, string, and binary attachments to the message.
1387
-   * Returns an empty string on failure.
1388
-   * @access private
1389
-   * @return string
1390
-   */
1391
-  private function AttachAll() {
1383
+    }
1384
+
1385
+    /**
1386
+     * Attaches all fs, string, and binary attachments to the message.
1387
+     * Returns an empty string on failure.
1388
+     * @access private
1389
+     * @return string
1390
+     */
1391
+    private function AttachAll() {
1392 1392
     // Return text of body
1393 1393
     $mime = array();
1394 1394
     $cidUniq = array();
@@ -1396,70 +1396,70 @@  discard block
 block discarded – undo
1396 1396
 
1397 1397
     // Add all attachments
1398 1398
     foreach ($this->attachment as $attachment) {
1399
-      // Check for string attachment
1400
-      $bString = $attachment[5];
1401
-      if ($bString) {
1399
+        // Check for string attachment
1400
+        $bString = $attachment[5];
1401
+        if ($bString) {
1402 1402
         $string = $attachment[0];
1403
-      } else {
1403
+        } else {
1404 1404
         $path = $attachment[0];
1405
-      }
1406
-
1407
-      if (in_array($attachment[0], $incl)) { continue; }
1408
-      $filename    = $attachment[1];
1409
-      $name        = $attachment[2];
1410
-      $encoding    = $attachment[3];
1411
-      $type        = $attachment[4];
1412
-      $disposition = $attachment[6];
1413
-      $cid         = $attachment[7];
1414
-      $incl[]      = $attachment[0];
1415
-      if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; }
1416
-      $cidUniq[$cid] = true;
1417
-
1418
-      $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
1419
-      $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE);
1420
-      $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
1421
-
1422
-      if($disposition == 'inline') {
1405
+        }
1406
+
1407
+        if (in_array($attachment[0], $incl)) { continue; }
1408
+        $filename    = $attachment[1];
1409
+        $name        = $attachment[2];
1410
+        $encoding    = $attachment[3];
1411
+        $type        = $attachment[4];
1412
+        $disposition = $attachment[6];
1413
+        $cid         = $attachment[7];
1414
+        $incl[]      = $attachment[0];
1415
+        if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; }
1416
+        $cidUniq[$cid] = true;
1417
+
1418
+        $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
1419
+        $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE);
1420
+        $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
1421
+
1422
+        if($disposition == 'inline') {
1423 1423
         $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
1424
-      }
1424
+        }
1425 1425
 
1426
-      $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE);
1426
+        $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE);
1427 1427
 
1428
-      // Encode as string attachment
1429
-      if($bString) {
1428
+        // Encode as string attachment
1429
+        if($bString) {
1430 1430
         $mime[] = $this->EncodeString($string, $encoding);
1431 1431
         if($this->IsError()) {
1432
-          return '';
1432
+            return '';
1433 1433
         }
1434 1434
         $mime[] = $this->LE.$this->LE;
1435
-      } else {
1435
+        } else {
1436 1436
         $mime[] = $this->EncodeFile($path, $encoding);
1437 1437
         if($this->IsError()) {
1438
-          return '';
1438
+            return '';
1439 1439
         }
1440 1440
         $mime[] = $this->LE.$this->LE;
1441
-      }
1441
+        }
1442 1442
     }
1443 1443
 
1444 1444
     $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
1445 1445
 
1446 1446
     return join('', $mime);
1447
-  }
1448
-
1449
-  /**
1450
-   * Encodes attachment in requested format.
1451
-   * Returns an empty string on failure.
1452
-   * @param string $path The full path to the file
1453
-   * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
1454
-   * @see EncodeFile()
1455
-   * @access private
1456
-   * @return string
1457
-   */
1458
-  private function EncodeFile($path, $encoding = 'base64') {
1447
+    }
1448
+
1449
+    /**
1450
+     * Encodes attachment in requested format.
1451
+     * Returns an empty string on failure.
1452
+     * @param string $path The full path to the file
1453
+     * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
1454
+     * @see EncodeFile()
1455
+     * @access private
1456
+     * @return string
1457
+     */
1458
+    private function EncodeFile($path, $encoding = 'base64') {
1459 1459
     try {
1460
-      if (!is_readable($path)) {
1460
+        if (!is_readable($path)) {
1461 1461
         throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
1462
-      }
1462
+        }
1463 1463
         $magic_quotes = get_magic_quotes_runtime();
1464 1464
         if ($magic_quotes) {
1465 1465
             if (version_compare(PHP_VERSION, '5.3.0', '<')) {
@@ -1479,114 +1479,114 @@  discard block
 block discarded – undo
1479 1479
         }
1480 1480
         return $file_buffer;
1481 1481
     } catch (Exception $e) {
1482
-      $this->SetError($e->getMessage());
1483
-      return '';
1484
-    }
1485
-  }
1486
-
1487
-  /**
1488
-   * Encodes string to requested format.
1489
-   * Returns an empty string on failure.
1490
-   * @param string $str The text to encode
1491
-   * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
1492
-   * @access public
1493
-   * @return string
1494
-   */
1495
-  public function EncodeString ($str, $encoding = 'base64') {
1482
+        $this->SetError($e->getMessage());
1483
+        return '';
1484
+    }
1485
+    }
1486
+
1487
+    /**
1488
+     * Encodes string to requested format.
1489
+     * Returns an empty string on failure.
1490
+     * @param string $str The text to encode
1491
+     * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
1492
+     * @access public
1493
+     * @return string
1494
+     */
1495
+    public function EncodeString ($str, $encoding = 'base64') {
1496 1496
     $encoded = '';
1497 1497
     switch(strtolower($encoding)) {
1498
-      case 'base64':
1498
+        case 'base64':
1499 1499
         $encoded = chunk_split(base64_encode($str), 76, $this->LE);
1500 1500
         break;
1501
-      case '7bit':
1501
+        case '7bit':
1502 1502
       case '8bit':
1503 1503
         $encoded = $this->FixEOL($str);
1504 1504
         //Make sure it ends with a line break
1505 1505
         if (substr($encoded, -(strlen($this->LE))) != $this->LE)
1506
-          $encoded .= $this->LE;
1506
+            $encoded .= $this->LE;
1507 1507
         break;
1508
-      case 'binary':
1508
+        case 'binary':
1509 1509
         $encoded = $str;
1510 1510
         break;
1511
-      case 'quoted-printable':
1511
+        case 'quoted-printable':
1512 1512
         $encoded = $this->EncodeQP($str);
1513 1513
         break;
1514
-      default:
1514
+        default:
1515 1515
         $this->SetError($this->Lang('encoding') . $encoding);
1516 1516
         break;
1517 1517
     }
1518 1518
     return $encoded;
1519
-  }
1520
-
1521
-  /**
1522
-   * Encode a header string to best (shortest) of Q, B, quoted or none.
1523
-   * @access public
1524
-   * @return string
1525
-   */
1526
-  public function EncodeHeader($str, $position = 'text') {
1519
+    }
1520
+
1521
+    /**
1522
+     * Encode a header string to best (shortest) of Q, B, quoted or none.
1523
+     * @access public
1524
+     * @return string
1525
+     */
1526
+    public function EncodeHeader($str, $position = 'text') {
1527 1527
     $x = 0;
1528 1528
 
1529 1529
     switch (strtolower($position)) {
1530
-      case 'phrase':
1530
+        case 'phrase':
1531 1531
         if (!preg_match('/[\200-\377]/', $str)) {
1532
-          // Can't use addslashes as we don't know what value has magic_quotes_sybase
1533
-          $encoded = addcslashes($str, "\0..\37\177\\\"");
1534
-          if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
1532
+            // Can't use addslashes as we don't know what value has magic_quotes_sybase
1533
+            $encoded = addcslashes($str, "\0..\37\177\\\"");
1534
+            if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
1535 1535
             return ($encoded);
1536
-          } else {
1536
+            } else {
1537 1537
             return ("\"$encoded\"");
1538
-          }
1538
+            }
1539 1539
         }
1540 1540
         $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
1541 1541
         break;
1542
-      case 'comment':
1542
+        case 'comment':
1543 1543
         $x = preg_match_all('/[()"]/', $str, $matches);
1544 1544
         // Fall-through
1545
-      case 'text':
1545
+        case 'text':
1546 1546
       default:
1547 1547
         $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
1548 1548
         break;
1549 1549
     }
1550 1550
 
1551 1551
     if ($x == 0) {
1552
-      return ($str);
1552
+        return ($str);
1553 1553
     }
1554 1554
 
1555 1555
     $maxlen = 75 - 7 - strlen($this->CharSet);
1556 1556
     // Try to select the encoding which should produce the shortest output
1557 1557
     if (strlen($str)/3 < $x) {
1558
-      $encoding = 'B';
1559
-      // Modified by Ivan Tcholakov, 24-JAN-2010.
1560
-      //if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
1561
-      if ($this->HasMultiBytes($str)) {
1562
-      //
1558
+        $encoding = 'B';
1559
+        // Modified by Ivan Tcholakov, 24-JAN-2010.
1560
+        //if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
1561
+        if ($this->HasMultiBytes($str)) {
1562
+        //
1563 1563
         // Use a custom function which correctly encodes and wraps long
1564 1564
         // multibyte strings without breaking lines within a character
1565 1565
         $encoded = $this->Base64EncodeWrapMB($str);
1566
-      } else {
1566
+        } else {
1567 1567
         $encoded = base64_encode($str);
1568 1568
         $maxlen -= $maxlen % 4;
1569 1569
         $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
1570
-      }
1570
+        }
1571 1571
     } else {
1572
-      $encoding = 'Q';
1573
-      $encoded = $this->EncodeQ($str, $position);
1574
-      $encoded = $this->WrapText($encoded, $maxlen, true);
1575
-      $encoded = str_replace('='.$this->LE, "\n", trim($encoded));
1572
+        $encoding = 'Q';
1573
+        $encoded = $this->EncodeQ($str, $position);
1574
+        $encoded = $this->WrapText($encoded, $maxlen, true);
1575
+        $encoded = str_replace('='.$this->LE, "\n", trim($encoded));
1576 1576
     }
1577 1577
 
1578 1578
     $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
1579 1579
     $encoded = trim(str_replace("\n", $this->LE, $encoded));
1580 1580
 
1581 1581
     return $encoded;
1582
-  }
1583
-
1584
-  /**
1585
-   * Checks if a string contains multibyte characters.
1586
-   * @access public
1587
-   * @param string $str multi-byte text to wrap encode
1588
-   * @return bool
1589
-   */
1582
+    }
1583
+
1584
+    /**
1585
+     * Checks if a string contains multibyte characters.
1586
+     * @access public
1587
+     * @param string $str multi-byte text to wrap encode
1588
+     * @return bool
1589
+     */
1590 1590
     public function HasMultiBytes($str)
1591 1591
     {
1592 1592
         if (function_exists('mb_strlen')) {
@@ -1597,15 +1597,15 @@  discard block
 block discarded – undo
1597 1597
 
1598 1598
     }
1599 1599
 
1600
-  /**
1601
-   * Correctly encodes and wraps long multibyte strings for mail headers
1602
-   * without breaking lines within a character.
1603
-   * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
1604
-   * @access public
1605
-   * @param string $str multi-byte text to wrap encode
1606
-   * @return string
1607
-   */
1608
-  public function Base64EncodeWrapMB($str) {
1600
+    /**
1601
+     * Correctly encodes and wraps long multibyte strings for mail headers
1602
+     * without breaking lines within a character.
1603
+     * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
1604
+     * @access public
1605
+     * @param string $str multi-byte text to wrap encode
1606
+     * @return string
1607
+     */
1608
+    public function Base64EncodeWrapMB($str) {
1609 1609
     $start = "=?".$this->CharSet."?B?";
1610 1610
     $end = "?=";
1611 1611
     $encoded = "";
@@ -1622,9 +1622,9 @@  discard block
 block discarded – undo
1622 1622
     $offset = $avgLength = floor($length * $ratio * .75);
1623 1623
 
1624 1624
     for ($i = 0; $i < $mb_length; $i += $offset) {
1625
-      $lookBack = 0;
1625
+        $lookBack = 0;
1626 1626
 
1627
-      do {
1627
+        do {
1628 1628
         $offset = $avgLength - $lookBack;
1629 1629
         // Modified by Ivan Tcholakov, 24-JAN-2010.
1630 1630
         //$chunk = mb_substr($str, $i, $offset, $this->CharSet);
@@ -1632,85 +1632,85 @@  discard block
 block discarded – undo
1632 1632
         //
1633 1633
         $chunk = base64_encode($chunk);
1634 1634
         $lookBack++;
1635
-      }
1636
-      while (strlen($chunk) > $length);
1635
+        }
1636
+        while (strlen($chunk) > $length);
1637 1637
 
1638
-      $encoded .= $chunk . $this->LE;
1638
+        $encoded .= $chunk . $this->LE;
1639 1639
     }
1640 1640
 
1641 1641
     // Chomp the last linefeed
1642 1642
     $encoded = substr($encoded, 0, -strlen($this->LE));
1643 1643
     return $encoded;
1644
-  }
1645
-
1646
-  /**
1647
-  * Encode string to quoted-printable.
1648
-  * Only uses standard PHP, slow, but will always work
1649
-  * @access public
1650
-  * @param string $string the text to encode
1651
-  * @param integer $line_max Number of chars allowed on a line before wrapping
1652
-  * @return string
1653
-  */
1654
-  public function EncodeQPphp( $input = '', $line_max = 76, $space_conv = false) {
1644
+    }
1645
+
1646
+    /**
1647
+     * Encode string to quoted-printable.
1648
+     * Only uses standard PHP, slow, but will always work
1649
+     * @access public
1650
+     * @param string $string the text to encode
1651
+     * @param integer $line_max Number of chars allowed on a line before wrapping
1652
+     * @return string
1653
+     */
1654
+    public function EncodeQPphp( $input = '', $line_max = 76, $space_conv = false) {
1655 1655
     $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
1656 1656
     $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
1657 1657
     $eol = "\r\n";
1658 1658
     $escape = '=';
1659 1659
     $output = '';
1660 1660
     while( list(, $line) = each($lines) ) {
1661
-      $linlen = strlen($line);
1662
-      $newline = '';
1663
-      for($i = 0; $i < $linlen; $i++) {
1661
+        $linlen = strlen($line);
1662
+        $newline = '';
1663
+        for($i = 0; $i < $linlen; $i++) {
1664 1664
         $c = substr( $line, $i, 1 );
1665 1665
         $dec = ord( $c );
1666 1666
         if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
1667
-          $c = '=2E';
1667
+            $c = '=2E';
1668 1668
         }
1669 1669
         if ( $dec == 32 ) {
1670
-          if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
1670
+            if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
1671 1671
             $c = '=20';
1672
-          } else if ( $space_conv ) {
1672
+            } else if ( $space_conv ) {
1673 1673
             $c = '=20';
1674
-          }
1674
+            }
1675 1675
         } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
1676
-          $h2 = floor($dec/16);
1677
-          $h1 = floor($dec%16);
1678
-          $c = $escape.$hex[$h2].$hex[$h1];
1676
+            $h2 = floor($dec/16);
1677
+            $h1 = floor($dec%16);
1678
+            $c = $escape.$hex[$h2].$hex[$h1];
1679 1679
         }
1680 1680
         if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
1681
-          $output .= $newline.$escape.$eol; //  soft line break; " =\r\n" is okay
1682
-          $newline = '';
1683
-          // check if newline first character will be point or not
1684
-          if ( $dec == 46 ) {
1681
+            $output .= $newline.$escape.$eol; //  soft line break; " =\r\n" is okay
1682
+            $newline = '';
1683
+            // check if newline first character will be point or not
1684
+            if ( $dec == 46 ) {
1685 1685
             $c = '=2E';
1686
-          }
1686
+            }
1687 1687
         }
1688 1688
         $newline .= $c;
1689
-      } // end of for
1690
-      $output .= $newline.$eol;
1689
+        } // end of for
1690
+        $output .= $newline.$eol;
1691 1691
     } // end of while
1692 1692
     return $output;
1693
-  }
1694
-
1695
-  /**
1696
-  * Encode string to RFC2045 (6.7) quoted-printable format
1697
-  * Uses a PHP5 stream filter to do the encoding about 64x faster than the old version
1698
-  * Also results in same content as you started with after decoding
1699
-  * @see EncodeQPphp()
1700
-  * @access public
1701
-  * @param string $string the text to encode
1702
-  * @param integer $line_max Number of chars allowed on a line before wrapping
1703
-  * @param boolean $space_conv Dummy param for compatibility with existing EncodeQP function
1704
-  * @return string
1705
-  * @author Marcus Bointon
1706
-  */
1707
-  public function EncodeQP($string, $line_max = 76, $space_conv = false) {
1693
+    }
1694
+
1695
+    /**
1696
+     * Encode string to RFC2045 (6.7) quoted-printable format
1697
+     * Uses a PHP5 stream filter to do the encoding about 64x faster than the old version
1698
+     * Also results in same content as you started with after decoding
1699
+     * @see EncodeQPphp()
1700
+     * @access public
1701
+     * @param string $string the text to encode
1702
+     * @param integer $line_max Number of chars allowed on a line before wrapping
1703
+     * @param boolean $space_conv Dummy param for compatibility with existing EncodeQP function
1704
+     * @return string
1705
+     * @author Marcus Bointon
1706
+     */
1707
+    public function EncodeQP($string, $line_max = 76, $space_conv = false) {
1708 1708
     if (function_exists('quoted_printable_encode')) { //Use native function if it's available (>= PHP5.3)
1709
-      return quoted_printable_encode($string);
1709
+        return quoted_printable_encode($string);
1710 1710
     }
1711 1711
     $filters = stream_get_filters();
1712 1712
     if (!in_array('convert.*', $filters)) { //Got convert stream filter?
1713
-      return $this->EncodeQPphp($string, $line_max, $space_conv); //Fall back to old implementation
1713
+        return $this->EncodeQPphp($string, $line_max, $space_conv); //Fall back to old implementation
1714 1714
     }
1715 1715
     $fp = fopen('php://temp/', 'r+');
1716 1716
     $string = preg_replace('/\r\n?/', $this->LE, $string); //Normalise line breaks
@@ -1723,32 +1723,32 @@  discard block
 block discarded – undo
1723 1723
     $out = preg_replace('/^\./m', '=2E', $out); //Encode . if it is first char on a line, workaround for bug in Exchange
1724 1724
     fclose($fp);
1725 1725
     return $out;
1726
-  }
1727
-
1728
-  /**
1729
-   * Encode string to q encoding.
1730
-   * @link http://tools.ietf.org/html/rfc2047
1731
-   * @param string $str the text to encode
1732
-   * @param string $position Where the text is going to be used, see the RFC for what that means
1733
-   * @access public
1734
-   * @return string
1735
-   */
1736
-  public function EncodeQ ($str, $position = 'text') {
1726
+    }
1727
+
1728
+    /**
1729
+     * Encode string to q encoding.
1730
+     * @link http://tools.ietf.org/html/rfc2047
1731
+     * @param string $str the text to encode
1732
+     * @param string $position Where the text is going to be used, see the RFC for what that means
1733
+     * @access public
1734
+     * @return string
1735
+     */
1736
+    public function EncodeQ ($str, $position = 'text') {
1737 1737
     // There should not be any EOL in the string
1738 1738
     $encoded = preg_replace('/[\r\n]*/', '', $str);
1739 1739
 
1740 1740
     switch (strtolower($position)) {
1741
-      case 'phrase':
1741
+        case 'phrase':
1742 1742
         $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
1743 1743
         break;
1744
-      case 'comment':
1744
+        case 'comment':
1745 1745
         $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
1746
-      case 'text':
1746
+        case 'text':
1747 1747
       default:
1748 1748
         // Replace every high ascii, control =, ? and _ characters
1749 1749
         //TODO using /e (equivalent to eval()) is probably not a good idea
1750 1750
         $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
1751
-              "'='.sprintf('%02X', ord('\\1'))", $encoded);
1751
+                "'='.sprintf('%02X', ord('\\1'))", $encoded);
1752 1752
         break;
1753 1753
     }
1754 1754
 
@@ -1756,187 +1756,187 @@  discard block
 block discarded – undo
1756 1756
     $encoded = str_replace(' ', '_', $encoded);
1757 1757
 
1758 1758
     return $encoded;
1759
-  }
1760
-
1761
-  /**
1762
-   * Adds a string or binary attachment (non-filesystem) to the list.
1763
-   * This method can be used to attach ascii or binary data,
1764
-   * such as a BLOB record from a database.
1765
-   * @param string $string String attachment data.
1766
-   * @param string $filename Name of the attachment.
1767
-   * @param string $encoding File encoding (see $Encoding).
1768
-   * @param string $type File extension (MIME) type.
1769
-   * @return void
1770
-   */
1771
-  public function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {
1759
+    }
1760
+
1761
+    /**
1762
+     * Adds a string or binary attachment (non-filesystem) to the list.
1763
+     * This method can be used to attach ascii or binary data,
1764
+     * such as a BLOB record from a database.
1765
+     * @param string $string String attachment data.
1766
+     * @param string $filename Name of the attachment.
1767
+     * @param string $encoding File encoding (see $Encoding).
1768
+     * @param string $type File extension (MIME) type.
1769
+     * @return void
1770
+     */
1771
+    public function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {
1772 1772
     // Append to $attachment array
1773 1773
     $this->attachment[] = array(
1774
-      0 => $string,
1775
-      1 => $filename,
1776
-      2 => basename($filename),
1777
-      3 => $encoding,
1778
-      4 => $type,
1779
-      5 => true,  // isStringAttachment
1780
-      6 => 'attachment',
1781
-      7 => 0
1774
+        0 => $string,
1775
+        1 => $filename,
1776
+        2 => basename($filename),
1777
+        3 => $encoding,
1778
+        4 => $type,
1779
+        5 => true,  // isStringAttachment
1780
+        6 => 'attachment',
1781
+        7 => 0
1782 1782
     );
1783
-  }
1784
-
1785
-  /**
1786
-   * Adds an embedded attachment.  This can include images, sounds, and
1787
-   * just about any other document.  Make sure to set the $type to an
1788
-   * image type.  For JPEG images use "image/jpeg" and for GIF images
1789
-   * use "image/gif".
1790
-   * @param string $path Path to the attachment.
1791
-   * @param string $cid Content ID of the attachment.  Use this to identify
1792
-   *        the Id for accessing the image in an HTML form.
1793
-   * @param string $name Overrides the attachment name.
1794
-   * @param string $encoding File encoding (see $Encoding).
1795
-   * @param string $type File extension (MIME) type.
1796
-   * @return bool
1797
-   */
1798
-  public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1783
+    }
1784
+
1785
+    /**
1786
+     * Adds an embedded attachment.  This can include images, sounds, and
1787
+     * just about any other document.  Make sure to set the $type to an
1788
+     * image type.  For JPEG images use "image/jpeg" and for GIF images
1789
+     * use "image/gif".
1790
+     * @param string $path Path to the attachment.
1791
+     * @param string $cid Content ID of the attachment.  Use this to identify
1792
+     *        the Id for accessing the image in an HTML form.
1793
+     * @param string $name Overrides the attachment name.
1794
+     * @param string $encoding File encoding (see $Encoding).
1795
+     * @param string $type File extension (MIME) type.
1796
+     * @return bool
1797
+     */
1798
+    public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1799 1799
 
1800 1800
     if ( !@is_file($path) ) {
1801
-      $this->SetError($this->Lang('file_access') . $path);
1802
-      return false;
1801
+        $this->SetError($this->Lang('file_access') . $path);
1802
+        return false;
1803 1803
     }
1804 1804
 
1805 1805
     $filename = basename($path);
1806 1806
     if ( $name == '' ) {
1807
-      $name = $filename;
1807
+        $name = $filename;
1808 1808
     }
1809 1809
 
1810 1810
     // Append to $attachment array
1811 1811
     $this->attachment[] = array(
1812
-      0 => $path,
1813
-      1 => $filename,
1814
-      2 => $name,
1815
-      3 => $encoding,
1816
-      4 => $type,
1817
-      5 => false,  // isStringAttachment
1818
-      6 => 'inline',
1819
-      7 => $cid
1812
+        0 => $path,
1813
+        1 => $filename,
1814
+        2 => $name,
1815
+        3 => $encoding,
1816
+        4 => $type,
1817
+        5 => false,  // isStringAttachment
1818
+        6 => 'inline',
1819
+        7 => $cid
1820 1820
     );
1821 1821
 
1822 1822
     return true;
1823
-  }
1824
-
1825
-  /**
1826
-   * Returns true if an inline attachment is present.
1827
-   * @access public
1828
-   * @return bool
1829
-   */
1830
-  public function InlineImageExists() {
1823
+    }
1824
+
1825
+    /**
1826
+     * Returns true if an inline attachment is present.
1827
+     * @access public
1828
+     * @return bool
1829
+     */
1830
+    public function InlineImageExists() {
1831 1831
     foreach($this->attachment as $attachment) {
1832
-      if ($attachment[6] == 'inline') {
1832
+        if ($attachment[6] == 'inline') {
1833 1833
         return true;
1834
-      }
1834
+        }
1835 1835
     }
1836 1836
     return false;
1837
-  }
1837
+    }
1838 1838
 
1839
-  /////////////////////////////////////////////////
1840
-  // CLASS METHODS, MESSAGE RESET
1841
-  /////////////////////////////////////////////////
1839
+    /////////////////////////////////////////////////
1840
+    // CLASS METHODS, MESSAGE RESET
1841
+    /////////////////////////////////////////////////
1842 1842
 
1843
-  /**
1844
-   * Clears all recipients assigned in the TO array.  Returns void.
1845
-   * @return void
1846
-   */
1847
-  public function ClearAddresses() {
1843
+    /**
1844
+     * Clears all recipients assigned in the TO array.  Returns void.
1845
+     * @return void
1846
+     */
1847
+    public function ClearAddresses() {
1848 1848
     foreach($this->to as $to) {
1849
-      unset($this->all_recipients[strtolower($to[0])]);
1849
+        unset($this->all_recipients[strtolower($to[0])]);
1850 1850
     }
1851 1851
     $this->to = array();
1852
-  }
1852
+    }
1853 1853
 
1854
-  /**
1855
-   * Clears all recipients assigned in the CC array.  Returns void.
1856
-   * @return void
1857
-   */
1858
-  public function ClearCCs() {
1854
+    /**
1855
+     * Clears all recipients assigned in the CC array.  Returns void.
1856
+     * @return void
1857
+     */
1858
+    public function ClearCCs() {
1859 1859
     foreach($this->cc as $cc) {
1860
-      unset($this->all_recipients[strtolower($cc[0])]);
1860
+        unset($this->all_recipients[strtolower($cc[0])]);
1861 1861
     }
1862 1862
     $this->cc = array();
1863
-  }
1863
+    }
1864 1864
 
1865
-  /**
1866
-   * Clears all recipients assigned in the BCC array.  Returns void.
1867
-   * @return void
1868
-   */
1869
-  public function ClearBCCs() {
1865
+    /**
1866
+     * Clears all recipients assigned in the BCC array.  Returns void.
1867
+     * @return void
1868
+     */
1869
+    public function ClearBCCs() {
1870 1870
     foreach($this->bcc as $bcc) {
1871
-      unset($this->all_recipients[strtolower($bcc[0])]);
1871
+        unset($this->all_recipients[strtolower($bcc[0])]);
1872 1872
     }
1873 1873
     $this->bcc = array();
1874
-  }
1874
+    }
1875 1875
 
1876
-  /**
1877
-   * Clears all recipients assigned in the ReplyTo array.  Returns void.
1878
-   * @return void
1879
-   */
1880
-  public function ClearReplyTos() {
1876
+    /**
1877
+     * Clears all recipients assigned in the ReplyTo array.  Returns void.
1878
+     * @return void
1879
+     */
1880
+    public function ClearReplyTos() {
1881 1881
     $this->ReplyTo = array();
1882
-  }
1883
-
1884
-  /**
1885
-   * Clears all recipients assigned in the TO, CC and BCC
1886
-   * array.  Returns void.
1887
-   * @return void
1888
-   */
1889
-  public function ClearAllRecipients() {
1882
+    }
1883
+
1884
+    /**
1885
+     * Clears all recipients assigned in the TO, CC and BCC
1886
+     * array.  Returns void.
1887
+     * @return void
1888
+     */
1889
+    public function ClearAllRecipients() {
1890 1890
     $this->to = array();
1891 1891
     $this->cc = array();
1892 1892
     $this->bcc = array();
1893 1893
     $this->all_recipients = array();
1894
-  }
1895
-
1896
-  /**
1897
-   * Clears all previously set filesystem, string, and binary
1898
-   * attachments.  Returns void.
1899
-   * @return void
1900
-   */
1901
-  public function ClearAttachments() {
1894
+    }
1895
+
1896
+    /**
1897
+     * Clears all previously set filesystem, string, and binary
1898
+     * attachments.  Returns void.
1899
+     * @return void
1900
+     */
1901
+    public function ClearAttachments() {
1902 1902
     $this->attachment = array();
1903
-  }
1903
+    }
1904 1904
 
1905
-  /**
1906
-   * Clears all custom headers.  Returns void.
1907
-   * @return void
1908
-   */
1909
-  public function ClearCustomHeaders() {
1905
+    /**
1906
+     * Clears all custom headers.  Returns void.
1907
+     * @return void
1908
+     */
1909
+    public function ClearCustomHeaders() {
1910 1910
     $this->CustomHeader = array();
1911
-  }
1912
-
1913
-  /////////////////////////////////////////////////
1914
-  // CLASS METHODS, MISCELLANEOUS
1915
-  /////////////////////////////////////////////////
1916
-
1917
-  /**
1918
-   * Adds the error message to the error container.
1919
-   * @access protected
1920
-   * @return void
1921
-   */
1922
-  protected function SetError($msg) {
1911
+    }
1912
+
1913
+    /////////////////////////////////////////////////
1914
+    // CLASS METHODS, MISCELLANEOUS
1915
+    /////////////////////////////////////////////////
1916
+
1917
+    /**
1918
+     * Adds the error message to the error container.
1919
+     * @access protected
1920
+     * @return void
1921
+     */
1922
+    protected function SetError($msg) {
1923 1923
     $this->error_count++;
1924 1924
     if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
1925
-      $lasterror = $this->smtp->getError();
1926
-      if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
1925
+        $lasterror = $this->smtp->getError();
1926
+        if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
1927 1927
         $msg .= '<p>' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
1928
-      }
1928
+        }
1929 1929
     }
1930 1930
     $this->ErrorInfo = $msg;
1931
-  }
1932
-
1933
-  /**
1934
-   * Returns the proper RFC 822 formatted date.
1935
-   * @access public
1936
-   * @return string
1937
-   * @static
1938
-   */
1939
-  public static function RFCDate() {
1931
+    }
1932
+
1933
+    /**
1934
+     * Returns the proper RFC 822 formatted date.
1935
+     * @access public
1936
+     * @return string
1937
+     * @static
1938
+     */
1939
+    public static function RFCDate() {
1940 1940
     $tz = date('Z');
1941 1941
     $tzs = ($tz < 0) ? '-' : '+';
1942 1942
     $tz = abs($tz);
@@ -1944,346 +1944,346 @@  discard block
 block discarded – undo
1944 1944
     $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
1945 1945
 
1946 1946
     return $result;
1947
-  }
1948
-
1949
-  /**
1950
-   * Returns the server hostname or 'localhost.localdomain' if unknown.
1951
-   * @access private
1952
-   * @return string
1953
-   */
1954
-  private function ServerHostname() {
1947
+    }
1948
+
1949
+    /**
1950
+     * Returns the server hostname or 'localhost.localdomain' if unknown.
1951
+     * @access private
1952
+     * @return string
1953
+     */
1954
+    private function ServerHostname() {
1955 1955
     if (!empty($this->Hostname)) {
1956
-      $result = $this->Hostname;
1956
+        $result = $this->Hostname;
1957 1957
     } elseif (isset($_SERVER['SERVER_NAME'])) {
1958
-      $result = $_SERVER['SERVER_NAME'];
1958
+        $result = $_SERVER['SERVER_NAME'];
1959 1959
     } else {
1960
-      $result = 'localhost.localdomain';
1960
+        $result = 'localhost.localdomain';
1961 1961
     }
1962 1962
 
1963 1963
     return $result;
1964
-  }
1965
-
1966
-  /**
1967
-   * Returns a message in the appropriate language.
1968
-   * @access private
1969
-   * @return string
1970
-   */
1971
-  private function Lang($key) {
1964
+    }
1965
+
1966
+    /**
1967
+     * Returns a message in the appropriate language.
1968
+     * @access private
1969
+     * @return string
1970
+     */
1971
+    private function Lang($key) {
1972 1972
     if(count($this->language) < 1) {
1973
-      $this->SetLanguage('en'); // set the default language
1973
+        $this->SetLanguage('en'); // set the default language
1974 1974
     }
1975 1975
 
1976 1976
     if(isset($this->language[$key])) {
1977
-      return $this->language[$key];
1977
+        return $this->language[$key];
1978 1978
     } else {
1979
-      return 'Language string failed to load: ' . $key;
1979
+        return 'Language string failed to load: ' . $key;
1980
+    }
1980 1981
     }
1981
-  }
1982 1982
 
1983
-  /**
1984
-   * Returns true if an error occurred.
1985
-   * @access public
1986
-   * @return bool
1987
-   */
1988
-  public function IsError() {
1983
+    /**
1984
+     * Returns true if an error occurred.
1985
+     * @access public
1986
+     * @return bool
1987
+     */
1988
+    public function IsError() {
1989 1989
     return ($this->error_count > 0);
1990
-  }
1991
-
1992
-  /**
1993
-   * Changes every end of line from CR or LF to CRLF.
1994
-   * @access private
1995
-   * @return string
1996
-   */
1997
-  private function FixEOL($str) {
1990
+    }
1991
+
1992
+    /**
1993
+     * Changes every end of line from CR or LF to CRLF.
1994
+     * @access private
1995
+     * @return string
1996
+     */
1997
+    private function FixEOL($str) {
1998 1998
     $str = str_replace("\r\n", "\n", $str);
1999 1999
     $str = str_replace("\r", "\n", $str);
2000 2000
     $str = str_replace("\n", $this->LE, $str);
2001 2001
     return $str;
2002
-  }
2003
-
2004
-  /**
2005
-   * Adds a custom header.
2006
-   * @access public
2007
-   * @return void
2008
-   */
2009
-  public function AddCustomHeader($custom_header) {
2002
+    }
2003
+
2004
+    /**
2005
+     * Adds a custom header.
2006
+     * @access public
2007
+     * @return void
2008
+     */
2009
+    public function AddCustomHeader($custom_header) {
2010 2010
     $this->CustomHeader[] = explode(':', $custom_header, 2);
2011
-  }
2012
-
2013
-  /**
2014
-   * Evaluates the message and returns modifications for inline images and backgrounds
2015
-   * @access public
2016
-   * @return $message
2017
-   */
2018
-  public function MsgHTML($message, $basedir = '') {
2011
+    }
2012
+
2013
+    /**
2014
+     * Evaluates the message and returns modifications for inline images and backgrounds
2015
+     * @access public
2016
+     * @return $message
2017
+     */
2018
+    public function MsgHTML($message, $basedir = '') {
2019 2019
     preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
2020 2020
     if(isset($images[2])) {
2021
-      foreach($images[2] as $i => $url) {
2021
+        foreach($images[2] as $i => $url) {
2022 2022
         // do not change urls for absolute images (thanks to corvuscorax)
2023 2023
         if (!preg_match('#^[A-z]+://#',$url)) {
2024
-          $filename = basename($url);
2025
-          $directory = dirname($url);
2026
-          ($directory == '.')?$directory='':'';
2027
-          $cid = 'cid:' . md5($filename);
2028
-          $ext = pathinfo($filename, PATHINFO_EXTENSION);
2029
-          $mimeType  = self::_mime_types($ext);
2030
-          if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
2031
-          if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
2032
-          if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
2024
+            $filename = basename($url);
2025
+            $directory = dirname($url);
2026
+            ($directory == '.')?$directory='':'';
2027
+            $cid = 'cid:' . md5($filename);
2028
+            $ext = pathinfo($filename, PATHINFO_EXTENSION);
2029
+            $mimeType  = self::_mime_types($ext);
2030
+            if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
2031
+            if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
2032
+            if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
2033 2033
             $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
2034
-          }
2034
+            }
2035
+        }
2035 2036
         }
2036
-      }
2037 2037
     }
2038 2038
     $this->IsHTML(true);
2039 2039
     $this->Body = $message;
2040 2040
     $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
2041 2041
     if (!empty($textMsg) && empty($this->AltBody)) {
2042
-      $this->AltBody = html_entity_decode($textMsg);
2042
+        $this->AltBody = html_entity_decode($textMsg);
2043 2043
     }
2044 2044
     if (empty($this->AltBody)) {
2045
-      $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
2046
-    }
2047
-  }
2048
-
2049
-  /**
2050
-   * Gets the MIME type of the embedded or inline image
2051
-   * @param string File extension
2052
-   * @access public
2053
-   * @return string MIME type of ext
2054
-   * @static
2055
-   */
2056
-  public static function _mime_types($ext = '') {
2045
+        $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
2046
+    }
2047
+    }
2048
+
2049
+    /**
2050
+     * Gets the MIME type of the embedded or inline image
2051
+     * @param string File extension
2052
+     * @access public
2053
+     * @return string MIME type of ext
2054
+     * @static
2055
+     */
2056
+    public static function _mime_types($ext = '') {
2057 2057
     $mimes = array(
2058
-      'hqx'   =>  'application/mac-binhex40',
2059
-      'cpt'   =>  'application/mac-compactpro',
2060
-      'doc'   =>  'application/msword',
2061
-      'bin'   =>  'application/macbinary',
2062
-      'dms'   =>  'application/octet-stream',
2063
-      'lha'   =>  'application/octet-stream',
2064
-      'lzh'   =>  'application/octet-stream',
2065
-      'exe'   =>  'application/octet-stream',
2066
-      'class' =>  'application/octet-stream',
2067
-      'psd'   =>  'application/octet-stream',
2068
-      'so'    =>  'application/octet-stream',
2069
-      'sea'   =>  'application/octet-stream',
2070
-      'dll'   =>  'application/octet-stream',
2071
-      'oda'   =>  'application/oda',
2072
-      'pdf'   =>  'application/pdf',
2073
-      'ai'    =>  'application/postscript',
2074
-      'eps'   =>  'application/postscript',
2075
-      'ps'    =>  'application/postscript',
2076
-      'smi'   =>  'application/smil',
2077
-      'smil'  =>  'application/smil',
2078
-      'mif'   =>  'application/vnd.mif',
2079
-      'xls'   =>  'application/vnd.ms-excel',
2080
-      'ppt'   =>  'application/vnd.ms-powerpoint',
2081
-      'wbxml' =>  'application/vnd.wap.wbxml',
2082
-      'wmlc'  =>  'application/vnd.wap.wmlc',
2083
-      'dcr'   =>  'application/x-director',
2084
-      'dir'   =>  'application/x-director',
2085
-      'dxr'   =>  'application/x-director',
2086
-      'dvi'   =>  'application/x-dvi',
2087
-      'gtar'  =>  'application/x-gtar',
2088
-      'php'   =>  'application/x-httpd-php',
2089
-      'php4'  =>  'application/x-httpd-php',
2090
-      'php3'  =>  'application/x-httpd-php',
2091
-      'phtml' =>  'application/x-httpd-php',
2092
-      'phps'  =>  'application/x-httpd-php-source',
2093
-      'js'    =>  'application/x-javascript',
2094
-      'swf'   =>  'application/x-shockwave-flash',
2095
-      'sit'   =>  'application/x-stuffit',
2096
-      'tar'   =>  'application/x-tar',
2097
-      'tgz'   =>  'application/x-tar',
2098
-      'xhtml' =>  'application/xhtml+xml',
2099
-      'xht'   =>  'application/xhtml+xml',
2100
-      'zip'   =>  'application/zip',
2101
-      'mid'   =>  'audio/midi',
2102
-      'midi'  =>  'audio/midi',
2103
-      'mpga'  =>  'audio/mpeg',
2104
-      'mp2'   =>  'audio/mpeg',
2105
-      'mp3'   =>  'audio/mpeg',
2106
-      'aif'   =>  'audio/x-aiff',
2107
-      'aiff'  =>  'audio/x-aiff',
2108
-      'aifc'  =>  'audio/x-aiff',
2109
-      'ram'   =>  'audio/x-pn-realaudio',
2110
-      'rm'    =>  'audio/x-pn-realaudio',
2111
-      'rpm'   =>  'audio/x-pn-realaudio-plugin',
2112
-      'ra'    =>  'audio/x-realaudio',
2113
-      'rv'    =>  'video/vnd.rn-realvideo',
2114
-      'wav'   =>  'audio/x-wav',
2115
-      'bmp'   =>  'image/bmp',
2116
-      'gif'   =>  'image/gif',
2117
-      'jpeg'  =>  'image/jpeg',
2118
-      'jpg'   =>  'image/jpeg',
2119
-      'jpe'   =>  'image/jpeg',
2120
-      'png'   =>  'image/png',
2121
-      'tiff'  =>  'image/tiff',
2122
-      'tif'   =>  'image/tiff',
2123
-      'css'   =>  'text/css',
2124
-      'html'  =>  'text/html',
2125
-      'htm'   =>  'text/html',
2126
-      'shtml' =>  'text/html',
2127
-      'txt'   =>  'text/plain',
2128
-      'text'  =>  'text/plain',
2129
-      'log'   =>  'text/plain',
2130
-      'rtx'   =>  'text/richtext',
2131
-      'rtf'   =>  'text/rtf',
2132
-      'xml'   =>  'text/xml',
2133
-      'xsl'   =>  'text/xml',
2134
-      'mpeg'  =>  'video/mpeg',
2135
-      'mpg'   =>  'video/mpeg',
2136
-      'mpe'   =>  'video/mpeg',
2137
-      'qt'    =>  'video/quicktime',
2138
-      'mov'   =>  'video/quicktime',
2139
-      'avi'   =>  'video/x-msvideo',
2140
-      'movie' =>  'video/x-sgi-movie',
2141
-      'doc'   =>  'application/msword',
2142
-      'word'  =>  'application/msword',
2143
-      'xl'    =>  'application/excel',
2144
-      'eml'   =>  'message/rfc822'
2058
+        'hqx'   =>  'application/mac-binhex40',
2059
+        'cpt'   =>  'application/mac-compactpro',
2060
+        'doc'   =>  'application/msword',
2061
+        'bin'   =>  'application/macbinary',
2062
+        'dms'   =>  'application/octet-stream',
2063
+        'lha'   =>  'application/octet-stream',
2064
+        'lzh'   =>  'application/octet-stream',
2065
+        'exe'   =>  'application/octet-stream',
2066
+        'class' =>  'application/octet-stream',
2067
+        'psd'   =>  'application/octet-stream',
2068
+        'so'    =>  'application/octet-stream',
2069
+        'sea'   =>  'application/octet-stream',
2070
+        'dll'   =>  'application/octet-stream',
2071
+        'oda'   =>  'application/oda',
2072
+        'pdf'   =>  'application/pdf',
2073
+        'ai'    =>  'application/postscript',
2074
+        'eps'   =>  'application/postscript',
2075
+        'ps'    =>  'application/postscript',
2076
+        'smi'   =>  'application/smil',
2077
+        'smil'  =>  'application/smil',
2078
+        'mif'   =>  'application/vnd.mif',
2079
+        'xls'   =>  'application/vnd.ms-excel',
2080
+        'ppt'   =>  'application/vnd.ms-powerpoint',
2081
+        'wbxml' =>  'application/vnd.wap.wbxml',
2082
+        'wmlc'  =>  'application/vnd.wap.wmlc',
2083
+        'dcr'   =>  'application/x-director',
2084
+        'dir'   =>  'application/x-director',
2085
+        'dxr'   =>  'application/x-director',
2086
+        'dvi'   =>  'application/x-dvi',
2087
+        'gtar'  =>  'application/x-gtar',
2088
+        'php'   =>  'application/x-httpd-php',
2089
+        'php4'  =>  'application/x-httpd-php',
2090
+        'php3'  =>  'application/x-httpd-php',
2091
+        'phtml' =>  'application/x-httpd-php',
2092
+        'phps'  =>  'application/x-httpd-php-source',
2093
+        'js'    =>  'application/x-javascript',
2094
+        'swf'   =>  'application/x-shockwave-flash',
2095
+        'sit'   =>  'application/x-stuffit',
2096
+        'tar'   =>  'application/x-tar',
2097
+        'tgz'   =>  'application/x-tar',
2098
+        'xhtml' =>  'application/xhtml+xml',
2099
+        'xht'   =>  'application/xhtml+xml',
2100
+        'zip'   =>  'application/zip',
2101
+        'mid'   =>  'audio/midi',
2102
+        'midi'  =>  'audio/midi',
2103
+        'mpga'  =>  'audio/mpeg',
2104
+        'mp2'   =>  'audio/mpeg',
2105
+        'mp3'   =>  'audio/mpeg',
2106
+        'aif'   =>  'audio/x-aiff',
2107
+        'aiff'  =>  'audio/x-aiff',
2108
+        'aifc'  =>  'audio/x-aiff',
2109
+        'ram'   =>  'audio/x-pn-realaudio',
2110
+        'rm'    =>  'audio/x-pn-realaudio',
2111
+        'rpm'   =>  'audio/x-pn-realaudio-plugin',
2112
+        'ra'    =>  'audio/x-realaudio',
2113
+        'rv'    =>  'video/vnd.rn-realvideo',
2114
+        'wav'   =>  'audio/x-wav',
2115
+        'bmp'   =>  'image/bmp',
2116
+        'gif'   =>  'image/gif',
2117
+        'jpeg'  =>  'image/jpeg',
2118
+        'jpg'   =>  'image/jpeg',
2119
+        'jpe'   =>  'image/jpeg',
2120
+        'png'   =>  'image/png',
2121
+        'tiff'  =>  'image/tiff',
2122
+        'tif'   =>  'image/tiff',
2123
+        'css'   =>  'text/css',
2124
+        'html'  =>  'text/html',
2125
+        'htm'   =>  'text/html',
2126
+        'shtml' =>  'text/html',
2127
+        'txt'   =>  'text/plain',
2128
+        'text'  =>  'text/plain',
2129
+        'log'   =>  'text/plain',
2130
+        'rtx'   =>  'text/richtext',
2131
+        'rtf'   =>  'text/rtf',
2132
+        'xml'   =>  'text/xml',
2133
+        'xsl'   =>  'text/xml',
2134
+        'mpeg'  =>  'video/mpeg',
2135
+        'mpg'   =>  'video/mpeg',
2136
+        'mpe'   =>  'video/mpeg',
2137
+        'qt'    =>  'video/quicktime',
2138
+        'mov'   =>  'video/quicktime',
2139
+        'avi'   =>  'video/x-msvideo',
2140
+        'movie' =>  'video/x-sgi-movie',
2141
+        'doc'   =>  'application/msword',
2142
+        'word'  =>  'application/msword',
2143
+        'xl'    =>  'application/excel',
2144
+        'eml'   =>  'message/rfc822'
2145 2145
     );
2146 2146
     return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
2147
-  }
2148
-
2149
-  /**
2150
-  * Set (or reset) Class Objects (variables)
2151
-  *
2152
-  * Usage Example:
2153
-  * $page->set('X-Priority', '3');
2154
-  *
2155
-  * @access public
2156
-  * @param string $name Parameter Name
2157
-  * @param mixed $value Parameter Value
2158
-  * NOTE: will not work with arrays, there are no arrays to set/reset
2159
-  * @todo Should this not be using __set() magic function?
2160
-  */
2161
-  public function set($name, $value = '') {
2147
+    }
2148
+
2149
+    /**
2150
+     * Set (or reset) Class Objects (variables)
2151
+     *
2152
+     * Usage Example:
2153
+     * $page->set('X-Priority', '3');
2154
+     *
2155
+     * @access public
2156
+     * @param string $name Parameter Name
2157
+     * @param mixed $value Parameter Value
2158
+     * NOTE: will not work with arrays, there are no arrays to set/reset
2159
+     * @todo Should this not be using __set() magic function?
2160
+     */
2161
+    public function set($name, $value = '') {
2162 2162
     try {
2163
-      if (isset($this->$name) ) {
2163
+        if (isset($this->$name) ) {
2164 2164
         $this->$name = $value;
2165
-      } else {
2165
+        } else {
2166 2166
         throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL);
2167
-      }
2167
+        }
2168 2168
     } catch (Exception $e) {
2169
-      $this->SetError($e->getMessage());
2170
-      if ($e->getCode() == self::STOP_CRITICAL) {
2169
+        $this->SetError($e->getMessage());
2170
+        if ($e->getCode() == self::STOP_CRITICAL) {
2171 2171
         return false;
2172
-      }
2172
+        }
2173 2173
     }
2174 2174
     return true;
2175
-  }
2176
-
2177
-  /**
2178
-   * Strips newlines to prevent header injection.
2179
-   * @access public
2180
-   * @param string $str String
2181
-   * @return string
2182
-   */
2183
-  public function SecureHeader($str) {
2175
+    }
2176
+
2177
+    /**
2178
+     * Strips newlines to prevent header injection.
2179
+     * @access public
2180
+     * @param string $str String
2181
+     * @return string
2182
+     */
2183
+    public function SecureHeader($str) {
2184 2184
     $str = str_replace("\r", '', $str);
2185 2185
     $str = str_replace("\n", '', $str);
2186 2186
     return trim($str);
2187
-  }
2188
-
2189
-  /**
2190
-   * Set the private key file and password to sign the message.
2191
-   *
2192
-   * @access public
2193
-   * @param string $key_filename Parameter File Name
2194
-   * @param string $key_pass Password for private key
2195
-   */
2196
-  public function Sign($cert_filename, $key_filename, $key_pass) {
2187
+    }
2188
+
2189
+    /**
2190
+     * Set the private key file and password to sign the message.
2191
+     *
2192
+     * @access public
2193
+     * @param string $key_filename Parameter File Name
2194
+     * @param string $key_pass Password for private key
2195
+     */
2196
+    public function Sign($cert_filename, $key_filename, $key_pass) {
2197 2197
     $this->sign_cert_file = $cert_filename;
2198 2198
     $this->sign_key_file = $key_filename;
2199 2199
     $this->sign_key_pass = $key_pass;
2200
-  }
2201
-
2202
-  /**
2203
-   * Set the private key file and password to sign the message.
2204
-   *
2205
-   * @access public
2206
-   * @param string $key_filename Parameter File Name
2207
-   * @param string $key_pass Password for private key
2208
-   */
2209
-  public function DKIM_QP($txt) {
2200
+    }
2201
+
2202
+    /**
2203
+     * Set the private key file and password to sign the message.
2204
+     *
2205
+     * @access public
2206
+     * @param string $key_filename Parameter File Name
2207
+     * @param string $key_pass Password for private key
2208
+     */
2209
+    public function DKIM_QP($txt) {
2210 2210
     $tmp="";
2211 2211
     $line="";
2212 2212
     for ($i=0;$i<strlen($txt);$i++) {
2213
-      $ord=ord($txt[$i]);
2214
-      if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) {
2213
+        $ord=ord($txt[$i]);
2214
+        if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) {
2215 2215
         $line.=$txt[$i];
2216
-      } else {
2216
+        } else {
2217 2217
         $line.="=".sprintf("%02X",$ord);
2218
-      }
2218
+        }
2219 2219
     }
2220 2220
     return $line;
2221
-  }
2222
-
2223
-  /**
2224
-   * Generate DKIM signature
2225
-   *
2226
-   * @access public
2227
-   * @param string $s Header
2228
-   */
2229
-  public function DKIM_Sign($s) {
2221
+    }
2222
+
2223
+    /**
2224
+     * Generate DKIM signature
2225
+     *
2226
+     * @access public
2227
+     * @param string $s Header
2228
+     */
2229
+    public function DKIM_Sign($s) {
2230 2230
     $privKeyStr = file_get_contents($this->DKIM_private);
2231 2231
     if ($this->DKIM_passphrase!='') {
2232
-      $privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase);
2232
+        $privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase);
2233 2233
     } else {
2234
-      $privKey = $privKeyStr;
2234
+        $privKey = $privKeyStr;
2235 2235
     }
2236 2236
     if (openssl_sign($s, $signature, $privKey)) {
2237
-      return base64_encode($signature);
2237
+        return base64_encode($signature);
2238
+    }
2238 2239
     }
2239
-  }
2240 2240
 
2241
-  /**
2242
-   * Generate DKIM Canonicalization Header
2243
-   *
2244
-   * @access public
2245
-   * @param string $s Header
2246
-   */
2247
-  public function DKIM_HeaderC($s) {
2241
+    /**
2242
+     * Generate DKIM Canonicalization Header
2243
+     *
2244
+     * @access public
2245
+     * @param string $s Header
2246
+     */
2247
+    public function DKIM_HeaderC($s) {
2248 2248
     $s=preg_replace("/\r\n\s+/"," ",$s);
2249 2249
     $lines=explode("\r\n",$s);
2250 2250
     foreach ($lines as $key=>$line) {
2251
-      list($heading,$value)=explode(":",$line,2);
2252
-      $heading=strtolower($heading);
2253
-      $value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces
2254
-      $lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value
2251
+        list($heading,$value)=explode(":",$line,2);
2252
+        $heading=strtolower($heading);
2253
+        $value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces
2254
+        $lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value
2255 2255
     }
2256 2256
     $s=implode("\r\n",$lines);
2257 2257
     return $s;
2258
-  }
2259
-
2260
-  /**
2261
-   * Generate DKIM Canonicalization Body
2262
-   *
2263
-   * @access public
2264
-   * @param string $body Message Body
2265
-   */
2266
-  public function DKIM_BodyC($body) {
2258
+    }
2259
+
2260
+    /**
2261
+     * Generate DKIM Canonicalization Body
2262
+     *
2263
+     * @access public
2264
+     * @param string $body Message Body
2265
+     */
2266
+    public function DKIM_BodyC($body) {
2267 2267
     if ($body == '') return "\r\n";
2268 2268
     // stabilize line endings
2269 2269
     $body=str_replace("\r\n","\n",$body);
2270 2270
     $body=str_replace("\n","\r\n",$body);
2271 2271
     // END stabilize line endings
2272 2272
     while (substr($body,strlen($body)-4,4) == "\r\n\r\n") {
2273
-      $body=substr($body,0,strlen($body)-2);
2273
+        $body=substr($body,0,strlen($body)-2);
2274 2274
     }
2275 2275
     return $body;
2276
-  }
2277
-
2278
-  /**
2279
-   * Create the DKIM header, body, as new header
2280
-   *
2281
-   * @access public
2282
-   * @param string $headers_line Header lines
2283
-   * @param string $subject Subject
2284
-   * @param string $body Body
2285
-   */
2286
-  public function DKIM_Add($headers_line,$subject,$body) {
2276
+    }
2277
+
2278
+    /**
2279
+     * Create the DKIM header, body, as new header
2280
+     *
2281
+     * @access public
2282
+     * @param string $headers_line Header lines
2283
+     * @param string $subject Subject
2284
+     * @param string $body Body
2285
+     */
2286
+    public function DKIM_Add($headers_line,$subject,$body) {
2287 2287
     $DKIMsignatureType    = 'rsa-sha1'; // Signature & hash algorithms
2288 2288
     $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
2289 2289
     $DKIMquery            = 'dns/txt'; // Query method
@@ -2291,11 +2291,11 @@  discard block
 block discarded – undo
2291 2291
     $subject_header       = "Subject: $subject";
2292 2292
     $headers              = explode("\r\n",$headers_line);
2293 2293
     foreach($headers as $header) {
2294
-      if (strpos($header,'From:') === 0) {
2294
+        if (strpos($header,'From:') === 0) {
2295 2295
         $from_header=$header;
2296
-      } elseif (strpos($header,'To:') === 0) {
2296
+        } elseif (strpos($header,'To:') === 0) {
2297 2297
         $to_header=$header;
2298
-      }
2298
+        }
2299 2299
     }
2300 2300
     $from     = str_replace('|','=7C',$this->DKIM_QP($from_header));
2301 2301
     $to       = str_replace('|','=7C',$this->DKIM_QP($to_header));
@@ -2316,20 +2316,20 @@  discard block
 block discarded – undo
2316 2316
     $toSign   = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs);
2317 2317
     $signed   = $this->DKIM_Sign($toSign);
2318 2318
     return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n";
2319
-  }
2319
+    }
2320 2320
 
2321
-  protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body) {
2321
+    protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body) {
2322 2322
     if (!empty($this->action_function) && function_exists($this->action_function)) {
2323
-      $params = array($isSent,$to,$cc,$bcc,$subject,$body);
2324
-      call_user_func_array($this->action_function,$params);
2323
+        $params = array($isSent,$to,$cc,$bcc,$subject,$body);
2324
+        call_user_func_array($this->action_function,$params);
2325
+    }
2325 2326
     }
2326
-  }
2327 2327
 }
2328 2328
 
2329 2329
 class phpmailerException extends Exception {
2330
-  public function errorMessage() {
2330
+    public function errorMessage() {
2331 2331
     $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
2332 2332
     return $errorMsg;
2333
-  }
2333
+    }
2334 2334
 }
2335 2335
 ?>
Please login to merge, or discard this patch.
Spacing   +235 added lines, -236 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
39 39
  */
40 40
 
41
-if (version_compare(PHP_VERSION, '5.0.0', '<') ) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
41
+if (version_compare(PHP_VERSION, '5.0.0', '<')) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
42 42
 
43 43
 class PHPMailer {
44 44
 
@@ -50,64 +50,64 @@  discard block
 block discarded – undo
50 50
    * Email priority (1 = High, 3 = Normal, 5 = low).
51 51
    * @var int
52 52
    */
53
-  public $Priority          = 3;
53
+  public $Priority = 3;
54 54
 
55 55
   /**
56 56
    * Sets the CharSet of the message.
57 57
    * @var string
58 58
    */
59
-  public $CharSet           = 'iso-8859-1';
59
+  public $CharSet = 'iso-8859-1';
60 60
 
61 61
   /**
62 62
    * Sets the Content-type of the message.
63 63
    * @var string
64 64
    */
65
-  public $ContentType       = 'text/plain';
65
+  public $ContentType = 'text/plain';
66 66
 
67 67
   /**
68 68
    * Sets the Encoding of the message. Options for this are
69 69
    *  "8bit", "7bit", "binary", "base64", and "quoted-printable".
70 70
    * @var string
71 71
    */
72
-  public $Encoding          = '8bit';
72
+  public $Encoding = '8bit';
73 73
 
74 74
   /**
75 75
    * Holds the most recent mailer error message.
76 76
    * @var string
77 77
    */
78
-  public $ErrorInfo         = '';
78
+  public $ErrorInfo = '';
79 79
 
80 80
   /**
81 81
    * Sets the From email address for the message.
82 82
    * @var string
83 83
    */
84
-  public $From              = 'root@localhost';
84
+  public $From = 'root@localhost';
85 85
 
86 86
   /**
87 87
    * Sets the From name of the message.
88 88
    * @var string
89 89
    */
90
-  public $FromName          = 'Root User';
90
+  public $FromName = 'Root User';
91 91
 
92 92
   /**
93 93
    * Sets the Sender email (Return-Path) of the message.  If not empty,
94 94
    * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
95 95
    * @var string
96 96
    */
97
-  public $Sender            = '';
97
+  public $Sender = '';
98 98
 
99 99
   /**
100 100
    * Sets the Subject of the message.
101 101
    * @var string
102 102
    */
103
-  public $Subject           = '';
103
+  public $Subject = '';
104 104
 
105 105
   /**
106 106
    * Sets the Body of the message.  This can be either an HTML or text body.
107 107
    * If HTML then run IsHTML(true).
108 108
    * @var string
109 109
    */
110
-  public $Body              = '';
110
+  public $Body = '';
111 111
 
112 112
   /**
113 113
    * Sets the text-only body of the message.  This automatically sets the
@@ -116,39 +116,39 @@  discard block
 block discarded – undo
116 116
    * that can read HTML will view the normal Body.
117 117
    * @var string
118 118
    */
119
-  public $AltBody           = '';
119
+  public $AltBody = '';
120 120
 
121 121
   /**
122 122
    * Sets word wrapping on the body of the message to a given number of
123 123
    * characters.
124 124
    * @var int
125 125
    */
126
-  public $WordWrap          = 0;
126
+  public $WordWrap = 0;
127 127
 
128 128
   /**
129 129
    * Method to send mail: ("mail", "sendmail", or "smtp").
130 130
    * @var string
131 131
    */
132
-  public $Mailer            = 'mail';
132
+  public $Mailer = 'mail';
133 133
 
134 134
   /**
135 135
    * Sets the path of the sendmail program.
136 136
    * @var string
137 137
    */
138
-  public $Sendmail          = '/usr/sbin/sendmail';
138
+  public $Sendmail = '/usr/sbin/sendmail';
139 139
 
140 140
   /**
141 141
    * Path to PHPMailer plugins.  Useful if the SMTP class
142 142
    * is in a different directory than the PHP include path.
143 143
    * @var string
144 144
    */
145
-  public $PluginDir         = '';
145
+  public $PluginDir = '';
146 146
 
147 147
   /**
148 148
    * Sets the email address that a reading confirmation will be sent.
149 149
    * @var string
150 150
    */
151
-  public $ConfirmReadingTo  = '';
151
+  public $ConfirmReadingTo = '';
152 152
 
153 153
   /**
154 154
    * Sets the hostname to use in Message-Id and Received headers
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
    * by SERVER_NAME is used or 'localhost.localdomain'.
157 157
    * @var string
158 158
    */
159
-  public $Hostname          = '';
159
+  public $Hostname = '';
160 160
 
161 161
   /**
162 162
    * Sets the message ID to be used in the Message-Id header.
163 163
    * If empty, a unique id will be generated.
164 164
    * @var string
165 165
    */
166
-  public $MessageID         = '';
166
+  public $MessageID = '';
167 167
 
168 168
   /////////////////////////////////////////////////
169 169
   // PROPERTIES FOR SMTP
@@ -177,57 +177,57 @@  discard block
 block discarded – undo
177 177
    * Hosts will be tried in order.
178 178
    * @var string
179 179
    */
180
-  public $Host          = 'localhost';
180
+  public $Host = 'localhost';
181 181
 
182 182
   /**
183 183
    * Sets the default SMTP server port.
184 184
    * @var int
185 185
    */
186
-  public $Port          = 25;
186
+  public $Port = 25;
187 187
 
188 188
   /**
189 189
    * Sets the SMTP HELO of the message (Default is $Hostname).
190 190
    * @var string
191 191
    */
192
-  public $Helo          = '';
192
+  public $Helo = '';
193 193
 
194 194
   /**
195 195
    * Sets connection prefix.
196 196
    * Options are "", "ssl" or "tls"
197 197
    * @var string
198 198
    */
199
-  public $SMTPSecure    = '';
199
+  public $SMTPSecure = '';
200 200
 
201 201
   /**
202 202
    * Sets SMTP authentication. Utilizes the Username and Password variables.
203 203
    * @var bool
204 204
    */
205
-  public $SMTPAuth      = false;
205
+  public $SMTPAuth = false;
206 206
 
207 207
   /**
208 208
    * Sets SMTP username.
209 209
    * @var string
210 210
    */
211
-  public $Username      = '';
211
+  public $Username = '';
212 212
 
213 213
   /**
214 214
    * Sets SMTP password.
215 215
    * @var string
216 216
    */
217
-  public $Password      = '';
217
+  public $Password = '';
218 218
 
219 219
   /**
220 220
    * Sets the SMTP server timeout in seconds.
221 221
    * This function will not work with the win32 version.
222 222
    * @var int
223 223
    */
224
-  public $Timeout       = 10;
224
+  public $Timeout = 10;
225 225
 
226 226
   /**
227 227
    * Sets SMTP class debugging on or off.
228 228
    * @var bool
229 229
    */
230
-  public $SMTPDebug     = false;
230
+  public $SMTPDebug = false;
231 231
 
232 232
   /**
233 233
    * Prevents the SMTP connection from being closed after each mail
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
    * emails, instead of sending to entire TO addresses
243 243
    * @var bool
244 244
    */
245
-  public $SingleTo      = false;
245
+  public $SingleTo = false;
246 246
 
247 247
    /**
248 248
    * If SingleTo is true, this provides the array to hold the email addresses
@@ -254,34 +254,34 @@  discard block
 block discarded – undo
254 254
    * Provides the ability to change the line ending
255 255
    * @var string
256 256
    */
257
-  public $LE              = "\n";
257
+  public $LE = "\n";
258 258
 
259 259
   /**
260 260
    * Used with DKIM DNS Resource Record
261 261
    * @var string
262 262
    */
263
-  public $DKIM_selector   = 'phpmailer';
263
+  public $DKIM_selector = 'phpmailer';
264 264
 
265 265
   /**
266 266
    * Used with DKIM DNS Resource Record
267 267
    * optional, in format of email address '[email protected]'
268 268
    * @var string
269 269
    */
270
-  public $DKIM_identity   = '';
270
+  public $DKIM_identity = '';
271 271
 
272 272
   /**
273 273
    * Used with DKIM DNS Resource Record
274 274
    * optional, in format of email address '[email protected]'
275 275
    * @var string
276 276
    */
277
-  public $DKIM_domain     = '';
277
+  public $DKIM_domain = '';
278 278
 
279 279
   /**
280 280
    * Used with DKIM DNS Resource Record
281 281
    * optional, in format of email address '[email protected]'
282 282
    * @var string
283 283
    */
284
-  public $DKIM_private    = '';
284
+  public $DKIM_private = '';
285 285
 
286 286
   /**
287 287
    * Callback Action function name
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
    * Sets the PHPMailer Version number
301 301
    * @var string
302 302
    */
303
-  public $Version         = '5.1';
303
+  public $Version = '5.1';
304 304
 
305 305
   /////////////////////////////////////////////////
306 306
   // PROPERTIES, PRIVATE AND PROTECTED
@@ -451,13 +451,13 @@  discard block
 block discarded – undo
451 451
    */
452 452
   private function AddAnAddress($kind, $address, $name = '') {
453 453
     if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) {
454
-      error_log('Invalid recipient array: ' . $kind);
454
+      error_log('Invalid recipient array: '.$kind);
455 455
       return false;
456 456
     }
457 457
     $address = trim($address);
458 458
     $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
459 459
     if (!self::ValidateAddress($address)) {
460
-      $this->SetError($this->Lang('invalid_address').': '. $address);
460
+      $this->SetError($this->Lang('invalid_address').': '.$address);
461 461
       if ($this->exceptions) {
462 462
         throw new phpmailerException($this->Lang('invalid_address').': '.$address);
463 463
       }
@@ -485,11 +485,11 @@  discard block
 block discarded – undo
485 485
  * @param string $name
486 486
  * @return boolean
487 487
  */
488
-  public function SetFrom($address, $name = '',$auto=1) {
488
+  public function SetFrom($address, $name = '', $auto = 1) {
489 489
     $address = trim($address);
490 490
     $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
491 491
     if (!self::ValidateAddress($address)) {
492
-      $this->SetError($this->Lang('invalid_address').': '. $address);
492
+      $this->SetError($this->Lang('invalid_address').': '.$address);
493 493
       if ($this->exceptions) {
494 494
         throw new phpmailerException($this->Lang('invalid_address').': '.$address);
495 495
       }
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
    */
523 523
   public static function ValidateAddress($address) {
524 524
     if (function_exists('filter_var')) { //Introduced in PHP 5.2
525
-      if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
525
+      if (filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
526 526
         return false;
527 527
       } else {
528 528
         return true;
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
       }
550 550
 
551 551
       // Set whether the message is multipart/alternative
552
-      if(!empty($this->AltBody)) {
552
+      if (!empty($this->AltBody)) {
553 553
         $this->ContentType = 'multipart/alternative';
554 554
       }
555 555
 
@@ -564,12 +564,12 @@  discard block
 block discarded – undo
564 564
 
565 565
       // digitally sign with DKIM if enabled
566 566
       if ($this->DKIM_domain && $this->DKIM_private) {
567
-        $header_dkim = $this->DKIM_Add($header,$this->Subject,$body);
568
-        $header = str_replace("\r\n","\n",$header_dkim) . $header;
567
+        $header_dkim = $this->DKIM_Add($header, $this->Subject, $body);
568
+        $header = str_replace("\r\n", "\n", $header_dkim).$header;
569 569
       }
570 570
 
571 571
       // Choose the mailer and send through it
572
-      switch($this->Mailer) {
572
+      switch ($this->Mailer) {
573 573
         case 'sendmail':
574 574
           return $this->SendmailSend($header, $body);
575 575
         case 'smtp':
@@ -602,32 +602,32 @@  discard block
 block discarded – undo
602 602
     }
603 603
     if ($this->SingleTo === true) {
604 604
       foreach ($this->SingleToArray as $key => $val) {
605
-        if(!@$mail = popen($sendmail, 'w')) {
606
-          throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
605
+        if (!@$mail = popen($sendmail, 'w')) {
606
+          throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL);
607 607
         }
608
-        fputs($mail, "To: " . $val . "\n");
608
+        fputs($mail, "To: ".$val."\n");
609 609
         fputs($mail, $header);
610 610
         fputs($mail, $body);
611 611
         $result = pclose($mail);
612 612
         // implement call back function if it exists
613 613
         $isSent = ($result == 0) ? 1 : 0;
614
-        $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
615
-        if($result != 0) {
616
-          throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
614
+        $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
615
+        if ($result != 0) {
616
+          throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL);
617 617
         }
618 618
       }
619 619
     } else {
620
-      if(!@$mail = popen($sendmail, 'w')) {
621
-        throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
620
+      if (!@$mail = popen($sendmail, 'w')) {
621
+        throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL);
622 622
       }
623 623
       fputs($mail, $header);
624 624
       fputs($mail, $body);
625 625
       $result = pclose($mail);
626 626
       // implement call back function if it exists
627 627
       $isSent = ($result == 0) ? 1 : 0;
628
-      $this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body);
629
-      if($result != 0) {
630
-        throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
628
+      $this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body);
629
+      if ($result != 0) {
630
+        throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL);
631 631
       }
632 632
     }
633 633
     return true;
@@ -642,13 +642,13 @@  discard block
 block discarded – undo
642 642
    */
643 643
   protected function MailSend($header, $body) {
644 644
     $toArr = array();
645
-    foreach($this->to as $t) {
645
+    foreach ($this->to as $t) {
646 646
       $toArr[] = $this->AddrFormat($t);
647 647
     }
648 648
     $to = implode(', ', $toArr);
649 649
 
650 650
     $params = sprintf("-oi -f %s", $this->Sender);
651
-    if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) {
651
+    if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) {
652 652
       $old_from = ini_get('sendmail_from');
653 653
       ini_set('sendmail_from', $this->Sender);
654 654
       if ($this->SingleTo === true && count($toArr) > 1) {
@@ -656,13 +656,13 @@  discard block
 block discarded – undo
656 656
           $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
657 657
           // implement call back function if it exists
658 658
           $isSent = ($rt == 1) ? 1 : 0;
659
-          $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
659
+          $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
660 660
         }
661 661
       } else {
662 662
         $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
663 663
         // implement call back function if it exists
664 664
         $isSent = ($rt == 1) ? 1 : 0;
665
-        $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
665
+        $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
666 666
       }
667 667
     } else {
668 668
       if ($this->SingleTo === true && count($toArr) > 1) {
@@ -670,19 +670,19 @@  discard block
 block discarded – undo
670 670
           $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
671 671
           // implement call back function if it exists
672 672
           $isSent = ($rt == 1) ? 1 : 0;
673
-          $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
673
+          $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
674 674
         }
675 675
       } else {
676 676
         $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
677 677
         // implement call back function if it exists
678 678
         $isSent = ($rt == 1) ? 1 : 0;
679
-        $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
679
+        $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
680 680
       }
681 681
     }
682 682
     if (isset($old_from)) {
683 683
       ini_set('sendmail_from', $old_from);
684 684
     }
685
-    if(!$rt) {
685
+    if (!$rt) {
686 686
       throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL);
687 687
     }
688 688
     return true;
@@ -698,64 +698,64 @@  discard block
 block discarded – undo
698 698
    * @return bool
699 699
    */
700 700
   protected function SmtpSend($header, $body) {
701
-    require_once $this->PluginDir . 'class.smtp.php';
701
+    require_once $this->PluginDir.'class.smtp.php';
702 702
     $bad_rcpt = array();
703 703
 
704
-    if(!$this->SmtpConnect()) {
704
+    if (!$this->SmtpConnect()) {
705 705
       throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
706 706
     }
707 707
     $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
708
-    if(!$this->smtp->Mail($smtp_from)) {
709
-      throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
708
+    if (!$this->smtp->Mail($smtp_from)) {
709
+      throw new phpmailerException($this->Lang('from_failed').$smtp_from, self::STOP_CRITICAL);
710 710
     }
711 711
 
712 712
     // Attempt to send attach all recipients
713
-    foreach($this->to as $to) {
713
+    foreach ($this->to as $to) {
714 714
       if (!$this->smtp->Recipient($to[0])) {
715 715
         $bad_rcpt[] = $to[0];
716 716
         // implement call back function if it exists
717 717
         $isSent = 0;
718
-        $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
718
+        $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body);
719 719
       } else {
720 720
         // implement call back function if it exists
721 721
         $isSent = 1;
722
-        $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
722
+        $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body);
723 723
       }
724 724
     }
725
-    foreach($this->cc as $cc) {
725
+    foreach ($this->cc as $cc) {
726 726
       if (!$this->smtp->Recipient($cc[0])) {
727 727
         $bad_rcpt[] = $cc[0];
728 728
         // implement call back function if it exists
729 729
         $isSent = 0;
730
-        $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
730
+        $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body);
731 731
       } else {
732 732
         // implement call back function if it exists
733 733
         $isSent = 1;
734
-        $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
734
+        $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body);
735 735
       }
736 736
     }
737
-    foreach($this->bcc as $bcc) {
737
+    foreach ($this->bcc as $bcc) {
738 738
       if (!$this->smtp->Recipient($bcc[0])) {
739 739
         $bad_rcpt[] = $bcc[0];
740 740
         // implement call back function if it exists
741 741
         $isSent = 0;
742
-        $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
742
+        $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body);
743 743
       } else {
744 744
         // implement call back function if it exists
745 745
         $isSent = 1;
746
-        $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
746
+        $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body);
747 747
       }
748 748
     }
749 749
 
750 750
 
751
-    if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
751
+    if (count($bad_rcpt) > 0) { //Create error message for any bad addresses
752 752
       $badaddresses = implode(', ', $bad_rcpt);
753
-      throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
753
+      throw new phpmailerException($this->Lang('recipients_failed').$badaddresses);
754 754
     }
755
-    if(!$this->smtp->Data($header . $body)) {
755
+    if (!$this->smtp->Data($header.$body)) {
756 756
       throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
757 757
     }
758
-    if($this->SMTPKeepAlive == true) {
758
+    if ($this->SMTPKeepAlive == true) {
759 759
       $this->smtp->Reset();
760 760
     }
761 761
     return true;
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
    * @return bool
770 770
    */
771 771
   public function SmtpConnect() {
772
-    if(is_null($this->smtp)) {
772
+    if (is_null($this->smtp)) {
773 773
       $this->smtp = new SMTP();
774 774
     }
775 775
 
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 
781 781
     // Retry while there is no connection
782 782
     try {
783
-      while($index < count($hosts) && !$connection) {
783
+      while ($index < count($hosts) && !$connection) {
784 784
         $hostinfo = array();
785 785
         if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) {
786 786
           $host = $hostinfo[1];
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
         $tls = ($this->SMTPSecure == 'tls');
794 794
         $ssl = ($this->SMTPSecure == 'ssl');
795 795
 
796
-        if ($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) {
796
+        if ($this->smtp->Connect(($ssl ? 'ssl://' : '').$host, $port, $this->Timeout)) {
797 797
 
798 798
           $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname());
799 799
           $this->smtp->Hello($hello);
@@ -831,8 +831,8 @@  discard block
 block discarded – undo
831 831
    * @return void
832 832
    */
833 833
   public function SmtpClose() {
834
-    if(!is_null($this->smtp)) {
835
-      if($this->smtp->Connected()) {
834
+    if (!is_null($this->smtp)) {
835
+      if ($this->smtp->Connected()) {
836 836
         $this->smtp->Quit();
837 837
         $this->smtp->Close();
838 838
       }
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
    * @return string
895 895
    */
896 896
   public function AddrAppend($type, $addr) {
897
-    $addr_str = $type . ': ';
897
+    $addr_str = $type.': ';
898 898
     $addresses = array();
899 899
     foreach ($addr as $a) {
900 900
       $addresses[] = $this->AddrFormat($a);
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
     if (empty($addr[1])) {
915 915
       return $this->SecureHeader($addr[0]);
916 916
     } else {
917
-      return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
917
+      return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase')." <".$this->SecureHeader($addr[0]).">";
918 918
     }
919 919
   }
920 920
 
@@ -941,10 +941,10 @@  discard block
 block discarded – undo
941 941
 
942 942
     $line = explode($this->LE, $message);
943 943
     $message = '';
944
-    for ($i=0 ;$i < count($line); $i++) {
944
+    for ($i = 0; $i < count($line); $i++) {
945 945
       $line_part = explode(' ', $line[$i]);
946 946
       $buf = '';
947
-      for ($e = 0; $e<count($line_part); $e++) {
947
+      for ($e = 0; $e < count($line_part); $e++) {
948 948
         $word = $line_part[$e];
949 949
         if ($qp_mode and (strlen($word) > $length)) {
950 950
           $space_left = $length - strlen($buf) - 1;
@@ -960,10 +960,10 @@  discard block
 block discarded – undo
960 960
               }
961 961
               $part = substr($word, 0, $len);
962 962
               $word = substr($word, $len);
963
-              $buf .= ' ' . $part;
964
-              $message .= $buf . sprintf("=%s", $this->LE);
963
+              $buf .= ' '.$part;
964
+              $message .= $buf.sprintf("=%s", $this->LE);
965 965
             } else {
966
-              $message .= $buf . $soft_break;
966
+              $message .= $buf.$soft_break;
967 967
             }
968 968
             $buf = '';
969 969
           }
@@ -980,22 +980,22 @@  discard block
 block discarded – undo
980 980
             $word = substr($word, $len);
981 981
 
982 982
             if (strlen($word) > 0) {
983
-              $message .= $part . sprintf("=%s", $this->LE);
983
+              $message .= $part.sprintf("=%s", $this->LE);
984 984
             } else {
985 985
               $buf = $part;
986 986
             }
987 987
           }
988 988
         } else {
989 989
           $buf_o = $buf;
990
-          $buf .= ($e == 0) ? $word : (' ' . $word);
990
+          $buf .= ($e == 0) ? $word : (' '.$word);
991 991
 
992 992
           if (strlen($buf) > $length and $buf_o != '') {
993
-            $message .= $buf_o . $soft_break;
993
+            $message .= $buf_o.$soft_break;
994 994
             $buf = $word;
995 995
           }
996 996
         }
997 997
       }
998
-      $message .= $buf . $this->LE;
998
+      $message .= $buf.$this->LE;
999 999
     }
1000 1000
 
1001 1001
     return $message;
@@ -1024,8 +1024,7 @@  discard block
 block discarded – undo
1024 1024
         if ($dec < 128) { // Single byte character.
1025 1025
           // If the encoded char was found at pos 0, it will fit
1026 1026
           // otherwise reduce maxLength to start of the encoded char
1027
-          $maxLength = ($encodedCharPos == 0) ? $maxLength :
1028
-          $maxLength - ($lookBack - $encodedCharPos);
1027
+          $maxLength = ($encodedCharPos == 0) ? $maxLength : $maxLength - ($lookBack - $encodedCharPos);
1029 1028
           $foundSplitPos = true;
1030 1029
         } elseif ($dec >= 192) { // First byte of a multi byte character
1031 1030
           // Reduce maxLength to split at start of character
@@ -1049,11 +1048,11 @@  discard block
 block discarded – undo
1049 1048
    * @return void
1050 1049
    */
1051 1050
   public function SetWordWrap() {
1052
-    if($this->WordWrap < 1) {
1051
+    if ($this->WordWrap < 1) {
1053 1052
       return;
1054 1053
     }
1055 1054
 
1056
-    switch($this->message_type) {
1055
+    switch ($this->message_type) {
1057 1056
       case 'alt':
1058 1057
       case 'alt_attachments':
1059 1058
         $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
@@ -1074,24 +1073,24 @@  discard block
 block discarded – undo
1074 1073
 
1075 1074
     // Set the boundaries
1076 1075
     $uniq_id = md5(uniqid(time()));
1077
-    $this->boundary[1] = 'b1_' . $uniq_id;
1078
-    $this->boundary[2] = 'b2_' . $uniq_id;
1076
+    $this->boundary[1] = 'b1_'.$uniq_id;
1077
+    $this->boundary[2] = 'b2_'.$uniq_id;
1079 1078
 
1080 1079
     $result .= $this->HeaderLine('Date', self::RFCDate());
1081
-    if($this->Sender == '') {
1080
+    if ($this->Sender == '') {
1082 1081
       $result .= $this->HeaderLine('Return-Path', trim($this->From));
1083 1082
     } else {
1084 1083
       $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
1085 1084
     }
1086 1085
 
1087 1086
     // To be created automatically by mail()
1088
-    if($this->Mailer != 'mail') {
1087
+    if ($this->Mailer != 'mail') {
1089 1088
       if ($this->SingleTo === true) {
1090
-        foreach($this->to as $t) {
1089
+        foreach ($this->to as $t) {
1091 1090
           $this->SingleToArray[] = $this->AddrFormat($t);
1092 1091
         }
1093 1092
       } else {
1094
-        if(count($this->to) > 0) {
1093
+        if (count($this->to) > 0) {
1095 1094
           $result .= $this->AddrAppend('To', $this->to);
1096 1095
         } elseif (count($this->cc) == 0) {
1097 1096
           $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
@@ -1105,38 +1104,38 @@  discard block
 block discarded – undo
1105 1104
     $result .= $this->AddrAppend('From', $from);
1106 1105
 
1107 1106
     // sendmail and mail() extract Cc from the header before sending
1108
-    if(count($this->cc) > 0) {
1107
+    if (count($this->cc) > 0) {
1109 1108
       $result .= $this->AddrAppend('Cc', $this->cc);
1110 1109
     }
1111 1110
 
1112 1111
     // sendmail and mail() extract Bcc from the header before sending
1113
-    if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
1112
+    if ((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
1114 1113
       $result .= $this->AddrAppend('Bcc', $this->bcc);
1115 1114
     }
1116 1115
 
1117
-    if(count($this->ReplyTo) > 0) {
1116
+    if (count($this->ReplyTo) > 0) {
1118 1117
       $result .= $this->AddrAppend('Reply-to', $this->ReplyTo);
1119 1118
     }
1120 1119
 
1121 1120
     // mail() sets the subject itself
1122
-    if($this->Mailer != 'mail') {
1121
+    if ($this->Mailer != 'mail') {
1123 1122
       $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
1124 1123
     }
1125 1124
 
1126
-    if($this->MessageID != '') {
1127
-      $result .= $this->HeaderLine('Message-ID',$this->MessageID);
1125
+    if ($this->MessageID != '') {
1126
+      $result .= $this->HeaderLine('Message-ID', $this->MessageID);
1128 1127
     } else {
1129 1128
       $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
1130 1129
     }
1131 1130
     $result .= $this->HeaderLine('X-Priority', $this->Priority);
1132 1131
     $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)');
1133 1132
 
1134
-    if($this->ConfirmReadingTo != '') {
1135
-      $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
1133
+    if ($this->ConfirmReadingTo != '') {
1134
+      $result .= $this->HeaderLine('Disposition-Notification-To', '<'.trim($this->ConfirmReadingTo).'>');
1136 1135
     }
1137 1136
 
1138 1137
     // Add custom headers
1139
-    for($index = 0; $index < count($this->CustomHeader); $index++) {
1138
+    for ($index = 0; $index < count($this->CustomHeader); $index++) {
1140 1139
       $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
1141 1140
     }
1142 1141
     if (!$this->sign_key_file) {
@@ -1154,27 +1153,27 @@  discard block
 block discarded – undo
1154 1153
    */
1155 1154
   public function GetMailMIME() {
1156 1155
     $result = '';
1157
-    switch($this->message_type) {
1156
+    switch ($this->message_type) {
1158 1157
       case 'plain':
1159 1158
         $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
1160 1159
         $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
1161 1160
         break;
1162 1161
       case 'attachments':
1163 1162
       case 'alt_attachments':
1164
-        if($this->InlineImageExists()){
1163
+        if ($this->InlineImageExists()) {
1165 1164
           $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
1166 1165
         } else {
1167 1166
           $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
1168
-          $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1167
+          $result .= $this->TextLine("\tboundary=\"".$this->boundary[1].'"');
1169 1168
         }
1170 1169
         break;
1171 1170
       case 'alt':
1172 1171
         $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
1173
-        $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1172
+        $result .= $this->TextLine("\tboundary=\"".$this->boundary[1].'"');
1174 1173
         break;
1175 1174
     }
1176 1175
 
1177
-    if($this->Mailer != 'mail') {
1176
+    if ($this->Mailer != 'mail') {
1178 1177
       $result .= $this->LE.$this->LE;
1179 1178
     }
1180 1179
 
@@ -1195,7 +1194,7 @@  discard block
 block discarded – undo
1195 1194
 
1196 1195
     $this->SetWordWrap();
1197 1196
 
1198
-    switch($this->message_type) {
1197
+    switch ($this->message_type) {
1199 1198
       case 'alt':
1200 1199
         $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
1201 1200
         $body .= $this->EncodeString($this->AltBody, $this->Encoding);
@@ -1216,11 +1215,11 @@  discard block
 block discarded – undo
1216 1215
         break;
1217 1216
       case 'alt_attachments':
1218 1217
         $body .= sprintf("--%s%s", $this->boundary[1], $this->LE);
1219
-        $body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
1220
-        $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
1218
+        $body .= sprintf("Content-Type: %s;%s"."\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
1219
+        $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '').$this->LE; // Create text body
1221 1220
         $body .= $this->EncodeString($this->AltBody, $this->Encoding);
1222 1221
         $body .= $this->LE.$this->LE;
1223
-        $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
1222
+        $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '').$this->LE; // Create the HTML body
1224 1223
         $body .= $this->EncodeString($this->Body, $this->Encoding);
1225 1224
         $body .= $this->LE.$this->LE;
1226 1225
         $body .= $this->EndBoundary($this->boundary[2]);
@@ -1261,16 +1260,16 @@  discard block
 block discarded – undo
1261 1260
    */
1262 1261
   private function GetBoundary($boundary, $charSet, $contentType, $encoding) {
1263 1262
     $result = '';
1264
-    if($charSet == '') {
1263
+    if ($charSet == '') {
1265 1264
       $charSet = $this->CharSet;
1266 1265
     }
1267
-    if($contentType == '') {
1266
+    if ($contentType == '') {
1268 1267
       $contentType = $this->ContentType;
1269 1268
     }
1270
-    if($encoding == '') {
1269
+    if ($encoding == '') {
1271 1270
       $encoding = $this->Encoding;
1272 1271
     }
1273
-    $result .= $this->TextLine('--' . $boundary);
1272
+    $result .= $this->TextLine('--'.$boundary);
1274 1273
     $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);
1275 1274
     $result .= $this->LE;
1276 1275
     $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
@@ -1284,7 +1283,7 @@  discard block
 block discarded – undo
1284 1283
    * @access private
1285 1284
    */
1286 1285
   private function EndBoundary($boundary) {
1287
-    return $this->LE . '--' . $boundary . '--' . $this->LE;
1286
+    return $this->LE.'--'.$boundary.'--'.$this->LE;
1288 1287
   }
1289 1288
 
1290 1289
   /**
@@ -1293,16 +1292,16 @@  discard block
 block discarded – undo
1293 1292
    * @return void
1294 1293
    */
1295 1294
   private function SetMessageType() {
1296
-    if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
1295
+    if (count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
1297 1296
       $this->message_type = 'plain';
1298 1297
     } else {
1299
-      if(count($this->attachment) > 0) {
1298
+      if (count($this->attachment) > 0) {
1300 1299
         $this->message_type = 'attachments';
1301 1300
       }
1302
-      if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
1301
+      if (strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
1303 1302
         $this->message_type = 'alt';
1304 1303
       }
1305
-      if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
1304
+      if (strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
1306 1305
         $this->message_type = 'alt_attachments';
1307 1306
       }
1308 1307
     }
@@ -1314,7 +1313,7 @@  discard block
 block discarded – undo
1314 1313
    * @return string
1315 1314
    */
1316 1315
   public function HeaderLine($name, $value) {
1317
-    return $name . ': ' . $value . $this->LE;
1316
+    return $name.': '.$value.$this->LE;
1318 1317
   }
1319 1318
 
1320 1319
   /**
@@ -1323,7 +1322,7 @@  discard block
 block discarded – undo
1323 1322
    * @return string
1324 1323
    */
1325 1324
   public function TextLine($value) {
1326
-    return $value . $this->LE;
1325
+    return $value.$this->LE;
1327 1326
   }
1328 1327
 
1329 1328
   /////////////////////////////////////////////////
@@ -1342,11 +1341,11 @@  discard block
 block discarded – undo
1342 1341
    */
1343 1342
   public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1344 1343
     try {
1345
-      if ( !@is_file($path) ) {
1346
-        throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
1344
+      if (!@is_file($path)) {
1345
+        throw new phpmailerException($this->Lang('file_access').$path, self::STOP_CONTINUE);
1347 1346
       }
1348 1347
       $filename = basename($path);
1349
-      if ( $name == '' ) {
1348
+      if ($name == '') {
1350 1349
         $name = $filename;
1351 1350
       }
1352 1351
 
@@ -1356,7 +1355,7 @@  discard block
 block discarded – undo
1356 1355
         2 => $name,
1357 1356
         3 => $encoding,
1358 1357
         4 => $type,
1359
-        5 => false,  // isStringAttachment
1358
+        5 => false, // isStringAttachment
1360 1359
         6 => 'attachment',
1361 1360
         7 => 0
1362 1361
       );
@@ -1367,7 +1366,7 @@  discard block
 block discarded – undo
1367 1366
         throw $e;
1368 1367
       }
1369 1368
       error_log($e->getMessage()."\n");
1370
-      if ( $e->getCode() == self::STOP_CRITICAL ) {
1369
+      if ($e->getCode() == self::STOP_CRITICAL) {
1371 1370
         return false;
1372 1371
       }
1373 1372
     }
@@ -1412,29 +1411,29 @@  discard block
 block discarded – undo
1412 1411
       $disposition = $attachment[6];
1413 1412
       $cid         = $attachment[7];
1414 1413
       $incl[]      = $attachment[0];
1415
-      if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; }
1414
+      if ($disposition == 'inline' && isset($cidUniq[$cid])) { continue; }
1416 1415
       $cidUniq[$cid] = true;
1417 1416
 
1418 1417
       $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
1419 1418
       $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE);
1420 1419
       $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
1421 1420
 
1422
-      if($disposition == 'inline') {
1421
+      if ($disposition == 'inline') {
1423 1422
         $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
1424 1423
       }
1425 1424
 
1426 1425
       $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE);
1427 1426
 
1428 1427
       // Encode as string attachment
1429
-      if($bString) {
1428
+      if ($bString) {
1430 1429
         $mime[] = $this->EncodeString($string, $encoding);
1431
-        if($this->IsError()) {
1430
+        if ($this->IsError()) {
1432 1431
           return '';
1433 1432
         }
1434 1433
         $mime[] = $this->LE.$this->LE;
1435 1434
       } else {
1436 1435
         $mime[] = $this->EncodeFile($path, $encoding);
1437
-        if($this->IsError()) {
1436
+        if ($this->IsError()) {
1438 1437
           return '';
1439 1438
         }
1440 1439
         $mime[] = $this->LE.$this->LE;
@@ -1458,7 +1457,7 @@  discard block
 block discarded – undo
1458 1457
   private function EncodeFile($path, $encoding = 'base64') {
1459 1458
     try {
1460 1459
       if (!is_readable($path)) {
1461
-        throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
1460
+        throw new phpmailerException($this->Lang('file_open').$path, self::STOP_CONTINUE);
1462 1461
       }
1463 1462
         $magic_quotes = get_magic_quotes_runtime();
1464 1463
         if ($magic_quotes) {
@@ -1492,9 +1491,9 @@  discard block
 block discarded – undo
1492 1491
    * @access public
1493 1492
    * @return string
1494 1493
    */
1495
-  public function EncodeString ($str, $encoding = 'base64') {
1494
+  public function EncodeString($str, $encoding = 'base64') {
1496 1495
     $encoded = '';
1497
-    switch(strtolower($encoding)) {
1496
+    switch (strtolower($encoding)) {
1498 1497
       case 'base64':
1499 1498
         $encoded = chunk_split(base64_encode($str), 76, $this->LE);
1500 1499
         break;
@@ -1512,7 +1511,7 @@  discard block
 block discarded – undo
1512 1511
         $encoded = $this->EncodeQP($str);
1513 1512
         break;
1514 1513
       default:
1515
-        $this->SetError($this->Lang('encoding') . $encoding);
1514
+        $this->SetError($this->Lang('encoding').$encoding);
1516 1515
         break;
1517 1516
     }
1518 1517
     return $encoded;
@@ -1554,7 +1553,7 @@  discard block
 block discarded – undo
1554 1553
 
1555 1554
     $maxlen = 75 - 7 - strlen($this->CharSet);
1556 1555
     // Try to select the encoding which should produce the shortest output
1557
-    if (strlen($str)/3 < $x) {
1556
+    if (strlen($str) / 3 < $x) {
1558 1557
       $encoding = 'B';
1559 1558
       // Modified by Ivan Tcholakov, 24-JAN-2010.
1560 1559
       //if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
@@ -1635,7 +1634,7 @@  discard block
 block discarded – undo
1635 1634
       }
1636 1635
       while (strlen($chunk) > $length);
1637 1636
 
1638
-      $encoded .= $chunk . $this->LE;
1637
+      $encoded .= $chunk.$this->LE;
1639 1638
     }
1640 1639
 
1641 1640
     // Chomp the last linefeed
@@ -1651,37 +1650,37 @@  discard block
 block discarded – undo
1651 1650
   * @param integer $line_max Number of chars allowed on a line before wrapping
1652 1651
   * @return string
1653 1652
   */
1654
-  public function EncodeQPphp( $input = '', $line_max = 76, $space_conv = false) {
1655
-    $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
1653
+  public function EncodeQPphp($input = '', $line_max = 76, $space_conv = false) {
1654
+    $hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
1656 1655
     $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
1657 1656
     $eol = "\r\n";
1658 1657
     $escape = '=';
1659 1658
     $output = '';
1660
-    while( list(, $line) = each($lines) ) {
1659
+    while (list(, $line) = each($lines)) {
1661 1660
       $linlen = strlen($line);
1662 1661
       $newline = '';
1663
-      for($i = 0; $i < $linlen; $i++) {
1664
-        $c = substr( $line, $i, 1 );
1665
-        $dec = ord( $c );
1666
-        if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
1662
+      for ($i = 0; $i < $linlen; $i++) {
1663
+        $c = substr($line, $i, 1);
1664
+        $dec = ord($c);
1665
+        if (($i == 0) && ($dec == 46)) { // convert first point in the line into =2E
1667 1666
           $c = '=2E';
1668 1667
         }
1669
-        if ( $dec == 32 ) {
1670
-          if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
1668
+        if ($dec == 32) {
1669
+          if ($i == ($linlen - 1)) { // convert space at eol only
1671 1670
             $c = '=20';
1672
-          } else if ( $space_conv ) {
1671
+          } else if ($space_conv) {
1673 1672
             $c = '=20';
1674 1673
           }
1675
-        } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
1676
-          $h2 = floor($dec/16);
1677
-          $h1 = floor($dec%16);
1674
+        } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required
1675
+          $h2 = floor($dec / 16);
1676
+          $h1 = floor($dec % 16);
1678 1677
           $c = $escape.$hex[$h2].$hex[$h1];
1679 1678
         }
1680
-        if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
1679
+        if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted
1681 1680
           $output .= $newline.$escape.$eol; //  soft line break; " =\r\n" is okay
1682 1681
           $newline = '';
1683 1682
           // check if newline first character will be point or not
1684
-          if ( $dec == 46 ) {
1683
+          if ($dec == 46) {
1685 1684
             $c = '=2E';
1686 1685
           }
1687 1686
         }
@@ -1733,7 +1732,7 @@  discard block
 block discarded – undo
1733 1732
    * @access public
1734 1733
    * @return string
1735 1734
    */
1736
-  public function EncodeQ ($str, $position = 'text') {
1735
+  public function EncodeQ($str, $position = 'text') {
1737 1736
     // There should not be any EOL in the string
1738 1737
     $encoded = preg_replace('/[\r\n]*/', '', $str);
1739 1738
 
@@ -1776,7 +1775,7 @@  discard block
 block discarded – undo
1776 1775
       2 => basename($filename),
1777 1776
       3 => $encoding,
1778 1777
       4 => $type,
1779
-      5 => true,  // isStringAttachment
1778
+      5 => true, // isStringAttachment
1780 1779
       6 => 'attachment',
1781 1780
       7 => 0
1782 1781
     );
@@ -1797,13 +1796,13 @@  discard block
 block discarded – undo
1797 1796
    */
1798 1797
   public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1799 1798
 
1800
-    if ( !@is_file($path) ) {
1801
-      $this->SetError($this->Lang('file_access') . $path);
1799
+    if (!@is_file($path)) {
1800
+      $this->SetError($this->Lang('file_access').$path);
1802 1801
       return false;
1803 1802
     }
1804 1803
 
1805 1804
     $filename = basename($path);
1806
-    if ( $name == '' ) {
1805
+    if ($name == '') {
1807 1806
       $name = $filename;
1808 1807
     }
1809 1808
 
@@ -1814,7 +1813,7 @@  discard block
 block discarded – undo
1814 1813
       2 => $name,
1815 1814
       3 => $encoding,
1816 1815
       4 => $type,
1817
-      5 => false,  // isStringAttachment
1816
+      5 => false, // isStringAttachment
1818 1817
       6 => 'inline',
1819 1818
       7 => $cid
1820 1819
     );
@@ -1828,7 +1827,7 @@  discard block
 block discarded – undo
1828 1827
    * @return bool
1829 1828
    */
1830 1829
   public function InlineImageExists() {
1831
-    foreach($this->attachment as $attachment) {
1830
+    foreach ($this->attachment as $attachment) {
1832 1831
       if ($attachment[6] == 'inline') {
1833 1832
         return true;
1834 1833
       }
@@ -1845,7 +1844,7 @@  discard block
 block discarded – undo
1845 1844
    * @return void
1846 1845
    */
1847 1846
   public function ClearAddresses() {
1848
-    foreach($this->to as $to) {
1847
+    foreach ($this->to as $to) {
1849 1848
       unset($this->all_recipients[strtolower($to[0])]);
1850 1849
     }
1851 1850
     $this->to = array();
@@ -1856,7 +1855,7 @@  discard block
 block discarded – undo
1856 1855
    * @return void
1857 1856
    */
1858 1857
   public function ClearCCs() {
1859
-    foreach($this->cc as $cc) {
1858
+    foreach ($this->cc as $cc) {
1860 1859
       unset($this->all_recipients[strtolower($cc[0])]);
1861 1860
     }
1862 1861
     $this->cc = array();
@@ -1867,7 +1866,7 @@  discard block
 block discarded – undo
1867 1866
    * @return void
1868 1867
    */
1869 1868
   public function ClearBCCs() {
1870
-    foreach($this->bcc as $bcc) {
1869
+    foreach ($this->bcc as $bcc) {
1871 1870
       unset($this->all_recipients[strtolower($bcc[0])]);
1872 1871
     }
1873 1872
     $this->bcc = array();
@@ -1924,7 +1923,7 @@  discard block
 block discarded – undo
1924 1923
     if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
1925 1924
       $lasterror = $this->smtp->getError();
1926 1925
       if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
1927
-        $msg .= '<p>' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
1926
+        $msg .= '<p>'.$this->Lang('smtp_error').$lasterror['smtp_msg']."</p>\n";
1928 1927
       }
1929 1928
     }
1930 1929
     $this->ErrorInfo = $msg;
@@ -1940,7 +1939,7 @@  discard block
 block discarded – undo
1940 1939
     $tz = date('Z');
1941 1940
     $tzs = ($tz < 0) ? '-' : '+';
1942 1941
     $tz = abs($tz);
1943
-    $tz = (int)($tz/3600)*100 + ($tz%3600)/60;
1942
+    $tz = (int) ($tz / 3600) * 100 + ($tz % 3600) / 60;
1944 1943
     $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
1945 1944
 
1946 1945
     return $result;
@@ -1969,14 +1968,14 @@  discard block
 block discarded – undo
1969 1968
    * @return string
1970 1969
    */
1971 1970
   private function Lang($key) {
1972
-    if(count($this->language) < 1) {
1971
+    if (count($this->language) < 1) {
1973 1972
       $this->SetLanguage('en'); // set the default language
1974 1973
     }
1975 1974
 
1976
-    if(isset($this->language[$key])) {
1975
+    if (isset($this->language[$key])) {
1977 1976
       return $this->language[$key];
1978 1977
     } else {
1979
-      return 'Language string failed to load: ' . $key;
1978
+      return 'Language string failed to load: '.$key;
1980 1979
     }
1981 1980
   }
1982 1981
 
@@ -2017,19 +2016,19 @@  discard block
 block discarded – undo
2017 2016
    */
2018 2017
   public function MsgHTML($message, $basedir = '') {
2019 2018
     preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
2020
-    if(isset($images[2])) {
2021
-      foreach($images[2] as $i => $url) {
2019
+    if (isset($images[2])) {
2020
+      foreach ($images[2] as $i => $url) {
2022 2021
         // do not change urls for absolute images (thanks to corvuscorax)
2023
-        if (!preg_match('#^[A-z]+://#',$url)) {
2022
+        if (!preg_match('#^[A-z]+://#', $url)) {
2024 2023
           $filename = basename($url);
2025 2024
           $directory = dirname($url);
2026
-          ($directory == '.')?$directory='':'';
2027
-          $cid = 'cid:' . md5($filename);
2025
+          ($directory == '.') ? $directory = '' : '';
2026
+          $cid = 'cid:'.md5($filename);
2028 2027
           $ext = pathinfo($filename, PATHINFO_EXTENSION);
2029
-          $mimeType  = self::_mime_types($ext);
2030
-          if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
2031
-          if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
2032
-          if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
2028
+          $mimeType = self::_mime_types($ext);
2029
+          if (strlen($basedir) > 1 && substr($basedir, -1) != '/') { $basedir .= '/'; }
2030
+          if (strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; }
2031
+          if ($this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType)) {
2033 2032
             $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
2034 2033
           }
2035 2034
         }
@@ -2037,12 +2036,12 @@  discard block
 block discarded – undo
2037 2036
     }
2038 2037
     $this->IsHTML(true);
2039 2038
     $this->Body = $message;
2040
-    $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
2039
+    $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message)));
2041 2040
     if (!empty($textMsg) && empty($this->AltBody)) {
2042 2041
       $this->AltBody = html_entity_decode($textMsg);
2043 2042
     }
2044 2043
     if (empty($this->AltBody)) {
2045
-      $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
2044
+      $this->AltBody = 'To view this email message, open it in a program that understands HTML!'."\n\n";
2046 2045
     }
2047 2046
   }
2048 2047
 
@@ -2160,10 +2159,10 @@  discard block
 block discarded – undo
2160 2159
   */
2161 2160
   public function set($name, $value = '') {
2162 2161
     try {
2163
-      if (isset($this->$name) ) {
2162
+      if (isset($this->$name)) {
2164 2163
         $this->$name = $value;
2165 2164
       } else {
2166
-        throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL);
2165
+        throw new phpmailerException($this->Lang('variable_set').$name, self::STOP_CRITICAL);
2167 2166
       }
2168 2167
     } catch (Exception $e) {
2169 2168
       $this->SetError($e->getMessage());
@@ -2207,14 +2206,14 @@  discard block
 block discarded – undo
2207 2206
    * @param string $key_pass Password for private key
2208 2207
    */
2209 2208
   public function DKIM_QP($txt) {
2210
-    $tmp="";
2211
-    $line="";
2212
-    for ($i=0;$i<strlen($txt);$i++) {
2213
-      $ord=ord($txt[$i]);
2214
-      if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) {
2215
-        $line.=$txt[$i];
2209
+    $tmp = "";
2210
+    $line = "";
2211
+    for ($i = 0; $i < strlen($txt); $i++) {
2212
+      $ord = ord($txt[$i]);
2213
+      if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) {
2214
+        $line .= $txt[$i];
2216 2215
       } else {
2217
-        $line.="=".sprintf("%02X",$ord);
2216
+        $line .= "=".sprintf("%02X", $ord);
2218 2217
       }
2219 2218
     }
2220 2219
     return $line;
@@ -2228,8 +2227,8 @@  discard block
 block discarded – undo
2228 2227
    */
2229 2228
   public function DKIM_Sign($s) {
2230 2229
     $privKeyStr = file_get_contents($this->DKIM_private);
2231
-    if ($this->DKIM_passphrase!='') {
2232
-      $privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase);
2230
+    if ($this->DKIM_passphrase != '') {
2231
+      $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
2233 2232
     } else {
2234 2233
       $privKey = $privKeyStr;
2235 2234
     }
@@ -2245,15 +2244,15 @@  discard block
 block discarded – undo
2245 2244
    * @param string $s Header
2246 2245
    */
2247 2246
   public function DKIM_HeaderC($s) {
2248
-    $s=preg_replace("/\r\n\s+/"," ",$s);
2249
-    $lines=explode("\r\n",$s);
2247
+    $s = preg_replace("/\r\n\s+/", " ", $s);
2248
+    $lines = explode("\r\n", $s);
2250 2249
     foreach ($lines as $key=>$line) {
2251
-      list($heading,$value)=explode(":",$line,2);
2252
-      $heading=strtolower($heading);
2253
-      $value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces
2254
-      $lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value
2250
+      list($heading, $value) = explode(":", $line, 2);
2251
+      $heading = strtolower($heading);
2252
+      $value = preg_replace("/\s+/", " ", $value); // Compress useless spaces
2253
+      $lines[$key] = $heading.":".trim($value); // Don't forget to remove WSP around the value
2255 2254
     }
2256
-    $s=implode("\r\n",$lines);
2255
+    $s = implode("\r\n", $lines);
2257 2256
     return $s;
2258 2257
   }
2259 2258
 
@@ -2266,11 +2265,11 @@  discard block
 block discarded – undo
2266 2265
   public function DKIM_BodyC($body) {
2267 2266
     if ($body == '') return "\r\n";
2268 2267
     // stabilize line endings
2269
-    $body=str_replace("\r\n","\n",$body);
2270
-    $body=str_replace("\n","\r\n",$body);
2268
+    $body = str_replace("\r\n", "\n", $body);
2269
+    $body = str_replace("\n", "\r\n", $body);
2271 2270
     // END stabilize line endings
2272
-    while (substr($body,strlen($body)-4,4) == "\r\n\r\n") {
2273
-      $body=substr($body,0,strlen($body)-2);
2271
+    while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") {
2272
+      $body = substr($body, 0, strlen($body) - 2);
2274 2273
     }
2275 2274
     return $body;
2276 2275
   }
@@ -2283,52 +2282,52 @@  discard block
 block discarded – undo
2283 2282
    * @param string $subject Subject
2284 2283
    * @param string $body Body
2285 2284
    */
2286
-  public function DKIM_Add($headers_line,$subject,$body) {
2285
+  public function DKIM_Add($headers_line, $subject, $body) {
2287 2286
     $DKIMsignatureType    = 'rsa-sha1'; // Signature & hash algorithms
2288 2287
     $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
2289 2288
     $DKIMquery            = 'dns/txt'; // Query method
2290
-    $DKIMtime             = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
2289
+    $DKIMtime             = time(); // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
2291 2290
     $subject_header       = "Subject: $subject";
2292
-    $headers              = explode("\r\n",$headers_line);
2293
-    foreach($headers as $header) {
2294
-      if (strpos($header,'From:') === 0) {
2295
-        $from_header=$header;
2296
-      } elseif (strpos($header,'To:') === 0) {
2297
-        $to_header=$header;
2291
+    $headers              = explode("\r\n", $headers_line);
2292
+    foreach ($headers as $header) {
2293
+      if (strpos($header, 'From:') === 0) {
2294
+        $from_header = $header;
2295
+      } elseif (strpos($header, 'To:') === 0) {
2296
+        $to_header = $header;
2298 2297
       }
2299 2298
     }
2300
-    $from     = str_replace('|','=7C',$this->DKIM_QP($from_header));
2301
-    $to       = str_replace('|','=7C',$this->DKIM_QP($to_header));
2302
-    $subject  = str_replace('|','=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable
2299
+    $from     = str_replace('|', '=7C', $this->DKIM_QP($from_header));
2300
+    $to       = str_replace('|', '=7C', $this->DKIM_QP($to_header));
2301
+    $subject  = str_replace('|', '=7C', $this->DKIM_QP($subject_header)); // Copied header fields (dkim-quoted-printable
2303 2302
     $body     = $this->DKIM_BodyC($body);
2304
-    $DKIMlen  = strlen($body) ; // Length of body
2305
-    $DKIMb64  = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body
2306
-    $ident    = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";";
2307
-    $dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n".
2308
-                "\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n".
2303
+    $DKIMlen  = strlen($body); // Length of body
2304
+    $DKIMb64  = base64_encode(pack("H*", sha1($body))); // Base64 of packed binary SHA-1 hash of body
2305
+    $ident    = ($this->DKIM_identity == '') ? '' : " i=".$this->DKIM_identity.";";
2306
+    $dkimhdrs = "DKIM-Signature: v=1; a=".$DKIMsignatureType."; q=".$DKIMquery."; l=".$DKIMlen."; s=".$this->DKIM_selector.";\r\n".
2307
+                "\tt=".$DKIMtime."; c=".$DKIMcanonicalization.";\r\n".
2309 2308
                 "\th=From:To:Subject;\r\n".
2310
-                "\td=" . $this->DKIM_domain . ";" . $ident . "\r\n".
2309
+                "\td=".$this->DKIM_domain.";".$ident."\r\n".
2311 2310
                 "\tz=$from\r\n".
2312 2311
                 "\t|$to\r\n".
2313 2312
                 "\t|$subject;\r\n".
2314
-                "\tbh=" . $DKIMb64 . ";\r\n".
2313
+                "\tbh=".$DKIMb64.";\r\n".
2315 2314
                 "\tb=";
2316
-    $toSign   = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs);
2315
+    $toSign   = $this->DKIM_HeaderC($from_header."\r\n".$to_header."\r\n".$subject_header."\r\n".$dkimhdrs);
2317 2316
     $signed   = $this->DKIM_Sign($toSign);
2318 2317
     return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n";
2319 2318
   }
2320 2319
 
2321
-  protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body) {
2320
+  protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body) {
2322 2321
     if (!empty($this->action_function) && function_exists($this->action_function)) {
2323
-      $params = array($isSent,$to,$cc,$bcc,$subject,$body);
2324
-      call_user_func_array($this->action_function,$params);
2322
+      $params = array($isSent, $to, $cc, $bcc, $subject, $body);
2323
+      call_user_func_array($this->action_function, $params);
2325 2324
     }
2326 2325
   }
2327 2326
 }
2328 2327
 
2329 2328
 class phpmailerException extends Exception {
2330 2329
   public function errorMessage() {
2331
-    $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
2330
+    $errorMsg = '<strong>'.$this->getMessage()."</strong><br />\n";
2332 2331
     return $errorMsg;
2333 2332
   }
2334 2333
 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -38,7 +38,9 @@  discard block
 block discarded – undo
38 38
  * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
39 39
  */
40 40
 
41
-if (version_compare(PHP_VERSION, '5.0.0', '<') ) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
41
+if (version_compare(PHP_VERSION, '5.0.0', '<') ) {
42
+    exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
43
+}
42 44
 
43 45
 class PHPMailer {
44 46
 
@@ -1502,8 +1504,9 @@  discard block
 block discarded – undo
1502 1504
       case '8bit':
1503 1505
         $encoded = $this->FixEOL($str);
1504 1506
         //Make sure it ends with a line break
1505
-        if (substr($encoded, -(strlen($this->LE))) != $this->LE)
1506
-          $encoded .= $this->LE;
1507
+        if (substr($encoded, -(strlen($this->LE))) != $this->LE) {
1508
+                  $encoded .= $this->LE;
1509
+        }
1507 1510
         break;
1508 1511
       case 'binary':
1509 1512
         $encoded = $str;
@@ -2264,7 +2267,9 @@  discard block
 block discarded – undo
2264 2267
    * @param string $body Message Body
2265 2268
    */
2266 2269
   public function DKIM_BodyC($body) {
2267
-    if ($body == '') return "\r\n";
2270
+    if ($body == '') {
2271
+        return "\r\n";
2272
+    }
2268 2273
     // stabilize line endings
2269 2274
     $body=str_replace("\r\n","\n",$body);
2270 2275
     $body=str_replace("\n","\r\n",$body);
Please login to merge, or discard this patch.
main/inc/lib/phpmailer/class.pop3.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -192,7 +192,7 @@
 block discarded – undo
192 192
    * @param string $host
193 193
    * @param integer $port
194 194
    * @param integer $tval
195
-   * @return boolean
195
+   * @return boolean|null
196 196
    */
197 197
   public function Connect ($host, $port = false, $tval = 30) {
198 198
     //  Are we already connected?
Please login to merge, or discard this patch.
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -60,103 +60,103 @@  discard block
 block discarded – undo
60 60
  */
61 61
 
62 62
 class POP3 {
63
-  /**
64
-   * Default POP3 port
65
-   * @var int
66
-   */
67
-  public $POP3_PORT = 110;
68
-
69
-  /**
70
-   * Default Timeout
71
-   * @var int
72
-   */
73
-  public $POP3_TIMEOUT = 30;
74
-
75
-  /**
76
-   * POP3 Carriage Return + Line Feed
77
-   * @var string
78
-   */
79
-  public $CRLF = "\r\n";
80
-
81
-  /**
82
-   * Displaying Debug warnings? (0 = now, 1+ = yes)
83
-   * @var int
84
-   */
85
-  public $do_debug = 2;
86
-
87
-  /**
88
-   * POP3 Mail Server
89
-   * @var string
90
-   */
91
-  public $host;
92
-
93
-  /**
94
-   * POP3 Port
95
-   * @var int
96
-   */
97
-  public $port;
98
-
99
-  /**
100
-   * POP3 Timeout Value
101
-   * @var int
102
-   */
103
-  public $tval;
104
-
105
-  /**
106
-   * POP3 Username
107
-   * @var string
108
-   */
109
-  public $username;
110
-
111
-  /**
112
-   * POP3 Password
113
-   * @var string
114
-   */
115
-  public $password;
116
-
117
-  /////////////////////////////////////////////////
118
-  // PROPERTIES, PRIVATE AND PROTECTED
119
-  /////////////////////////////////////////////////
120
-
121
-  private $pop_conn;
122
-  private $connected;
123
-  private $error;     //  Error log array
124
-
125
-  /**
126
-   * Constructor, sets the initial values
127
-   * @access public
128
-   * @return POP3
129
-   */
130
-  public function __construct() {
63
+    /**
64
+     * Default POP3 port
65
+     * @var int
66
+     */
67
+    public $POP3_PORT = 110;
68
+
69
+    /**
70
+     * Default Timeout
71
+     * @var int
72
+     */
73
+    public $POP3_TIMEOUT = 30;
74
+
75
+    /**
76
+     * POP3 Carriage Return + Line Feed
77
+     * @var string
78
+     */
79
+    public $CRLF = "\r\n";
80
+
81
+    /**
82
+     * Displaying Debug warnings? (0 = now, 1+ = yes)
83
+     * @var int
84
+     */
85
+    public $do_debug = 2;
86
+
87
+    /**
88
+     * POP3 Mail Server
89
+     * @var string
90
+     */
91
+    public $host;
92
+
93
+    /**
94
+     * POP3 Port
95
+     * @var int
96
+     */
97
+    public $port;
98
+
99
+    /**
100
+     * POP3 Timeout Value
101
+     * @var int
102
+     */
103
+    public $tval;
104
+
105
+    /**
106
+     * POP3 Username
107
+     * @var string
108
+     */
109
+    public $username;
110
+
111
+    /**
112
+     * POP3 Password
113
+     * @var string
114
+     */
115
+    public $password;
116
+
117
+    /////////////////////////////////////////////////
118
+    // PROPERTIES, PRIVATE AND PROTECTED
119
+    /////////////////////////////////////////////////
120
+
121
+    private $pop_conn;
122
+    private $connected;
123
+    private $error;     //  Error log array
124
+
125
+    /**
126
+     * Constructor, sets the initial values
127
+     * @access public
128
+     * @return POP3
129
+     */
130
+    public function __construct() {
131 131
     $this->pop_conn  = 0;
132 132
     $this->connected = false;
133 133
     $this->error     = null;
134
-  }
135
-
136
-  /**
137
-   * Combination of public events - connect, login, disconnect
138
-   * @access public
139
-   * @param string $host
140
-   * @param integer $port
141
-   * @param integer $tval
142
-   * @param string $username
143
-   * @param string $password
144
-   */
145
-  public function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0) {
134
+    }
135
+
136
+    /**
137
+     * Combination of public events - connect, login, disconnect
138
+     * @access public
139
+     * @param string $host
140
+     * @param integer $port
141
+     * @param integer $tval
142
+     * @param string $username
143
+     * @param string $password
144
+     */
145
+    public function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0) {
146 146
     $this->host = $host;
147 147
 
148 148
     //  If no port value is passed, retrieve it
149 149
     if ($port == false) {
150
-      $this->port = $this->POP3_PORT;
150
+        $this->port = $this->POP3_PORT;
151 151
     } else {
152
-      $this->port = $port;
152
+        $this->port = $port;
153 153
     }
154 154
 
155 155
     //  If no port value is passed, retrieve it
156 156
     if ($tval == false) {
157
-      $this->tval = $this->POP3_TIMEOUT;
157
+        $this->tval = $this->POP3_TIMEOUT;
158 158
     } else {
159
-      $this->tval = $tval;
159
+        $this->tval = $tval;
160 160
     }
161 161
 
162 162
     $this->do_debug = $debug_level;
@@ -170,13 +170,13 @@  discard block
 block discarded – undo
170 170
     $result = $this->Connect($this->host, $this->port, $this->tval);
171 171
 
172 172
     if ($result) {
173
-      $login_result = $this->Login($this->username, $this->password);
173
+        $login_result = $this->Login($this->username, $this->password);
174 174
 
175
-      if ($login_result) {
175
+        if ($login_result) {
176 176
         $this->Disconnect();
177 177
 
178 178
         return true;
179
-      }
179
+        }
180 180
 
181 181
     }
182 182
 
@@ -184,20 +184,20 @@  discard block
 block discarded – undo
184 184
     $this->Disconnect();
185 185
 
186 186
     return false;
187
-  }
188
-
189
-  /**
190
-   * Connect to the POP3 server
191
-   * @access public
192
-   * @param string $host
193
-   * @param integer $port
194
-   * @param integer $tval
195
-   * @return boolean
196
-   */
197
-  public function Connect ($host, $port = false, $tval = 30) {
187
+    }
188
+
189
+    /**
190
+     * Connect to the POP3 server
191
+     * @access public
192
+     * @param string $host
193
+     * @param integer $port
194
+     * @param integer $tval
195
+     * @return boolean
196
+     */
197
+    public function Connect ($host, $port = false, $tval = 30) {
198 198
     //  Are we already connected?
199 199
     if ($this->connected) {
200
-      return true;
200
+        return true;
201 201
     }
202 202
 
203 203
     /*
@@ -209,45 +209,45 @@  discard block
 block discarded – undo
209 209
 
210 210
     //  Connect to the POP3 server
211 211
     $this->pop_conn = fsockopen($host,    //  POP3 Host
212
-                  $port,    //  Port #
213
-                  $errno,   //  Error Number
214
-                  $errstr,  //  Error Message
215
-                  $tval);   //  Timeout (seconds)
212
+                    $port,    //  Port #
213
+                    $errno,   //  Error Number
214
+                    $errstr,  //  Error Message
215
+                    $tval);   //  Timeout (seconds)
216 216
 
217 217
     //  Restore the error handler
218 218
     restore_error_handler();
219 219
 
220 220
     //  Does the Error Log now contain anything?
221 221
     if ($this->error && $this->do_debug >= 1) {
222
-      $this->displayErrors();
222
+        $this->displayErrors();
223 223
     }
224 224
 
225 225
     //  Did we connect?
226 226
     if ($this->pop_conn == false) {
227
-      //  It would appear not...
228
-      $this->error = array(
227
+        //  It would appear not...
228
+        $this->error = array(
229 229
         'error' => "Failed to connect to server $host on port $port",
230 230
         'errno' => $errno,
231 231
         'errstr' => $errstr
232
-      );
232
+        );
233 233
 
234
-      if ($this->do_debug >= 1) {
234
+        if ($this->do_debug >= 1) {
235 235
         $this->displayErrors();
236
-      }
236
+        }
237 237
 
238
-      return false;
238
+        return false;
239 239
     }
240 240
 
241 241
     //  Increase the stream time-out
242 242
 
243 243
     //  Check for PHP 4.3.0 or later
244 244
     if (version_compare(phpversion(), '5.0.0', 'ge')) {
245
-      stream_set_timeout($this->pop_conn, $tval, 0);
245
+        stream_set_timeout($this->pop_conn, $tval, 0);
246 246
     } else {
247
-      //  Does not work on Windows
248
-      if (substr(PHP_OS, 0, 3) !== 'WIN') {
247
+        //  Does not work on Windows
248
+        if (substr(PHP_OS, 0, 3) !== 'WIN') {
249 249
         socket_set_timeout($this->pop_conn, $tval, 0);
250
-      }
250
+        }
251 251
     }
252 252
 
253 253
     //  Get the POP3 server response
@@ -257,33 +257,33 @@  discard block
 block discarded – undo
257 257
     if ($this->checkResponse($pop3_response)) {
258 258
     //  The connection is established and the POP3 server is talking
259 259
     $this->connected = true;
260
-      return true;
260
+        return true;
261 261
     }
262 262
 
263
-  }
263
+    }
264 264
 
265
-  /**
266
-   * Login to the POP3 server (does not support APOP yet)
267
-   * @access public
268
-   * @param string $username
269
-   * @param string $password
270
-   * @return boolean
271
-   */
272
-  public function Login ($username = '', $password = '') {
265
+    /**
266
+     * Login to the POP3 server (does not support APOP yet)
267
+     * @access public
268
+     * @param string $username
269
+     * @param string $password
270
+     * @return boolean
271
+     */
272
+    public function Login ($username = '', $password = '') {
273 273
     if ($this->connected == false) {
274
-      $this->error = 'Not connected to POP3 server';
274
+        $this->error = 'Not connected to POP3 server';
275 275
 
276
-      if ($this->do_debug >= 1) {
276
+        if ($this->do_debug >= 1) {
277 277
         $this->displayErrors();
278
-      }
278
+        }
279 279
     }
280 280
 
281 281
     if (empty($username)) {
282
-      $username = $this->username;
282
+        $username = $this->username;
283 283
     }
284 284
 
285 285
     if (empty($password)) {
286
-      $password = $this->password;
286
+        $password = $this->password;
287 287
     }
288 288
 
289 289
     $pop_username = "USER $username" . $this->CRLF;
@@ -294,114 +294,114 @@  discard block
 block discarded – undo
294 294
     $pop3_response = $this->getResponse();
295 295
 
296 296
     if ($this->checkResponse($pop3_response)) {
297
-      //  Send the Password
298
-      $this->sendString($pop_password);
299
-      $pop3_response = $this->getResponse();
297
+        //  Send the Password
298
+        $this->sendString($pop_password);
299
+        $pop3_response = $this->getResponse();
300 300
 
301
-      if ($this->checkResponse($pop3_response)) {
301
+        if ($this->checkResponse($pop3_response)) {
302 302
         return true;
303
-      } else {
303
+        } else {
304 304
         return false;
305
-      }
305
+        }
306 306
     } else {
307
-      return false;
307
+        return false;
308
+    }
308 309
     }
309
-  }
310 310
 
311
-  /**
312
-   * Disconnect from the POP3 server
313
-   * @access public
314
-   */
315
-  public function Disconnect () {
311
+    /**
312
+     * Disconnect from the POP3 server
313
+     * @access public
314
+     */
315
+    public function Disconnect () {
316 316
     $this->sendString('QUIT');
317 317
 
318 318
     fclose($this->pop_conn);
319
-  }
320
-
321
-  /////////////////////////////////////////////////
322
-  //  Private Methods
323
-  /////////////////////////////////////////////////
324
-
325
-  /**
326
-   * Get the socket response back.
327
-   * $size is the maximum number of bytes to retrieve
328
-   * @access private
329
-   * @param integer $size
330
-   * @return string
331
-   */
332
-  private function getResponse ($size = 128) {
319
+    }
320
+
321
+    /////////////////////////////////////////////////
322
+    //  Private Methods
323
+    /////////////////////////////////////////////////
324
+
325
+    /**
326
+     * Get the socket response back.
327
+     * $size is the maximum number of bytes to retrieve
328
+     * @access private
329
+     * @param integer $size
330
+     * @return string
331
+     */
332
+    private function getResponse ($size = 128) {
333 333
     $pop3_response = fgets($this->pop_conn, $size);
334 334
 
335 335
     return $pop3_response;
336
-  }
337
-
338
-  /**
339
-   * Send a string down the open socket connection to the POP3 server
340
-   * @access private
341
-   * @param string $string
342
-   * @return integer
343
-   */
344
-  private function sendString ($string) {
336
+    }
337
+
338
+    /**
339
+     * Send a string down the open socket connection to the POP3 server
340
+     * @access private
341
+     * @param string $string
342
+     * @return integer
343
+     */
344
+    private function sendString ($string) {
345 345
     $bytes_sent = fwrite($this->pop_conn, $string, strlen($string));
346 346
 
347 347
     return $bytes_sent;
348
-  }
349
-
350
-  /**
351
-   * Checks the POP3 server response for +OK or -ERR
352
-   * @access private
353
-   * @param string $string
354
-   * @return boolean
355
-   */
356
-  private function checkResponse ($string) {
348
+    }
349
+
350
+    /**
351
+     * Checks the POP3 server response for +OK or -ERR
352
+     * @access private
353
+     * @param string $string
354
+     * @return boolean
355
+     */
356
+    private function checkResponse ($string) {
357 357
     if (substr($string, 0, 3) !== '+OK') {
358
-      $this->error = array(
358
+        $this->error = array(
359 359
         'error' => "Server reported an error: $string",
360 360
         'errno' => 0,
361 361
         'errstr' => ''
362
-      );
362
+        );
363 363
 
364
-      if ($this->do_debug >= 1) {
364
+        if ($this->do_debug >= 1) {
365 365
         $this->displayErrors();
366
-      }
366
+        }
367 367
 
368
-      return false;
368
+        return false;
369 369
     } else {
370
-      return true;
370
+        return true;
371 371
     }
372 372
 
373
-  }
373
+    }
374 374
 
375
-  /**
376
-   * If debug is enabled, display the error message array
377
-   * @access private
378
-   */
379
-  private function displayErrors () {
375
+    /**
376
+     * If debug is enabled, display the error message array
377
+     * @access private
378
+     */
379
+    private function displayErrors () {
380 380
     echo '<pre>';
381 381
 
382 382
     foreach ($this->error as $single_error) {
383
-      print_r($single_error);
383
+        print_r($single_error);
384 384
     }
385 385
 
386 386
     echo '</pre>';
387
-  }
388
-
389
-  /**
390
-   * Takes over from PHP for the socket warning handler
391
-   * @access private
392
-   * @param integer $errno
393
-   * @param string $errstr
394
-   * @param string $errfile
395
-   * @param integer $errline
396
-   */
397
-  private function catchWarning ($errno, $errstr, $errfile, $errline) {
387
+    }
388
+
389
+    /**
390
+     * Takes over from PHP for the socket warning handler
391
+     * @access private
392
+     * @param integer $errno
393
+     * @param string $errstr
394
+     * @param string $errfile
395
+     * @param integer $errline
396
+     */
397
+    private function catchWarning ($errno, $errstr, $errfile, $errline) {
398 398
     $this->error[] = array(
399
-      'error' => "Connecting to the POP3 server raised a PHP warning: ",
400
-      'errno' => $errno,
401
-      'errstr' => $errstr
399
+        'error' => "Connecting to the POP3 server raised a PHP warning: ",
400
+        'errno' => $errno,
401
+        'errstr' => $errstr
402 402
     );
403
-  }
403
+    }
404 404
 
405
-  //  End of class
405
+    //  End of class
406 406
 }
407 407
 ?>
408 408
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
   private $pop_conn;
122 122
   private $connected;
123
-  private $error;     //  Error log array
123
+  private $error; //  Error log array
124 124
 
125 125
   /**
126 126
    * Constructor, sets the initial values
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
    * @param string $username
143 143
    * @param string $password
144 144
    */
145
-  public function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0) {
145
+  public function Authorise($host, $port = false, $tval = false, $username, $password, $debug_level = 0) {
146 146
     $this->host = $host;
147 147
 
148 148
     //  If no port value is passed, retrieve it
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
    * @param integer $tval
195 195
    * @return boolean
196 196
    */
197
-  public function Connect ($host, $port = false, $tval = 30) {
197
+  public function Connect($host, $port = false, $tval = 30) {
198 198
     //  Are we already connected?
199 199
     if ($this->connected) {
200 200
       return true;
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
     set_error_handler(array(&$this, 'catchWarning'));
209 209
 
210 210
     //  Connect to the POP3 server
211
-    $this->pop_conn = fsockopen($host,    //  POP3 Host
212
-                  $port,    //  Port #
213
-                  $errno,   //  Error Number
214
-                  $errstr,  //  Error Message
215
-                  $tval);   //  Timeout (seconds)
211
+    $this->pop_conn = fsockopen($host, //  POP3 Host
212
+                  $port, //  Port #
213
+                  $errno, //  Error Number
214
+                  $errstr, //  Error Message
215
+                  $tval); //  Timeout (seconds)
216 216
 
217 217
     //  Restore the error handler
218 218
     restore_error_handler();
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
    * @param string $password
270 270
    * @return boolean
271 271
    */
272
-  public function Login ($username = '', $password = '') {
272
+  public function Login($username = '', $password = '') {
273 273
     if ($this->connected == false) {
274 274
       $this->error = 'Not connected to POP3 server';
275 275
 
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
       $password = $this->password;
287 287
     }
288 288
 
289
-    $pop_username = "USER $username" . $this->CRLF;
290
-    $pop_password = "PASS $password" . $this->CRLF;
289
+    $pop_username = "USER $username".$this->CRLF;
290
+    $pop_password = "PASS $password".$this->CRLF;
291 291
 
292 292
     //  Send the Username
293 293
     $this->sendString($pop_username);
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
    * Disconnect from the POP3 server
313 313
    * @access public
314 314
    */
315
-  public function Disconnect () {
315
+  public function Disconnect() {
316 316
     $this->sendString('QUIT');
317 317
 
318 318
     fclose($this->pop_conn);
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
    * @param integer $size
330 330
    * @return string
331 331
    */
332
-  private function getResponse ($size = 128) {
332
+  private function getResponse($size = 128) {
333 333
     $pop3_response = fgets($this->pop_conn, $size);
334 334
 
335 335
     return $pop3_response;
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
    * @param string $string
342 342
    * @return integer
343 343
    */
344
-  private function sendString ($string) {
344
+  private function sendString($string) {
345 345
     $bytes_sent = fwrite($this->pop_conn, $string, strlen($string));
346 346
 
347 347
     return $bytes_sent;
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
    * @param string $string
354 354
    * @return boolean
355 355
    */
356
-  private function checkResponse ($string) {
356
+  private function checkResponse($string) {
357 357
     if (substr($string, 0, 3) !== '+OK') {
358 358
       $this->error = array(
359 359
         'error' => "Server reported an error: $string",
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
    * If debug is enabled, display the error message array
377 377
    * @access private
378 378
    */
379
-  private function displayErrors () {
379
+  private function displayErrors() {
380 380
     echo '<pre>';
381 381
 
382 382
     foreach ($this->error as $single_error) {
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
    * @param string $errfile
395 395
    * @param integer $errline
396 396
    */
397
-  private function catchWarning ($errno, $errstr, $errfile, $errline) {
397
+  private function catchWarning($errno, $errstr, $errfile, $errline) {
398 398
     $this->error[] = array(
399 399
       'error' => "Connecting to the POP3 server raised a PHP warning: ",
400 400
       'errno' => $errno,
Please login to merge, or discard this patch.
main/inc/lib/phpmailer/class.smtp.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -321,6 +321,7 @@  discard block
 block discarded – undo
321 321
    * SMTP CODE FAILURE: 451,554
322 322
    * SMTP CODE ERROR  : 500,501,503,421
323 323
    * @access public
324
+   * @param string $msg_data
324 325
    * @return bool
325 326
    */
326 327
   public function Data($msg_data) {
@@ -488,6 +489,8 @@  discard block
 block discarded – undo
488 489
   /**
489 490
    * Sends a HELO/EHLO command.
490 491
    * @access private
492
+   * @param string $hello
493
+   * @param string $host
491 494
    * @return bool
492 495
    */
493 496
   private function SendHello($hello, $host) {
@@ -528,6 +531,7 @@  discard block
 block discarded – undo
528 531
    * SMTP CODE SUCCESS: 552,451,452
529 532
    * SMTP CODE SUCCESS: 500,501,421
530 533
    * @access public
534
+   * @param string $from
531 535
    * @return bool
532 536
    */
533 537
   public function Mail($from) {
Please login to merge, or discard this patch.
Indentation   +429 added lines, -429 removed lines patch added patch discarded remove patch
@@ -47,130 +47,130 @@  discard block
 block discarded – undo
47 47
  */
48 48
 
49 49
 class SMTP {
50
-  /**
51
-   *  SMTP server port
52
-   *  @var int
53
-   */
54
-  public $SMTP_PORT = 25;
55
-
56
-  /**
57
-   *  SMTP reply line ending
58
-   *  @var string
59
-   */
60
-  public $CRLF = "\r\n";
61
-
62
-  /**
63
-   *  Sets whether debugging is turned on
64
-   *  @var bool
65
-   */
66
-  public $do_debug;       // the level of debug to perform
67
-
68
-  /**
69
-   *  Sets VERP use on/off (default is off)
70
-   *  @var bool
71
-   */
72
-  public $do_verp = false;
73
-
74
-  /////////////////////////////////////////////////
75
-  // PROPERTIES, PRIVATE AND PROTECTED
76
-  /////////////////////////////////////////////////
77
-
78
-  private $smtp_conn; // the socket to the server
79
-  private $error;     // error if any on the last call
80
-  private $helo_rply; // the reply the server sent to us for HELO
81
-
82
-  /**
83
-   * Initialize the class so that the data is in a known state.
84
-   * @access public
85
-   * @return void
86
-   */
87
-  public function __construct() {
50
+    /**
51
+     *  SMTP server port
52
+     *  @var int
53
+     */
54
+    public $SMTP_PORT = 25;
55
+
56
+    /**
57
+     *  SMTP reply line ending
58
+     *  @var string
59
+     */
60
+    public $CRLF = "\r\n";
61
+
62
+    /**
63
+     *  Sets whether debugging is turned on
64
+     *  @var bool
65
+     */
66
+    public $do_debug;       // the level of debug to perform
67
+
68
+    /**
69
+     *  Sets VERP use on/off (default is off)
70
+     *  @var bool
71
+     */
72
+    public $do_verp = false;
73
+
74
+    /////////////////////////////////////////////////
75
+    // PROPERTIES, PRIVATE AND PROTECTED
76
+    /////////////////////////////////////////////////
77
+
78
+    private $smtp_conn; // the socket to the server
79
+    private $error;     // error if any on the last call
80
+    private $helo_rply; // the reply the server sent to us for HELO
81
+
82
+    /**
83
+     * Initialize the class so that the data is in a known state.
84
+     * @access public
85
+     * @return void
86
+     */
87
+    public function __construct() {
88 88
     $this->smtp_conn = 0;
89 89
     $this->error = null;
90 90
     $this->helo_rply = null;
91 91
 
92 92
     $this->do_debug = 0;
93
-  }
94
-
95
-  /////////////////////////////////////////////////
96
-  // CONNECTION FUNCTIONS
97
-  /////////////////////////////////////////////////
98
-
99
-  /**
100
-   * Connect to the server specified on the port specified.
101
-   * If the port is not specified use the default SMTP_PORT.
102
-   * If tval is specified then a connection will try and be
103
-   * established with the server for that number of seconds.
104
-   * If tval is not specified the default is 30 seconds to
105
-   * try on the connection.
106
-   *
107
-   * SMTP CODE SUCCESS: 220
108
-   * SMTP CODE FAILURE: 421
109
-   * @access public
110
-   * @return bool
111
-   */
112
-  public function Connect($host, $port = 0, $tval = 30) {
93
+    }
94
+
95
+    /////////////////////////////////////////////////
96
+    // CONNECTION FUNCTIONS
97
+    /////////////////////////////////////////////////
98
+
99
+    /**
100
+     * Connect to the server specified on the port specified.
101
+     * If the port is not specified use the default SMTP_PORT.
102
+     * If tval is specified then a connection will try and be
103
+     * established with the server for that number of seconds.
104
+     * If tval is not specified the default is 30 seconds to
105
+     * try on the connection.
106
+     *
107
+     * SMTP CODE SUCCESS: 220
108
+     * SMTP CODE FAILURE: 421
109
+     * @access public
110
+     * @return bool
111
+     */
112
+    public function Connect($host, $port = 0, $tval = 30) {
113 113
     // set the error val to null so there is no confusion
114 114
     $this->error = null;
115 115
 
116 116
     // make sure we are __not__ connected
117 117
     if($this->connected()) {
118
-      // already connected, generate error
119
-      $this->error = array("error" => "Already connected to a server");
120
-      return false;
118
+        // already connected, generate error
119
+        $this->error = array("error" => "Already connected to a server");
120
+        return false;
121 121
     }
122 122
 
123 123
     if(empty($port)) {
124
-      $port = $this->SMTP_PORT;
124
+        $port = $this->SMTP_PORT;
125 125
     }
126 126
 
127 127
     // connect to the smtp server
128 128
     $this->smtp_conn = @fsockopen($host,    // the host of the server
129
-                                 $port,    // the port to use
130
-                                 $errno,   // error number if any
131
-                                 $errstr,  // error message if any
132
-                                 $tval);   // give up after ? secs
129
+                                    $port,    // the port to use
130
+                                    $errno,   // error number if any
131
+                                    $errstr,  // error message if any
132
+                                    $tval);   // give up after ? secs
133 133
     // verify we connected properly
134 134
     if(empty($this->smtp_conn)) {
135
-      $this->error = array("error" => "Failed to connect to server",
136
-                           "errno" => $errno,
137
-                           "errstr" => $errstr);
138
-      if($this->do_debug >= 1) {
135
+        $this->error = array("error" => "Failed to connect to server",
136
+                            "errno" => $errno,
137
+                            "errstr" => $errstr);
138
+        if($this->do_debug >= 1) {
139 139
         echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />';
140
-      }
141
-      return false;
140
+        }
141
+        return false;
142 142
     }
143 143
 
144 144
     // SMTP server can take longer to respond, give longer timeout for first read
145 145
     // Windows does not have support for this timeout function
146 146
     if(substr(PHP_OS, 0, 3) != "WIN")
147
-     socket_set_timeout($this->smtp_conn, $tval, 0);
147
+        socket_set_timeout($this->smtp_conn, $tval, 0);
148 148
 
149 149
     // get any announcement
150 150
     $announce = $this->get_lines();
151 151
 
152 152
     if($this->do_debug >= 2) {
153
-      echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />';
153
+        echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />';
154 154
     }
155 155
 
156 156
     return true;
157
-  }
158
-
159
-  /**
160
-   * Initiate a TLS communication with the server.
161
-   *
162
-   * SMTP CODE 220 Ready to start TLS
163
-   * SMTP CODE 501 Syntax error (no parameters allowed)
164
-   * SMTP CODE 454 TLS not available due to temporary reason
165
-   * @access public
166
-   * @return bool success
167
-   */
168
-  public function StartTLS() {
157
+    }
158
+
159
+    /**
160
+     * Initiate a TLS communication with the server.
161
+     *
162
+     * SMTP CODE 220 Ready to start TLS
163
+     * SMTP CODE 501 Syntax error (no parameters allowed)
164
+     * SMTP CODE 454 TLS not available due to temporary reason
165
+     * @access public
166
+     * @return bool success
167
+     */
168
+    public function StartTLS() {
169 169
     $this->error = null; # to avoid confusion
170 170
 
171 171
     if(!$this->connected()) {
172
-      $this->error = array("error" => "Called StartTLS() without being connected");
173
-      return false;
172
+        $this->error = array("error" => "Called StartTLS() without being connected");
173
+        return false;
174 174
     }
175 175
 
176 176
     fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
@@ -179,35 +179,35 @@  discard block
 block discarded – undo
179 179
     $code = substr($rply,0,3);
180 180
 
181 181
     if($this->do_debug >= 2) {
182
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
182
+        echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
183 183
     }
184 184
 
185 185
     if($code != 220) {
186
-      $this->error =
187
-         array("error"     => "STARTTLS not accepted from server",
188
-               "smtp_code" => $code,
189
-               "smtp_msg"  => substr($rply,4));
190
-      if($this->do_debug >= 1) {
186
+        $this->error =
187
+            array("error"     => "STARTTLS not accepted from server",
188
+                "smtp_code" => $code,
189
+                "smtp_msg"  => substr($rply,4));
190
+        if($this->do_debug >= 1) {
191 191
         echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
192
-      }
193
-      return false;
192
+        }
193
+        return false;
194 194
     }
195 195
 
196 196
     // Begin encrypted connection
197 197
     if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
198
-      return false;
198
+        return false;
199 199
     }
200 200
 
201 201
     return true;
202
-  }
203
-
204
-  /**
205
-   * Performs SMTP authentication.  Must be run after running the
206
-   * Hello() method.  Returns true if successfully authenticated.
207
-   * @access public
208
-   * @return bool
209
-   */
210
-  public function Authenticate($username, $password) {
202
+    }
203
+
204
+    /**
205
+     * Performs SMTP authentication.  Must be run after running the
206
+     * Hello() method.  Returns true if successfully authenticated.
207
+     * @access public
208
+     * @return bool
209
+     */
210
+    public function Authenticate($username, $password) {
211 211
     // Start authentication
212 212
     fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
213 213
 
@@ -215,14 +215,14 @@  discard block
 block discarded – undo
215 215
     $code = substr($rply,0,3);
216 216
 
217 217
     if($code != 334) {
218
-      $this->error =
218
+        $this->error =
219 219
         array("error" => "AUTH not accepted from server",
220
-              "smtp_code" => $code,
221
-              "smtp_msg" => substr($rply,4));
222
-      if($this->do_debug >= 1) {
220
+                "smtp_code" => $code,
221
+                "smtp_msg" => substr($rply,4));
222
+        if($this->do_debug >= 1) {
223 223
         echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
224
-      }
225
-      return false;
224
+        }
225
+        return false;
226 226
     }
227 227
 
228 228
     // Send encoded username
@@ -232,14 +232,14 @@  discard block
 block discarded – undo
232 232
     $code = substr($rply,0,3);
233 233
 
234 234
     if($code != 334) {
235
-      $this->error =
235
+        $this->error =
236 236
         array("error" => "Username not accepted from server",
237
-              "smtp_code" => $code,
238
-              "smtp_msg" => substr($rply,4));
239
-      if($this->do_debug >= 1) {
237
+                "smtp_code" => $code,
238
+                "smtp_msg" => substr($rply,4));
239
+        if($this->do_debug >= 1) {
240 240
         echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
241
-      }
242
-      return false;
241
+        }
242
+        return false;
243 243
     }
244 244
 
245 245
     // Send encoded password
@@ -249,87 +249,87 @@  discard block
 block discarded – undo
249 249
     $code = substr($rply,0,3);
250 250
 
251 251
     if($code != 235) {
252
-      $this->error =
252
+        $this->error =
253 253
         array("error" => "Password not accepted from server",
254
-              "smtp_code" => $code,
255
-              "smtp_msg" => substr($rply,4));
256
-      if($this->do_debug >= 1) {
254
+                "smtp_code" => $code,
255
+                "smtp_msg" => substr($rply,4));
256
+        if($this->do_debug >= 1) {
257 257
         echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
258
-      }
259
-      return false;
258
+        }
259
+        return false;
260 260
     }
261 261
 
262 262
     return true;
263
-  }
264
-
265
-  /**
266
-   * Returns true if connected to a server otherwise false
267
-   * @access public
268
-   * @return bool
269
-   */
270
-  public function Connected() {
263
+    }
264
+
265
+    /**
266
+     * Returns true if connected to a server otherwise false
267
+     * @access public
268
+     * @return bool
269
+     */
270
+    public function Connected() {
271 271
     if(!empty($this->smtp_conn)) {
272
-      $sock_status = socket_get_status($this->smtp_conn);
273
-      if($sock_status["eof"]) {
272
+        $sock_status = socket_get_status($this->smtp_conn);
273
+        if($sock_status["eof"]) {
274 274
         // the socket is valid but we are not connected
275 275
         if($this->do_debug >= 1) {
276 276
             echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected";
277 277
         }
278 278
         $this->Close();
279 279
         return false;
280
-      }
281
-      return true; // everything looks good
280
+        }
281
+        return true; // everything looks good
282 282
     }
283 283
     return false;
284
-  }
285
-
286
-  /**
287
-   * Closes the socket and cleans up the state of the class.
288
-   * It is not considered good to use this function without
289
-   * first trying to use QUIT.
290
-   * @access public
291
-   * @return void
292
-   */
293
-  public function Close() {
284
+    }
285
+
286
+    /**
287
+     * Closes the socket and cleans up the state of the class.
288
+     * It is not considered good to use this function without
289
+     * first trying to use QUIT.
290
+     * @access public
291
+     * @return void
292
+     */
293
+    public function Close() {
294 294
     $this->error = null; // so there is no confusion
295 295
     $this->helo_rply = null;
296 296
     if(!empty($this->smtp_conn)) {
297
-      // close the connection and cleanup
298
-      fclose($this->smtp_conn);
299
-      $this->smtp_conn = 0;
300
-    }
301
-  }
302
-
303
-  /////////////////////////////////////////////////
304
-  // SMTP COMMANDS
305
-  /////////////////////////////////////////////////
306
-
307
-  /**
308
-   * Issues a data command and sends the msg_data to the server
309
-   * finializing the mail transaction. $msg_data is the message
310
-   * that is to be send with the headers. Each header needs to be
311
-   * on a single line followed by a <CRLF> with the message headers
312
-   * and the message body being seperated by and additional <CRLF>.
313
-   *
314
-   * Implements rfc 821: DATA <CRLF>
315
-   *
316
-   * SMTP CODE INTERMEDIATE: 354
317
-   *     [data]
318
-   *     <CRLF>.<CRLF>
319
-   *     SMTP CODE SUCCESS: 250
320
-   *     SMTP CODE FAILURE: 552,554,451,452
321
-   * SMTP CODE FAILURE: 451,554
322
-   * SMTP CODE ERROR  : 500,501,503,421
323
-   * @access public
324
-   * @return bool
325
-   */
326
-  public function Data($msg_data) {
297
+        // close the connection and cleanup
298
+        fclose($this->smtp_conn);
299
+        $this->smtp_conn = 0;
300
+    }
301
+    }
302
+
303
+    /////////////////////////////////////////////////
304
+    // SMTP COMMANDS
305
+    /////////////////////////////////////////////////
306
+
307
+    /**
308
+     * Issues a data command and sends the msg_data to the server
309
+     * finializing the mail transaction. $msg_data is the message
310
+     * that is to be send with the headers. Each header needs to be
311
+     * on a single line followed by a <CRLF> with the message headers
312
+     * and the message body being seperated by and additional <CRLF>.
313
+     *
314
+     * Implements rfc 821: DATA <CRLF>
315
+     *
316
+     * SMTP CODE INTERMEDIATE: 354
317
+     *     [data]
318
+     *     <CRLF>.<CRLF>
319
+     *     SMTP CODE SUCCESS: 250
320
+     *     SMTP CODE FAILURE: 552,554,451,452
321
+     * SMTP CODE FAILURE: 451,554
322
+     * SMTP CODE ERROR  : 500,501,503,421
323
+     * @access public
324
+     * @return bool
325
+     */
326
+    public function Data($msg_data) {
327 327
     $this->error = null; // so no confusion is caused
328 328
 
329 329
     if(!$this->connected()) {
330
-      $this->error = array(
331
-              "error" => "Called Data() without being connected");
332
-      return false;
330
+        $this->error = array(
331
+                "error" => "Called Data() without being connected");
332
+        return false;
333 333
     }
334 334
 
335 335
     fputs($this->smtp_conn,"DATA" . $this->CRLF);
@@ -338,18 +338,18 @@  discard block
 block discarded – undo
338 338
     $code = substr($rply,0,3);
339 339
 
340 340
     if($this->do_debug >= 2) {
341
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
341
+        echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
342 342
     }
343 343
 
344 344
     if($code != 354) {
345
-      $this->error =
345
+        $this->error =
346 346
         array("error" => "DATA command not accepted from server",
347
-              "smtp_code" => $code,
348
-              "smtp_msg" => substr($rply,4));
349
-      if($this->do_debug >= 1) {
347
+                "smtp_code" => $code,
348
+                "smtp_msg" => substr($rply,4));
349
+        if($this->do_debug >= 1) {
350 350
         echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
351
-      }
352
-      return false;
351
+        }
352
+        return false;
353 353
     }
354 354
 
355 355
     /* the server is ready to accept data!
@@ -380,49 +380,49 @@  discard block
 block discarded – undo
380 380
     $field = substr($lines[0],0,strpos($lines[0],":"));
381 381
     $in_headers = false;
382 382
     if(!empty($field) && !strstr($field," ")) {
383
-      $in_headers = true;
383
+        $in_headers = true;
384 384
     }
385 385
 
386 386
     $max_line_length = 998; // used below; set here for ease in change
387 387
 
388 388
     while(list(,$line) = @each($lines)) {
389
-      $lines_out = null;
390
-      if($line == "" && $in_headers) {
389
+        $lines_out = null;
390
+        if($line == "" && $in_headers) {
391 391
         $in_headers = false;
392
-      }
393
-      // ok we need to break this line up into several smaller lines
394
-      while(strlen($line) > $max_line_length) {
392
+        }
393
+        // ok we need to break this line up into several smaller lines
394
+        while(strlen($line) > $max_line_length) {
395 395
         $pos = strrpos(substr($line,0,$max_line_length)," ");
396 396
 
397 397
         // Patch to fix DOS attack
398 398
         if(!$pos) {
399
-          $pos = $max_line_length - 1;
400
-          $lines_out[] = substr($line,0,$pos);
401
-          $line = substr($line,$pos);
399
+            $pos = $max_line_length - 1;
400
+            $lines_out[] = substr($line,0,$pos);
401
+            $line = substr($line,$pos);
402 402
         } else {
403
-          $lines_out[] = substr($line,0,$pos);
404
-          $line = substr($line,$pos + 1);
403
+            $lines_out[] = substr($line,0,$pos);
404
+            $line = substr($line,$pos + 1);
405 405
         }
406 406
 
407 407
         /* if processing headers add a LWSP-char to the front of new line
408 408
          * rfc 822 on long msg headers
409 409
          */
410 410
         if($in_headers) {
411
-          $line = "\t" . $line;
411
+            $line = "\t" . $line;
412 412
         }
413
-      }
414
-      $lines_out[] = $line;
413
+        }
414
+        $lines_out[] = $line;
415 415
 
416
-      // send the lines to the server
417
-      while(list(,$line_out) = @each($lines_out)) {
416
+        // send the lines to the server
417
+        while(list(,$line_out) = @each($lines_out)) {
418 418
         if(strlen($line_out) > 0)
419 419
         {
420
-          if(substr($line_out, 0, 1) == ".") {
420
+            if(substr($line_out, 0, 1) == ".") {
421 421
             $line_out = "." . $line_out;
422
-          }
422
+            }
423 423
         }
424 424
         fputs($this->smtp_conn,$line_out . $this->CRLF);
425
-      }
425
+        }
426 426
     }
427 427
 
428 428
     // message data has been sent
@@ -432,111 +432,111 @@  discard block
 block discarded – undo
432 432
     $code = substr($rply,0,3);
433 433
 
434 434
     if($this->do_debug >= 2) {
435
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
435
+        echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
436 436
     }
437 437
 
438 438
     if($code != 250) {
439
-      $this->error =
439
+        $this->error =
440 440
         array("error" => "DATA not accepted from server",
441
-              "smtp_code" => $code,
442
-              "smtp_msg" => substr($rply,4));
443
-      if($this->do_debug >= 1) {
441
+                "smtp_code" => $code,
442
+                "smtp_msg" => substr($rply,4));
443
+        if($this->do_debug >= 1) {
444 444
         echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
445
-      }
446
-      return false;
445
+        }
446
+        return false;
447 447
     }
448 448
     return true;
449
-  }
450
-
451
-  /**
452
-   * Sends the HELO command to the smtp server.
453
-   * This makes sure that we and the server are in
454
-   * the same known state.
455
-   *
456
-   * Implements from rfc 821: HELO <SP> <domain> <CRLF>
457
-   *
458
-   * SMTP CODE SUCCESS: 250
459
-   * SMTP CODE ERROR  : 500, 501, 504, 421
460
-   * @access public
461
-   * @return bool
462
-   */
463
-  public function Hello($host = '') {
449
+    }
450
+
451
+    /**
452
+     * Sends the HELO command to the smtp server.
453
+     * This makes sure that we and the server are in
454
+     * the same known state.
455
+     *
456
+     * Implements from rfc 821: HELO <SP> <domain> <CRLF>
457
+     *
458
+     * SMTP CODE SUCCESS: 250
459
+     * SMTP CODE ERROR  : 500, 501, 504, 421
460
+     * @access public
461
+     * @return bool
462
+     */
463
+    public function Hello($host = '') {
464 464
     $this->error = null; // so no confusion is caused
465 465
 
466 466
     if(!$this->connected()) {
467
-      $this->error = array(
467
+        $this->error = array(
468 468
             "error" => "Called Hello() without being connected");
469
-      return false;
469
+        return false;
470 470
     }
471 471
 
472 472
     // if hostname for HELO was not specified send default
473 473
     if(empty($host)) {
474
-      // determine appropriate default to send to server
475
-      $host = "localhost";
474
+        // determine appropriate default to send to server
475
+        $host = "localhost";
476 476
     }
477 477
 
478 478
     // Send extended hello first (RFC 2821)
479 479
     if(!$this->SendHello("EHLO", $host)) {
480
-      if(!$this->SendHello("HELO", $host)) {
480
+        if(!$this->SendHello("HELO", $host)) {
481 481
         return false;
482
-      }
482
+        }
483 483
     }
484 484
 
485 485
     return true;
486
-  }
487
-
488
-  /**
489
-   * Sends a HELO/EHLO command.
490
-   * @access private
491
-   * @return bool
492
-   */
493
-  private function SendHello($hello, $host) {
486
+    }
487
+
488
+    /**
489
+     * Sends a HELO/EHLO command.
490
+     * @access private
491
+     * @return bool
492
+     */
493
+    private function SendHello($hello, $host) {
494 494
     fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
495 495
 
496 496
     $rply = $this->get_lines();
497 497
     $code = substr($rply,0,3);
498 498
 
499 499
     if($this->do_debug >= 2) {
500
-      echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />';
500
+        echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />';
501 501
     }
502 502
 
503 503
     if($code != 250) {
504
-      $this->error =
504
+        $this->error =
505 505
         array("error" => $hello . " not accepted from server",
506
-              "smtp_code" => $code,
507
-              "smtp_msg" => substr($rply,4));
508
-      if($this->do_debug >= 1) {
506
+                "smtp_code" => $code,
507
+                "smtp_msg" => substr($rply,4));
508
+        if($this->do_debug >= 1) {
509 509
         echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
510
-      }
511
-      return false;
510
+        }
511
+        return false;
512 512
     }
513 513
 
514 514
     $this->helo_rply = $rply;
515 515
 
516 516
     return true;
517
-  }
518
-
519
-  /**
520
-   * Starts a mail transaction from the email address specified in
521
-   * $from. Returns true if successful or false otherwise. If True
522
-   * the mail transaction is started and then one or more Recipient
523
-   * commands may be called followed by a Data command.
524
-   *
525
-   * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
526
-   *
527
-   * SMTP CODE SUCCESS: 250
528
-   * SMTP CODE SUCCESS: 552,451,452
529
-   * SMTP CODE SUCCESS: 500,501,421
530
-   * @access public
531
-   * @return bool
532
-   */
533
-  public function Mail($from) {
517
+    }
518
+
519
+    /**
520
+     * Starts a mail transaction from the email address specified in
521
+     * $from. Returns true if successful or false otherwise. If True
522
+     * the mail transaction is started and then one or more Recipient
523
+     * commands may be called followed by a Data command.
524
+     *
525
+     * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
526
+     *
527
+     * SMTP CODE SUCCESS: 250
528
+     * SMTP CODE SUCCESS: 552,451,452
529
+     * SMTP CODE SUCCESS: 500,501,421
530
+     * @access public
531
+     * @return bool
532
+     */
533
+    public function Mail($from) {
534 534
     $this->error = null; // so no confusion is caused
535 535
 
536 536
     if(!$this->connected()) {
537
-      $this->error = array(
538
-              "error" => "Called Mail() without being connected");
539
-      return false;
537
+        $this->error = array(
538
+                "error" => "Called Mail() without being connected");
539
+        return false;
540 540
     }
541 541
 
542 542
     $useVerp = ($this->do_verp ? "XVERP" : "");
@@ -546,40 +546,40 @@  discard block
 block discarded – undo
546 546
     $code = substr($rply,0,3);
547 547
 
548 548
     if($this->do_debug >= 2) {
549
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
549
+        echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
550 550
     }
551 551
 
552 552
     if($code != 250) {
553
-      $this->error =
553
+        $this->error =
554 554
         array("error" => "MAIL not accepted from server",
555
-              "smtp_code" => $code,
556
-              "smtp_msg" => substr($rply,4));
557
-      if($this->do_debug >= 1) {
555
+                "smtp_code" => $code,
556
+                "smtp_msg" => substr($rply,4));
557
+        if($this->do_debug >= 1) {
558 558
         echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
559
-      }
560
-      return false;
559
+        }
560
+        return false;
561 561
     }
562 562
     return true;
563
-  }
564
-
565
-  /**
566
-   * Sends the quit command to the server and then closes the socket
567
-   * if there is no error or the $close_on_error argument is true.
568
-   *
569
-   * Implements from rfc 821: QUIT <CRLF>
570
-   *
571
-   * SMTP CODE SUCCESS: 221
572
-   * SMTP CODE ERROR  : 500
573
-   * @access public
574
-   * @return bool
575
-   */
576
-  public function Quit($close_on_error = true) {
563
+    }
564
+
565
+    /**
566
+     * Sends the quit command to the server and then closes the socket
567
+     * if there is no error or the $close_on_error argument is true.
568
+     *
569
+     * Implements from rfc 821: QUIT <CRLF>
570
+     *
571
+     * SMTP CODE SUCCESS: 221
572
+     * SMTP CODE ERROR  : 500
573
+     * @access public
574
+     * @return bool
575
+     */
576
+    public function Quit($close_on_error = true) {
577 577
     $this->error = null; // so there is no confusion
578 578
 
579 579
     if(!$this->connected()) {
580
-      $this->error = array(
581
-              "error" => "Called Quit() without being connected");
582
-      return false;
580
+        $this->error = array(
581
+                "error" => "Called Quit() without being connected");
582
+        return false;
583 583
     }
584 584
 
585 585
     // send the quit command to the server
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
     $byemsg = $this->get_lines();
590 590
 
591 591
     if($this->do_debug >= 2) {
592
-      echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />';
592
+        echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />';
593 593
     }
594 594
 
595 595
     $rval = true;
@@ -597,42 +597,42 @@  discard block
 block discarded – undo
597 597
 
598 598
     $code = substr($byemsg,0,3);
599 599
     if($code != 221) {
600
-      // use e as a tmp var cause Close will overwrite $this->error
601
-      $e = array("error" => "SMTP server rejected quit command",
602
-                 "smtp_code" => $code,
603
-                 "smtp_rply" => substr($byemsg,4));
604
-      $rval = false;
605
-      if($this->do_debug >= 1) {
600
+        // use e as a tmp var cause Close will overwrite $this->error
601
+        $e = array("error" => "SMTP server rejected quit command",
602
+                    "smtp_code" => $code,
603
+                    "smtp_rply" => substr($byemsg,4));
604
+        $rval = false;
605
+        if($this->do_debug >= 1) {
606 606
         echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />';
607
-      }
607
+        }
608 608
     }
609 609
 
610 610
     if(empty($e) || $close_on_error) {
611
-      $this->Close();
611
+        $this->Close();
612 612
     }
613 613
 
614 614
     return $rval;
615
-  }
616
-
617
-  /**
618
-   * Sends the command RCPT to the SMTP server with the TO: argument of $to.
619
-   * Returns true if the recipient was accepted false if it was rejected.
620
-   *
621
-   * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
622
-   *
623
-   * SMTP CODE SUCCESS: 250,251
624
-   * SMTP CODE FAILURE: 550,551,552,553,450,451,452
625
-   * SMTP CODE ERROR  : 500,501,503,421
626
-   * @access public
627
-   * @return bool
628
-   */
629
-  public function Recipient($to) {
615
+    }
616
+
617
+    /**
618
+     * Sends the command RCPT to the SMTP server with the TO: argument of $to.
619
+     * Returns true if the recipient was accepted false if it was rejected.
620
+     *
621
+     * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
622
+     *
623
+     * SMTP CODE SUCCESS: 250,251
624
+     * SMTP CODE FAILURE: 550,551,552,553,450,451,452
625
+     * SMTP CODE ERROR  : 500,501,503,421
626
+     * @access public
627
+     * @return bool
628
+     */
629
+    public function Recipient($to) {
630 630
     $this->error = null; // so no confusion is caused
631 631
 
632 632
     if(!$this->connected()) {
633
-      $this->error = array(
634
-              "error" => "Called Recipient() without being connected");
635
-      return false;
633
+        $this->error = array(
634
+                "error" => "Called Recipient() without being connected");
635
+        return false;
636 636
     }
637 637
 
638 638
     fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
@@ -641,41 +641,41 @@  discard block
 block discarded – undo
641 641
     $code = substr($rply,0,3);
642 642
 
643 643
     if($this->do_debug >= 2) {
644
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
644
+        echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
645 645
     }
646 646
 
647 647
     if($code != 250 && $code != 251) {
648
-      $this->error =
648
+        $this->error =
649 649
         array("error" => "RCPT not accepted from server",
650
-              "smtp_code" => $code,
651
-              "smtp_msg" => substr($rply,4));
652
-      if($this->do_debug >= 1) {
650
+                "smtp_code" => $code,
651
+                "smtp_msg" => substr($rply,4));
652
+        if($this->do_debug >= 1) {
653 653
         echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
654
-      }
655
-      return false;
654
+        }
655
+        return false;
656 656
     }
657 657
     return true;
658
-  }
659
-
660
-  /**
661
-   * Sends the RSET command to abort and transaction that is
662
-   * currently in progress. Returns true if successful false
663
-   * otherwise.
664
-   *
665
-   * Implements rfc 821: RSET <CRLF>
666
-   *
667
-   * SMTP CODE SUCCESS: 250
668
-   * SMTP CODE ERROR  : 500,501,504,421
669
-   * @access public
670
-   * @return bool
671
-   */
672
-  public function Reset() {
658
+    }
659
+
660
+    /**
661
+     * Sends the RSET command to abort and transaction that is
662
+     * currently in progress. Returns true if successful false
663
+     * otherwise.
664
+     *
665
+     * Implements rfc 821: RSET <CRLF>
666
+     *
667
+     * SMTP CODE SUCCESS: 250
668
+     * SMTP CODE ERROR  : 500,501,504,421
669
+     * @access public
670
+     * @return bool
671
+     */
672
+    public function Reset() {
673 673
     $this->error = null; // so no confusion is caused
674 674
 
675 675
     if(!$this->connected()) {
676
-      $this->error = array(
677
-              "error" => "Called Reset() without being connected");
678
-      return false;
676
+        $this->error = array(
677
+                "error" => "Called Reset() without being connected");
678
+        return false;
679 679
     }
680 680
 
681 681
     fputs($this->smtp_conn,"RSET" . $this->CRLF);
@@ -684,46 +684,46 @@  discard block
 block discarded – undo
684 684
     $code = substr($rply,0,3);
685 685
 
686 686
     if($this->do_debug >= 2) {
687
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
687
+        echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
688 688
     }
689 689
 
690 690
     if($code != 250) {
691
-      $this->error =
691
+        $this->error =
692 692
         array("error" => "RSET failed",
693
-              "smtp_code" => $code,
694
-              "smtp_msg" => substr($rply,4));
695
-      if($this->do_debug >= 1) {
693
+                "smtp_code" => $code,
694
+                "smtp_msg" => substr($rply,4));
695
+        if($this->do_debug >= 1) {
696 696
         echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
697
-      }
698
-      return false;
697
+        }
698
+        return false;
699 699
     }
700 700
 
701 701
     return true;
702
-  }
703
-
704
-  /**
705
-   * Starts a mail transaction from the email address specified in
706
-   * $from. Returns true if successful or false otherwise. If True
707
-   * the mail transaction is started and then one or more Recipient
708
-   * commands may be called followed by a Data command. This command
709
-   * will send the message to the users terminal if they are logged
710
-   * in and send them an email.
711
-   *
712
-   * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
713
-   *
714
-   * SMTP CODE SUCCESS: 250
715
-   * SMTP CODE SUCCESS: 552,451,452
716
-   * SMTP CODE SUCCESS: 500,501,502,421
717
-   * @access public
718
-   * @return bool
719
-   */
720
-  public function SendAndMail($from) {
702
+    }
703
+
704
+    /**
705
+     * Starts a mail transaction from the email address specified in
706
+     * $from. Returns true if successful or false otherwise. If True
707
+     * the mail transaction is started and then one or more Recipient
708
+     * commands may be called followed by a Data command. This command
709
+     * will send the message to the users terminal if they are logged
710
+     * in and send them an email.
711
+     *
712
+     * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
713
+     *
714
+     * SMTP CODE SUCCESS: 250
715
+     * SMTP CODE SUCCESS: 552,451,452
716
+     * SMTP CODE SUCCESS: 500,501,502,421
717
+     * @access public
718
+     * @return bool
719
+     */
720
+    public function SendAndMail($from) {
721 721
     $this->error = null; // so no confusion is caused
722 722
 
723 723
     if(!$this->connected()) {
724
-      $this->error = array(
725
-          "error" => "Called SendAndMail() without being connected");
726
-      return false;
724
+        $this->error = array(
725
+            "error" => "Called SendAndMail() without being connected");
726
+        return false;
727 727
     }
728 728
 
729 729
     fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
@@ -732,82 +732,82 @@  discard block
 block discarded – undo
732 732
     $code = substr($rply,0,3);
733 733
 
734 734
     if($this->do_debug >= 2) {
735
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
735
+        echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
736 736
     }
737 737
 
738 738
     if($code != 250) {
739
-      $this->error =
739
+        $this->error =
740 740
         array("error" => "SAML not accepted from server",
741
-              "smtp_code" => $code,
742
-              "smtp_msg" => substr($rply,4));
743
-      if($this->do_debug >= 1) {
741
+                "smtp_code" => $code,
742
+                "smtp_msg" => substr($rply,4));
743
+        if($this->do_debug >= 1) {
744 744
         echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
745
-      }
746
-      return false;
745
+        }
746
+        return false;
747 747
     }
748 748
     return true;
749
-  }
750
-
751
-  /**
752
-   * This is an optional command for SMTP that this class does not
753
-   * support. This method is here to make the RFC821 Definition
754
-   * complete for this class and __may__ be implimented in the future
755
-   *
756
-   * Implements from rfc 821: TURN <CRLF>
757
-   *
758
-   * SMTP CODE SUCCESS: 250
759
-   * SMTP CODE FAILURE: 502
760
-   * SMTP CODE ERROR  : 500, 503
761
-   * @access public
762
-   * @return bool
763
-   */
764
-  public function Turn() {
749
+    }
750
+
751
+    /**
752
+     * This is an optional command for SMTP that this class does not
753
+     * support. This method is here to make the RFC821 Definition
754
+     * complete for this class and __may__ be implimented in the future
755
+     *
756
+     * Implements from rfc 821: TURN <CRLF>
757
+     *
758
+     * SMTP CODE SUCCESS: 250
759
+     * SMTP CODE FAILURE: 502
760
+     * SMTP CODE ERROR  : 500, 503
761
+     * @access public
762
+     * @return bool
763
+     */
764
+    public function Turn() {
765 765
     $this->error = array("error" => "This method, TURN, of the SMTP ".
766 766
                                     "is not implemented");
767 767
     if($this->do_debug >= 1) {
768
-      echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />';
768
+        echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />';
769 769
     }
770 770
     return false;
771
-  }
772
-
773
-  /**
774
-  * Get the current error
775
-  * @access public
776
-  * @return array
777
-  */
778
-  public function getError() {
771
+    }
772
+
773
+    /**
774
+     * Get the current error
775
+     * @access public
776
+     * @return array
777
+     */
778
+    public function getError() {
779 779
     return $this->error;
780
-  }
781
-
782
-  /////////////////////////////////////////////////
783
-  // INTERNAL FUNCTIONS
784
-  /////////////////////////////////////////////////
785
-
786
-  /**
787
-   * Read in as many lines as possible
788
-   * either before eof or socket timeout occurs on the operation.
789
-   * With SMTP we can tell if we have more lines to read if the
790
-   * 4th character is '-' symbol. If it is a space then we don't
791
-   * need to read anything else.
792
-   * @access private
793
-   * @return string
794
-   */
795
-  private function get_lines() {
780
+    }
781
+
782
+    /////////////////////////////////////////////////
783
+    // INTERNAL FUNCTIONS
784
+    /////////////////////////////////////////////////
785
+
786
+    /**
787
+     * Read in as many lines as possible
788
+     * either before eof or socket timeout occurs on the operation.
789
+     * With SMTP we can tell if we have more lines to read if the
790
+     * 4th character is '-' symbol. If it is a space then we don't
791
+     * need to read anything else.
792
+     * @access private
793
+     * @return string
794
+     */
795
+    private function get_lines() {
796 796
     $data = "";
797 797
     while($str = @fgets($this->smtp_conn,515)) {
798
-      if($this->do_debug >= 4) {
798
+        if($this->do_debug >= 4) {
799 799
         echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />';
800 800
         echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />';
801
-      }
802
-      $data .= $str;
803
-      if($this->do_debug >= 4) {
801
+        }
802
+        $data .= $str;
803
+        if($this->do_debug >= 4) {
804 804
         echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />';
805
-      }
806
-      // if 4th character is a space, we are done reading, break the loop
807
-      if(substr($str,3,1) == " ") { break; }
805
+        }
806
+        // if 4th character is a space, we are done reading, break the loop
807
+        if(substr($str,3,1) == " ") { break; }
808 808
     }
809 809
     return $data;
810
-  }
810
+    }
811 811
 
812 812
 }
813 813
 
Please login to merge, or discard this patch.
Spacing   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
    *  Sets whether debugging is turned on
64 64
    *  @var bool
65 65
    */
66
-  public $do_debug;       // the level of debug to perform
66
+  public $do_debug; // the level of debug to perform
67 67
 
68 68
   /**
69 69
    *  Sets VERP use on/off (default is off)
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
   /////////////////////////////////////////////////
77 77
 
78 78
   private $smtp_conn; // the socket to the server
79
-  private $error;     // error if any on the last call
79
+  private $error; // error if any on the last call
80 80
   private $helo_rply; // the reply the server sent to us for HELO
81 81
 
82 82
   /**
@@ -114,43 +114,43 @@  discard block
 block discarded – undo
114 114
     $this->error = null;
115 115
 
116 116
     // make sure we are __not__ connected
117
-    if($this->connected()) {
117
+    if ($this->connected()) {
118 118
       // already connected, generate error
119 119
       $this->error = array("error" => "Already connected to a server");
120 120
       return false;
121 121
     }
122 122
 
123
-    if(empty($port)) {
123
+    if (empty($port)) {
124 124
       $port = $this->SMTP_PORT;
125 125
     }
126 126
 
127 127
     // connect to the smtp server
128
-    $this->smtp_conn = @fsockopen($host,    // the host of the server
129
-                                 $port,    // the port to use
130
-                                 $errno,   // error number if any
131
-                                 $errstr,  // error message if any
132
-                                 $tval);   // give up after ? secs
128
+    $this->smtp_conn = @fsockopen($host, // the host of the server
129
+                                 $port, // the port to use
130
+                                 $errno, // error number if any
131
+                                 $errstr, // error message if any
132
+                                 $tval); // give up after ? secs
133 133
     // verify we connected properly
134
-    if(empty($this->smtp_conn)) {
134
+    if (empty($this->smtp_conn)) {
135 135
       $this->error = array("error" => "Failed to connect to server",
136 136
                            "errno" => $errno,
137 137
                            "errstr" => $errstr);
138
-      if($this->do_debug >= 1) {
139
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />';
138
+      if ($this->do_debug >= 1) {
139
+        echo "SMTP -> ERROR: ".$this->error["error"].": $errstr ($errno)".$this->CRLF.'<br />';
140 140
       }
141 141
       return false;
142 142
     }
143 143
 
144 144
     // SMTP server can take longer to respond, give longer timeout for first read
145 145
     // Windows does not have support for this timeout function
146
-    if(substr(PHP_OS, 0, 3) != "WIN")
146
+    if (substr(PHP_OS, 0, 3) != "WIN")
147 147
      socket_set_timeout($this->smtp_conn, $tval, 0);
148 148
 
149 149
     // get any announcement
150 150
     $announce = $this->get_lines();
151 151
 
152
-    if($this->do_debug >= 2) {
153
-      echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />';
152
+    if ($this->do_debug >= 2) {
153
+      echo "SMTP -> FROM SERVER:".$announce.$this->CRLF.'<br />';
154 154
     }
155 155
 
156 156
     return true;
@@ -168,33 +168,33 @@  discard block
 block discarded – undo
168 168
   public function StartTLS() {
169 169
     $this->error = null; # to avoid confusion
170 170
 
171
-    if(!$this->connected()) {
171
+    if (!$this->connected()) {
172 172
       $this->error = array("error" => "Called StartTLS() without being connected");
173 173
       return false;
174 174
     }
175 175
 
176
-    fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
176
+    fputs($this->smtp_conn, "STARTTLS".$this->CRLF);
177 177
 
178 178
     $rply = $this->get_lines();
179
-    $code = substr($rply,0,3);
179
+    $code = substr($rply, 0, 3);
180 180
 
181
-    if($this->do_debug >= 2) {
182
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
181
+    if ($this->do_debug >= 2) {
182
+      echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />';
183 183
     }
184 184
 
185
-    if($code != 220) {
185
+    if ($code != 220) {
186 186
       $this->error =
187 187
          array("error"     => "STARTTLS not accepted from server",
188 188
                "smtp_code" => $code,
189
-               "smtp_msg"  => substr($rply,4));
190
-      if($this->do_debug >= 1) {
191
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
189
+               "smtp_msg"  => substr($rply, 4));
190
+      if ($this->do_debug >= 1) {
191
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
192 192
       }
193 193
       return false;
194 194
     }
195 195
 
196 196
     // Begin encrypted connection
197
-    if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
197
+    if (!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
198 198
       return false;
199 199
     }
200 200
 
@@ -209,52 +209,52 @@  discard block
 block discarded – undo
209 209
    */
210 210
   public function Authenticate($username, $password) {
211 211
     // Start authentication
212
-    fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
212
+    fputs($this->smtp_conn, "AUTH LOGIN".$this->CRLF);
213 213
 
214 214
     $rply = $this->get_lines();
215
-    $code = substr($rply,0,3);
215
+    $code = substr($rply, 0, 3);
216 216
 
217
-    if($code != 334) {
217
+    if ($code != 334) {
218 218
       $this->error =
219 219
         array("error" => "AUTH not accepted from server",
220 220
               "smtp_code" => $code,
221
-              "smtp_msg" => substr($rply,4));
222
-      if($this->do_debug >= 1) {
223
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
221
+              "smtp_msg" => substr($rply, 4));
222
+      if ($this->do_debug >= 1) {
223
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
224 224
       }
225 225
       return false;
226 226
     }
227 227
 
228 228
     // Send encoded username
229
-    fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
229
+    fputs($this->smtp_conn, base64_encode($username).$this->CRLF);
230 230
 
231 231
     $rply = $this->get_lines();
232
-    $code = substr($rply,0,3);
232
+    $code = substr($rply, 0, 3);
233 233
 
234
-    if($code != 334) {
234
+    if ($code != 334) {
235 235
       $this->error =
236 236
         array("error" => "Username not accepted from server",
237 237
               "smtp_code" => $code,
238
-              "smtp_msg" => substr($rply,4));
239
-      if($this->do_debug >= 1) {
240
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
238
+              "smtp_msg" => substr($rply, 4));
239
+      if ($this->do_debug >= 1) {
240
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
241 241
       }
242 242
       return false;
243 243
     }
244 244
 
245 245
     // Send encoded password
246
-    fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
246
+    fputs($this->smtp_conn, base64_encode($password).$this->CRLF);
247 247
 
248 248
     $rply = $this->get_lines();
249
-    $code = substr($rply,0,3);
249
+    $code = substr($rply, 0, 3);
250 250
 
251
-    if($code != 235) {
251
+    if ($code != 235) {
252 252
       $this->error =
253 253
         array("error" => "Password not accepted from server",
254 254
               "smtp_code" => $code,
255
-              "smtp_msg" => substr($rply,4));
256
-      if($this->do_debug >= 1) {
257
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
255
+              "smtp_msg" => substr($rply, 4));
256
+      if ($this->do_debug >= 1) {
257
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
258 258
       }
259 259
       return false;
260 260
     }
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
    * @return bool
269 269
    */
270 270
   public function Connected() {
271
-    if(!empty($this->smtp_conn)) {
271
+    if (!empty($this->smtp_conn)) {
272 272
       $sock_status = socket_get_status($this->smtp_conn);
273
-      if($sock_status["eof"]) {
273
+      if ($sock_status["eof"]) {
274 274
         // the socket is valid but we are not connected
275
-        if($this->do_debug >= 1) {
276
-            echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected";
275
+        if ($this->do_debug >= 1) {
276
+            echo "SMTP -> NOTICE:".$this->CRLF."EOF caught while checking if connected";
277 277
         }
278 278
         $this->Close();
279 279
         return false;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
   public function Close() {
294 294
     $this->error = null; // so there is no confusion
295 295
     $this->helo_rply = null;
296
-    if(!empty($this->smtp_conn)) {
296
+    if (!empty($this->smtp_conn)) {
297 297
       // close the connection and cleanup
298 298
       fclose($this->smtp_conn);
299 299
       $this->smtp_conn = 0;
@@ -326,28 +326,28 @@  discard block
 block discarded – undo
326 326
   public function Data($msg_data) {
327 327
     $this->error = null; // so no confusion is caused
328 328
 
329
-    if(!$this->connected()) {
329
+    if (!$this->connected()) {
330 330
       $this->error = array(
331 331
               "error" => "Called Data() without being connected");
332 332
       return false;
333 333
     }
334 334
 
335
-    fputs($this->smtp_conn,"DATA" . $this->CRLF);
335
+    fputs($this->smtp_conn, "DATA".$this->CRLF);
336 336
 
337 337
     $rply = $this->get_lines();
338
-    $code = substr($rply,0,3);
338
+    $code = substr($rply, 0, 3);
339 339
 
340
-    if($this->do_debug >= 2) {
341
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
340
+    if ($this->do_debug >= 2) {
341
+      echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />';
342 342
     }
343 343
 
344
-    if($code != 354) {
344
+    if ($code != 354) {
345 345
       $this->error =
346 346
         array("error" => "DATA command not accepted from server",
347 347
               "smtp_code" => $code,
348
-              "smtp_msg" => substr($rply,4));
349
-      if($this->do_debug >= 1) {
350
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
348
+              "smtp_msg" => substr($rply, 4));
349
+      if ($this->do_debug >= 1) {
350
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
351 351
       }
352 352
       return false;
353 353
     }
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
      */
365 365
 
366 366
     // normalize the line breaks so we know the explode works
367
-    $msg_data = str_replace("\r\n","\n",$msg_data);
368
-    $msg_data = str_replace("\r","\n",$msg_data);
369
-    $lines = explode("\n",$msg_data);
367
+    $msg_data = str_replace("\r\n", "\n", $msg_data);
368
+    $msg_data = str_replace("\r", "\n", $msg_data);
369
+    $lines = explode("\n", $msg_data);
370 370
 
371 371
     /* we need to find a good way to determine is headers are
372 372
      * in the msg_data or if it is a straight msg body
@@ -377,71 +377,71 @@  discard block
 block discarded – undo
377 377
      * headers.
378 378
      */
379 379
 
380
-    $field = substr($lines[0],0,strpos($lines[0],":"));
380
+    $field = substr($lines[0], 0, strpos($lines[0], ":"));
381 381
     $in_headers = false;
382
-    if(!empty($field) && !strstr($field," ")) {
382
+    if (!empty($field) && !strstr($field, " ")) {
383 383
       $in_headers = true;
384 384
     }
385 385
 
386 386
     $max_line_length = 998; // used below; set here for ease in change
387 387
 
388
-    while(list(,$line) = @each($lines)) {
388
+    while (list(,$line) = @each($lines)) {
389 389
       $lines_out = null;
390
-      if($line == "" && $in_headers) {
390
+      if ($line == "" && $in_headers) {
391 391
         $in_headers = false;
392 392
       }
393 393
       // ok we need to break this line up into several smaller lines
394
-      while(strlen($line) > $max_line_length) {
395
-        $pos = strrpos(substr($line,0,$max_line_length)," ");
394
+      while (strlen($line) > $max_line_length) {
395
+        $pos = strrpos(substr($line, 0, $max_line_length), " ");
396 396
 
397 397
         // Patch to fix DOS attack
398
-        if(!$pos) {
398
+        if (!$pos) {
399 399
           $pos = $max_line_length - 1;
400
-          $lines_out[] = substr($line,0,$pos);
401
-          $line = substr($line,$pos);
400
+          $lines_out[] = substr($line, 0, $pos);
401
+          $line = substr($line, $pos);
402 402
         } else {
403
-          $lines_out[] = substr($line,0,$pos);
404
-          $line = substr($line,$pos + 1);
403
+          $lines_out[] = substr($line, 0, $pos);
404
+          $line = substr($line, $pos + 1);
405 405
         }
406 406
 
407 407
         /* if processing headers add a LWSP-char to the front of new line
408 408
          * rfc 822 on long msg headers
409 409
          */
410
-        if($in_headers) {
411
-          $line = "\t" . $line;
410
+        if ($in_headers) {
411
+          $line = "\t".$line;
412 412
         }
413 413
       }
414 414
       $lines_out[] = $line;
415 415
 
416 416
       // send the lines to the server
417
-      while(list(,$line_out) = @each($lines_out)) {
418
-        if(strlen($line_out) > 0)
417
+      while (list(,$line_out) = @each($lines_out)) {
418
+        if (strlen($line_out) > 0)
419 419
         {
420
-          if(substr($line_out, 0, 1) == ".") {
421
-            $line_out = "." . $line_out;
420
+          if (substr($line_out, 0, 1) == ".") {
421
+            $line_out = ".".$line_out;
422 422
           }
423 423
         }
424
-        fputs($this->smtp_conn,$line_out . $this->CRLF);
424
+        fputs($this->smtp_conn, $line_out.$this->CRLF);
425 425
       }
426 426
     }
427 427
 
428 428
     // message data has been sent
429
-    fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
429
+    fputs($this->smtp_conn, $this->CRLF.".".$this->CRLF);
430 430
 
431 431
     $rply = $this->get_lines();
432
-    $code = substr($rply,0,3);
432
+    $code = substr($rply, 0, 3);
433 433
 
434
-    if($this->do_debug >= 2) {
435
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
434
+    if ($this->do_debug >= 2) {
435
+      echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />';
436 436
     }
437 437
 
438
-    if($code != 250) {
438
+    if ($code != 250) {
439 439
       $this->error =
440 440
         array("error" => "DATA not accepted from server",
441 441
               "smtp_code" => $code,
442
-              "smtp_msg" => substr($rply,4));
443
-      if($this->do_debug >= 1) {
444
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
442
+              "smtp_msg" => substr($rply, 4));
443
+      if ($this->do_debug >= 1) {
444
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
445 445
       }
446 446
       return false;
447 447
     }
@@ -463,21 +463,21 @@  discard block
 block discarded – undo
463 463
   public function Hello($host = '') {
464 464
     $this->error = null; // so no confusion is caused
465 465
 
466
-    if(!$this->connected()) {
466
+    if (!$this->connected()) {
467 467
       $this->error = array(
468 468
             "error" => "Called Hello() without being connected");
469 469
       return false;
470 470
     }
471 471
 
472 472
     // if hostname for HELO was not specified send default
473
-    if(empty($host)) {
473
+    if (empty($host)) {
474 474
       // determine appropriate default to send to server
475 475
       $host = "localhost";
476 476
     }
477 477
 
478 478
     // Send extended hello first (RFC 2821)
479
-    if(!$this->SendHello("EHLO", $host)) {
480
-      if(!$this->SendHello("HELO", $host)) {
479
+    if (!$this->SendHello("EHLO", $host)) {
480
+      if (!$this->SendHello("HELO", $host)) {
481 481
         return false;
482 482
       }
483 483
     }
@@ -491,22 +491,22 @@  discard block
 block discarded – undo
491 491
    * @return bool
492 492
    */
493 493
   private function SendHello($hello, $host) {
494
-    fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
494
+    fputs($this->smtp_conn, $hello." ".$host.$this->CRLF);
495 495
 
496 496
     $rply = $this->get_lines();
497
-    $code = substr($rply,0,3);
497
+    $code = substr($rply, 0, 3);
498 498
 
499
-    if($this->do_debug >= 2) {
500
-      echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />';
499
+    if ($this->do_debug >= 2) {
500
+      echo "SMTP -> FROM SERVER: ".$rply.$this->CRLF.'<br />';
501 501
     }
502 502
 
503
-    if($code != 250) {
503
+    if ($code != 250) {
504 504
       $this->error =
505
-        array("error" => $hello . " not accepted from server",
505
+        array("error" => $hello." not accepted from server",
506 506
               "smtp_code" => $code,
507
-              "smtp_msg" => substr($rply,4));
508
-      if($this->do_debug >= 1) {
509
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
507
+              "smtp_msg" => substr($rply, 4));
508
+      if ($this->do_debug >= 1) {
509
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
510 510
       }
511 511
       return false;
512 512
     }
@@ -533,29 +533,29 @@  discard block
 block discarded – undo
533 533
   public function Mail($from) {
534 534
     $this->error = null; // so no confusion is caused
535 535
 
536
-    if(!$this->connected()) {
536
+    if (!$this->connected()) {
537 537
       $this->error = array(
538 538
               "error" => "Called Mail() without being connected");
539 539
       return false;
540 540
     }
541 541
 
542 542
     $useVerp = ($this->do_verp ? "XVERP" : "");
543
-    fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
543
+    fputs($this->smtp_conn, "MAIL FROM:<".$from.">".$useVerp.$this->CRLF);
544 544
 
545 545
     $rply = $this->get_lines();
546
-    $code = substr($rply,0,3);
546
+    $code = substr($rply, 0, 3);
547 547
 
548
-    if($this->do_debug >= 2) {
549
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
548
+    if ($this->do_debug >= 2) {
549
+      echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />';
550 550
     }
551 551
 
552
-    if($code != 250) {
552
+    if ($code != 250) {
553 553
       $this->error =
554 554
         array("error" => "MAIL not accepted from server",
555 555
               "smtp_code" => $code,
556
-              "smtp_msg" => substr($rply,4));
557
-      if($this->do_debug >= 1) {
558
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
556
+              "smtp_msg" => substr($rply, 4));
557
+      if ($this->do_debug >= 1) {
558
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
559 559
       }
560 560
       return false;
561 561
     }
@@ -576,38 +576,38 @@  discard block
 block discarded – undo
576 576
   public function Quit($close_on_error = true) {
577 577
     $this->error = null; // so there is no confusion
578 578
 
579
-    if(!$this->connected()) {
579
+    if (!$this->connected()) {
580 580
       $this->error = array(
581 581
               "error" => "Called Quit() without being connected");
582 582
       return false;
583 583
     }
584 584
 
585 585
     // send the quit command to the server
586
-    fputs($this->smtp_conn,"quit" . $this->CRLF);
586
+    fputs($this->smtp_conn, "quit".$this->CRLF);
587 587
 
588 588
     // get any good-bye messages
589 589
     $byemsg = $this->get_lines();
590 590
 
591
-    if($this->do_debug >= 2) {
592
-      echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />';
591
+    if ($this->do_debug >= 2) {
592
+      echo "SMTP -> FROM SERVER:".$byemsg.$this->CRLF.'<br />';
593 593
     }
594 594
 
595 595
     $rval = true;
596 596
     $e = null;
597 597
 
598
-    $code = substr($byemsg,0,3);
599
-    if($code != 221) {
598
+    $code = substr($byemsg, 0, 3);
599
+    if ($code != 221) {
600 600
       // use e as a tmp var cause Close will overwrite $this->error
601 601
       $e = array("error" => "SMTP server rejected quit command",
602 602
                  "smtp_code" => $code,
603
-                 "smtp_rply" => substr($byemsg,4));
603
+                 "smtp_rply" => substr($byemsg, 4));
604 604
       $rval = false;
605
-      if($this->do_debug >= 1) {
606
-        echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />';
605
+      if ($this->do_debug >= 1) {
606
+        echo "SMTP -> ERROR: ".$e["error"].": ".$byemsg.$this->CRLF.'<br />';
607 607
       }
608 608
     }
609 609
 
610
-    if(empty($e) || $close_on_error) {
610
+    if (empty($e) || $close_on_error) {
611 611
       $this->Close();
612 612
     }
613 613
 
@@ -629,28 +629,28 @@  discard block
 block discarded – undo
629 629
   public function Recipient($to) {
630 630
     $this->error = null; // so no confusion is caused
631 631
 
632
-    if(!$this->connected()) {
632
+    if (!$this->connected()) {
633 633
       $this->error = array(
634 634
               "error" => "Called Recipient() without being connected");
635 635
       return false;
636 636
     }
637 637
 
638
-    fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
638
+    fputs($this->smtp_conn, "RCPT TO:<".$to.">".$this->CRLF);
639 639
 
640 640
     $rply = $this->get_lines();
641
-    $code = substr($rply,0,3);
641
+    $code = substr($rply, 0, 3);
642 642
 
643
-    if($this->do_debug >= 2) {
644
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
643
+    if ($this->do_debug >= 2) {
644
+      echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />';
645 645
     }
646 646
 
647
-    if($code != 250 && $code != 251) {
647
+    if ($code != 250 && $code != 251) {
648 648
       $this->error =
649 649
         array("error" => "RCPT not accepted from server",
650 650
               "smtp_code" => $code,
651
-              "smtp_msg" => substr($rply,4));
652
-      if($this->do_debug >= 1) {
653
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
651
+              "smtp_msg" => substr($rply, 4));
652
+      if ($this->do_debug >= 1) {
653
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
654 654
       }
655 655
       return false;
656 656
     }
@@ -672,28 +672,28 @@  discard block
 block discarded – undo
672 672
   public function Reset() {
673 673
     $this->error = null; // so no confusion is caused
674 674
 
675
-    if(!$this->connected()) {
675
+    if (!$this->connected()) {
676 676
       $this->error = array(
677 677
               "error" => "Called Reset() without being connected");
678 678
       return false;
679 679
     }
680 680
 
681
-    fputs($this->smtp_conn,"RSET" . $this->CRLF);
681
+    fputs($this->smtp_conn, "RSET".$this->CRLF);
682 682
 
683 683
     $rply = $this->get_lines();
684
-    $code = substr($rply,0,3);
684
+    $code = substr($rply, 0, 3);
685 685
 
686
-    if($this->do_debug >= 2) {
687
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
686
+    if ($this->do_debug >= 2) {
687
+      echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />';
688 688
     }
689 689
 
690
-    if($code != 250) {
690
+    if ($code != 250) {
691 691
       $this->error =
692 692
         array("error" => "RSET failed",
693 693
               "smtp_code" => $code,
694
-              "smtp_msg" => substr($rply,4));
695
-      if($this->do_debug >= 1) {
696
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
694
+              "smtp_msg" => substr($rply, 4));
695
+      if ($this->do_debug >= 1) {
696
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
697 697
       }
698 698
       return false;
699 699
     }
@@ -720,28 +720,28 @@  discard block
 block discarded – undo
720 720
   public function SendAndMail($from) {
721 721
     $this->error = null; // so no confusion is caused
722 722
 
723
-    if(!$this->connected()) {
723
+    if (!$this->connected()) {
724 724
       $this->error = array(
725 725
           "error" => "Called SendAndMail() without being connected");
726 726
       return false;
727 727
     }
728 728
 
729
-    fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
729
+    fputs($this->smtp_conn, "SAML FROM:".$from.$this->CRLF);
730 730
 
731 731
     $rply = $this->get_lines();
732
-    $code = substr($rply,0,3);
732
+    $code = substr($rply, 0, 3);
733 733
 
734
-    if($this->do_debug >= 2) {
735
-      echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
734
+    if ($this->do_debug >= 2) {
735
+      echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />';
736 736
     }
737 737
 
738
-    if($code != 250) {
738
+    if ($code != 250) {
739 739
       $this->error =
740 740
         array("error" => "SAML not accepted from server",
741 741
               "smtp_code" => $code,
742
-              "smtp_msg" => substr($rply,4));
743
-      if($this->do_debug >= 1) {
744
-        echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
742
+              "smtp_msg" => substr($rply, 4));
743
+      if ($this->do_debug >= 1) {
744
+        echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />';
745 745
       }
746 746
       return false;
747 747
     }
@@ -764,8 +764,8 @@  discard block
 block discarded – undo
764 764
   public function Turn() {
765 765
     $this->error = array("error" => "This method, TURN, of the SMTP ".
766 766
                                     "is not implemented");
767
-    if($this->do_debug >= 1) {
768
-      echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />';
767
+    if ($this->do_debug >= 1) {
768
+      echo "SMTP -> NOTICE: ".$this->error["error"].$this->CRLF.'<br />';
769 769
     }
770 770
     return false;
771 771
   }
@@ -794,17 +794,17 @@  discard block
 block discarded – undo
794 794
    */
795 795
   private function get_lines() {
796 796
     $data = "";
797
-    while($str = @fgets($this->smtp_conn,515)) {
798
-      if($this->do_debug >= 4) {
799
-        echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />';
800
-        echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />';
797
+    while ($str = @fgets($this->smtp_conn, 515)) {
798
+      if ($this->do_debug >= 4) {
799
+        echo "SMTP -> get_lines(): \$data was \"$data\"".$this->CRLF.'<br />';
800
+        echo "SMTP -> get_lines(): \$str is \"$str\"".$this->CRLF.'<br />';
801 801
       }
802 802
       $data .= $str;
803
-      if($this->do_debug >= 4) {
804
-        echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />';
803
+      if ($this->do_debug >= 4) {
804
+        echo "SMTP -> get_lines(): \$data is \"$data\"".$this->CRLF.'<br />';
805 805
       }
806 806
       // if 4th character is a space, we are done reading, break the loop
807
-      if(substr($str,3,1) == " ") { break; }
807
+      if (substr($str, 3, 1) == " ") { break; }
808 808
     }
809 809
     return $data;
810 810
   }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -143,8 +143,9 @@
 block discarded – undo
143 143
 
144 144
     // SMTP server can take longer to respond, give longer timeout for first read
145 145
     // Windows does not have support for this timeout function
146
-    if(substr(PHP_OS, 0, 3) != "WIN")
147
-     socket_set_timeout($this->smtp_conn, $tval, 0);
146
+    if(substr(PHP_OS, 0, 3) != "WIN") {
147
+         socket_set_timeout($this->smtp_conn, $tval, 0);
148
+    }
148 149
 
149 150
     // get any announcement
150 151
     $announce = $this->get_lines();
Please login to merge, or discard this patch.