PHP 7.4.33
Preview: OpenDocument.php Size: 8.62 KB
/usr/share/phpmyadmin/libraries/classes/OpenDocument.php
<?php
/**
 * Simple interface for creating OASIS OpenDocument files.
 */

declare(strict_types=1);

namespace PhpMyAdmin;

use DateTime;

use const DATE_W3C;

/**
 * Simplified OpenDocument creator class
 */
class OpenDocument
{
    public const NS = <<<EOT
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
EOT;

    /**
     * Minimalistic creator of OASIS OpenDocument
     *
     * @param string $mime desired MIME type
     * @param string $data document content
     *
     * @return string  OASIS OpenDocument data
     */
    public static function create($mime, $data)
    {
        // Use the same date method as other PHP libs
        // https://github.com/PHPOffice/PhpSpreadsheet/blob/1.22.0/src/PhpSpreadsheet/Writer/Ods/Meta.php#L49
        $dateTimeCreation = (new DateTime())->format(DATE_W3C);
        $data = [
            $mime,
            $data,
            '<?xml version="1.0" encoding="UTF-8"?' . '>'
            . '<office:document-meta '
            . 'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" '
            . 'xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" '
            . 'office:version="1.0">'
            . '<office:meta>'
            . '<meta:generator>phpMyAdmin ' . Version::VERSION . '</meta:generator>'
            . '<meta:initial-creator>phpMyAdmin ' . Version::VERSION
            . '</meta:initial-creator>'
            . '<meta:creation-date>' . $dateTimeCreation
            . '</meta:creation-date>'
            . '</office:meta>'
            . '</office:document-meta>',
            '<?xml version="1.0" encoding="UTF-8"?' . '>'
            . '<office:document-styles ' . self::NS
            . ' office:version="1.0">'
            . '<office:font-face-decls>'
            . '<style:font-face style:name="Arial Unicode MS"'
            . ' svg:font-family="\'Arial Unicode MS\'" style:font-pitch="variable"/>'
            . '<style:font-face style:name="DejaVu Sans1"'
            . ' svg:font-family="\'DejaVu Sans\'" style:font-pitch="variable"/>'
            . '<style:font-face style:name="HG Mincho Light J"'
            . ' svg:font-family="\'HG Mincho Light J\'" style:font-pitch="variable"/>'
            . '<style:font-face style:name="DejaVu Serif"'
            . ' svg:font-family="\'DejaVu Serif\'" style:font-family-generic="roman"'
            . ' style:font-pitch="variable"/>'
            . '<style:font-face style:name="Thorndale"'
            . ' svg:font-family="Thorndale" style:font-family-generic="roman"'
            . ' style:font-pitch="variable"/>'
            . '<style:font-face style:name="DejaVu Sans"'
            . ' svg:font-family="\'DejaVu Sans\'" style:font-family-generic="swiss"'
            . ' style:font-pitch="variable"/>'
            . '</office:font-face-decls>'
            . '<office:styles>'
            . '<style:default-style style:family="paragraph">'
            . '<style:paragraph-properties fo:hyphenation-ladder-count="no-limit"'
            . ' style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging"'
            . ' style:line-break="strict" style:tab-stop-distance="0.4925in"'
            . ' style:writing-mode="page"/>'
            . '<style:text-properties style:use-window-font-color="true"'
            . ' style:font-name="DejaVu Serif" fo:font-size="12pt" fo:language="en"'
            . ' fo:country="US" style:font-name-asian="DejaVu Sans1"'
            . ' style:font-size-asian="12pt" style:language-asian="none"'
            . ' style:country-asian="none" style:font-name-complex="DejaVu Sans1"'
            . ' style:font-size-complex="12pt" style:language-complex="none"'
            . ' style:country-complex="none" fo:hyphenate="false"'
            . ' fo:hyphenation-remain-char-count="2"'
            . ' fo:hyphenation-push-char-count="2"/>'
            . '</style:default-style>'
            . '<style:style style:name="Standard" style:family="paragraph"'
            . ' style:class="text"/>'
            . '<style:style style:name="Text_body" style:display-name="Text body"'
            . ' style:family="paragraph" style:parent-style-name="Standard"'
            . ' style:class="text">'
            . '<style:paragraph-properties fo:margin-top="0in"'
            . ' fo:margin-bottom="0.0835in"/>'
            . '</style:style>'
            . '<style:style style:name="Heading" style:family="paragraph"'
            . ' style:parent-style-name="Standard" style:next-style-name="Text_body"'
            . ' style:class="text">'
            . '<style:paragraph-properties fo:margin-top="0.1665in"'
            . ' fo:margin-bottom="0.0835in" fo:keep-with-next="always"/>'
            . '<style:text-properties style:font-name="DejaVu Sans" fo:font-size="14pt"'
            . ' style:font-name-asian="DejaVu Sans1" style:font-size-asian="14pt"'
            . ' style:font-name-complex="DejaVu Sans1" style:font-size-complex="14pt"/>'
            . '</style:style>'
            . '<style:style style:name="Heading_1" style:display-name="Heading 1"'
            . ' style:family="paragraph" style:parent-style-name="Heading"'
            . ' style:next-style-name="Text_body" style:class="text"'
            . ' style:default-outline-level="1">'
            . '<style:text-properties style:font-name="Thorndale" fo:font-size="24pt"'
            . ' fo:font-weight="bold" style:font-name-asian="HG Mincho Light J"'
            . ' style:font-size-asian="24pt" style:font-weight-asian="bold"'
            . ' style:font-name-complex="Arial Unicode MS"'
            . ' style:font-size-complex="24pt" style:font-weight-complex="bold"/>'
            . '</style:style>'
            . '<style:style style:name="Heading_2" style:display-name="Heading 2"'
            . ' style:family="paragraph" style:parent-style-name="Heading"'
            . ' style:next-style-name="Text_body" style:class="text"'
            . ' style:default-outline-level="2">'
            . '<style:text-properties style:font-name="DejaVu Serif"'
            . ' fo:font-size="18pt" fo:font-weight="bold"'
            . ' style:font-name-asian="DejaVu Sans1" style:font-size-asian="18pt"'
            . ' style:font-weight-asian="bold" style:font-name-complex="DejaVu Sans1"'
            . ' style:font-size-complex="18pt" style:font-weight-complex="bold"/>'
            . '</style:style>'
            . '</office:styles>'
            . '<office:automatic-styles>'
            . '<style:page-layout style:name="pm1">'
            . '<style:page-layout-properties fo:page-width="8.2673in"'
            . ' fo:page-height="11.6925in" style:num-format="1"'
            . ' style:print-orientation="portrait" fo:margin-top="1in"'
            . ' fo:margin-bottom="1in" fo:margin-left="1.25in"'
            . ' fo:margin-right="1.25in" style:writing-mode="lr-tb"'
            . ' style:footnote-max-height="0in">'
            . '<style:footnote-sep style:width="0.0071in"'
            . ' style:distance-before-sep="0.0398in"'
            . ' style:distance-after-sep="0.0398in" style:adjustment="left"'
            . ' style:rel-width="25%" style:color="#000000"/>'
            . '</style:page-layout-properties>'
            . '<style:header-style/>'
            . '<style:footer-style/>'
            . '</style:page-layout>'
            . '</office:automatic-styles>'
            . '<office:master-styles>'
            . '<style:master-page style:name="Standard" style:page-layout-name="pm1"/>'
            . '</office:master-styles>'
            . '</office:document-styles>',
            '<?xml version="1.0" encoding="UTF-8"?' . '>'
            . '<manifest:manifest'
            . ' xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">'
            . '<manifest:file-entry manifest:media-type="' . $mime
            . '" manifest:full-path="/"/>'
            . '<manifest:file-entry manifest:media-type="text/xml"'
            . ' manifest:full-path="content.xml"/>'
            . '<manifest:file-entry manifest:media-type="text/xml"'
            . ' manifest:full-path="meta.xml"/>'
            . '<manifest:file-entry manifest:media-type="text/xml"'
            . ' manifest:full-path="styles.xml"/>'
            . '</manifest:manifest>',
        ];

        $name = [
            'mimetype',
            'content.xml',
            'meta.xml',
            'styles.xml',
            'META-INF/manifest.xml',
        ];

        $zipExtension = new ZipExtension();

        return $zipExtension->createFile($data, $name);
    }
}

