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