]> git.pld-linux.org Git - packages/dokuwiki-plugin-include.git/blame - dokuwiki-include-odt.patch
- update to 20080707
[packages/dokuwiki-plugin-include.git] / dokuwiki-include-odt.patch
CommitLineData
547abce4
ER
1diff --git a/helper.php b/helper.php
2index 0beb7ac..dd9af45 100644
3--- a/helper.php
4+++ b/helper.php
5@@ -223,6 +223,38 @@ class helper_plugin_include extends DokuWiki_Plugin { // DokuWiki_Helper_Plugin
6 return $this->doc;
7 }
8
9+ /**
10+ * Builds the ODT to embed the page to include
11+ */
12+ function renderODT(&$renderer){
13+ global $ID;
14+
15+ if (!$this->page['id']) return ''; // page must be set first
16+ if (!$this->page['exists'] && ($this->page['perm'] < AUTH_CREATE)) return '';
17+
18+ // prepare variable
19+ $this->renderer =& $renderer;
20+
21+ // get instructions and render them on the fly
22+ $this->ins = p_cached_instructions($this->page['file']);
23+
24+ // show only a given section?
25+ if ($this->page['section'] && $this->page['exists']) $this->_getSection();
26+
27+ // convert relative links
28+ $this->_convertInstructions();
29+
30+ // render the included page
31+ $backupID = $ID; // store the current ID
32+ $ID = $this->page['id']; // change ID to the included page
33+ // remove document_start and document_end to avoid zipping
34+ $this->ins = array_slice($this->ins, 1, -1);
35+ p_render('odt', $this->ins, $info);
36+ $ID = $backupID; // restore ID
37+ // reset defaults
38+ $this->helper_plugin_include();
39+ }
40+
41 /* ---------- Private Methods ---------- */
42
43 /**
44diff --git a/syntax.php b/syntax.php
45index fb6548b..5d08253 100644
46--- a/syntax.php
47+++ b/syntax.php
48@@ -100,6 +100,21 @@ class syntax_plugin_include extends DokuWiki_Syntax_Plugin {
49
50 return true;
51
52+ } elseif ($mode == 'odt'){
53+ if ($nocache) $renderer->info['cache'] = false;
54+
55+ // current section level
56+ $clevel = 0;
57+ preg_match_all('|<text:h text:style-name="Heading_20_\d" text:outline-level="(\d)">|i', $renderer->doc, $matches, PREG_SET_ORDER);
58+ $n = count($matches) - 1;
59+ if ($n > -1) $clevel = $matches[$n][1];
60+ $include->setLevel($clevel);
61+
62+ // include the page now
63+ $include->renderODT($renderer);
64+
65+ return true;
66+
67 // for metadata renderer
68 } elseif ($mode == 'metadata'){
69 if (!$flg_macro) $renderer->meta['relation']['haspart'][$id] = $exists;
This page took 0.040402 seconds and 4 git commands to generate.