aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche
diff options
context:
space:
mode:
authortcit <tcit@tcit.fr>2014-07-25 00:33:19 +0200
committertcit <tcit@tcit.fr>2014-07-25 00:33:19 +0200
commitdeab6280d3cbe3f8d001ff5214d36399653e3027 (patch)
tree674491cc45923e35f6d9bff8468b6a9d9c859c6b /inc/poche
parentd07abb5c42a816c94d05c5a1d7a78122e1b8b65c (diff)
downloadwallabag-deab6280d3cbe3f8d001ff5214d36399653e3027.tar.gz
wallabag-deab6280d3cbe3f8d001ff5214d36399653e3027.tar.zst
wallabag-deab6280d3cbe3f8d001ff5214d36399653e3027.zip
mobi (not tested on actual device) and pdf working
Diffstat (limited to 'inc/poche')
-rw-r--r--inc/poche/WallabagEBooks.class.php26
1 files changed, 19 insertions, 7 deletions
diff --git a/inc/poche/WallabagEBooks.class.php b/inc/poche/WallabagEBooks.class.php
index deaf57e2..2b18b718 100644
--- a/inc/poche/WallabagEBooks.class.php
+++ b/inc/poche/WallabagEBooks.class.php
@@ -36,7 +36,7 @@ class WallabagEBooks
36 break; 36 break;
37 case 'all': 37 case 'all':
38 $this->entries = $this->wallabag->store->retrieveAll($this->wallabag->user->getId()); 38 $this->entries = $this->wallabag->store->retrieveAll($this->wallabag->user->getId());
39 $this->bookTitle = sprintf(_('All my articles on '), date(_('d.m.y'))); #translatable because each country has it's own date format system 39 $this->bookTitle = sprintf(_('All my articles on %s'), date(_('d.m.y'))); #translatable because each country has it's own date format system
40 $this->bookFileName = _('Allarticles') . date(_('dmY')); 40 $this->bookFileName = _('Allarticles') . date(_('dmY'));
41 break; 41 break;
42 case 'tag': 42 case 'tag':
@@ -154,17 +154,17 @@ class WallabagMobi extends WallabagEBooks
154 public function produceMobi($send = FALSE) 154 public function produceMobi($send = FALSE)
155 { 155 {
156 156
157 # Good try
158 $mobi = new MOBI(); 157 $mobi = new MOBI();
159 158
160 $content = new MOBIFile(); 159 $content = new MOBIFile();
161 160
162 $content->set("title", $this->bookTitle); 161 $content->set("title", $this->bookTitle);
163 $content->set("author", "wallabag"); 162 $content->set("author", "wallabag");
163 $content->set("subject", $this->bookTitle);
164 164
165 # introduction 165 # introduction
166 //$content->appendChapterTitle("Cover"); 166 //$content->appendChapterTitle("Cover");
167 $content->appendParagraph('<div style="text-align:center;"><p>' . _('Produced by wallabag with PHPMobi') . '</p><p>'. _('Please open <a href="https://github.com/wallabag/wallabag/issues" >an issue</a> if you have trouble with the display of this E-Book on your device.') . '</p></div>'); 167 $content->appendParagraph('<div style="text-align:center;" ><p>' . _('Produced by wallabag with PHPMobi') . '</p><p>'. _('Please open <a href="https://github.com/wallabag/wallabag/issues" >an issue</a> if you have trouble with the display of this E-Book on your device.') . '</p></div>');
168 $content->appendImage(imagecreatefrompng("themes/baggy/img/apple-touch-icon-152.png")); 168 $content->appendImage(imagecreatefrompng("themes/baggy/img/apple-touch-icon-152.png"));
169 $content->appendPageBreak(); 169 $content->appendPageBreak();
170 170
@@ -183,20 +183,25 @@ class WallabagPDF extends WallabagEbooks
183{ 183{
184 public function producePDF() 184 public function producePDF()
185 { 185 {
186 //$this->prepareData();
187 $mpdf = new mPDF('c'); 186 $mpdf = new mPDF('c');
188 187
189 # intro 188 # intro
190 189
191 $html = '<h1>' . $this->bookTitle . '</h1><img src="themes/baggy/img/apple-touch-icon-152.png" />'; 190 $html = '<h1>' . $this->bookTitle . '<bookmark content="Cover" /></h1><div style="text-align:center;" >
191 <p>' . _('Produced by wallabag with mPDF') . '</p>
192 <p>'. _('Please open <a href="https://github.com/wallabag/wallabag/issues" >an issue</a> if you have trouble with the display of this E-Book on your device.') . '</p>
193 <img src="themes/baggy/img/apple-touch-icon-152.png" /></div>';
194 $html .= '<pagebreak type="next-odd" />';
195 $i = 1;
192 196
193 foreach ($this->entries as $item) { 197 foreach ($this->entries as $item) {
194 $html .= '<h1>' . $item['title'] . '</h1>'; 198 $html .= '<h1>' . $item['title'] . '<bookmark content="' . $item['title'] . '" /></h1>';
195 $html .= '<indexentry content="'. $item['title'] .'" />'; 199 $html .= '<indexentry content="'. $item['title'] .'" />';
196 $html .= $item['content']; 200 $html .= $item['content'];
201 $html .= '<pagebreak type="next-odd" />';
202 $i = $i+1;
197 } 203 }
198 204
199 //$mpdf->h2toc = array('H1'=>0);
200 205
201 # headers 206 # headers
202 $mpdf->SetHeader('{DATE j-m-Y}|{PAGENO}/{nb}|Produced with wallabag'); 207 $mpdf->SetHeader('{DATE j-m-Y}|{PAGENO}/{nb}|Produced with wallabag');
@@ -207,6 +212,13 @@ class WallabagPDF extends WallabagEbooks
207 # remove characters that make mpdf bug 212 # remove characters that make mpdf bug
208 $char_in = array('/', '.', ',', ':', '|'); 213 $char_in = array('/', '.', ',', ':', '|');
209 $pdfExportName = preg_replace('/\s+/', '-', str_replace($char_in, '-', $this->bookFileName . '.pdf')); 214 $pdfExportName = preg_replace('/\s+/', '-', str_replace($char_in, '-', $this->bookFileName . '.pdf'));
215
216 # index
217 $html = '<h2>Index<bookmark content="Index" /></h2>
218 <indexinsert cols="2" offset="5" usedivletters="on" div-font-size="15" gap="5" font="Trebuchet" div-font="sans-serif" links="on" />
219 ';
220
221 $mpdf->WriteHTML($html);
210 222
211 $mpdf->Output('cache/' . $pdfExportName); 223 $mpdf->Output('cache/' . $pdfExportName);
212 224