forked from lpaulsen93/dokuwiki-plugin-odt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ODTmeta.php
61 lines (57 loc) · 2.2 KB
/
ODTmeta.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
<?php
/**
* ODTMeta: class for maintaining the meta data of an ODT document.
* Code was previously included in renderer.php.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <[email protected]>
* @author Aurelien Bompard <[email protected]>
* @author LarsDW223
*/
class ODTMeta
{
var $meta = array();
/**
* Constructor. Set initial meta data.
*/
public function __construct() {
$this->meta = array(
'meta:generator' => 'DokuWiki '.getversion(),
'meta:initial-creator' => 'Generated',
'meta:creation-date' => date('Y-m-d\\TH::i:s', null), //FIXME
'dc:creator' => 'Generated',
'dc:date' => date('Y-m-d\\TH::i:s', null),
'dc:language' => 'en-US',
'meta:editing-cycles' => '1',
'meta:editing-duration' => 'PT0S',
);
}
/**
* @param string $title
*/
function setTitle ($title) {
$this->meta ['dc:title'] = $title;
}
/**
* Returns the complete meta content.
*/
function getContent(){
$value = '<' . '?xml version="1.0" encoding="UTF-8"?' . ">\n";
$value .= '<office:document-meta ';
$value .= 'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" ';
$value .= 'xmlns:xlink="http://www.w3.org/1999/xlink" ';
$value .= 'xmlns:dc="http://purl.org/dc/elements/1.1/" ';
$value .= 'xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" ';
$value .= 'xmlns:ooo="http://openoffice.org/2004/office" ';
$value .= 'xmlns:grddl="http://www.w3.org/2003/g/data-view#" ';
$value .= 'office:version="1.2">';
$value .= '<office:meta>';
# FIXME
foreach($this->meta as $meta_key => $meta_value) {
$value .= '<' . $meta_key . '>' . htmlspecialchars($meta_value, ENT_QUOTES, 'UTF-8') . '</' . $meta_key . '>';
}
$value .= '</office:meta>';
$value .= '</office:document-meta>';
return $value;
}
}