@@ -31,7 +31,7 @@ discard block |
||
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 |
||
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(WEB_CSS_PATH).'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(WEB_CSS_PATH).'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 |
||
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 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | // Clean styles and javascript document |
238 | - $clean_search = array ( |
|
238 | + $clean_search = array( |
|
239 | 239 | '@<script[^>]*?>.*?</script>@si', |
240 | 240 | '@<style[^>]*?>.*?</style>@si' |
241 | 241 | ); |
@@ -256,7 +256,7 @@ discard block |
||
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); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | //it's not a chapter but the file exists, print its title |
289 | 289 | if ($print_title) { |
290 | 290 | $this->pdf->WriteHTML( |
291 | - '<html><body><h3>' . $html_title . '</h3></body></html>', |
|
291 | + '<html><body><h3>'.$html_title.'</h3></body></html>', |
|
292 | 292 | 2 |
293 | 293 | ); |
294 | 294 | } |
@@ -299,12 +299,12 @@ discard block |
||
299 | 299 | if (in_array($extension, array('html', 'htm'))) { |
300 | 300 | $dirName = $file_info['dirname']; |
301 | 301 | $filename = $file_info['basename']; |
302 | - $filename = str_replace('_',' ',$filename); |
|
302 | + $filename = str_replace('_', ' ', $filename); |
|
303 | 303 | |
304 | 304 | if ($extension == 'html') { |
305 | - $filename = basename($filename,'.html'); |
|
306 | - } elseif($extension == 'htm'){ |
|
307 | - $filename = basename($filename,'.htm'); |
|
305 | + $filename = basename($filename, '.html'); |
|
306 | + } elseif ($extension == 'htm') { |
|
307 | + $filename = basename($filename, '.htm'); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | $document_html = @file_get_contents($file); |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $document_html = str_replace('href="./css/frames.css"', $absolute_css_path, $document_html); |
316 | 316 | |
317 | 317 | if (!empty($course_data['path'])) { |
318 | - $document_html= str_replace('../','', $document_html); |
|
318 | + $document_html = str_replace('../', '', $document_html); |
|
319 | 319 | $document_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/document/'; |
320 | 320 | |
321 | 321 | $doc = new DOMDocument(); |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | if (!empty($document_html)) { |
394 | 394 | $this->pdf->WriteHTML($document_html.$page_break, 2); |
395 | 395 | } |
396 | - } elseif (in_array($extension, array('jpg','jpeg','png','gif'))) { |
|
396 | + } elseif (in_array($extension, array('jpg', 'jpeg', 'png', 'gif'))) { |
|
397 | 397 | //Images |
398 | 398 | $image = Display::img($file); |
399 | 399 | $this->pdf->WriteHTML('<html><body>'.$image.'</body></html>'.$page_break, 2); |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | //clean styles and javascript document |
445 | - $clean_search = array ( |
|
445 | + $clean_search = array( |
|
446 | 446 | '@<script[^>]*?>.*?</script>@si', |
447 | 447 | '@<style[^>]*?>.*?</style>@siU' |
448 | 448 | ); |
@@ -456,11 +456,11 @@ discard block |
||
456 | 456 | |
457 | 457 | //absolute path for frames.css //TODO: necessary? |
458 | 458 | $absolute_css_path = api_get_path(WEB_CSS_PATH).api_get_setting('stylesheets').'/frames.css'; |
459 | - $document_html = str_replace('href="./css/frames.css"','href="'.$absolute_css_path.'"', $document_html); |
|
459 | + $document_html = str_replace('href="./css/frames.css"', 'href="'.$absolute_css_path.'"', $document_html); |
|
460 | 460 | |
461 | - $document_html= str_replace('../../','',$document_html); |
|
462 | - $document_html= str_replace('../','',$document_html); |
|
463 | - $document_html= str_replace((empty($_configuration['url_append'])?'':$_configuration['url_append'].'/').'courses/'.$course_code.'/document/','',$document_html); |
|
461 | + $document_html = str_replace('../../', '', $document_html); |
|
462 | + $document_html = str_replace('../', '', $document_html); |
|
463 | + $document_html = str_replace((empty($_configuration['url_append']) ? '' : $_configuration['url_append'].'/').'courses/'.$course_code.'/document/', '', $document_html); |
|
464 | 464 | |
465 | 465 | if (!empty($course_data['path'])) { |
466 | 466 | $document_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/document/'; |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | $old_src_fixed = str_replace('/courses/'.$course_data['path'].'/document/', '', $old_src); |
482 | 482 | $old_src_fixed = str_replace('courses/'.$course_data['path'].'/document/', '', $old_src_fixed); |
483 | 483 | $new_path = $document_path.$old_src_fixed; |
484 | - $document_html= str_replace($old_src, $new_path, $document_html); |
|
484 | + $document_html = str_replace($old_src, $new_path, $document_html); |
|
485 | 485 | |
486 | 486 | } |
487 | 487 | } |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | //$document_html= str_replace('temp_template_path', 'src="/main/default_course_document/', $document_html);// restore src templates |
501 | 501 | |
502 | 502 | api_set_encoding_html($document_html, 'UTF-8'); // The library mPDF expects UTF-8 encoded input data. |
503 | - $title = api_get_title_html($document_html, 'UTF-8', 'UTF-8'); // TODO: Maybe it is better idea the title to be passed through |
|
503 | + $title = api_get_title_html($document_html, 'UTF-8', 'UTF-8'); // TODO: Maybe it is better idea the title to be passed through |
|
504 | 504 | // $_GET[] too, as it is done with file name. |
505 | 505 | // At the moment the title is retrieved from the html document itself. |
506 | 506 | |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | //$this->pdf->Output($output_file, $outputMode); // F to save the pdf in a file |
523 | 523 | |
524 | 524 | if ($outputMode == 'F') { |
525 | - $output_file = api_get_path(SYS_ARCHIVE_PATH) . $output_file; |
|
525 | + $output_file = api_get_path(SYS_ARCHIVE_PATH).$output_file; |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | if ($saveInFile) { |
@@ -555,14 +555,14 @@ discard block |
||
555 | 555 | $web_path = false; |
556 | 556 | if (!empty($course_code) && api_get_setting('pdf_export_watermark_by_course') == 'true') { |
557 | 557 | $course_info = api_get_course_info($course_code); |
558 | - $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path |
|
558 | + $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path |
|
559 | 559 | if (file_exists($store_path)) { |
560 | - $web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
|
560 | + $web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
|
561 | 561 | } |
562 | 562 | } else { |
563 | - $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path |
|
563 | + $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path |
|
564 | 564 | if (file_exists($store_path)) |
565 | - $web_path = api_get_path(WEB_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
|
565 | + $web_path = api_get_path(WEB_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
|
566 | 566 | } |
567 | 567 | return $web_path; |
568 | 568 | } |
@@ -601,10 +601,10 @@ discard block |
||
601 | 601 | { |
602 | 602 | if (!empty($course_code) && api_get_setting('pdf_export_watermark_by_course') == 'true') { |
603 | 603 | $course_info = api_get_course_info($course_code); |
604 | - $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path']; // course path |
|
604 | + $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path']; // course path |
|
605 | 605 | $web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/pdf_watermark.png'; |
606 | 606 | } else { |
607 | - $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images'; // course path |
|
607 | + $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images'; // course path |
|
608 | 608 | $web_path = api_get_path(WEB_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
609 | 609 | } |
610 | 610 | $course_image = $store_path.'/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
@@ -639,9 +639,9 @@ discard block |
||
639 | 639 | */ |
640 | 640 | public function set_footer() |
641 | 641 | { |
642 | - $this->pdf->defaultfooterfontsize = 12; // in pts |
|
643 | - $this->pdf->defaultfooterfontstyle = B; // blank, B, I, or BI |
|
644 | - $this->pdf->defaultfooterline = 1; // 1 to include line below header/above footer |
|
642 | + $this->pdf->defaultfooterfontsize = 12; // in pts |
|
643 | + $this->pdf->defaultfooterfontstyle = B; // blank, B, I, or BI |
|
644 | + $this->pdf->defaultfooterline = 1; // 1 to include line below header/above footer |
|
645 | 645 | $platform_name = api_get_setting('Institution'); |
646 | 646 | $left_content = $platform_name; |
647 | 647 | $center_content = ''; |
@@ -707,9 +707,9 @@ discard block |
||
707 | 707 | */ |
708 | 708 | public function set_header($course_data) |
709 | 709 | { |
710 | - $this->pdf->defaultheaderfontsize = 10; // in pts |
|
711 | - $this->pdf->defaultheaderfontstyle = 'BI'; // blank, B, I, or BI |
|
712 | - $this->pdf->defaultheaderline = 1; // 1 to include line below header/above footer |
|
710 | + $this->pdf->defaultheaderfontsize = 10; // in pts |
|
711 | + $this->pdf->defaultheaderfontstyle = 'BI'; // blank, B, I, or BI |
|
712 | + $this->pdf->defaultheaderline = 1; // 1 to include line below header/above footer |
|
713 | 713 | |
714 | 714 | if (!empty($course_data['code'])) { |
715 | 715 | $teacher_list = CourseManager::get_teacher_list_from_course_code($course_data['code']); |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | if (!empty($teacher_list)) { |
719 | 719 | |
720 | 720 | foreach ($teacher_list as $teacher) { |
721 | - $teachers[]= $teacher['firstname'].' '.$teacher['lastname']; |
|
721 | + $teachers[] = $teacher['firstname'].' '.$teacher['lastname']; |
|
722 | 722 | } |
723 | 723 | if (count($teachers) > 1) { |
724 | 724 | $teachers = get_lang('Teachers').': '.implode(', ', $teachers); |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | 'line' => 1, |
786 | 786 | ), |
787 | 787 | ); |
788 | - $this->pdf->SetHeader($header);// ('{DATE j-m-Y}|{PAGENO}/{nb}|'.$title); |
|
788 | + $this->pdf->SetHeader($header); // ('{DATE j-m-Y}|{PAGENO}/{nb}|'.$title); |
|
789 | 789 | } |
790 | 790 | } |
791 | 791 | |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | $this->pdf->directionality = api_get_text_direction(); |
831 | 831 | $this->pdf->useOnlyCoreFonts = true; |
832 | 832 | // Use different Odd/Even headers and footers and mirror margins |
833 | - $this->pdf->mirrorMargins = 1; |
|
833 | + $this->pdf->mirrorMargins = 1; |
|
834 | 834 | |
835 | 835 | // Add decoration only if not stated otherwise |
836 | 836 | if ($complete) { |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | $watermark_text = api_get_setting('pdf_export_watermark_text'); |
859 | 859 | } |
860 | 860 | if (!empty($watermark_text)) { |
861 | - $this->pdf->SetWatermarkText(strcode2utf($watermark_text),0.1); |
|
861 | + $this->pdf->SetWatermarkText(strcode2utf($watermark_text), 0.1); |
|
862 | 862 | $this->pdf->showWatermarkText = true; |
863 | 863 | } |
864 | 864 | } |
@@ -866,8 +866,8 @@ discard block |
||
866 | 866 | if (empty($this->custom_header)) { |
867 | 867 | self::set_header($course_data); |
868 | 868 | } else { |
869 | - $this->pdf->SetHTMLHeader($this->custom_header,'E'); |
|
870 | - $this->pdf->SetHTMLHeader($this->custom_header,'O'); |
|
869 | + $this->pdf->SetHTMLHeader($this->custom_header, 'E'); |
|
870 | + $this->pdf->SetHTMLHeader($this->custom_header, 'O'); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | if (empty($this->custom_footer)) { |