コード例 #1
0
ファイル: tree.php プロジェクト: igorsimdyanov/php7
function printTree($level = 1)
{
    // Открываем каталог и выходим в случае ошибки.
    $d = @opendir(".");
    if (!$d) {
        return;
    }
    while (($e = readdir($d)) !== false) {
        // Игнорируем элементы .. и .
        if ($e == '.' || $e == '..') {
            continue;
        }
        // Нам нужны только подкаталоги.
        if (!@is_dir($e)) {
            continue;
        }
        // Печатаем пробелы, чтобы сместить вывод.
        for ($i = 0; $i < $level; $i++) {
            echo "  ";
        }
        // Выводим текущий элемент.
        echo "{$e}\n";
        // Входим в текущий подкаталог и печатаем его
        if (!chdir($e)) {
            continue;
        }
        printTree($level + 1);
        // Возвращаемся назад
        chdir("..");
        // Отправляем данные в браузер, чтобы избежать видимости зависания
        // для больших распечаток.
        flush();
    }
    closedir($d);
}
コード例 #2
0
function HandleViewSite()
{
    define("CMD_SEL_ITEMSCOUNT", <<<SQL
\t\tSELECT count(*) FROM items
\t\t\tWHERE category_id = ? AND our_category_id = 0
\t\t\tORDER BY status DESC, mdate DESC
SQL
);
    define("CMD_SEL_SITECATEGORIES", <<<SQL
\t\tSELECT * FROM site_categories
\t\t\tWHERE site_id = ? AND our_category_id = 0
SQL
);
    global $db;
    $res =& $db->query(CMD_SEL_SITECATEGORIES, array($_REQUEST["siteId"]));
    if (PEAR::isError($res)) {
        printError($res);
        exit;
    }
    $categories = array();
    while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
        $catCount =& $db->getOne(CMD_SEL_ITEMSCOUNT, array($row->id));
        if (PEAR::isError($catCount)) {
            $catCount = 0;
        }
        $state = null;
        if ((int) $catCount > 0) {
            $state = "collapsed";
        }
        $customAttrs = array("siteId" => $_REQUEST["siteId"]);
        $categories[] = array("nodeId" => $row->id, "name" => $row->name, "state" => $state, "tp" => NODE_SITE_CATEGORY, "image" => getCategoryImageState($row), "customAttrs" => $customAttrs);
    }
    printTree($categories, true, true, "TreeCategories");
    print "<span id=\"siteId\" siteIdNum=\"" . $_REQUEST["siteId"] . "\" style=\"display: none;\"></span>";
}
コード例 #3
0
 public function test_printTree()
 {
     $actual = '<li><a rel=site >site</a></li><li><h2>slug</h2><ul><li><a rel=0 >0</a></li><li><a rel=1 >1</a></li></ul></li><li><h2>query</h2><ul><li><a rel=comp >comp</a></li><li><a rel=category >category</a></li></ul></li>';
     $testArray = array('site' => 'dummy', 'slug' => array(0 => 'testkit', 1 => ''), 'query' => array('comp' => 'testcase', 'category' => '22ffa003527fc7b4cfddb491cbfb1804'));
     $result = printTree($testArray);
     //echo $result;
     $this->assertEquals($actual, $result);
 }
