From bcf1d6571eee82153c8fc7eb3fdbc0060416f76b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 23 Dec 2010 15:21:04 +0100 Subject: [PATCH] Fixing pdf name for lps --- main/inc/lib/pdf.lib.php | 11 +++---- main/newscorm/learnpath.class.php | 51 ++++++++++++++++--------------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/main/inc/lib/pdf.lib.php b/main/inc/lib/pdf.lib.php index 64be25e751..4b86850f5c 100644 --- a/main/inc/lib/pdf.lib.php +++ b/main/inc/lib/pdf.lib.php @@ -14,20 +14,17 @@ class PDF { /** * Creates the mPDF object - * @params string orientation "P" = Portrait "L" = Landscape + * @param string format A4 A4-L see http://mpdf1.com/manual/index.php?tid=184&searchstring=format + * @param string orientation "P" = Portrait "L" = Landscape */ public function __construct($page_format ='A4', $orientation = 'P') { /* More info @ http://mpdf1.com/manual/index.php?tid=184&searchstring=mPDF * 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 ]]]]]]) - */ - + */ if(!in_array($orientation,array('P','L'))) { $orientation = 'P'; } - $this->pdf = $pdf = new mPDF('UTF-8', $page_format, '', '', 30, 20, 27, 25, 16, 13, $orientation); - - - //$mpdf->mirrorMargins = 0; // Use different Odd/Even headers and footers and mirror margins + $this->pdf = $pdf = new mPDF('UTF-8', $page_format, '', '', 30, 20, 27, 25, 16, 13, $orientation); } /** diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 5fa46c8ce1..ede3764fcc 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -8361,32 +8361,33 @@ EOD; $lp_id = intval($lp_id); $files_to_export = array(); $course_data = api_get_course_info($this->cc); - - $scorm_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/scorm/'.$this->path; - require_once api_get_path(LIBRARY_PATH).'document.lib.php'; - foreach($this->items as $item) { - //Getting documents from a LP with chamilo documents - switch ($item->type) { - case 'document': - $file_data = DocumentManager::get_document_data_by_id($item->path, $this->cc); - $file_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/document'.$file_data['path']; - if (file_exists($file_path)) { - $files_to_export[] = $file_path; - } - break; - case 'sco': - $file_path = $scorm_path.'/'.$item->path; - if (file_exists($file_path)) { - $files_to_export[] = $file_path; - } - break; - - } + if (!empty($course_data)) { + $scorm_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/scorm/'.$this->path; + require_once api_get_path(LIBRARY_PATH).'document.lib.php'; + foreach($this->items as $item) { + //Getting documents from a LP with chamilo documents + switch ($item->type) { + case 'document': + $file_data = DocumentManager::get_document_data_by_id($item->path, $this->cc); + $file_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/document'.$file_data['path']; + if (file_exists($file_path)) { + $files_to_export[] = $file_path; + } + break; + case 'sco': + $file_path = $scorm_path.'/'.$item->path; + if (file_exists($file_path)) { + $files_to_export[] = $file_path; + } + break; + } + } + require_once api_get_path(LIBRARY_PATH).'pdf.lib.php'; + $pdf = new PDF(); + $result = $pdf->html_to_pdf($files_to_export, $this->name, $this->cc); + return $result; } - require_once api_get_path(LIBRARY_PATH).'pdf.lib.php'; - $pdf = new PDF(); - $result = $pdf->html_to_pdf($files_to_export, '', $this->cc); - return $result; + return false; } /**