@@ -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); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $visualTheme = api_get_visual_theme(); |
| 112 | 112 | $img = api_get_path(SYS_CSS_PATH).'themes/'.$visualTheme.'/images/pdf_logo_header.png'; |
| 113 | 113 | if (file_exists($img)) { |
| 114 | - $img = api_get_path(WEB_CSS_PATH) . 'themes/' . $visualTheme . '/images/pdf_logo_header.png'; |
|
| 114 | + $img = api_get_path(WEB_CSS_PATH).'themes/'.$visualTheme.'/images/pdf_logo_header.png'; |
|
| 115 | 115 | $organization = "<img src='$img'>"; |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // Clean styles and javascript document |
| 232 | - $clean_search = array ( |
|
| 232 | + $clean_search = array( |
|
| 233 | 233 | '@<script[^>]*?>.*?</script>@si', |
| 234 | 234 | '@<style[^>]*?>.*?</style>@si' |
| 235 | 235 | ); |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | // then print the title in the PDF |
| 251 | 251 | if (is_array($file) && isset($file['title'])) { |
| 252 | 252 | $html_title = $file['title']; |
| 253 | - $file = $file['path']; |
|
| 253 | + $file = $file['path']; |
|
| 254 | 254 | } else { |
| 255 | 255 | //we suppose we've only been sent a file path |
| 256 | 256 | $html_title = basename($file); |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | //it's not a chapter but the file exists, print its title |
| 283 | 283 | if ($print_title) { |
| 284 | 284 | $this->pdf->WriteHTML( |
| 285 | - '<html><body><h3>' . $html_title . '</h3></body></html>', |
|
| 285 | + '<html><body><h3>'.$html_title.'</h3></body></html>', |
|
| 286 | 286 | 2 |
| 287 | 287 | ); |
| 288 | 288 | } |
@@ -293,12 +293,12 @@ discard block |
||
| 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 |
||
| 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 |
||
| 387 | 387 | if (!empty($document_html)) { |
| 388 | 388 | $this->pdf->WriteHTML($document_html.$page_break, 2); |
| 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, 2); |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | //clean styles and javascript document |
| 439 | - $clean_search = array ( |
|
| 439 | + $clean_search = array( |
|
| 440 | 440 | '@<script[^>]*?>.*?</script>@si', |
| 441 | 441 | '@<style[^>]*?>.*?</style>@siU' |
| 442 | 442 | ); |
@@ -450,11 +450,11 @@ discard block |
||
| 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/'; |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | $old_src_fixed = str_replace('/courses/'.$course_data['path'].'/document/', '', $old_src); |
| 476 | 476 | $old_src_fixed = str_replace('courses/'.$course_data['path'].'/document/', '', $old_src_fixed); |
| 477 | 477 | $new_path = $document_path.$old_src_fixed; |
| 478 | - $document_html= str_replace($old_src, $new_path, $document_html); |
|
| 478 | + $document_html = str_replace($old_src, $new_path, $document_html); |
|
| 479 | 479 | |
| 480 | 480 | } |
| 481 | 481 | } |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | //$document_html= str_replace('temp_template_path', 'src="/main/default_course_document/', $document_html);// restore src templates |
| 495 | 495 | |
| 496 | 496 | api_set_encoding_html($document_html, 'UTF-8'); // The library mPDF expects UTF-8 encoded input data. |
| 497 | - $title = api_get_title_html($document_html, 'UTF-8', 'UTF-8'); // TODO: Maybe it is better idea the title to be passed through |
|
| 497 | + $title = api_get_title_html($document_html, 'UTF-8', 'UTF-8'); // TODO: Maybe it is better idea the title to be passed through |
|
| 498 | 498 | // $_GET[] too, as it is done with file name. |
| 499 | 499 | // At the moment the title is retrieved from the html document itself. |
| 500 | 500 | |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | //$this->pdf->Output($output_file, $outputMode); // F to save the pdf in a file |
| 517 | 517 | |
| 518 | 518 | if ($outputMode == 'F') { |
| 519 | - $output_file = api_get_path(SYS_ARCHIVE_PATH) . $output_file; |
|
| 519 | + $output_file = api_get_path(SYS_ARCHIVE_PATH).$output_file; |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | if ($saveInFile) { |
@@ -549,14 +549,14 @@ discard block |
||
| 549 | 549 | $web_path = false; |
| 550 | 550 | if (!empty($course_code) && api_get_setting('pdf_export_watermark_by_course') == 'true') { |
| 551 | 551 | $course_info = api_get_course_info($course_code); |
| 552 | - $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path |
|
| 552 | + $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path |
|
| 553 | 553 | if (file_exists($store_path)) { |
| 554 | - $web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
|
| 554 | + $web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
|
| 555 | 555 | } |
| 556 | 556 | } else { |
| 557 | - $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path |
|
| 557 | + $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path |
|
| 558 | 558 | if (file_exists($store_path)) |
| 559 | - $web_path = api_get_path(WEB_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
|
| 559 | + $web_path = api_get_path(WEB_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png'; |
|
| 560 | 560 | } |
| 561 | 561 | return $web_path; |
| 562 | 562 | } |
@@ -595,10 +595,10 @@ discard block |
||
| 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 |
||
| 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 = ''; |
@@ -701,9 +701,9 @@ discard block |
||
| 701 | 701 | */ |
| 702 | 702 | public function set_header($course_data) |
| 703 | 703 | { |
| 704 | - $this->pdf->defaultheaderfontsize = 10; // in pts |
|
| 705 | - $this->pdf->defaultheaderfontstyle = 'BI'; // blank, B, I, or BI |
|
| 706 | - $this->pdf->defaultheaderline = 1; // 1 to include line below header/above footer |
|
| 704 | + $this->pdf->defaultheaderfontsize = 10; // in pts |
|
| 705 | + $this->pdf->defaultheaderfontstyle = 'BI'; // blank, B, I, or BI |
|
| 706 | + $this->pdf->defaultheaderline = 1; // 1 to include line below header/above footer |
|
| 707 | 707 | |
| 708 | 708 | if (!empty($course_data['code'])) { |
| 709 | 709 | $teacher_list = CourseManager::get_teacher_list_from_course_code($course_data['code']); |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | if (!empty($teacher_list)) { |
| 713 | 713 | |
| 714 | 714 | foreach ($teacher_list as $teacher) { |
| 715 | - $teachers[]= $teacher['firstname'].' '.$teacher['lastname']; |
|
| 715 | + $teachers[] = $teacher['firstname'].' '.$teacher['lastname']; |
|
| 716 | 716 | } |
| 717 | 717 | if (count($teachers) > 1) { |
| 718 | 718 | $teachers = get_lang('Teachers').': '.implode(', ', $teachers); |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | 'line' => 1, |
| 780 | 780 | ), |
| 781 | 781 | ); |
| 782 | - $this->pdf->SetHeader($header);// ('{DATE j-m-Y}|{PAGENO}/{nb}|'.$title); |
|
| 782 | + $this->pdf->SetHeader($header); // ('{DATE j-m-Y}|{PAGENO}/{nb}|'.$title); |
|
| 783 | 783 | } |
| 784 | 784 | } |
| 785 | 785 | |
@@ -824,7 +824,7 @@ discard block |
||
| 824 | 824 | $this->pdf->directionality = api_get_text_direction(); |
| 825 | 825 | $this->pdf->useOnlyCoreFonts = true; |
| 826 | 826 | // Use different Odd/Even headers and footers and mirror margins |
| 827 | - $this->pdf->mirrorMargins = 1; |
|
| 827 | + $this->pdf->mirrorMargins = 1; |
|
| 828 | 828 | |
| 829 | 829 | // Add decoration only if not stated otherwise |
| 830 | 830 | if ($complete) { |
@@ -852,7 +852,7 @@ discard block |
||
| 852 | 852 | $watermark_text = api_get_setting('pdf_export_watermark_text'); |
| 853 | 853 | } |
| 854 | 854 | if (!empty($watermark_text)) { |
| 855 | - $this->pdf->SetWatermarkText(strcode2utf($watermark_text),0.1); |
|
| 855 | + $this->pdf->SetWatermarkText(strcode2utf($watermark_text), 0.1); |
|
| 856 | 856 | $this->pdf->showWatermarkText = true; |
| 857 | 857 | } |
| 858 | 858 | } |
@@ -860,8 +860,8 @@ discard block |
||
| 860 | 860 | if (empty($this->custom_header)) { |
| 861 | 861 | self::set_header($course_data); |
| 862 | 862 | } else { |
| 863 | - $this->pdf->SetHTMLHeader($this->custom_header,'E'); |
|
| 864 | - $this->pdf->SetHTMLHeader($this->custom_header,'O'); |
|
| 863 | + $this->pdf->SetHTMLHeader($this->custom_header, 'E'); |
|
| 864 | + $this->pdf->SetHTMLHeader($this->custom_header, 'O'); |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | if (empty($this->custom_footer)) { |