Refactored ConfigFile class so that it is no longer a singleton
[phpmyadmin.git] / libraries / opendocument.lib.php
blob08ff2b16b748d321c7decfb22b1241ceb3e79436
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Simple interface for creating OASIS OpenDocument files.
6 * @package PhpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /**
13 * Load ZIP handler.
15 require_once './libraries/zip.lib.php';
17 $GLOBALS['OpenDocumentNS']
18 = 'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" '
19 . 'xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" '
20 . 'xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" '
21 . 'xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" '
22 . 'xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" '
23 . 'xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" ';
25 /**
26 * Minimalistic creator of OASIS OpenDocument
28 * @param string $mime desired MIME type
29 * @param string $data document content
31 * @return string OASIS OpenDocument data
33 * @access public
35 function PMA_createOpenDocument($mime, $data)
37 $zipfile = new ZipFile();
38 $zipfile -> addFile($mime, 'mimetype');
39 $zipfile -> addFile($data, 'content.xml');
40 $zipfile -> addFile(
41 '<?xml version="1.0" encoding="UTF-8"?'. '>'
42 . '<office:document-meta '
43 . 'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" '
44 . 'xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" '
45 . 'office:version="1.0">'
46 . '<office:meta>'
47 . '<meta:generator>phpMyAdmin ' . PMA_VERSION . '</meta:generator>'
48 . '<meta:initial-creator>phpMyAdmin ' . PMA_VERSION
49 . '</meta:initial-creator>'
50 . '<meta:creation-date>' . strftime('%Y-%m-%dT%H:%M:%S')
51 . '</meta:creation-date>'
52 . '</office:meta>'
53 . '</office:document-meta>',
54 'meta.xml'
56 $zipfile -> addFile(
57 '<?xml version="1.0" encoding="UTF-8"?' . '>'
58 . '<office:document-styles '. $GLOBALS['OpenDocumentNS']
59 . 'office:version="1.0">'
60 . '<office:font-face-decls>'
61 . '<style:font-face style:name="Arial Unicode MS"'
62 . ' svg:font-family="\'Arial Unicode MS\'" style:font-pitch="variable"/>'
63 . '<style:font-face style:name="DejaVu Sans1"'
64 . ' svg:font-family="\'DejaVu Sans\'" style:font-pitch="variable"/>'
65 . '<style:font-face style:name="HG Mincho Light J"'
66 . ' svg:font-family="\'HG Mincho Light J\'" style:font-pitch="variable"/>'
67 . '<style:font-face style:name="DejaVu Serif"'
68 . ' svg:font-family="\'DejaVu Serif\'" style:font-family-generic="roman"'
69 . ' style:font-pitch="variable"/>'
70 . '<style:font-face style:name="Thorndale"'
71 . ' svg:font-family="Thorndale" style:font-family-generic="roman"'
72 . ' style:font-pitch="variable"/>'
73 . '<style:font-face style:name="DejaVu Sans"'
74 . ' svg:font-family="\'DejaVu Sans\'" style:font-family-generic="swiss"'
75 . ' style:font-pitch="variable"/>'
76 . '</office:font-face-decls>'
77 . '<office:styles>'
78 . '<style:default-style style:family="paragraph">'
79 . '<style:paragraph-properties fo:hyphenation-ladder-count="no-limit"'
80 . ' style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging"'
81 . ' style:line-break="strict" style:tab-stop-distance="0.4925in"'
82 . ' style:writing-mode="page"/>'
83 . '<style:text-properties style:use-window-font-color="true"'
84 . ' style:font-name="DejaVu Serif" fo:font-size="12pt" fo:language="en"'
85 . ' fo:country="US" style:font-name-asian="DejaVu Sans1"'
86 . ' style:font-size-asian="12pt" style:language-asian="none"'
87 . ' style:country-asian="none" style:font-name-complex="DejaVu Sans1"'
88 . ' style:font-size-complex="12pt" style:language-complex="none"'
89 . ' style:country-complex="none" fo:hyphenate="false"'
90 . ' fo:hyphenation-remain-char-count="2"'
91 . ' fo:hyphenation-push-char-count="2"/>'
92 . '</style:default-style>'
93 . '<style:style style:name="Standard" style:family="paragraph"'
94 . ' style:class="text"/>'
95 . '<style:style style:name="Text_body" style:display-name="Text body"'
96 . ' style:family="paragraph" style:parent-style-name="Standard"'
97 . ' style:class="text">'
98 . '<style:paragraph-properties fo:margin-top="0in"'
99 . ' fo:margin-bottom="0.0835in"/>'
100 . '</style:style>'
101 . '<style:style style:name="Heading" style:family="paragraph"'
102 . ' style:parent-style-name="Standard" style:next-style-name="Text_body"'
103 . ' style:class="text">'
104 . '<style:paragraph-properties fo:margin-top="0.1665in"'
105 . ' fo:margin-bottom="0.0835in" fo:keep-with-next="always"/>'
106 . '<style:text-properties style:font-name="DejaVu Sans" fo:font-size="14pt"'
107 . ' style:font-name-asian="DejaVu Sans1" style:font-size-asian="14pt"'
108 . ' style:font-name-complex="DejaVu Sans1" style:font-size-complex="14pt"/>'
109 . '</style:style>'
110 . '<style:style style:name="Heading_1" style:display-name="Heading 1"'
111 . ' style:family="paragraph" style:parent-style-name="Heading"'
112 . ' style:next-style-name="Text_body" style:class="text"'
113 . ' style:default-outline-level="1">'
114 . '<style:text-properties style:font-name="Thorndale" fo:font-size="24pt"'
115 . ' fo:font-weight="bold" style:font-name-asian="HG Mincho Light J"'
116 . ' style:font-size-asian="24pt" style:font-weight-asian="bold"'
117 . ' style:font-name-complex="Arial Unicode MS"'
118 . ' style:font-size-complex="24pt" style:font-weight-complex="bold"/>'
119 . '</style:style>'
120 . '<style:style style:name="Heading_2" style:display-name="Heading 2"'
121 . ' style:family="paragraph" style:parent-style-name="Heading"'
122 . ' style:next-style-name="Text_body" style:class="text"'
123 . ' style:default-outline-level="2">'
124 . '<style:text-properties style:font-name="DejaVu Serif"'
125 . ' fo:font-size="18pt" fo:font-weight="bold"'
126 . ' style:font-name-asian="DejaVu Sans1" style:font-size-asian="18pt"'
127 . ' style:font-weight-asian="bold" style:font-name-complex="DejaVu Sans1"'
128 . ' style:font-size-complex="18pt" style:font-weight-complex="bold"/>'
129 . '</style:style>'
130 . '</office:styles>'
131 . '<office:automatic-styles>'
132 . '<style:page-layout style:name="pm1">'
133 . '<style:page-layout-properties fo:page-width="8.2673in"'
134 . ' fo:page-height="11.6925in" style:num-format="1"'
135 . ' style:print-orientation="portrait" fo:margin-top="1in"'
136 . ' fo:margin-bottom="1in" fo:margin-left="1.25in"'
137 . ' fo:margin-right="1.25in" style:writing-mode="lr-tb"'
138 . ' style:footnote-max-height="0in">'
139 . '<style:footnote-sep style:width="0.0071in"'
140 . ' style:distance-before-sep="0.0398in"'
141 . ' style:distance-after-sep="0.0398in" style:adjustment="left"'
142 . ' style:rel-width="25%" style:color="#000000"/>'
143 . '</style:page-layout-properties>'
144 . '<style:header-style/>'
145 . '<style:footer-style/>'
146 . '</style:page-layout>'
147 . '</office:automatic-styles>'
148 . '<office:master-styles>'
149 . '<style:master-page style:name="Standard" style:page-layout-name="pm1"/>'
150 . '</office:master-styles>'
151 . '</office:document-styles>',
152 'styles.xml'
154 $zipfile -> addFile(
155 '<?xml version="1.0" encoding="UTF-8"?' . '>'
156 . '<manifest:manifest'
157 . ' xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">'
158 . '<manifest:file-entry manifest:media-type="' . $mime
159 . '" manifest:full-path="/"/>'
160 . '<manifest:file-entry manifest:media-type="text/xml"'
161 . ' manifest:full-path="content.xml"/>'
162 . '<manifest:file-entry manifest:media-type="text/xml"'
163 . ' manifest:full-path="meta.xml"/>'
164 . '<manifest:file-entry manifest:media-type="text/xml"'
165 . ' manifest:full-path="styles.xml"/>'
166 . '</manifest:manifest>',
167 'META-INF/manifest.xml'
169 return $zipfile -> file();