Skip to content

Commit 09f226c

Browse files
committed
Corrected merge failures. Updated plugin.info.txt/ChangeLog.txt.
1 parent 5c3ce78 commit 09f226c

File tree

7 files changed

+42
-427
lines changed

7 files changed

+42
-427
lines changed

ChangeLog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2015-07-04 LarsDW223
2+
3+
* Added/merged support for exporting books to ODT (interface to bookcreator plugin).
4+
This is a contribution from Klap-in. Thanks a lot!
5+
16
2015-06-08 LarsDW223
27

38
* Fixed issue 'Table does not span across 100% of the page #40'.

ODT/ODTTemplateDH.php

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// must be run within Dokuwiki
1414
if(!defined('DOKU_INC')) die();
1515

16-
require_once DOKU_INC.'inc/ZipLib.class.php';
16+
require_once DOKU_INC.'inc/io.php';
1717
require_once DOKU_INC.'lib/plugins/odt/ODT/ODTmanifest.php';
1818
require_once DOKU_INC.'lib/plugins/odt/ODT/docHandler.php';
1919

@@ -23,6 +23,7 @@
2323
class ODTTemplateDH extends docHandler
2424
{
2525
var $template = null;
26+
var $directory = null;
2627

2728
/**
2829
* Constructor.
@@ -40,6 +41,15 @@ public function setTemplate($template) {
4041
$this->template = $template;
4142
}
4243

44+
/**
45+
* Set the template directory.
46+
*
47+
* @param string $directory
48+
*/
49+
public function setDirectory($directory) {
50+
$this->directory = $directory;
51+
}
52+
4353
/**
4454
* Build the document from the template.
4555
* (code taken from old function 'document_end_scratch')
@@ -65,12 +75,15 @@ public function build($doc=null, $autostyles=null, $commonstyles=null, $meta=nul
6575
$temp_dir = $conf['savedir'].'/cache/tmp';
6676
}
6777
$temp_dir = $temp_dir."/odt/".str_replace(':','-',$ID);
68-
if (is_dir($temp_dir)) { $this->io_rm_rf($temp_dir); }
78+
if (is_dir($temp_dir)) { io_rmdir($temp_dir,true); }
6979
io_mkdir_p($temp_dir);
7080

7181
// Extract template
72-
$template_path = $conf['mediadir'].'/'.$this->getConf("tpl_dir")."/".$this->template; // FIXME replace plugin function getConf()
73-
$this->ZIP->Extract($template_path, $temp_dir);
82+
$template_path = $conf['mediadir'].'/'.$this->directory."/".$this->template;
83+
$ok = $this->ZIP->Extract($template_path, $temp_dir);
84+
if($ok == -1){
85+
throw new Exception(' Error extracting the zip archive:'.$template_path.' to '.$temp_dir);
86+
}
7487

7588
// Prepare content
7689
$missingstyles = $styleset->getMissingStyles($temp_dir.'/styles.xml');
@@ -110,7 +123,7 @@ public function build($doc=null, $autostyles=null, $commonstyles=null, $meta=nul
110123

111124
// Build the Zip
112125
$this->ZIP->Compress(null, $temp_dir, null);
113-
$this->io_rm_rf($temp_dir);
126+
io_rmdir($temp_dir,true);
114127
}
115128

116129
/**
@@ -130,26 +143,5 @@ protected function _odtReplaceInFile($from, $to, $file, $regexp=FALSE) {
130143
fwrite($file_f, $value);
131144
fclose($file_f);
132145
}
133-
134-
/**
135-
* Recursively deletes a directory (equivalent to the "rm -rf" command)
136-
* Found in comments on http://www.php.net/rmdir
137-
*
138-
* @param string $f
139-
*/
140-
protected function io_rm_rf($f) {
141-
if (is_dir($f)) {
142-
foreach(glob($f.'/*') as $sf) {
143-
if (is_dir($sf) && !is_link($sf)) {
144-
$this->io_rm_rf($sf);
145-
} else {
146-
unlink($sf);
147-
}
148-
}
149-
} else { // avoid nasty consequenses if something wrong is given
150-
die("Error: not a directory - $f");
151-
}
152-
rmdir($f);
153-
}
154146
}
155147

0 commit comments

Comments
 (0)