コード例 #4
0
ファイル: BrNestedSet.php プロジェクト: jagermesh/bright
function deletes($nestedSet, $deletes)
{
    foreach ($deletes as $delete) {
        $row = br()->db()->getRow('SELECT * FROM br_nested_set WHERE name = ?', $delete);
        br()->db()->table('br_nested_set')->remove($row['id']);
        $nestedSet->processDelete($row);
        printTree();
        $nestedSet->verify();
    }
}
コード例 #5
0
ファイル: categories.php プロジェクト: anurag95/SpinLogics
function printTree($tree)
{
    if (!is_null($tree) && count($tree) > 0) {
        echo '<ul>';
        foreach ($tree as $node) {
            $dep_id = $node['name'][0];
            echo '<li onclick=\'display_info(' . $dep_id . ')\'>' . $node['name'][1];
            printTree($node['children']);
            echo '</li>';
        }
        echo '</ul>';
    }
}
コード例 #6
0
ファイル: snippets2.php プロジェクト: atonevbg/snippets
function printTree($tree, $r = 0, $p = null)
{
    foreach ($tree as $i => $t) {
        $dash = $t['parent'] == 0 ? '' : str_repeat('-', $r) . ' ';
        printf("\t<option value='%d'>%s%s</option>\n", $t['id'], $dash, $t['name']);
        if ($t['parent'] == $p) {
            // reset $r
            $r = 0;
        }
        if (isset($t['_children'])) {
            printTree($t['_children'], ++$r, $t['parent']);
        }
    }
}
コード例 #7
0
ファイル: tree_helper.php プロジェクト: ariborneo/koperasi
function printTree($tree, $r = 0, $p = null, $id)
{
    foreach ($tree as $i => $t) {
        $dash = $t->parent_id == 0 ? '' : str_repeat('----', $r) . ' ';
        $selected = $t->id == $id ? 'selected' : '';
        print "\t<option " . $selected . " value='" . $t->id . "'>" . $dash . $t->name . "</option>\n";
        if ($t->parent_id == $p) {
            //reset $r
            $r = 0;
        }
        if (isset($t->_children)) {
            $j = printTree($t->_children, $r + 1, $t->parent_id, $id);
        }
    }
    return $j;
}
コード例 #8
0
function printTree($node, $indent, $prefix)
{
    $indentStr = "    ";
    $printStr = "";
    for ($i = 0; $i < $indent; $i++) {
        $printStr = $printStr . $indentStr;
    }
    echo $printStr . $prefix . " value: " . $node->data . "\n";
    $indent++;
    if ($node->left) {
        printTree($node->left, $indent, "left: ");
    }
    if ($node->right) {
        printTree($node->right, $indent, "right: ");
    }
}
コード例 #9
0
ファイル: Misc.php プロジェクト: rivetweb/old-auto-catalog
/**
 * Построение дерева
 */
function printTree($tree, $printUL = true, $isRoot = false, $name = "")
{
    if ($isRoot) {
        print '<ul id="' . $name . '" class="tree">';
    } else {
        if ($printUL) {
            print '<ul>';
        }
    }
    foreach ($tree as $item) {
        $img = "";
        $childsCode = "";
        // Имеются дочерние узлы
        if (isset($item["childs"]) && sizeof($item["childs"]) > 0) {
            $img = "collapsed";
            $childsCode = printTree($item["childs"]);
        } else {
            $img = "leaf";
        }
        if (isset($item["state"])) {
            $img = $item["state"];
        }
        $nodeType = isset($item["tp"]) ? " tp='" . $item["tp"] . "'" : "";
        $customImg = "";
        if (isset($item["image"])) {
            $imgAlt = "alt='" . basename($item["image"], ".png") . "'";
            $customImg = "<img src='" . $item["image"] . "' {$imgAlt}>";
        }
        $customAttrsCode = " ";
        if (isset($item["customAttrs"])) {
            $customAttrs = $item["customAttrs"];
            foreach ($customAttrs as $k => $v) {
                $customAttrsCode .= "{$k}=\"{$v}\" ";
            }
        }
        $liClass = isset($item["liClass"]) ? "class='" . $item["liClass"] . "'" : "";
        print "<li {$liClass}><img src='" . sprintf(TREE_IMAGE_MASK, $img) . "'>" . "<span nodeId='" . $item["nodeId"] . "'" . $nodeType . $customAttrsCode . ">" . $customImg . $item["name"] . "</span>" . $childsCode . "</li>";
    }
    if ($printUL) {
        print '</ul>';
    }
}
コード例 #10
0
ファイル: listarray.php プロジェクト: logiks/logiks-core
 function printTree($arr, $format = "ul,li,h2,a")
 {
     if (!is_array($format)) {
         $format = explode(",", $format);
     }
     for ($i = sizeOf($format); $i <= 4; $i++) {
         array_push($format, "span");
     }
     $s = "";
     foreach ($arr as $a => $b) {
         if (is_array($b)) {
             $s .= "<{$format[1]}><{$format[2]}>{$a}</{$format[2]}>";
             $s .= "<{$format[0]}>" . printTree($b, $format) . "</{$format[0]}>";
             $s .= "</{$format[1]}>";
         } else {
             $s .= "<{$format[1]}><{$format[3]} rel={$a} >{$a}</{$format[3]}></{$format[1]}>";
         }
     }
     return $s;
 }
