1<?php
2
3/**
4 * ODTMeta: class for maintaining the meta data of an ODT document.
5 *          Code was previously included in renderer.php.
6 *
7 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
8 * @author Andreas Gohr <andi@splitbrain.org>
9 * @author Aurelien Bompard <aurelien@bompard.org>
10 * @author LarsDW223
11 */
12class ODTMeta
13{
14    var $meta = array();
15
16    /**
17     * Constructor. Set initial meta data.
18     */
19    public function __construct() {
20        $this->meta = array(
21                'meta:generator'            => 'DokuWiki '.getversion(),
22                'meta:initial-creator'      => 'Generated',
23                'meta:creation-date'        => date('Y-m-d\\TH::i:s', null), //FIXME
24                'dc:creator'                => 'Generated',
25                'dc:date'                   => date('Y-m-d\\TH::i:s', null),
26                'dc:language'               => 'en-US',
27                'meta:editing-cycles'       => '1',
28                'meta:editing-duration'     => 'PT0S',
29            );
30    }
31
32    /**
33     * @param string $title
34     */
35    function setTitle ($title) {
36        $this->meta ['dc:title'] = $title;
37    }
38
39    /**
40     * Returns the complete meta content.
41     */
42    function getContent(){
43        $value  =   '<' . '?xml version="1.0" encoding="UTF-8"?' . ">\n";
44        $value .=   '<office:document-meta ';
45        $value .=       'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" ';
46        $value .=       'xmlns:xlink="http://www.w3.org/1999/xlink" ';
47        $value .=       'xmlns:dc="http://purl.org/dc/elements/1.1/" ';
48        $value .=       'xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" ';
49        $value .=       'xmlns:ooo="http://openoffice.org/2004/office" ';
50        $value .=       'xmlns:grddl="http://www.w3.org/2003/g/data-view#" ';
51        $value .=       'office:version="1.2">';
52        $value .=       '<office:meta>';
53        # FIXME
54        foreach($this->meta as $meta_key => $meta_value) {
55            $value .= '<' . $meta_key . '>' . htmlspecialchars($meta_value, ENT_QUOTES, 'UTF-8') . '</' . $meta_key . '>';
56        }
57        $value .=       '</office:meta>';
58        $value .=   '</office:document-meta>';
59        return $value;
60    }
61}
62