-
Notifications
You must be signed in to change notification settings - Fork 26
/
page.php
2285 lines (2036 loc) · 77.5 KB
/
page.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* ODT Plugin: Exports to ODT
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
* @author Aurelien Bompard <aurelien@bompard.org>
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
require_once DOKU_PLUGIN . 'odt/helper/cssimport.php';
require_once DOKU_PLUGIN . 'odt/ODT/ODTDefaultStyles.php';
// Central class for ODT export
require_once DOKU_PLUGIN . 'odt/ODT/ODTDocument.php';
/**
* The Page Renderer
*
* @package DokuWiki\Renderer\Page
*/
class renderer_plugin_odt_page extends Doku_Renderer {
/** @var helper_plugin_odt_cssimport */
protected $import = null;
/** @var helper_plugin_odt_config */
protected $config = null;
protected $document = null;
/** @var string */
protected $css;
/** @var bool */
protected $init_ok;
/**
* Constructor. Loads helper plugins.
*/
public function __construct() {
// Set up empty array with known config parameters
$this->config = plugin_load('helper', 'odt_config');
// Create and initialize document
$this->document = new ODTDocument();
$this->init_ok = $this->document->initialize ();
}
/**
* Set a config parameter from extern.
*/
public function setConfigParam($name, $value) {
$this->config->setParam($name, $value);
}
/**
* Is the $string specified the name of a ODT plugin config parameter?
*
* @return bool Is it a config parameter?
*/
public function isConfigParam($string) {
return $this->config->isParam($string);
}
/**
* Returns the format produced by this renderer.
*/
function getFormat(){
return "odt";
}
/**
* Do not make multiple instances of this class
*/
function isSingleton(){
return true;
}
public function replaceURLPrefixesCallback ($property, $value, $url) {
if (strncmp($url, '/lib/plugins', strlen('/lib/plugins')) == 0) {
return DOKU_INC.substr($url,1);
}
return $url;
}
/**
* Load and imports CSS.
*/
protected function load_css() {
global $conf, $lang;
/** @var helper_plugin_odt_dwcssloader $loader */
$loader = plugin_load('helper', 'odt_dwcssloader');
if ( isset($loader) ) {
$this->css = $loader->load
('odt', 'odt', $this->config->getParam('css_template'));
}
// Import CSS (old API, deprecated)
$this->import = plugin_load('helper', 'odt_cssimport');
if ( isset($this->import) ) {
$this->import->importFromString ($this->css);
// Call adjustLengthValues to make our callback function being called for every
// length value imported. This gives us the chance to convert it once from
// pixel to points.
$this->import->adjustLengthValues (array($this, 'adjustLengthCallback'));
}
// Set CSS usage according to configuration
switch ($this->config->getParam('css_usage')) {
case 'basic style import':
$this->document->setCSSUsage('basic');
break;
case 'full':
$this->document->setCSSUsage('full');
break;
default:
$this->document->setCSSUsage('off');
break;
}
$this->document->setMediaSelector($this->config->getParam('media_sel'));
// Put some root element on the HTML stack which should always
// be present for our CSS matching
$this->document->addHTMLElement ('html', 'lang="'.$conf['lang'].'" dir="'.$lang['direction'].'"');
$this->document->addHTMLElement ('body');
$this->document->addHTMLElement ('div', 'id="dokuwiki__site"');
$this->document->addHTMLElement ('div', 'id="dokuwiki__top" class="site dokuwiki mode_show tpl_adoradark loggedIn"');
$this->document->addHTMLElement ('div', 'id="dokuwiki__content"');
$this->document->addHTMLElement ('div', 'class="page group"');
// Import CSS (new API)
$this->document->importCSSFromString
($this->css, $this->config->getParam('media_sel'), array($this, 'replaceURLPrefixesCallback'), false, $this->config->getParam('olist_label_align'));
}
/**
* Configure units to our configuration values.
*/
protected function setupUnits()
{
$this->document->setPixelPerEm($this->config->getParam ('css_font_size'));
$this->document->setTwipsPerPixelX($this->config->getParam ('twips_per_pixel_x'));
$this->document->setTwipsPerPixelY($this->config->getParam ('twips_per_pixel_y'));
}
/**
* Initialize the document,
* Do the things that are common to all documents regardless of the
* output format (ODT or PDF).
*/
function document_setup()
{
global $ID;
// First, get export mode.
$warning = '';
$mode = $this->config->load($warning);
// Setup Units before CSS import!
$this->setupUnits();
switch($mode) {
case 'ODT template':
case 'CSS template':
break;
default:
// Set ordered list alignment before calling load_css().
// load_css() will eventually overwrite the list settings!
$this->document->setOrderedListParams(NULL, $this->config->getParam('olist_label_align'));
$this->document->setUnorderedListParams(NULL, $this->config->getParam('olist_label_align'));
break;
}
// Import CSS files
$this->load_css();
switch($mode) {
case 'ODT template':
// Document based on ODT template.
$this->buildODTPathes ($ODTtemplate, $temp_dir);
$this->document->importODTStyles($ODTtemplate, $temp_dir);
if ($this->config->getParam ('apply_fs_to_non_css')) {
$this->document->adjustFontSizes($this->config->getParam('css_font_size').'pt');
}
break;
case 'CSS template':
// Document based on DokuWiki CSS template.
$media_sel = $this->config->getParam ('media_sel');
$template = $this->config->getParam ('odt_template');
$directory = $this->config->getParam ('tpl_dir');
$template_path = $this->config->getParam('mediadir').'/'.$directory."/".$template;
$this->document->importCSSFromFile
($template_path, $media_sel, array($this, 'replaceURLPrefixesCallback'), $this->config->getParam('olist_label_align'));
// Set outline style.
$this->document->setOutlineStyle($this->config->getParam('outline_list_style'));
break;
default:
// Document from scratch.
// Set outline style.
$this->document->setOutlineStyle($this->config->getParam('outline_list_style'));
if ($this->config->getParam ('apply_fs_to_non_css')) {
$this->document->adjustFontSizes($this->config->getParam('css_font_size').'pt');
}
break;
}
// If we are using ODT for style import (a template or the default 'styles.xml')
// then adjust the pixel per em value to the font-size of the default paragraph style
// otherwise plugins might inherit a wrong font-size on CSS import!
if ($mode != 'CSS template') {
$default = $this->document->getDefaultStyle ('paragraph');
if (isset($default)) {
$fontFize = $default->getProperty('font-size');
if (!empty($fontFize)) {
$fontFizeInPx = $this->document->toPixel($fontFize);
if (!empty($fontFizeInPx)) {
$this->document->setPixelPerEm(trim ($fontFizeInPx, 'px'));
}
}
}
}
// Setup page format.
$this->document->setStartPageFormat ($this->config->getParam ('format'),
$this->config->getParam ('orientation'),
$this->config->getParam ('margin_top'),
$this->config->getParam ('margin_right'),
$this->config->getParam ('margin_bottom'),
$this->config->getParam ('margin_left'));
// Set title in meta info.
// FIXME article title != book title SOLUTION: overwrite at the end for book
$this->document->setTitle($ID);
// Enable/disable links according to configuration
$disabled = $this->config->getParam ('disable_links');
if ($disabled) {
$this->document->disableLinks();
} else {
$this->document->enableLinks();
}
$this->set_page_bookmark($ID);
}
/**
* Initialize the rendering
*/
function document_start() {
global $ID;
if (!$this->init_ok) {
// Initialization of the ODT document failed!
// Send "Internal Server Error"
http_status(500);
$message = $this->getLang('init_failed_msg');
$message = str_replace('%DWVERSION%', getVersion(), $message);
$instructions = p_get_instructions($message);
print p_render('xhtml', $instructions, $info);
exit;
}
// Initialize the document
$this->document_setup();
// Create HTTP headers
$output_filename = str_replace(':','-',$ID).'.odt';
$headers = array(
'Content-Type' => 'application/vnd.oasis.opendocument.text',
'Content-Disposition' => 'attachment; filename="'.$output_filename.'";',
);
// store the content type headers in metadata
p_set_metadata($ID,array('format' => array('odt_page' => $headers) ));
}
/**
* Closes the document
*/
function document_end(){
// Build the document
$this->finalize_ODTfile();
// Refresh certain config parameters e.g. 'disable_links'
$this->config->refresh();
// Reset state.
$this->document->state->reset();
}
/**
* This function sets the page format.
* The format, orientation and page margins can be changed.
* See function queryFormat() in ODT/page.php for supported formats.
*
* @param string $format e.g. 'A4', 'A3'
* @param string $orientation e.g. 'portrait' or 'landscape'
* @param numeric $margin_top Top-Margin in cm, default 2
* @param numeric $margin_right Right-Margin in cm, default 2
* @param numeric $margin_bottom Bottom-Margin in cm, default 2
* @param numeric $margin_left Left-Margin in cm, default 2
* @see ODTDocument::setPageFormat
*/
public function setPageFormat ($format=NULL, $orientation=NULL, $margin_top=NULL, $margin_right=NULL, $margin_bottom=NULL, $margin_left=NULL) {
$this->document->setPageFormat ($format, $orientation, $margin_top, $margin_right, $margin_bottom, $margin_left);
}
/**
* Completes the ODT file.
*/
public function finalize_ODTfile() {
global $ID;
$this->buildODTPathes ($ODTtemplate, $temp_dir);
// Build/assign the document
$this->doc = $this->document->getODTFileAsString ($ODTtemplate, $temp_dir);
}
/**
* Simple setter to enable creating links.
*/
function enable_links() {
$this->config->setParam ('disable_links', false);
$this->document->enableLinks();
}
/**
* Simple setter to disable creating links.
*/
function disable_links() {
$this->config->setParam ('disable_links', true);
$this->document->disableLinks();
}
/**
* Dummy function.
*
* @return string
*/
function render_TOC() {
return '';
}
/**
* This function does not really render an index but inserts a placeholder.
*
* @return string
* @see ODTDocument::insertIndex for API wrapper function
* @see ODTIndex::insertIndex for more information
*/
function render_index($type='toc', $settings=NULL) {
$data = array();
$data = $this->get_index_settings($type, $settings);
$this->document->insertIndex($type, $data);
return '';
}
/**
* This function detmerines the settings for a TOC or chapter index.
* The layout settings are taken from the configuration and $settings.
* The result is returned as an array.
*
* $settings can include the following options syntax:
* - Title e.g. 'title=Example;'.
* Default is 'Table of Contents' (for english, see language files for other languages default value).
* - Leader sign, e.g. 'leader-sign=.;'.
* Default is '.'.
* - Indents (in cm), e.g. 'indents=indents=0,0.5,1,1.5,2,2.5,3;'.
* Default is 0.5 cm indent more per level.
* - Maximum outline/TOC level, e.g. 'maxtoclevel=5;'.
* Default is taken from DokuWiki config setting 'maxtoclevel'.
* - Insert pagebreak after TOC, e.g. 'pagebreak=1;'.
* Default is '1', means insert pagebreak after TOC.
* - Set style per outline/TOC level, e.g. 'styleL2="color:red;font-weight:900;";'.
* Default is 'color:black'.
*
* It is allowed to use defaults for all settings by omitting $settings.
* Multiple settings can be combined, e.g. 'leader-sign=.;indents=0,0.5,1,1.5,2,2.5,3;'.
*/
protected function get_index_settings($type, $settings) {
$matches = array();
$data = array();
$data ['numbered_headings'] = false;
if ($this->config->getParam('outline_list_style') == 'Numbers') {
$data ['numbered_headings'] = true;
}
// It seems to be not supported in ODT to have a different start
// outline level than 1.
$data ['maxlevel'] = $this->config->getParam('toc_maxlevel');
if ( preg_match('/maxlevel=[^;]+;/', $settings, $matches) === 1 ) {
$temp = substr ($matches [0], 9);
$temp = trim ($temp, ';');
$data ['maxlevel'] = $temp;
}
// Determine title, default for table of contents is 'Table of Contents'.
// Default for chapter index is empty.
// Syntax for 'Test' as title would be "title=test;".
$data ['title'] = '';
if ($type == 'toc') {
$data ['title'] = $this->getLang('toc_title');
}
if ( preg_match('/title=[^;]+;/', $settings, $matches) === 1 ) {
$temp = substr ($matches [0], 6);
$temp = trim ($temp, ';');
$data ['title'] = $temp;
}
// Determine leader-sign, default is '.'.
// Syntax for '.' as leader-sign would be "leader_sign=.;".
$data ['leader_sign'] = $this->config->getParam('toc_leader_sign');
if ( preg_match('/leader_sign=[^;]+;/', $settings, $matches) === 1 ) {
$temp = substr ($matches [0], 12);
$temp = trim ($temp, ';');
$data ['leader_sign'] = $temp [0];
}
// Determine indents, default is '0.5' (cm) per level.
// Syntax for a indent of '0.5' for 5 levels would be "indents=0,0.5,1,1.5,2;".
// The values are absolute for each level, not relative to the higher level.
$data ['indents'] = explode (',', $this->config->getParam('toc_indents'));
if ( preg_match('/indents=[^;]+;/', $settings, $matches) === 1 ) {
$temp = substr ($matches [0], 8);
$temp = trim ($temp, ';');
$data ['indents'] = explode (',', $temp);
}
// Determine pagebreak, default is on '1'.
// Syntax for pagebreak off would be "pagebreak=0;".
$data ['pagebreak'] = $this->config->getParam('toc_pagebreak');
if ( preg_match('/pagebreak=[^;]+;/', $settings, $matches) === 1 ) {
$temp = substr ($matches [0], 10);
$temp = trim ($temp, ';');
$data ['pagebreak'] = 'false';
if ( $temp == '1' ) {
$data ['pagebreak'] = 'true';
} else if ( strcasecmp($temp, 'true') == 0 ) {
$data ['pagebreak'] = 'true';
}
}
// Determine text style for the index heading.
$data ['style_heading'] = NULL;
if ( preg_match('/styleH="[^"]+";/', $settings, $matches) === 1 ) {
$quote = strpos ($matches [0], '"');
$temp = substr ($matches [0], $quote+1);
$temp = trim ($temp, '";');
$data ['style_heading'] = $temp.';';
}
// Determine text styles per level.
// Syntax for a style level 1 is "styleL1="color:black;"".
// The default style is just 'color:black;'.
for ( $count = 0 ; $count < $data ['maxlevel'] ; $count++ ) {
$data ['styleL'.($count + 1)] = $this->config->getParam('toc_style');
if ( preg_match('/styleL'.($count + 1).'="[^"]+";/', $settings, $matches) === 1 ) {
$quote = strpos ($matches [0], '"');
$temp = substr ($matches [0], $quote+1);
$temp = trim ($temp, '";');
$data ['styleL'.($count + 1)] = $temp.';';
}
}
return $data;
}
/**
* Add an item to the TOC
* (Dummy function required by the Doku_Renderer class)
*
* @param string $id the hash link
* @param string $text the text to display
* @param int $level the nesting level
*/
function toc_additem($id, $text, $level) {}
/**
* Return total page width in centimeters
* (margins are included)
*
* @see ODTDocument::getWidth for API wrapper function
* @see pageFormat::getWidth for more information
* @author LarsDW223
*/
function _getPageWidth(){
return $this->document->getWidth();
}
/**
* Return total page height in centimeters
* (margins are included)
*
* @see ODTDocument::getHeight for API wrapper function
* @see pageFormat::getHeight for more information
* @author LarsDW223
*/
function _getPageHeight(){
return $this->document->getHeight();
}
/**
* Return left margin in centimeters
*
* @see ODTDocument::getMarginLeft for API wrapper function
* @see pageFormat::getMarginLeft for more information
* @author LarsDW223
*/
function _getLeftMargin(){
return $this->document->getMarginLeft();
}
/**
* Return right margin in centimeters
*
* @see ODTDocument::getMarginRight for API wrapper function
* @see pageFormat::getMarginRight for more information
* @author LarsDW223
*/
function _getRightMargin(){
return $this->document->getMarginRight();
}
/**
* Return top margin in centimeters
*
* @see ODTDocument::getMarginTop for API wrapper function
* @see pageFormat::getMarginTop for more information
* @author LarsDW223
*/
function _getTopMargin(){
return $this->document->getMarginTop();
}
/**
* Return bottom margin in centimeters
*
* @see ODTDocument::getMarginBottom for API wrapper function
* @see pageFormat::getMarginBottom for more information
* @author LarsDW223
*/
function _getBottomMargin(){
return $this->document->getMarginBottom();
}
/**
* Return width percentage value if margins are taken into account.
* Usually "100%" means 21cm in case of A4 format.
* But usually you like to take care of margins. This function
* adjusts the percentage to the value which should be used for margins.
* So 100% == 21cm e.g. becomes 80.9% == 17cm (assuming a margin of 2 cm on both sides).
*
* @param int|string $percentage
* @return int|string
*
* @see ODTDocument::getRelWidthMindMargins for API wrapper function
* @see pageFormat::getRelWidthMindMargins for more information
* @author LarsDW223
*/
function _getRelWidthMindMargins ($percentage = '100'){
return $this->document->getRelWidthMindMargins($percentage);
}
/**
* Like _getRelWidthMindMargins but returns the absulute width
* in centimeters.
*
* @param string|int|float $percentage
* @return float
*
* @see ODTDocument::getAbsWidthMindMargins for API wrapper function
* @see pageFormat::getAbsWidthMindMargins for more information
* @author LarsDW223
*/
function _getAbsWidthMindMargins ($percentage = '100'){
return $this->document->getAbsWidthMindMargins($percentage);
}
/**
* Return height percentage value if margins are taken into account.
* Usually "100%" means 29.7cm in case of A4 format.
* But usually you like to take care of margins. This function
* adjusts the percentage to the value which should be used for margins.
* So 100% == 29.7cm e.g. becomes 86.5% == 25.7cm (assuming a margin of 2 cm on top and bottom).
*
* @param string|float|int $percentage
* @return float|string
*
* @see ODTDocument::getRelHeightMindMargins for API wrapper function
* @see pageFormat::getRelHeightMindMargins for more information
* @author LarsDW223
*/
function _getRelHeightMindMargins ($percentage = '100'){
return $this->document->getRelHeightMindMargins($percentage);
}
/**
* Like _getRelHeightMindMargins but returns the absulute width
* in centimeters.
*
* @param string|int|float $percentage
* @return float
*
* @see ODTDocument::getAbsHeightMindMargins for API wrapper function
* @see pageFormat::getAbsHeightMindMargins for more information
* @author LarsDW223
*/
function _getAbsHeightMindMargins ($percentage = '100'){
return $this->document->getAbsHeightMindMargins($percentage);
}
/**
* Render plain text data.
*
* @param string $text
* @see ODTDocument::addPlainText for more information
*/
function cdata($text) {
$this->document->addPlainText($text);
}
/**
* Open a paragraph.
*
* @param string $style Name of the style to use for the paragraph
*
* @see ODTDocument::paragraphOpen for API wrapper function
* @see ODTParagraph::paragraphOpen for more information
*/
function p_open($style=NULL){
$this->document->paragraphOpen($style);
}
/**
* Close a paragraph.
*
* @see ODTDocument::paragraphClose for API wrapper function
* @see ODTParagraph::paragraphClose for more information
*/
function p_close(){
$this->document->paragraphClose();
}
/**
* Set bookmark for the start of the page. This just saves the title temporarily.
* It is then to be inserted in the first header or paragraph.
*
* @param string $id ID of the bookmark
*/
function set_page_bookmark($id){
$this->document->setPageBookmark($id);
}
/**
* Render a heading
*
* @param string $text the text to display
* @param int $level header level
* @param int $pos byte position in the original source
*/
function header($text, $level, $pos){
$this->document->heading($text, $level);
}
function hr() {
$this->document->horizontalRule();
}
function linebreak() {
$this->document->linebreak();
}
function pagebreak() {
$this->document->pagebreak();
}
function strong_open() {
$this->document->spanOpen($this->document->getStyleName('strong'));
}
function strong_close() {
$this->document->spanClose();
}
function emphasis_open() {
$this->document->spanOpen($this->document->getStyleName('emphasis'));
}
function emphasis_close() {
$this->document->spanClose();
}
function underline_open() {
$this->document->spanOpen($this->document->getStyleName('underline'));
}
function underline_close() {
$this->document->spanClose();
}
function monospace_open() {
$this->document->spanOpen($this->document->getStyleName('monospace'));
}
function monospace_close() {
$this->document->spanClose();
}
function subscript_open() {
$this->document->spanOpen($this->document->getStyleName('sub'));
}
function subscript_close() {
$this->document->spanClose();
}
function superscript_open() {
$this->document->spanOpen($this->document->getStyleName('sup'));
}
function superscript_close() {
$this->document->spanClose();
}
function deleted_open() {
$this->document->spanOpen($this->document->getStyleName('del'));
}
function deleted_close() {
$this->document->spanClose();
}
function generateSpansfromHTMLCode($HTMLCode){
$this->document->generateSpansfromHTMLCode($HTMLCode);
}
/*
* Tables
*/
/**
* Start a table
*
* @param int $maxcols maximum number of columns
* @param int $numrows NOT IMPLEMENTED
*/
function table_open($maxcols = NULL, $numrows = NULL, $pos = NULL){
$this->document->tableOpen($maxcols, $numrows);
}
function table_close($pos = NULL){
$this->document->tableClose();
}
function tablecolumn_add(){
$this->document->tableAddColumn();
}
function tablerow_open(){
$this->document->tableRowOpen();
}
function tablerow_close(){
$this->document->tableRowClose();
}
/**
* Open a table header cell
*
* @param int $colspan
* @param string $align left|center|right
* @param int $rowspan
*/
function tableheader_open($colspan = 1, $align = "left", $rowspan = 1){
$this->document->tableHeaderOpen($colspan, $rowspan, $align);
}
function tableheader_close(){
$this->document->tableHeaderClose();
}
/**
* Open a table cell
*
* @param int $colspan
* @param string $align left|center|right
* @param int $rowspan
*/
function tablecell_open($colspan = 1, $align = "left", $rowspan = 1){
$this->document->tableCellOpen($colspan, $rowspan, $align);
}
function tablecell_close(){
$this->document->tableCellClose();
}
/**
* Callback for footnote start syntax.
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function footnote_open() {
$this->document->footnoteOpen();
}
/**
* Callback for footnote end syntax.
*
* @author Andreas Gohr
*/
function footnote_close() {
$this->document->footnoteClose();
}
function listu_open($continue=false) {
$this->document->listOpen($continue, $this->document->getStyleName('list'), 'ul');
}
function listu_close() {
$this->document->listClose();
}
function listo_open($continue=false) {
$this->document->listOpen($continue, $this->document->getStyleName('numbering'), 'ol');
}
function listo_close() {
$this->document->listClose();
}
function list_close() {
$this->document->listClose();
}
/**
* Open a list item
*
* @param int $level the nesting level
*/
function listitem_open($level, $node = false) {
$this->document->listItemOpen($level);
}
function listitem_close() {
$this->document->listItemClose();
}
/**
* Open a list header
*
* @param int $level the nesting level
*/
function listheader_open($level) {
$this->document->listHeaderOpen($level);
}
function listheader_close() {
$this->document->listHeaderClose();
}
function listcontent_open() {
$this->document->listContentOpen();
}
function listcontent_close() {
$this->document->listContentClose();
}
/**
* Output unformatted $text
*
* @param string $text
*/
function unformatted($text) {
$this->document->addPlainText($text);
}
/**
* Format an acronym
*
* @param string $acronym
*/
function acronym($acronym) {
$this->document->addPlainText($acronym);
}
/**
* @param string $smiley
*/
function smiley($smiley) {
if ( array_key_exists($smiley, $this->smileys) ) {
$src = DOKU_INC."lib/images/smileys/".$this->smileys[$smiley];
$this->_odtAddImage($src);
} else {
$this->document->addPlainText($smiley);
}
}
/**
* Format an entity
*
* @param string $entity
*/
function entity($entity) {
if (array_key_exists($entity, $this->entities)) {
$entity = $this->entities[$entity];
}
// Add plain text will replace XML entities
$this->document->addPlainText($entity);
}
/**
* Typographically format a multiply sign
*
* Example: ($x=640, $y=480) should result in "640×480"
*
* @param string|int $x first value
* @param string|int $y second value
*/
function multiplyentity($x, $y) {
$text = $x.'×'.$y;
$this->document->addPlainText($text);
}
function singlequoteopening() {
global $lang;
$text = $lang['singlequoteopening'];
$this->document->addPlainText($text);
}
function singlequoteclosing() {
global $lang;
$text = $lang['singlequoteclosing'];
$this->document->addPlainText($text);
}
function apostrophe() {
global $lang;
$text = $lang['apostrophe'];
$this->document->addPlainText($text);
}
function doublequoteopening() {
global $lang;
$text = $lang['doublequoteopening'];
$this->document->addPlainText($text);
}
function doublequoteclosing() {
global $lang;
$text = $lang['doublequoteclosing'];
$this->document->addPlainText($text);
}
/**
* Output inline PHP code
*
* @param string $text The PHP code
*/
function php($text) {
$this->monospace_open();
$this->document->addPlainText($text);
$this->monospace_close();
}
/**
* Output block level PHP code
*
* @param string $text The PHP code
*/
function phpblock($text) {
$this->file($text);
}
/**
* Output raw inline HTML
*
* @param string $text The HTML
*/
function html($text) {
$this->monospace_open();
$this->document->addPlainText($text);
$this->monospace_close();
}
/**
* Output raw block-level HTML
*
* @param string $text The HTML
*/
function htmlblock($text) {