Directory Contents

Dirs: 29 × Files: 80
Name Size Perms Modified Actions
Charsets DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Command DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Config DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Crypto DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Database DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Dbal DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Display DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Engines DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Export DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Gis DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Html DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Http DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Image DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Import DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Plugins DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Providers DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Query DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Server DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Setup DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Table DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Twig DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
Utils DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
WebAuthn DIR
- drwxr-xr-x 2023-02-07 16:26:36
Edit Download
12.32 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
9.19 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
10.63 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
1.50 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
6.82 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
11.30 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
19.40 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
41.65 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
3.25 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
28.91 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
15.83 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
71.73 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
2.86 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
8.41 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
13.63 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
18.63 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
8.99 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
45.70 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
11.11 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
19.75 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
2.88 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
1.22 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
5.58 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
8.06 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
18.00 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
20.00 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
48.72 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
14.83 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
4.75 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
89.05 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
17.31 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
9.13 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
4.47 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
22.74 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
4.99 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
1.67 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
4.11 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
2.69 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
20.40 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
18.68 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
918 B lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
41.53 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
8.62 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
35.11 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
4.10 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
2.34 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
4.17 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
21.83 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
2.16 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
11.44 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
4.81 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
21.24 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
4.79 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
13.50 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
6.55 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
11.98 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
11.33 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
3.74 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
8.16 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
64.01 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
6.74 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
15.71 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
3.98 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
90.33 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
4.50 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
7.32 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
7.00 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
30.34 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
36.11 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
16.31 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
7.49 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
25.85 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
10.61 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
1.74 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
6.86 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
10.49 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
86.45 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
556 B lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
7.30 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
10.33 KB lrwxr-xr-x 2023-02-07 16:26:36
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).