Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * phpDocumentor :: docBuilder Web Interface
4
 *
5
 * PHP versions 4 and 5
6
 *
7
 * Copyright (c) 2003-2006 Andrew Eddie, Greg Beaver
8
 *
9
 * LICENSE:
10
 *
11
 * This library is free software; you can redistribute it
12
 * and/or modify it under the terms of the GNU Lesser General
13
 * Public License as published by the Free Software Foundation;
14
 * either version 2.1 of the License, or (at your option) any
15
 * later version.
16
 *
17
 * This library is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
 * Lesser General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU Lesser General Public
23
 * License along with this library; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
 *
26
 * @package    phpDocumentor
27
 * @author     Andrew Eddie
28
 * @author     Greg Beaver <cellog@php.net>
29
 * @copyright  2003-2006 Andrew Eddie, Greg Beaver
30
 * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
31
 * @version    CVS: $Id: utilities.php 212211 2006-04-30 22:18:14Z cellog $
32
 */
33
 
34
if ('/usr/share/php/data' != '@'.'DATA-DIR@')
35
{
36
    include_once('PhpDocumentor/HTML_TreeMenu-1.1.2/TreeMenu.php');
37
} else {
38
    include_once(dirname(realpath(__FILE__))."/../../HTML_TreeMenu-1.1.2/TreeMenu.php");
39
}
40
 
41
/**
42
 *	Allows png's with alpha transparency to be displayed in IE 6
43
 *	@param string $src path to the source image
44
 *	@param int $wid width on the image [optional]
45
 *	@param int $hgt height on the image [optional]
46
 *	@param string $alt hover text for the image [optional]
47
 */
48
function showImage( $src, $wid='', $hgt='', $alt='' ) {
49
	if (strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 6.0' ) !== false) {
50
		return "<div style=\"height:{$hgt}px; width:{$wid}px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='$src', sizingMethod='scale');\" ></div>";
51
	} else {
52
		return "<img src=\"$src\" width=\"$wid\" height=\"$hgt\" alt=\"$alt\" border=\"0\" />";
53
	}
54
}
55
 
56
/**
57
 *	Returns a select box based on an key,value array where selected is based on key
58
 *	@param array $arr array of the key-text pairs
59
 *	@param string $select_name The name of the select box
60
 *	@param string $select_attribs Additional attributes to insert into the html select tag
61
 *	@param string $selected The key value of the selected eleme
62
 */
63
function htmlArraySelect( &$arr, $select_name, $select_attribs, $selected ) {
64
	GLOBAL $AppUI;
65
	reset( $arr );
66
	$s = "\n<select name=\"$select_name\" $select_attribs>";
67
	foreach ($arr as $k => $v ) {
68
		$s .= "\n\t<option value=\"".$k."\"".($k == $selected ? " selected=\"selected\"" : '').">" . $v . "</option>";
69
	}
70
	$s .= "\n</select>\n";
71
	return $s;
72
}
73
 
74
function getDir($path,&$node) {
75
	global $pd;
76
	if (!$dir = opendir($path)) return;
77
 
78
	$node = new HTML_TreeNode(array('text' => basename(realpath($path)), 'link' => "", 'icon' => 'folder.gif'));
79
	while (($file = readdir($dir)) !== false)
80
	{
81
		if ($file != '.' && $file != '..')
82
		{
83
			if (is_dir("$path$pd$file") && !is_link("$path$pd$file"))
84
			{
85
				$entry[] = "$path$pd$file";
86
			}
87
		}
88
	}
89
	closedir($dir);
90
	for($i = 0; $i < count($entry); $i++)
91
	{
92
		$node->addItem(new HTML_TreeNode(array('text'=>basename(realpath($entry[$i])), 'link' => "javascript:setHelp('".addslashes(realpath($entry[$i]))."');", 'icon' => 'folder.gif')));
93
	}
94
}
95
 
96
function recurseDir($path, &$node) {
97
	global $pd;
98
	if (!$dir = opendir($path)) {
99
		return false;
100
	}
101
	$anode = new HTML_TreeNode(array('text' => basename($path), 'link' => "javascript:setHelpVal('".$path."');", 'icon' => 'folder.gif'));
102
	$result = addslashes(realpath(stripslashes($path).$pd.".."));
103
	if (!$node) $anode->addItem(new DirNode('..',"javascript:setHelp('".$result."');",'folder.gif'),'..');
104
	while (($file = readdir($dir)) !== false) {
105
		if ($file != '.' && $file != '..') {
106
			if (is_dir("$path$pd$file")) {
107
				recurseDir("$path$pd$file",$anode);
108
			}
109
		}
110
	}
111
	rewinddir($dir);//
112
	while (false){//($file = readdir($dir)) !== false) {
113
		if ($file != '.' && $file != '..') {
114
			if (is_file("$path$pd$file")) {
115
				$anode->addItem(new DirNode($file,"javascript:setHelpVal('$path$pd$file');",'branchtop.gif',"$path$pd$file"));
116
			}
117
		}
118
	}
119
	if (!$node) $node = $anode;
120
	else
121
	$node->addItem($anode);
122
	closedir($dir);
123
}
124
 
