Source for file utilities.php
Documentation is available at utilities.php
* phpDocumentor :: docBuilder Web Interface
* Copyright (c) 2003-2006 Andrew Eddie, Greg Beaver
* This library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* @copyright 2003-2006 Andrew Eddie, Greg Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version CVS: $Id: utilities.php,v 1.4 2006/04/30 22:18:13 cellog Exp $
if ('@DATA-DIR@' != '@'. 'DATA-DIR@')
include_once('PhpDocumentor/HTML_TreeMenu-1.1.2/TreeMenu.php');
include_once(dirname(realpath(__FILE__ )). "/../../HTML_TreeMenu-1.1.2/TreeMenu.php");
* Allows png's with alpha transparency to be displayed in IE 6
* @param string $src path to the source image
* @param int $wid width on the image [optional]
* @param int $hgt height on the image [optional]
* @param string $alt hover text for the image [optional]
function showImage( $src, $wid= '', $hgt= '', $alt= '' ) {
if (strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 6.0' ) !== false) {
return "<div style=\"height:{$hgt}px; width:{$wid}px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='$src', sizingMethod='scale');\" ></div>";
return "<img src=\"$src\" width=\"$wid\" height=\"$hgt\" alt=\"$alt\" border=\"0\" />";
* Returns a select box based on an key,value array where selected is based on key
* @param array $arr array of the key-text pairs
* @param string $select_name The name of the select box
* @param string $select_attribs Additional attributes to insert into the html select tag
* @param string $selected The key value of the selected eleme
function htmlArraySelect( &$arr, $select_name, $select_attribs, $selected ) {
$s = "\n<select name=\"$select_name\" $select_attribs>";
foreach ($arr as $k => $v ) {
$s .= "\n\t<option value=\"". $k. "\"". ($k == $selected ? " selected=\"selected\"" : ''). ">" . $v . "</option>";
function getDir($path,&$node) {
if (!$dir = opendir($path)) return;
while (($file = readdir($dir)) !== false)
if ($file != '.' && $file != '..')
$entry[] = "$path$pd$file";
for($i = 0; $i < count($entry); $i++ )
$anode = new HTML_TreeNode(array('text' => basename($path), 'link' => "javascript:setHelpVal('". $path. "');", 'icon' => 'folder.gif'));
if (!$node) $anode->addItem(new DirNode('..',"javascript:setHelp('". $result. "');",'folder.gif'),'..');
while (($file = readdir($dir)) !== false) {
if ($file != '.' && $file != '..') {
if (is_dir("$path$pd$file")) {
while (false){//($file = readdir($dir)) !== false) {
if ($file != '.' && $file != '..') {
$anode->addItem(new DirNode($file,"javascript:setHelpVal('$path$pd$file');",'branchtop.gif',"$path$pd$file"));
if (!$node) $node = $anode;
// initialize recursion simulation values
// array format: path => &parent in $node itemlist
$parent_indexes = array();
$node = new DirNode(basename($path),"javascript:setHelpVal('". $path. "');",'folder.gif',$path);
$node->addItem(new DirNode('..',"javascript:setHelp('". $result. "');",'folder.gif','..'));
if ($recur++ > 120) return;
// no child files or directories
// echo "$path no child files or directories return to ";
if (isset ($parent_indexes[realpath($path)])) $parenti = $parent_indexes[realpath($path)];
// echo "$path parenti $parenti<br>";
// fancy_debug($path,$parent_indexes);
if (!isset ($parent_indexes[realpath($path)]))
while ($file !== false) {
if ($file != '.' && $file != '..') {
if (!isset ($parent_indexes[realpath($path)])) $parent_indexes[realpath($path)] = true;
$parent[realpath("$path$pd$file")] = &$rnode;
// echo "<br>adding new ".addslashes(realpath($path.$pd.$file))." to $path<br>";
// go down the tree if possible
if (isset ($parent_indexes[realpath($path)]))
if ($parenti + 1 > (count($rnode->items)))
// no more children, go back up to parent
// echo "$path no more children, go back up to parent ";
if (isset ($parent_indexes[realpath($path)])) $parenti = $parent_indexes[realpath($path)];
// echo $path." parenti $parenti<br>";
// echo "$path go to next child ";
$parent_indexes[realpath($path)] = $parenti+ 1;
// debug("set parent ".$rnode->items[$parenti]->path." = ".$rnode->path.'<br>');
$parent[realpath($rnode->items[$parenti]->path)] = &$rnode;
$rnode = &$rnode->items[$parenti];
// no children, go back up the tree to the next child
// echo "$path no children, go back up to parent ";
if (isset ($parent_indexes[realpath($path)])) $parenti = $parent_indexes[realpath($path)];
// echo "$path parenti $parenti<br>";
} while ($path && (($parenti < (count($rnode->items))) || ($parent[realpath($path)] !== false)));
foreach($tree as $key => $val)
debug($key. ' -> false<br>');
debug($key. ' -> ' . $val->path. '<br>');
|