File: phpkdevelop.php

package info (click to toggle)
php-doc 20100521-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 59,992 kB
  • ctags: 4,085
  • sloc: xml: 796,833; php: 21,338; cpp: 500; sh: 117; makefile: 58; awk: 28
file content (160 lines) | stat: -rw-r--r-- 5,471 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php

require_once $ROOT . '/themes/php/chunkedhtml.php';
class phpkdevelop extends PhDTheme {
    const DEFAULT_TITLE = "PHP Manual";
    const DEFAULT_HREF = "http://www.php.net/manual/en/";

    protected $elementmap = array(
        'book'                  => 'format_tocsect1',
        'bibliography'          => array(
            /* DEFAULT */          false,
            'book'              => 'format_tocsect2',
        ),
        'article'               => array(
            /* DEFAULT */          false,
            'book'              => 'format_tocsect2',
        ),
        'appendix'              => array(
            /* DEFAULT */          false,
            'book'              => 'format_tocsect2',
        ),
        'colophon'              => array(
            /* DEFAULT */          false,
            'book'              => 'format_tocsect2',
        ),
        'chapter'               => array(
            /* DEFAULT */          false,
            'book'              => 'format_tocsect2',
        ),
        'glossary'              => array(
            /* DEFAULT */          false,
            'book'              => 'format_tocsect2',
        ),
        'index'                 => array(
            /* DEFAULT */          false,
            'book'              => 'format_tocsect2',
        ),
        'part'                  => array(
            /* DEFAULT */          false,
            'book'              => 'format_tocsect2',
        ),
        'preface'               => array(
            /* DEFAULT */          false,
            'book'              => 'format_tocsect2',
        ),
        'reference'             => array(
            /* DEFAULT */          false,
            'book'              => 'format_tocsect2',
        ),
        'refentry'              => 'format_refentry',
        'refname'               => 'format_suppressed_tags',
        'refpurpose'            => 'format_suppressed_tags',
        'refsection'            => 'format_suppressed_tags',



    );
    protected $textmap =        array(
        'refname'               => 'format_refname_text',
    );

    // Kdevelop TOC file
    protected $tocStream;
    // TOC Output directory
    protected $tocDir;

    protected $ext;

    protected $currentEntryName;
    protected $index = array();

    // CHM Table of contents
    protected $currentTocDepth = 0;
    protected $lastContent = null;
    protected $toc;
    // CHM Index Map
    protected $hhkStream;

    public function __construct(array $IDs, $filename, $ext = "php") {
        parent::__construct($IDs, $ext);
        $this->tocDir = $GLOBALS['OPTIONS']['output_dir'];

        $this->ext = $ext;

        $this->tocStream = fopen($this->tocDir . "php.toc", "w");

        self::headerToc();
    }

    public function __destruct() {
        self::footerToc();
        fclose($this->tocStream);
    }

    public function format_suppressed_tags($open, $name, $attrs) {
        return "";
    }


    protected function headerToc() {
        fwrite($this->tocStream, "<!DOCTYPE kdeveloptoc>\n<kdeveloptoc>\n<title>" . self::DEFAULT_TITLE . "</title>\n" .
          "<base href=\"" . self::DEFAULT_HREF . "\"/>\n");
    }

    protected function footerToc() {
        fwrite($this->tocStream, "<index>\n");
        foreach ($this->index as $name => $url)
            fwrite($this->tocStream, "<entry name=\"{$name}\" url=\"{$url}\"/>\n");
        fwrite($this->tocStream, "</index>\n</kdeveloptoc>\n");
    }

    public function appendData($data, $isChunk) {
    }

    public function format_tocsect1($open, $name, $attrs) {
        if (!isset($attrs[PhDReader::XMLNS_XML]["id"])) return "";
        $id = $attrs[PhDReader::XMLNS_XML]["id"];
        $hasChild = (count(PhDHelper::getChildren($id)) > 0);
        if ($open) {
            $name = htmlspecialchars(PhDHelper::getDescription($id), ENT_QUOTES, 'UTF-8');
            $url = (PhDHelper::getFilename($id) ? PhDHelper::getFilename($id) : $id) . "." . $this->ext;
            fwrite($this->tocStream, "<tocsect1 name=\"{$name}\" url=\"{$url}\"" . ($hasChild ? "" : "/") . ">\n");
        } else {
            if ($hasChild)
                fwrite($this->tocStream, "</tocsect1>\n");
        }
        return "";
    }

    public function format_tocsect2($open, $name, $attrs) {
        if (!isset($attrs[PhDReader::XMLNS_XML]["id"])) return "";
        $id = $attrs[PhDReader::XMLNS_XML]["id"];
        $hasChild = (count(PhDHelper::getChildren($id)) > 0);
        if ($open) {
            $name = htmlspecialchars(PhDHelper::getDescription($id), ENT_QUOTES, 'UTF-8');
            $url = (PhDHelper::getFilename($id) ? PhDHelper::getFilename($id) : $id) . "." . $this->ext;
            fwrite($this->tocStream, "    <tocsect2 name=\"{$name}\" url=\"{$url}\"/>\n");
        }
        return "";
    }

    public function format_refentry($open, $name, $attrs) {
        if (!isset($attrs[PhDReader::XMLNS_XML]["id"])) return "";
        $id = $attrs[PhDReader::XMLNS_XML]["id"];
        if ($open) {
            $this->currentEntryName = null;
        }
        if (!$open && $this->currentEntryName) {
            $url = (PhDHelper::getFilename($id) ? PhDHelper::getFilename($id) : $id) . "." . $this->ext;
            $this->index[$this->currentEntryName] = $url;
        }
        return "";
    }

    public function format_refname_text($value, $tag) {
        $this->currentEntryName = $value;
        return "";
    }

}