125
function switchDirTree($path, &$node)
126
{
127
	global $pd;
128
 
129
	// initialize recursion simulation values
130
	// array format: path => &parent in $node itemlist
131
	$parent = array();
132
	$parent_indexes = array();
133
	$parenti = 1;
134
 
135
	$node = new DirNode(basename($path),"javascript:setHelpVal('".$path."');",'folder.gif',$path);
136
	$result = addslashes(realpath($path.$pd.".."));
137
	$node->addItem(new DirNode('..',"javascript:setHelp('".$result."');",'folder.gif','..'));
138
	$rnode = &$node;
139
	$parent[realpath($path)] = false;
140
	$recur = 0;
141
	do
142
	{
143
		if ($recur++ > 120) return;
144
		if (!$dir = @opendir($path)) {
145
			// no child files or directories
146
//                    echo "$path no child files or directories return to ";
147
			$rnode = &$parent[realpath($path)];
148
			$path = $rnode->path;
149
			if (isset($parent_indexes[realpath($path)])) $parenti = $parent_indexes[realpath($path)];
150
//                    echo "$path parenti $parenti<br>";
151
		}
152
//                fancy_debug($path,$parent_indexes);
153
//                vdump_par($parent);
154
		if (!isset($parent_indexes[realpath($path)]))
155
		{
156
			$file = readdir($dir);
157
			while ($file !== false) {
158
				if ($file != '.' && $file != '..') {
159
					if (@is_dir(realpath("$path$pd$file"))) {
160
						if (!isset($parent_indexes[realpath($path)])) $parent_indexes[realpath($path)] = true;
161
						$parent[realpath("$path$pd$file")] = &$rnode;
162
//                                echo "<br>adding new ".addslashes(realpath($path.$pd.$file))." to $path<br>";
163
						$rnode->addItem(new DirNode(addslashes(realpath("$path$pd$file")),"javascript:setHelpVal('".addslashes(realpath($path.$pd.$file))."');",'folder.gif',addslashes(realpath($path.$pd.$file))));
164
					}
165
				}
166
				$file = readdir($dir);
167
			}
168
		}
169
		// go down the tree if possible
170
		if (isset($parent_indexes[realpath($path)]))
171
		{
172
			if ($parenti + 1 > (count($rnode->items)))
173
			{
174
				// no more children, go back up to parent
175
//                        echo "$path no more children, go back up to parent ";
176
				$rnode = &$parent[realpath($path)];
177
				$path = $rnode->path;
178
				if (isset($parent_indexes[realpath($path)])) $parenti = $parent_indexes[realpath($path)];
179
//                        echo $path." parenti $parenti<br>";
180
			} else
181
			{
182
				// go to next child
183
//                        echo "$path go to next child ";
184
				$parent_indexes[realpath($path)] = $parenti+1;
185
//                        debug("set parent ".$rnode->items[$parenti]->path." = ".$rnode->path.'<br>');
186
				$parent[realpath($rnode->items[$parenti]->path)] = &$rnode;
187
				$rnode = &$rnode->items[$parenti];
188
				$path = $rnode->path;
189
//                        echo "$path<br>";
190
				$parenti = 0;
191
			}
192
		} else
193
		{
194
			// no children, go back up the tree to the next child
195
//                    echo "$path no children, go back up to parent ";
196
			$rnode = &$parent[realpath($path)];
197
			$path = $rnode->path;
198
			if (isset($parent_indexes[realpath($path)])) $parenti = $parent_indexes[realpath($path)];
199
//                    echo "$path parenti $parenti<br>";
200
		}
201
		@closedir($dir);
202
	} while ($path && (($parenti < (count($rnode->items))) || ($parent[realpath($path)] !== false)));
203
}
204
 
205
function vdump_par($tree)
206
{
207
	foreach($tree as $key => $val)
208
	{
209
		if ($val === false)
210
		debug($key.' -> false<br>');
211
		else
212
		debug($key.' -> ' .$val->path.'<br>');
213
	}
214
	debug('<br>');
215
}
216
?>