/** * topdf returns the protocol as pdf * * @param int $pid entry-id for protocol * @return string pdf of the protocol */ private function topdf($pid) { // pagecaption $this->tpl->assign('pagecaption', parent::lang('class.ProtocolView#page#caption#topdf')); // get protocol $protocol = new Protocol($pid); // get status $correctable = $protocol->get_correctable(false); // check rights if (Rights::check_rights($pid, 'protocol', true) && ($correctable['status'] == 2 || $_SESSION['user']->get_userinfo('name') == $protocol->get_owner())) { // smarty $sP = new JudoIntranetSmarty(); // prepare marker-array $infos = array('version' => date('dmy')); // add calendar-fields to array $protocol->addMarks($infos, false); // add tmce-css $fh = fopen('templates/protocols/tmce_' . $protocol->get_preset()->get_path() . '.css', 'r'); $css = fread($fh, filesize('templates/protocols/tmce_' . $protocol->get_preset()->get_path() . '.css')); fclose($fh); $infos['tmceStyles'] = $css; // smarty $sP->assign('p', $infos); // check marks in values foreach ($infos as $k => $v) { if (preg_match('/\\{\\$p\\..*\\}/U', $v)) { $infos[$k] = $sP->fetch('string:' . $v); } } // smarty $sP->assign('p', $infos); $pdf_out = $sP->fetch('templates/protocols/' . $protocol->get_preset()->get_path() . '.tpl'); // replace <p></p> to <div></div> for css use with HTML2PDF $pdf_out = preg_replace('/<p class="tmceItem">(.*)<\\/p>/U', '<div class="tmceItem">$1</div>', $pdf_out); $pdf_out = preg_replace('/<p class="tmceDecision">(.*)<\\/p>/U', '<div class="tmceDecision">$1</div>', $pdf_out); // get HTML2PDF-object $pdf = new HTML2PDF('P', 'A4', 'de', true, 'UTF-8', array(0, 0, 0, 0)); // convert $pdf->writeHTML($pdf_out, false); // output $pdf_filename = $this->replace_umlaute(html_entity_decode($sP->fetch('string:' . $protocol->get_preset()->get_filename()), ENT_XHTML, 'ISO-8859-1')); $pdf->Output($pdf_filename, 'D'); } else { // error $errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id')); $GLOBALS['Error']->handle_error($errno); return $GLOBALS['Error']->to_html($errno); } }