Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/* vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +----------------------------------------------------------------------+
4
// | PHP version 5                                                        |
5
// +----------------------------------------------------------------------+
6
// | Copyright (c) 2004, Clay Loveless                                    |
7
// | All rights reserved.                                                 |
8
// +----------------------------------------------------------------------+
9
// | This LICENSE is in the BSD license style.                            |
10
// | http://www.opensource.org/licenses/bsd-license.php                   |
11
// |                                                                      |
12
// | Redistribution and use in source and binary forms, with or without   |
13
// | modification, are permitted provided that the following conditions   |
14
// | are met:                                                             |
15
// |                                                                      |
16
// |  * Redistributions of source code must retain the above copyright    |
17
// |    notice, this list of conditions and the following disclaimer.     |
18
// |                                                                      |
19
// |  * Redistributions in binary form must reproduce the above           |
20
// |    copyright notice, this list of conditions and the following       |
21
// |    disclaimer in the documentation and/or other materials provided   |
22
// |    with the distribution.                                            |
23
// |                                                                      |
24
// |  * Neither the name of Clay Loveless nor the names of contributors   |
25
// |    may be used to endorse or promote products derived from this      |
26
// |    software without specific prior written permission.               |
27
// |                                                                      |
28
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  |
29
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT    |
30
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS    |
31
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE      |
32
// | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,  |
33
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
34
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;     |
35
// | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER     |
36
// | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT   |
37
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN    |
38
// | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE      |
39
// | POSSIBILITY OF SUCH DAMAGE.                                          |
40
// +----------------------------------------------------------------------+
41
// | Author: Clay Loveless <clay@killersoft.com>                          |
42
// +----------------------------------------------------------------------+
43
//
44
// $Id: example_tree.php 286753 2009-08-03 19:37:03Z mrook $
45
//
46
 
47
/*
48
    This is a more complex example, that also illustrates the use of
49
    HTML_TreeMenu.
50
 
51
    In this example, we'll get a recusive list of files in a repository.
52
    We will then loop through the files and build a dynamic HTML_TreeMenu
53
    object for easy navigation.
54
*/
55
 
56
error_reporting(E_ALL);
57
ini_set('display_errors', 'on');
58
 
59
require_once 'VersionControl/SVN.php';
60
 
61
// Setup our error stack
62
$svnstack = &PEAR_ErrorStack::singleton('VersionControl_SVN');
63
 
64
// Default options
65
$base_url = 'https://www.killersoft.com/svn/packages/pear/VersionControl_SVN/trunk';
66
$base_add = '';
67
if (isset($_SERVER['PATH_INFO'])) {
68
    $base_add = $_SERVER['PATH_INFO'];
69
}
70
 
71
$cmd = '';
72
$cmd = isset($_GET['cmd']) ? $_GET['cmd'] : 'list';
73
 
74
$options = array('fetchmode' => VERSIONCONTROL_SVN_FETCHMODE_ASSOC);
75
$switches = array('R' => true);
76
$args = array("{$base_url}{$base_add}");
77
 
78
// Create svn object with subcommands we'll want
79
$svn = VersionControl_SVN::factory(array('list', 'cat'), $options);
80
 
81
// A quickie sample of browsing a Subversion repository
82
if ($base_add != '') {
83
    $source = $svn->cat->run($args);
84
    if (substr($base_add, -4) == '.php') {
85
        highlight_string($source);
86
    } else {
87
        echo '<pre>'.htmlentities($source, ENT_NOQUOTES)."</pre>\n";
88
    }
89
 
90
} else {
91
 
92
    // TreeMenu setup
93
    require_once 'HTML/TreeMenu.php';
94
    // Change icons to appropriate names
95
    // See HTML_TreeMenu docs for more details.
96
    $foldericon = 'aquafolder.gif';
97
    $docicon = 'bbedit_doc.gif';
98
    $menu = new HTML_TreeMenu();
99
    $node1 = new HTML_TreeNode(array('text' => 'VersionControl_SVN',
100
                                     'icon' => $foldericon));
101
 
102
    $list = $svn->list->run($args, $switches);
103
    foreach ($list as $dir => $contents) {
104
        foreach ($list[$dir]['name'] as $i => $item) {
105
            if ($list[$dir]['type'][$i] == 'D') {
106
                $icon = $foldericon;
107
                $link = '';
108
            } else {
109
                $icon = $docicon;
110
                $link = $_SERVER['PHP_SELF']."/$dir/$item";
111
                // don't need the link for the .
112
                $link = str_replace('/.', '', $link);
113
            }
114
 
115
            if ($dir == '.') {
116
                // Adding to root level
117
                $obj = $item;
118
                $$obj =& $node1->addItem(new HTML_TreeNode(array('text' => $item, 'icon' => $icon, 'link' => $link)));
119
            } else {
120
                // Get parent item
121
                $parent = basename($dir);
122
                $obj = $item;
123
                $$obj =& $$parent->addItem(new HTML_TreeNode(array('text' => $item, 'icon' => $icon, 'link' => $link)));
124
            }
125
        }
126
    }
127
 
128
    $menu->addItem($node1);
129
 
130
    // Create presentation class
131
    $treeMenu = &new HTML_TreeMenu_DHTML($menu, array('images' => 'images',
132
                                                    'defaultClass' => 'treeMenuDefault'));
133
 
134
    ?>
135
<html>
136
<head>
137
    <title>VersionControl_SVN Source Listing</title>
138
    <script language="javascript" type="text/javascript" src="TreeMenu.js"></script>
139
    <style type="text/css">
140
    body, td, th {
141
        font-family: verdana,arial,helvetica,sans-serif;
142
        font-size: 80%;
143
    }
144
    .squeeze { line-height: 96%; font-size: xx-small; font-family:Verdana,Geneva,Arial; color: #999999; }
145
    </style>
146
</head>
147
<body>
148
<h3>VersionControl_SVN Source Listing</h3>
149
<?php
150
$treeMenu->printMenu();
151
?>
152
 
153
<p>
154
<span class="squeeze">
155
Source listing driven by <a href="http://pear.php.net/package/HTML_TreeMenu">HTML_TreeMenu</a> and <a href="VersionControl_SVN_docs/index.html">VersionControl_SVN</a>
156
</span>
157
</p>
158
 
159
<?php
160
// Check for errors
161
if (count($errs = $svnstack->getErrors())) {
162
    echo "<pre>\n";
163
    print_r($errs);
164
    echo "</pre>\n";
165
}
166
?>
167
 
168
</body>
169
</html>
170
<?php
171
}
172
?>