コード例 #11
0
ファイル: tree.php プロジェクト: songjian/songjian.github.io
function printTree($tree, $keys, $prefix = '')
{
	if(is_array($tree))
	{
		foreach($tree as $key => $subTree)
		{
			if(in_array($key, $keys, true))
			{
				echo '- ' . $key . "\n";
			}
			elseif(!is_numeric($key))
			{
				$prefix .= '  ';
				echo $prefix . '|_ ' . $key . "\n";
			}
			printTree($subTree, $keys, $prefix);
		}
	}
	else
		echo $prefix . '|_ ' . $tree . "\n";
}
コード例 #12
0
ファイル: import3.php プロジェクト: dehvCurtis/phplist
function printTree($tree, $root, $delim)
{
    reset($tree);
    #  print "<hr/>ROOT: $root<br/>";
    foreach ($tree as $node => $rec) {
        if (!in_array($node, $GLOBALS["nodesdone"])) {
            if (preg_match("#" . preg_quote($root) . "#i", $node)) {
                print '<li>';
                printf('<input type="checkbox" name="checkfolder[]" value="%s">&nbsp;', $node);
                print "<b>{$node}</b>\n";
                printf('<input type="checkbox" name="%s" id="%s" value="1"
          onchange="checkSubFolders(\'%s\');"> (add subfolders)', $node, $node, $node);
                print "</li>";
                print "<ul>\n";
                foreach ($tree[$node]["children"] as $leaf) {
                    if ($tree[$node . $delim . $leaf]) {
                        #          print "<ul>";
                        printTree($tree, $node . $delim . $leaf, $delim);
                        #          print "</ul>";
                    } else {
                        #  print "NO $node$delim$leaf <br/>";
                        print '<li>';
                        printf('<input type="checkbox" name="checkfolder[]" value="%s">&nbsp;', $node . $delim . $leaf);
                        #            print "$node.$delim";
                        print "{$leaf}</li>\n";
                    }
                    array_push($GLOBALS["nodesdone"], $node);
                }
                print "</ul>";
            } else {
                #     print "<li>$node</li>";
                #      print $root ."===". $node . "<br/>";
            }
        } else {
            #   print "<br/>Done: $node";
        }
    }
}
コード例 #13
0
function HandleExpand()
{
    global $db;
    if ($_REQUEST["treeId"] == "TreeCategories") {
        $res =& $db->query(CMD_SEL_ITEMS, array($_REQUEST["nodeId"]));
        if (PEAR::isError($res)) {
            printErr($res);
            exit;
        }
        $items = array();
        while ($row =& $res->fetchRow(DB_FETCHMODE_OBJECT)) {
            $customAttrs = array("categId" => $row->category_id);
            $items[] = array("nodeId" => $row->id, "name" => $row->art . " - " . $row->name, "state" => "item", "tp" => NODE_SITE_ITEM, "image" => getImageState($row), "customAttrs" => $customAttrs);
        }
        printTree($items, false);
    } else {
        if ($_REQUEST["treeId"] == "TreeOurSite") {
            $res =& $db->query(CMD_SEL_SUBCATEGORIES, array($_REQUEST["nodeId"]));
            if (PEAR::isError($res)) {
                printError($res);
                exit;
            }
            $categories = array();
            while ($row =& $res->fetchRow(DB_FETCHMODE_OBJECT)) {
                $catCount = getItemsCount($row->id);
                $state = null;
                if ($catCount > 0) {
                    $state = "collapsed";
                }
                $imgState = $row->viewmode == true ? "pics/ourcategoryHidden.png" : "pics/ourcategory.png";
                $categories[] = array("nodeId" => $row->id, "name" => $row->name, "state" => $state, "image" => $imgState);
            }
            addMovedItems($categories, $_REQUEST["nodeId"]);
            printTree($categories, false);
        }
    }
}
コード例 #14
0
ファイル: tree.php プロジェクト: apmuthu/phpMyOLAP
<?php

$cubename = $_GET['cube'];
include "../config.php";
include "views/views.php";
$xml = simplexml_load_file($xmlfile);
printTree($cubename, $img_cube, $img_plus);
コード例 #15
0
ファイル: menu-edit.php プロジェクト: ariborneo/koperasi
						<div class="col-md-4">							
							<select class="col-md-12 full-width-fix" name="link" id="link">								
								<option value="0">Unidentify</option>
								<?php 
printTree($link, '', '', $parsing->resource_id);
?>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">Parent:</label> 
						<div class="col-md-4">
							<select class="select2-01 col-md-12 full-width-fix" name="parent" id="parent">
							<option value="0">Unidentify</option>
							<?php 
printTree($menu_parent, '', '', $parsing->id);
?>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">Active:</label> 
						<div class="col-md-4">
							<select name="active" id="active" class="form-control">
								
								<option <?php 
if ($parsing->active == 0) {
    echo "selected";
} else {
    echo "";
}
コード例 #16
0
ファイル: OurSite.php プロジェクト: rivetweb/old-auto-catalog
$res =& $db->query(CMD_SEL_SUBCATEGORIES, array(0));
if (PEAR::isError($res)) {
    print $res->getMessage();
    exit;
}
$categories = array();
while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
    $catCount = getItemsCount($row->id);
    $state = null;
    if ($catCount > 0) {
        $state = "collapsed";
    }
    $imgState = $row->viewmode == true ? "pics/ourcategoryHidden.png" : "pics/ourcategory.png";
    $categories[] = array("nodeId" => $row->id, "name" => $row->name, "state" => $state, "image" => $imgState);
}
printTree($categories, true, true, "TreeOurSite");
?>

