public static function prepare_header(&$tcpdf, $title = '', $subject = '', $printed_by = true, $logo_filename = null, $l = array()) { if ($title !== null) { if ($logo_filename === null) { $logo_filename = Libs_TCPDFCommon::get_logo_filename(); } if ($logo_filename !== false && !file_exists($logo_filename)) { $logo_filename = Base_ThemeCommon::get_template_file(Libs_TCPDF::module_name(), 'logo-small.png'); } $margins = $tcpdf->getMargins(); if ($logo_filename) { $logo_size = getimagesize($logo_filename); $logo_height = $logo_size[1] * PDF_HEADER_LOGO_WIDTH / $logo_size[0]; } else { $logo_height = 0; } $tcpdf->SetHeaderMargin(10); $tcpdf->SetTopMargin($logo_height + $margins['top']); $tcpdf->SetHeaderData($logo_filename, $logo_filename ? PDF_HEADER_LOGO_WIDTH : 0, $title, $subject); } else { $tcpdf->setPrintHeader(false); } //set some language-dependent strings $l['a_meta_charset'] = "UTF-8"; $l['a_meta_dir'] = "ltr"; $l['a_meta_language'] = "pl"; $who = null; if (CRM_ContactsInstall::is_installed()) { $who = CRM_ContactsCommon::get_contact_by_user_id(Acl::get_user()); } if ($who !== null) { $who = $who['last_name'] . ' ' . $who['first_name']; } else { $who = Base_UserCommon::get_user_login(Acl::get_user()); } $when = date('Y-m-d H:i:s'); if (!isset($l['w_page'])) { $l['w_page'] = ''; if ($printed_by) { $product_name = EPESI; $url = EPESI == 'EPESI' ? ' (http://epe.si)' : ''; $l['w_page'] .= __('Printed with %s by %s, on %s, ', array($product_name . $url, $who, $when)); } $l['w_page'] .= __('Page'); } $tcpdf->setLanguageArray($l); self::SetFont($tcpdf, self::$default_font, '', 9); }
public function upload_logo($file, $oryg, $data) { $fp = fopen($file, "r"); $ext = strrchr($oryg, '.'); if ($ext === '' || $ext !== '.png') { print __('Invalid extension. Only *.png is allowed.', array(), false); return; } $target_filename = Libs_TCPDFCommon::get_logo_filename(); if (file_exists($target_filename)) { unlink($target_filename); } copy($file, $target_filename); print __('Upload successful.', array(), false); }