Completed
Push — 1.11.x ( c89d59...ff9faa )
by José
229:46 queued 193:01
created
main/inc/lib/pdf.lib.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         /* More info @ http://mpdf1.com/manual/index.php?tid=184&searchstring=mPDF
32 32
          * mPDF ([ string $mode [, mixed $format [, float $default_font_size [, string $default_font [, float $margin_left , float $margin_right , float $margin_top , float $margin_bottom , float $margin_header , float $margin_footer [, string $orientation ]]]]]])
33 33
          */
34
-        if (!in_array($orientation, array('P','L'))) {
34
+        if (!in_array($orientation, array('P', 'L'))) {
35 35
             $orientation = 'P';
36 36
         }
37 37
         //$this->pdf = $pdf = new mPDF('UTF-8', $pageFormat, '', '', 30, 20, 27, 25, 16, 13, $orientation);
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
         $tpl->assign('pdf_content', $content);
95 95
 
96 96
         $organization = api_get_setting('Institution');
97
-        $img = api_get_path(SYS_CSS_PATH).'themes/' . $theme . '/images/header-logo.png';
98
-        $customImg = api_get_path(SYS_PUBLIC_PATH).'css/themes/' . $theme . '/images/header-logo-custom.png';
97
+        $img = api_get_path(SYS_CSS_PATH).'themes/'.$theme.'/images/header-logo.png';
98
+        $customImg = api_get_path(SYS_PUBLIC_PATH).'css/themes/'.$theme.'/images/header-logo-custom.png';
99 99
 
100 100
         // Search for classic logo
101 101
         if (file_exists($customImg)) {
102
-            $img = api_get_path(WEB_CSS_PATH).'themes/' . $theme . '/images/header-logo-custom.png';
102
+            $img = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo-custom.png';
103 103
             $organization = "<img src='$img'>";
104 104
         } else if (file_exists($img)) {
105
-            $img = api_get_path(WEB_CSS_PATH).'themes/' . $theme . '/images/header-logo.png';
105
+            $img = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo.png';
106 106
             $organization = "<img src='$img'>";
107 107
         } else {
108 108
             // Just use the platform title.
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             $visualTheme = api_get_visual_theme();
118 118
             $img = api_get_path(SYS_CSS_PATH).'themes/'.$visualTheme.'/images/pdf_logo_header.png';
119 119
             if (file_exists($img)) {
120
-                $img = api_get_path(WEB_CSS_PATH) . 'themes/' . $visualTheme . '/images/pdf_logo_header.png';
120
+                $img = api_get_path(WEB_CSS_PATH).'themes/'.$visualTheme.'/images/pdf_logo_header.png';
121 121
                 $organization = "<img src='$img'>";
122 122
             }
123 123
         }
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
             // then print the title in the PDF
257 257
             if (is_array($file) && isset($file['title'])) {
258 258
                 $html_title = $file['title'];
259
-                $file  = $file['path'];
259
+                $file = $file['path'];
260 260
             } else {
261 261
                 //we suppose we've only been sent a file path
262 262
                 $html_title = basename($file);
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
             //it's not a chapter but the file exists, print its title
286 286
             if ($print_title) {
287
-                $this->pdf->WriteHTML('<html><body><h3>' . $html_title . '</h3></body></html>');
287
+                $this->pdf->WriteHTML('<html><body><h3>'.$html_title.'</h3></body></html>');
288 288
             }
289 289
 
290 290
             $file_info = pathinfo($file);
@@ -293,12 +293,12 @@  discard block
 block discarded – undo
293 293
             if (in_array($extension, array('html', 'htm'))) {
294 294
                 $dirName = $file_info['dirname'];
295 295
                 $filename = $file_info['basename'];
296
-                $filename = str_replace('_',' ',$filename);
296
+                $filename = str_replace('_', ' ', $filename);
297 297
 
298 298
                 if ($extension == 'html') {
299
-                    $filename = basename($filename,'.html');
300
-                } elseif($extension == 'htm'){
301
-                    $filename = basename($filename,'.htm');
299
+                    $filename = basename($filename, '.html');
300
+                } elseif ($extension == 'htm') {
301
+                    $filename = basename($filename, '.htm');
302 302
                 }
303 303
 
304 304
                 $document_html = @file_get_contents($file);
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
                 $document_html = str_replace('href="./css/frames.css"', $absolute_css_path, $document_html);
310 310
 
311 311
                 if (!empty($course_data['path'])) {
312
-                    $document_html= str_replace('../','', $document_html);
312
+                    $document_html = str_replace('../', '', $document_html);
313 313
                     $document_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/document/';
314 314
 
315 315
                     $doc = new DOMDocument();
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
                 if (!empty($document_html)) {
388 388
                     $this->pdf->WriteHTML($document_html.$page_break);
389 389
                 }
390
-            } elseif (in_array($extension, array('jpg','jpeg','png','gif'))) {
390
+            } elseif (in_array($extension, array('jpg', 'jpeg', 'png', 'gif'))) {
391 391
                 //Images
392 392
                 $image = Display::img($file);
393 393
                 $this->pdf->WriteHTML('<html><body>'.$image.'</body></html>'.$page_break);
@@ -450,11 +450,11 @@  discard block
 block discarded – undo
450 450
 
451 451
         //absolute path for frames.css //TODO: necessary?
452 452
         $absolute_css_path = api_get_path(WEB_CSS_PATH).api_get_setting('stylesheets').'/frames.css';
453
-        $document_html = str_replace('href="./css/frames.css"','href="'.$absolute_css_path.'"', $document_html);
453
+        $document_html = str_replace('href="./css/frames.css"', 'href="'.$absolute_css_path.'"', $document_html);
454 454
 
455
-        $document_html= str_replace('../../','',$document_html);
456
-        $document_html= str_replace('../','',$document_html);
457
-        $document_html= str_replace((empty($_configuration['url_append'])?'':$_configuration['url_append'].'/').'courses/'.$course_code.'/document/','',$document_html);
455
+        $document_html = str_replace('../../', '', $document_html);
456
+        $document_html = str_replace('../', '', $document_html);
457
+        $document_html = str_replace((empty($_configuration['url_append']) ? '' : $_configuration['url_append'].'/').'courses/'.$course_code.'/document/', '', $document_html);
458 458
 
459 459
         if (!empty($course_data['path'])) {
460 460
             $document_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/document/';
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
                                 $old_src_fixed = str_replace(api_get_path(REL_COURSE_PATH).$course_data['path'].'/document/', '', $old_src);
475 475
                                 $old_src_fixed = str_replace('courses/'.$course_data['path'].'/document/', '', $old_src_fixed);
476 476
                                 $new_path = $document_path.$old_src_fixed;
477
-                                $document_html= str_replace($old_src, $new_path, $document_html);
477
+                                $document_html = str_replace($old_src, $new_path, $document_html);
478 478
 
479 479
                             }
480 480
                         }
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
         //$document_html= str_replace('temp_template_path', 'src="/main/default_course_document/', $document_html);// restore src templates
494 494
 
495 495
         api_set_encoding_html($document_html, 'UTF-8'); // The library mPDF expects UTF-8 encoded input data.
496
-        $title = api_get_title_html($document_html, 'UTF-8', 'UTF-8');  // TODO: Maybe it is better idea the title to be passed through
496
+        $title = api_get_title_html($document_html, 'UTF-8', 'UTF-8'); // TODO: Maybe it is better idea the title to be passed through
497 497
         // $_GET[] too, as it is done with file name.
498 498
         // At the moment the title is retrieved from the html document itself.
499 499
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
         //$this->pdf->Output($output_file, $outputMode); // F to save the pdf in a file
516 516
 
517 517
         if ($outputMode == 'F') {
518
-            $output_file = api_get_path(SYS_ARCHIVE_PATH) . $output_file;
518
+            $output_file = api_get_path(SYS_ARCHIVE_PATH).$output_file;
519 519
         }
520 520
 
521 521
         if ($saveInFile) {
@@ -548,14 +548,14 @@  discard block
 block discarded – undo
548 548
         $web_path = false;
549 549
         if (!empty($course_code) && api_get_setting('pdf_export_watermark_by_course') == 'true') {
550 550
             $course_info = api_get_course_info($course_code);
551
-            $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png';   // course path
551
+            $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path
552 552
             if (file_exists($store_path)) {
553
-                $web_path   = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png';
553
+                $web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png';
554 554
             }
555 555
         } else {
556
-            $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png';   // course path
556
+            $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path
557 557
             if (file_exists($store_path))
558
-                $web_path   = api_get_path(WEB_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png';
558
+                $web_path = api_get_path(WEB_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png';
559 559
         }
560 560
         return $web_path;
561 561
     }
@@ -595,10 +595,10 @@  discard block
 block discarded – undo
595 595
     {
596 596
         if (!empty($course_code) && api_get_setting('pdf_export_watermark_by_course') == 'true') {
597 597
             $course_info = api_get_course_info($course_code);
598
-            $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path'];   // course path
598
+            $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path']; // course path
599 599
             $web_path   = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/pdf_watermark.png';
600 600
         } else {
601
-            $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images';   // course path
601
+            $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images'; // course path
602 602
             $web_path   = api_get_path(WEB_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png';
603 603
         }
604 604
         $course_image = $store_path.'/'.api_get_current_access_url_id().'_pdf_watermark.png';
@@ -633,9 +633,9 @@  discard block
 block discarded – undo
633 633
      */
634 634
     public function set_footer()
635 635
     {
636
-        $this->pdf->defaultfooterfontsize = 12;   // in pts
637
-        $this->pdf->defaultfooterfontstyle = 'B';   // blank, B, I, or BI
638
-        $this->pdf->defaultfooterline = 1;        // 1 to include line below header/above footer
636
+        $this->pdf->defaultfooterfontsize = 12; // in pts
637
+        $this->pdf->defaultfooterfontstyle = 'B'; // blank, B, I, or BI
638
+        $this->pdf->defaultfooterline = 1; // 1 to include line below header/above footer
639 639
         $platform_name   = api_get_setting('Institution');
640 640
         $left_content    = $platform_name;
641 641
         $center_content  = '';
@@ -702,9 +702,9 @@  discard block
 block discarded – undo
702 702
      */
703 703
     public function set_header($course_data)
704 704
     {
705
-        $this->pdf->defaultheaderfontsize   = 10;   // in pts
706
-        $this->pdf->defaultheaderfontstyle  = 'BI';   // blank, B, I, or BI
707
-        $this->pdf->defaultheaderline       = 1;    // 1 to include line below header/above footer
705
+        $this->pdf->defaultheaderfontsize   = 10; // in pts
706
+        $this->pdf->defaultheaderfontstyle  = 'BI'; // blank, B, I, or BI
707
+        $this->pdf->defaultheaderline       = 1; // 1 to include line below header/above footer
708 708
 
709 709
         if (!empty($course_data['code'])) {
710 710
             $teacher_list = CourseManager::get_teacher_list_from_course_code($course_data['code']);
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
             if (!empty($teacher_list)) {
714 714
 
715 715
                 foreach ($teacher_list as $teacher) {
716
-                    $teachers[]= $teacher['firstname'].' '.$teacher['lastname'];
716
+                    $teachers[] = $teacher['firstname'].' '.$teacher['lastname'];
717 717
                 }
718 718
                 if (count($teachers) > 1) {
719 719
                     $teachers = get_lang('Teachers').': '.implode(', ', $teachers);
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
                     'line' => 1,
781 781
                 ),
782 782
             );
783
-            $this->pdf->SetHeader($header);// ('{DATE j-m-Y}|{PAGENO}/{nb}|'.$title);
783
+            $this->pdf->SetHeader($header); // ('{DATE j-m-Y}|{PAGENO}/{nb}|'.$title);
784 784
         }
785 785
     }
786 786
 
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
         $this->pdf->directionality = api_get_text_direction();
826 826
         $this->pdf->useOnlyCoreFonts = true;
827 827
         // Use different Odd/Even headers and footers and mirror margins
828
-        $this->pdf->mirrorMargins       = 1;
828
+        $this->pdf->mirrorMargins = 1;
829 829
 
830 830
         // Add decoration only if not stated otherwise
831 831
         if ($complete) {
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
                     $watermark_text = api_get_setting('pdf_export_watermark_text');
854 854
                 }
855 855
                 if (!empty($watermark_text)) {
856
-                    $this->pdf->SetWatermarkText(strcode2utf($watermark_text),0.1);
856
+                    $this->pdf->SetWatermarkText(strcode2utf($watermark_text), 0.1);
857 857
                     $this->pdf->showWatermarkText = true;
858 858
                 }
859 859
             }
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
             if (empty($this->custom_header)) {
862 862
                 self::set_header($course_data);
863 863
             } else {
864
-                $this->pdf->SetHTMLHeader($this->custom_header,'E');
865
-                $this->pdf->SetHTMLHeader($this->custom_header,'O');
864
+                $this->pdf->SetHTMLHeader($this->custom_header, 'E');
865
+                $this->pdf->SetHTMLHeader($this->custom_header, 'O');
866 866
             }
867 867
 
868 868
             if (empty($this->custom_footer)) {
Please login to merge, or discard this patch.