<script>

var ourSiteObj = document.getElementById("OurSite");

var getSrcNodesParam = function (nodes) {
	var res = "";
	if (nodes == null) return res;
	if (nodes.length == 0) return res;

	for (var i = 0; i < nodes.length; i++) {
		var nodeType = nodes[i].getAttribute("tp");
		if (nodeType == null) {
			nodeType = "";
コード例 #17
0
ファイル: pipelines.php プロジェクト: pmolfese/nidb
function PrintTree($tree, $level)
{
    MarkTime("PrintTree()");
    if (!is_null($tree) && count($tree) > 0) {
        $level++;
        foreach ($tree as $node) {
            PrintPipelineRow($GLOBALS['info'][$node['pipeline_id']], $level);
            #PrintPipelineRow(GetPipelineInfo($node['pipeline_id']), $level);
            $level = printTree($node['child_id'], $level);
        }
        $level--;
    }
    return $level;
}
コード例 #18
0
ファイル: menu-add.php プロジェクト: ariborneo/koperasi
						<label class="col-md-2 control-label">Link:</label> 
						<div class="col-md-4">							
							<select class="col-md-12 full-width-fix" name="link" id="link">								
								<?php 
printTree($link);
?>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 control-label">Parent:</label> 
						<div class="col-md-4">
							<select class="col-md-12 full-width-fix" name="parent" id="parent">								
								<option value='0'>No Parent</option>
								<?php 
printTree($menu_parent);
?>
							</select>
						</div>
					</div> 
					<div class="form-group">
						<label class="col-md-2 control-label">Active:</label> 
						<div class="col-md-4">
							<select name="active" id="active" class="form-control">								
								<option value="0">Active</option>
								<option value="1">Inactive</option>							
							</select>
						</div>
					</div>	
					<div class="form-actions">
						<div class="row">						
コード例 #19
0
ファイル: sqlprint.php プロジェクト: kshyana/Logiks-Core
 function printTreeList($treeArray)
 {
     if (sizeOf($treeArray) <= 0) {
         return "";
     }
     $s = "";
     foreach ($treeArray as $a => $b) {
         $data = $b['data'];
         unset($b['data']);
         if (count($b) > 0) {
             $s .= "<li>";
             $s .= "<h3 rel='{$data['id']}'>{$a}</h3>";
             $s .= "<ul>";
             $s .= printTree($b);
             $s .= "</ul>";
             $s .= "</li>";
         } else {
             $s .= "<li><a rel='{$data['id']}'>{$a}</a></li>";
         }
     }
     return $s;
 }
コード例 #20
0
ファイル: lib.php プロジェクト: ixias/web-thing
function printEditor($ndid, $tree, $test)
{
    $data = mysqli_query($tree, "SELECT * FROM nodes WHERE id='" . $ndid . "'");
    $info = mysqli_fetch_array($data, MYSQLI_ASSOC);
    echo "<form method=\"POST\" action=\"/\">\n";
    echo " <div><input type=\"text\" id=\"id\" name=\"id\" placeholder=\"id\" value=\"" . $info["id"] . "\"/></div>\n";
    echo " <div><input type=\"text\" id=\"title\" name=\"title\" placeholder=\"title\" value=\"" . $info["title"] . "\"/></div>\n";
    echo " <div><input type=\"text\" id=\"description\" name=\"description\" placeholder=\"description\" value=\"" . $info["description"] . "\"/></div>\n";
    echo " <div><textarea id=\"body\" name=\"body\" placeholder=\"body\">" . $info["body"] . "</textarea></div>\n";
    echo " <div><input type=\"text\" id=\"images\" name=\"images\" placeholder=\"images\" value=\"" . $info["images"] . "\"/></div>\n";
    echo "<div id=\"tree\">\n";
    printTree($test, "/", 1);
    echo "</div>\n\n";
    echo " <div><input type=\"text\" id=\"connections\" name=\"connections\" placeholder=\"connections\" value=\"" . $info["connections"] . "\"/></div>\n";
    echo " <input type=\"hidden\" id=\"edit\" name=\"edit\" value=\"" . $ndid . "\"/>\n";
    echo " <div><input type=\"submit\" value=\"Save\"/></div>\n";
    echo "</form>\n";
}
コード例 #21
0
ファイル: beehub_directory.php プロジェクト: niekbosch/BeeHub
function printTree($path, $treeState, $selectedPath)
{
    $registry = BeeHub_Registry::inst();
    $resource = $registry->resource($path);
    $members = array();
    foreach ($resource as $member) {
        // Skip the /system/ directory, as there is no need to see this
        if ($path === '/' && $member === 'system/' || substr($member, -1) !== '/') {
            continue;
        }
        $members[] = $member;
    }
    usort($members, 'strnatcasecmp');
    $last = count($members) - 1;
    for ($counter = 0; $counter <= $last; $counter++) {
        $member = $members[$counter];
        $memberResource = $registry->resource($path . $member);
        // Previous versions actually checked whether the resource has children
        // or not. But with the new set-up that means a query for each resource
        // and this is simply to expensive. Setting this to true for all cases
        // means the end-user will find out there are no child resources on the
        // first attempt to unfold the directory in the tree
        $hasChildren = true;
        $expanded = isset($treeState[$memberResource->path]) && $hasChildren ? $treeState[$memberResource->path] : false;
        ?>
<li <?php 
        echo $counter === $last ? 'class="dynatree-lastsib"' : '';
        ?>
          ><span class="dynatree-node dynatree-folder
                       <?php 
        echo $hasChildren ? 'dynatree-has-children' : '';
        ?>
                       <?php 
        echo $expanded ? 'dynatree-expanded' : ($hasChildren ? 'dynatree-lazy' : '');
        ?>
                       dynatree-exp-<?php 
        echo $expanded ? 'e' : 'cd';
        echo $counter === $last ? 'l dynatree-lastsib' : '';
        ?>
                       dynatree-ico-<?php 
        echo $expanded ? 'e' : 'c';
        ?>
f
                       <?php 
        echo $memberResource->path === $selectedPath ? 'dynatree-focused' : '';
        ?>
                "
            ><span class="dynatree-<?php 
        echo $hasChildren ? 'expander' : 'connector';
        ?>
"></span
            ><span class="dynatree-icon"></span
            ><a class="dynatree-title" href="<?php 
        echo DAV::xmlescape(DAV::encodeURIFullPath($memberResource->path));
        ?>
"><?php 
        echo DAV::xmlescape($memberResource->user_prop_displayname());
        ?>
</a
          ></span
          <?php 
        if ($expanded && $hasChildren) {
            ?>
            ><ul><?php 
            echo printTree($memberResource->path, $treeState, $selectedPath);
            ?>
</ul
          <?php 
        }
        ?>
        ></li>
        <?php 
        $registry->forget($path . $member);
    }
}
コード例 #22
0
ファイル: list_coa.php プロジェクト: rylsteel/phpledger
        </section>

        <!-- Main content -->
        <section class="content">

 <!-- Default box -->
          <div class="box">
            <div class="box-header with-border">
              <h3 class="box-title">Chart of Accounts</h3> <a href="<?php 
echo SITE_ROOT;
?>
?route=modules/gl/setup/coa/add_coa" class="btn btn-primary btn-sm" ><i class="fa fa-plus"></i>&nbsp Add New Account</a>
              <div class="box-tools pull-right">
                <button class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse"><i class="fa fa-minus"></i></button>
                <button class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove"><i class="fa fa-times"></i></button>
              </div>
            </div>
            <div class="box-body">
			 
				 <?php 
printTree($list);
$result1 = parseTree(null, $list);
printTree($result1);
?>
			 
            </div><!-- /.box-body -->
            <div class="box-footer">
             <small> Please do not make changes to these unless you are really sure what you are doing. making changes here have system wide impact</small>
            </div><!-- /.box-footer-->
          </div><!-- /.box -->
     	 </section><!-- /.content -->
コード例 #23
0
ファイル: menu.php プロジェクト: ariborneo/koperasi
 function test()
 {
     $data = $this->mgeneral->getAll("tr_menu");
     $resource = $this->db->query("select id,name,parent as parent_id from acl_resources ")->result();
     $tree = buildTree($data);
     echo "<pre/>";
     print_r(buildTree($data));
     echo printTree($tree);
 }
コード例 #24
0
function printTree($arr)
{
    if (!is_null($arr) && count($arr) > 0) {
        echo '<ul>';
        foreach ($arr as $node) {
            echo "<li>" . $node['sect_name'] . "";
            if (array_key_exists('children', $node)) {
                printTree($node['children']);
            }
            echo '</li>';
        }
        echo '</ul>';
    }
}
コード例 #25
0
ファイル: tree2.php プロジェクト: rahul7633/yii2-repo1
 <script>
            function printTreeNode(node) {  
               console.log(node);
               $('#tree').children().find('#node-'+node.parentID).append('<ul class="'+node.position+'"><li id="node-'+node.id+'" ><span>'+node.data+'</span></li></ul>');
            }
        </script>
    </head>    
    <body>
        <div id="tree">
            <ul>
                <li id="node-1">
                    <span>Root</span>
                </li>
            </ul>
        </div>

        <?php 
$tree = [['parentID' => 1, 'level' => 1, 'position' => 'left', 'data' => 'a', 'id' => 2], ['parentID' => 1, 'level' => 1, 'position' => 'right', 'data' => 'b', 'id' => 3], ['parentID' => 2, 'level' => 2, 'position' => 'left', 'data' => 'c', 'id' => 4], ['parentID' => 2, 'level' => 2, 'position' => 'right', 'data' => 'd', 'id' => 5], ['parentID' => 3, 'level' => 3, 'position' => 'left', 'data' => 'e', 'id' => 6], ['parentID' => 3, 'level' => 3, 'position' => 'right', 'data' => 'f', 'id' => 7], ['parentID' => 4, 'level' => 4, 'position' => 'left', 'data' => 'g', 'id' => 8], ['parentID' => 4, 'level' => 4, 'position' => 'right', 'data' => 'g', 'id' => 9]];
printTree($tree);
$root = [];
function printTree(array $tree)
{
    foreach ($tree as $node) {
        echo "<script>printTreeNode(" . json_encode($node) . ")</script>";
    }
}
?>
        

    <body>
</html>