/** * Init PDF class * * @param array $options The pdf options. * * @return void */ protected function initPdf($options) { $_defaults = array('orientation' => 'P', 'unit' => 'mm', 'format' => 'A4', 'unicode' => true, 'encoding' => 'UTF-8', 'diskcache' => false, 'creator' => 'LilIntranet', 'author' => 'ARHIM d.o.o.', 'title' => 'PDF document', 'subject' => '', 'keywords' => '', 'font' => 'dejavusans', 'font_size' => 10, 'language' => array('a_meta_charset' => 'UTF-8', 'a_meta_dir' => 'ltr', 'a_meta_language' => 'sl'), 'margin' => array('left' => 15, 'top' => 27, 'right' => 15), 'header' => array('margin' => 5, 'font_size' => 8, 'lines' => array()), 'footer' => array('margin' => 10, 'font_size' => 8, 'lines' => array()), 'file_name' => 'untitled.pdf', 'dest' => 'I'); if (isset($options['download']) && $options['download'] == true) { $options['dest'] = 'D'; unset($options['download']); } $this->options = array_replace_recursive($_defaults, (array) $options); $this->pdf = new LilPdf($this->options); // set document information $this->pdf->SetCreator($this->options['creator']); $this->pdf->SetAuthor($this->options['author']); $this->pdf->SetTitle($this->options['title']); $this->pdf->SetSubject($this->options['subject']); $this->pdf->SetKeywords($this->options['keywords']); // lang $this->pdf->setLanguageArray($this->options['language']); //set auto page breaks $this->pdf->SetAutoPageBreak(true, $this->options['footer']['margin']); // set font $this->pdf->SetFont($this->options['font'], '', $this->options['font_size']); $this->pdf->SetCellPadding(2); // margins $this->pdf->SetMargins($this->options['margin']['left'], $this->options['margin']['top'], $this->options['margin']['right'], true); //if (empty($this->options['header'])) { //$this->pdf->SetPrintHeader(false); //} else { $this->pdf->SetHeaderMargin($this->options['header']['margin']); //} //if (empty($this->options['footer'])) { // $this->pdf->SetPrintFooter(false); //} else { $this->pdf->SetFooterMargin($this->options['footer']['margin']); //} }
/** * Create ATOM struct * * @access public * @param string $feed_type OPTIONAL feed type * @return mixed Can return the Atom Object or Jaws_Error on error */ function GetAtomStruct($feed_type = 'atom') { if (isset($this->_Atom) && is_array($this->_Atom->Entries) && count($this->_Atom->Entries) > 0) { return $this->_Atom; } $this->_Atom = new Jaws_AtomFeed(); $now = Jaws_DB::getInstance()->date(); $limit = $this->gadget->registry->fetch('xml_limit'); $blogTable = Jaws_ORM::getInstance()->table('blog'); $blogTable->select('blog.id:integer', 'user_id:integer', 'username', 'email', 'nickname', 'title', 'summary', 'text', 'fast_url', 'blog.publishtime', 'blog.updatetime', 'clicks:integer', 'comments:integer', 'allow_comments:boolean', 'published:boolean', 'categories')->join('users', 'blog.user_id', 'users.id'); $blogTable->where('blog.published', true)->and()->where('blog.publishtime', $now, '<='); $result = $blogTable->orderBy('blog.publishtime desc')->limit($limit)->fetchAll(); if (Jaws_Error::IsError($result)) { return new Jaws_Error(_t('BLOG_ERROR_GETTING_ATOMSTRUCT')); } // Check dynamic ACL foreach ($result as $key => $entry) { foreach (explode(",", $entry['categories']) as $cat) { if (!$this->gadget->GetPermission('CategoryAccess', $cat)) { unset($result[$key]); } } } $siteURL = $GLOBALS['app']->GetSiteURL('/'); $url = $this->gadget->urlMap($feed_type == 'atom' ? 'Atom' : 'RSS', array(), true); $this->_Atom->SetTitle($this->gadget->registry->fetch('site_name', 'Settings')); $this->_Atom->SetLink($url); $this->_Atom->SetId($siteURL); $this->_Atom->SetTagLine($this->gadget->registry->fetch('site_slogan', 'Settings')); $this->_Atom->SetAuthor($this->gadget->registry->fetch('site_author', 'Settings'), $GLOBALS['app']->GetSiteURL(), $this->gadget->registry->fetch('gate_email', 'Settings')); $this->_Atom->SetGenerator('JAWS ' . $GLOBALS['app']->Registry->fetch('version')); $this->_Atom->SetCopyright($this->gadget->registry->fetch('site_copyright', 'Settings')); $objDate = Jaws_Date::getInstance(); foreach ($result as $r) { $entry = new AtomEntry(); $entry->SetTitle($r['title']); $post_id = empty($r['fast_url']) ? $r['id'] : $r['fast_url']; $url = $this->gadget->urlMap('SingleView', array('id' => $post_id), true); $entry->SetLink($url); $entry->SetId($url); $summary = $r['summary']; $text = $r['text']; // for compatibility with old versions $more_pos = Jaws_UTF8::strpos($text, '[more]'); if ($more_pos !== false) { $summary = Jaws_UTF8::substr($text, 0, $more_pos); $text = Jaws_UTF8::str_replace('[more]', '', $text); // Update this entry to split summary and body of post $model = $this->gadget->model->load('Posts'); $model->SplitEntry($r['id'], $summary, $text); } $summary = empty($summary) ? $text : $summary; $summary = $this->gadget->ParseText($summary); $text = $this->gadget->ParseText($text); $entry->SetSummary($summary, 'html'); //$entry->SetContent($text, 'html'); $email = $r['email']; $entry->SetAuthor($r['nickname'], $this->_Atom->Link->HRef, $email); $entry->SetPublished($objDate->ToISO($r['publishtime'])); $entry->SetUpdated($objDate->ToISO($r['updatetime'])); $model = $this->gadget->model->load('Categories'); $cats = $model->GetCategoriesInEntry($r['id']); foreach ($cats as $c) { $schema = $this->gadget->urlMap('ShowCategory', array('id' => $c['id']), true); $entry->AddCategory($c['id'], $c['name'], $schema); } $this->_Atom->AddEntry($entry); if (!isset($last_modified) || $last_modified < $r['updatetime']) { $last_modified = $r['updatetime']; } } if (isset($last_modified)) { $this->_Atom->SetUpdated($objDate->ToISO($last_modified)); } else { $this->_Atom->SetUpdated($objDate->ToISO(date('Y-m-d H:i:s'))); } return $this->_Atom; }