~hexmode/+junk/main

« back to all changes in this revision

Viewing changes to install-files/apps/phpmyadmin2.10.1/libraries/opendocument.lib.php

  • Committer: Mark A. Hershberger
  • Date: 2008-01-05 19:38:56 UTC
  • Revision ID: hershberger@spawn-xp-20080105193856-6rnzgwa4nehue3qj
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/* $Id: opendocument.lib.php 9000 2006-04-28 10:46:13Z nijel $ */
 
3
// vim: expandtab sw=4 ts=4 sts=4:
 
4
 
 
5
/**
 
6
 * Simple interface for creating OASIS OpenDocument files.
 
7
 */
 
8
 
 
9
require_once('./libraries/zip.lib.php');
 
10
 
 
11
$GLOBALS['OpenDocumentNS'] = 'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" '
 
12
                . 'xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" '
 
13
                . 'xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" '
 
14
                . 'xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" '
 
15
                . 'xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" ';
 
16
 
 
17
/**
 
18
 * Minimalistic creator of OASIS OpenDocument
 
19
 *
 
20
 * @param   string      desired MIME type
 
21
 * @param   string      document content
 
22
 *
 
23
 * @return  string      OASIS OpenDocument data
 
24
 *
 
25
 * @access  public
 
26
 */
 
27
function PMA_createOpenDocument($mime, $data) {
 
28
    $zipfile = new zipfile();
 
29
    $zipfile -> addFile($mime, 'mimetype');
 
30
    $zipfile -> addFile($data, 'content.xml');
 
31
    $zipfile -> addFile('<?xml version="1.0" encoding="UTF-8"?'. '>'
 
32
        . '<office:document-meta '
 
33
            . 'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" '
 
34
            . 'xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" '
 
35
            . 'office:version="1.0">'
 
36
            . '<office:meta>'
 
37
                . '<meta:generator>phpMyAdmin ' . PMA_VERSION . '</meta:generator>'
 
38
                . '<meta:initial-creator>phpMyAdmin ' . PMA_VERSION . '</meta:initial-creator>'
 
39
                . '<meta:creation-date>' . strftime('%Y-%m-%dT%H:%M:%S') . '</meta:creation-date>'
 
40
            . '</office:meta>'
 
41
        . '</office:document-meta>'
 
42
        , 'meta.xml');
 
43
    $zipfile -> addFile('<?xml version="1.0" encoding="UTF-8"?' . '>'
 
44
        . '<office:document-styles '. $GLOBALS['OpenDocumentNS'] . 'office:version="1.0">'
 
45
            . '<office:font-face-decls>'
 
46
                . '<style:font-face style:name="Arial Unicode MS" svg:font-family="\'Arial Unicode MS\'" style:font-pitch="variable"/>'
 
47
                . '<style:font-face style:name="DejaVu Sans1" svg:font-family="\'DejaVu Sans\'" style:font-pitch="variable"/>'
 
48
                . '<style:font-face style:name="HG Mincho Light J" svg:font-family="\'HG Mincho Light J\'" style:font-pitch="variable"/>'
 
49
                . '<style:font-face style:name="DejaVu Serif" svg:font-family="\'DejaVu Serif\'" style:font-family-generic="roman" style:font-pitch="variable"/>'
 
50
                . '<style:font-face style:name="Thorndale" svg:font-family="Thorndale" style:font-family-generic="roman" style:font-pitch="variable"/>'
 
51
                . '<style:font-face style:name="DejaVu Sans" svg:font-family="\'DejaVu Sans\'" style:font-family-generic="swiss" style:font-pitch="variable"/>'
 
52
            . '</office:font-face-decls>'
 
53
            . '<office:styles>'
 
54
                . '<style:default-style style:family="paragraph">'
 
55
                    . '<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"/>'
 
56
                    . '<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"/>'
 
57
                . '</style:default-style>'
 
58
                . '<style:style style:name="Standard" style:family="paragraph" style:class="text"/>'
 
59
                . '<style:style style:name="Text_body" style:display-name="Text body" style:family="paragraph" style:parent-style-name="Standard" style:class="text">'
 
60
                    . '<style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0.0835in"/>'
 
61
                . '</style:style>'
 
62
                . '<style:style style:name="Heading" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_body" style:class="text">'
 
63
                    . '<style:paragraph-properties fo:margin-top="0.1665in" fo:margin-bottom="0.0835in" fo:keep-with-next="always"/>'
 
64
                    . '<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"/>'
 
65
                    . '</style:style>'
 
66
                . '<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">'
 
67
                    . '<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"/>'
 
68
                . '</style:style>'
 
69
                . '<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">'
 
70
                    . '<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"/>'
 
71
                . '</style:style>'
 
72
            . '</office:styles>'
 
73
            . '<office:automatic-styles>'
 
74
                . '<style:page-layout style:name="pm1">'
 
75
                    . '<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">'
 
76
                        . '<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"/>'
 
77
                    . '</style:page-layout-properties>'
 
78
                    . '<style:header-style/>'
 
79
                    . '<style:footer-style/>'
 
80
                . '</style:page-layout>'
 
81
            . '</office:automatic-styles>'
 
82
            . '<office:master-styles>'
 
83
                . '<style:master-page style:name="Standard" style:page-layout-name="pm1"/>'
 
84
            . '</office:master-styles>'
 
85
        . '</office:document-styles>'
 
86
        , 'styles.xml');
 
87
    $zipfile -> addFile('<?xml version="1.0" encoding="UTF-8"?' . '>'
 
88
        . '<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">'
 
89
        . '<manifest:file-entry manifest:media-type="' . $mime . '" manifest:full-path="/"/>'
 
90
        . '<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="content.xml"/>'
 
91
        . '<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="meta.xml"/>'
 
92
        . '<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="styles.xml"/>'
 
93
        . '</manifest:manifest>'
 
94
        , 'META-INF/manifest.xml');
 
95
    return $zipfile -> file();
 
96
}
 
97
?>