Ejemplo n.º 1
0
/**
 * Prints an array as a "tree" of data
 */
function dbug_printtree($dir, $indent = "\t")
{
    static $t = 0;
    $foo = '';
    foreach ($dir as $key => $val) {
        //if this item is an array, its probobly a direcotry
        if (is_array($val)) {
            for ($i = 0; $i < $t; $i++) {
                $foo .= $indent;
            }
            //return the directory name
            $foo .= '[' . $key . ']' . "\n";
            ++$t;
            printtree($val, $indent);
            --$t;
        } else {
            for ($i = 0; $i < $t; $i++) {
                $foo .= $indent;
            }
            //return file name
            $foo .= $val . "\n";
        }
    }
}
Ejemplo n.º 2
0
function printtree($current, $icons, $imgpath, &$xml_tree, &$tree_id, &$tree_level, $maxlevels, $mode, $noclick, $subnodes, $itext)
{
    if ($tree_level > $maxlevels) {
        $tree_level--;
        return;
    }
    $svrload = 'false';
    if ($tree_level == (int) $maxlevels) {
        $svrload = 'true';
    }
    while (list($key, $value) = each($current)) {
        if ($current[$key]['LEVEL'] > 1 && $current[$key]['EMBEDDED'] == '0' && $current[$key]['NAME'] != '__BLIND__') {
            $node_svrload = 'false';
            if ($svrload == 'true') {
                if ($current[$key]['CHILDREN'] != NULL) {
                    $node_svrload = $svrload;
                }
                if ($mode == 'copy' || $mode == 'move' || $mode == 'restore') {
                    // In copy/move/restore mode, only set "svrload" to true, when there are folders as children
                    $hasSubFolders = false;
                    foreach ($current[$key]['CHILDREN'] as $childItem) {
                        if ($childItem['FOLDER'] == 1) {
                            $hasSubFolders = true;
                        }
                    }
                    if (!$hasSubFolders) {
                        $node_svrload = 'false';
                    }
                }
            }
            $img = $icons['cblock_small'];
            $url = '';
            // Add path
            if ($img != '') {
                $img = $imgpath . 'icons/' . $img;
            }
            $cststyle = '';
            $dnd = '';
            if ($current[$key]['FOLDER'] != 1) {
                // CBLOCK
                if ($current[$key]["VERSIONPUBLISHED"] + 2 != $current[$key]["VERSION"] && $current[$key]["VERSIONPUBLISHED"] != ALWAYS_LATEST_APPROVED_VERSION && $current[$key]["HASCHANGED"] == "1") {
                    // Editiert (grün)
                    $cststyle = "changed changed1";
                } elseif ($current[$key]["HASCHANGED"] == "1") {
                    $cststyle = "changed changed2";
                }
                if ($current[$key]['RWRITE'] == '0') {
                    // Nur Leserecht (hellgrau)
                    $cststyle .= ' nowrite';
                }
                if ($current[$key]["RDELETE"] == "0") {
                    // Nur Leserecht (hellgrau)
                    $cststyle .= " nodelete";
                }
                $cststyle .= " nosub";
                $curr_noclick = '';
                $dnd = '';
                /*
                if ($mode=='choose') {
                	$dnd = 'false';
                }
                */
            } else {
                // FOLDER
                if ($current[$key]['RWRITE'] == '0') {
                    // Nur Leserecht (hellgrau)
                    $cststyle = 'nowrite';
                }
                if ($current[$key]["RDELETE"] == "0") {
                    // Nur Leserecht (hellgrau)
                    $cststyle .= " nodelete";
                }
                if ($current[$key]["RSUB"] == "0") {
                    $cststyle .= " nosub";
                }
                $img = $imgpath . 'icons/ico_folder_s.png,' . $imgpath . 'icons/ico_folderopen_s.png';
                $cststyle .= ' folder';
                $dnd = 'false';
                if ($mode == 'choose' || $mode == 'insertcontent') {
                    $curr_noclick = 'noclick';
                }
            }
            $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'cblock_' . $current[$key]['ID'], 'CAPTION' => htmlspecialchars($current[$key]['NAME']), 'URL' => $url, 'IC' => $img, 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => $cststyle, 'TARGET' => '', 'TITLE' => '', 'SVRLOAD' => $node_svrload, 'YG_ID' => $current[$key]['ID'] . '-cblock', 'YG_TYPE' => 'cblock', 'YG_PROPERTY' => 'name', 'DND' => $dnd, 'XTRA' => $curr_noclick);
            if ($mode == 'copy' || $mode == 'move' || $mode == 'restore') {
                if ($current[$key]['FOLDER'] == 1) {
                    array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
                }
            } else {
                array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
            }
            if (is_array($current[$key]['CHILDREN'])) {
                $tree_level++;
                printtree($current[$key]['CHILDREN'], $icons, $imgpath, $xml_tree, $tree_id, $tree_level, $maxlevels, $mode, $noclick, $subnodes, $itext);
            }
        }
    }
    if (!$mode && !$subnodes && $tree_level == 1) {
        $props = array('TREE_ID' => ++$tree_id, 'TREE_LEVEL' => $tree_level, 'ID' => 'cblock_trash', 'CAPTION' => htmlspecialchars($itext['TXT_TRASHCAN']), 'URL' => $url, 'IC' => $imgpath . 'icons/ico_trashcan_s.png', 'EXP' => 'false', 'CHK' => 'false', 'CSTSTYLE' => 'nodrag nodrop nosub', 'TARGET' => '', 'TITLE' => '', 'DND' => 'false', 'SVRLOAD' => 'false', 'YG_ID' => 'trash-cblock', 'YG_TYPE' => 'cblocktrash', 'YG_PROPERTY' => 'name');
        array_push($xml_tree, array('OBJECTID' => $tree_id, 'LEVEL' => $tree_level, 'PROPS' => $props));
    }
    $tree_level--;
}