function tree($array, $parent, $parts = array(), $step = 0) { // echo "<pre>"; // print_r( $array ); // echo "</pre>"; // die(); if (!count($array)) { return ''; } $tid = $step == 0 ? 'id="tree"' : ''; $t = '<ul class="list-unstyled" ' . $tid . '>'; foreach ($array as $key => $item) { if (is_array($item)) { $open = $step !== false && (isset($parts[$step]) && $key == $parts[$step]); $t .= '<li class="directory' . ($open ? ' open' : '') . '" oncontextmenu="return false;">'; $t .= '<a href="#" data-role="directory" id="' . preg_replace("/[^A-Za-z0-9]/", "", $key) . '" class="directory-name"><span class="glyphicon glyphicon-folder-' . ($open ? 'open' : 'close') . '"></span>' . $key . '</a>'; $t .= tree($item, "{$parent}/{$key}", $parts, $open ? $step + 1 : false); $t .= '</li>'; } else { $selected = isset($parts[$step]) && $item == $parts[$step]; $t .= '<li class="file' . ($selected ? ' active' : '') . '"><a href="' . $parent . '/' . $item . '">' . $item . '</a></li>'; } } $t .= '</ul>'; return $t; }
function tree($array, $parent, $parts = array(), $step = 0, $folder = "") { if (!count($array)) { return ''; } $tid = $step == 0 ? 'id="tree"' : ''; $t = '<ul class="unstyled" ' . $tid . '>'; foreach ($array as $key => $item) { if (is_array($item)) { $open = $step !== false && (isset($parts[$step]) && $key == $parts[$step]); $t .= '<li class="directory' . ($open ? ' open' : '') . '">'; $t .= '<a href="#" data-role="directory"><i class="icon icon-folder-' . ($open ? 'open' : 'close') . '"></i> ' . $key . '</a>'; $t .= tree($item, "{$parent}/{$key}", $parts, $open ? $step + 1 : false, $folder = $key); $folder = ""; $t .= '</li>'; } else { $selected = isset($parts[$step]) && $item == $parts[$step]; if ($folder != "") { $folder = $folder . "/"; } $t .= '<li class="file' . ($selected ? ' active' : '') . '"><a href="' . PLUGPATH . urlencode($folder . $item) . '">' . $item . '</a></li>'; } } $t .= '</ul>'; return $t; }
private function get_categories() { $categories = Cache::rememberForever('wyshop_admin_category_categories', function () { $categories = Category::orderBy('parent_id', 'asc')->orderBy('sort_order', 'asc')->orderBy('id', 'asc')->get(); return tree($categories); }); return $categories; }
function tree($data, $i = 0, &$result = array()) { $result[$i] = []; if (array_key_exists($i, $data)) { foreach ($data[$i] as $value) { tree($data, $value, $result[$i]); } } }
function tree($parent) { $d = "<li><a href='?Id=" . $parent->getId() . "'>" . $parent->getName() . "</a>"; foreach ($parent->getZones() as $zone) { $d .= "<ul>"; $d .= tree($zone); $d .= "</ul>"; } return $d . "</li>"; }
public static function tree($data, $pid = 0, $depth = 0, &$tree = array()) { foreach ($data as $key => $val) { if ($pid == $val['pid']) { $val['depth'] = $depth; $tree[] = $val; tree($data, $val['id'], $depth + 1, $tree); } } return $tree; }
function tree(&$data, $parent_id = 0, $count = 1) { static $result = array(); foreach ($data as $key => $value) { if ($value['parent_id'] == $parent_id) { $value['count'] = $count; $result[] = $value; unset($data[$key]); tree($data, $value['id'], $count + 1); } } return $result; }
function tree($dir, $exclude) { $dirs = preg_grep('/^([^.])/', array_diff(scandir($dir), $exclude)); $tree = array(); foreach ($dirs as $current) { if (is_dir($dir . "/" . $current)) { $tree[$current] = tree($dir . "/" . $current, $exclude); } else { $tree[$current] = $current; } } return $tree; }
function tree($tree) { foreach ($tree as $value) { echo "<li><a href=\"javascript:delService('" . $value['id'] . "','" . $value['name_cn'] . "');\" class='delSub'>删除</a>"; echo "<a href='" . ROOT_URL . "service/update?id=" . $value['id'] . "'>更改</a>"; echo "<a href='" . ROOT_URL . "service/create?pid=" . $value['id'] . "'>增加子节点</a>"; echo "<a href='" . ROOT_URL . "service/detail?id=" . $value['id'] . "'>查看</a>"; echo "<span style='margin-left:" . (string) ($value['depth'] * 30) . "px'>" . $value['name_cn'] . "</span><input type='hidden' class='catid' value='" . $value['id'] . "'></li>"; if ($value['children'] != null) { tree($value['children']); } } }
function tree(&$list, $pid = 0, $level = 0, $html = '<lable class="label label-info">|----</lable>') { static $tree = array(); foreach ($list as $v) { if ($v['pid'] == $pid) { $v['sort'] = $level; $v['html'] = str_repeat($html, $level); $tree[] = $v; tree($list, $v['id'], $level + 1); } } return $tree; }
function tree($tree) { foreach ($tree as $value) { echo "<li><a href=\"javascript:delPractice('" . $value['id'] . "','" . $value['name_cn'] . "');\" class='delSub'>delete</a>"; echo "<a href='" . ROOT_URL . "practice/update?lang=en&id=" . $value['id'] . "'>update</a>"; echo "<a href='" . ROOT_URL . "practice/create?lang=en&pid=" . $value['id'] . "'>create child node</a>"; echo "<a href='" . ROOT_URL . "practice/detail?lang=en&id=" . $value['id'] . "'>view</a>"; echo "<span style='margin-left:" . (string) ($value['depth'] * 30) . "px'>" . $value['name_en'] . "</span><input type='hidden' class='catid' value='" . $value['id'] . "'></li>"; if ($value['children'] != null) { tree($value['children']); } } }
/** * 无线分类的树形简单实现 * @param type $list * @param type $pid_key 父字段名 * @param type $id_key 主键名 * @param type $pid * @param type $level * @param type $html * @return type */ function tree($list, $pid_key = 'pid', $id_key = 'id', $pid = 0, $level = 0, $html = '----') { $tree = array(); foreach ($list as $v) { if ($v[$pid_key] == $pid) { $v['sort'] = $level; $v['html'] = str_repeat($html, $level); $tree[] = $v; $tree = array_merge($tree, tree($list, $pid_key, $id_key, $v[$id_key], $level + 1, $html)); } } return $tree; }
/** * Output a microdata object representation as tree * * @param \stdClass $object Object * @param \boolean $link Link values * @return \string HTML */ function tree($object, $link = false) { $html = ''; // If it's a true object if ($object instanceof \stdClass) { // If it's a micro information item if (property_exists($object, 'types') && property_exists($object, 'id') && property_exists($object, 'value') && property_exists($object, 'properties')) { $html .= '<h3><span class="item-type">' . implode('</span> + <span class="item-type">', array_map('htmlspecialchars', $object->types)) . '</span> <span class="item-id">[ID = ' . htmlspecialchars($object->id ? $object->id : 'NULL') . ']</span></h3>'; if (strlen($object->value)) { $html .= '<div class="item-value">' . htmlspecialchars($object->value) . '</div>'; } if (count($object->properties)) { $html .= '<dl class="item-properties">'; foreach ($object->properties as $property => $values) { $html .= '<dt>' . htmlspecialchars($property) . '</dt>'; $html .= '<dd>' . tree($values, in_array($property, \Jkphl\Micrometa\Item::$urlProperties)) . '</dd>'; } $html .= '</dl>'; } if (count($object->children)) { $html .= '<dl class="item-children">'; $html .= '<dt>children</dt>'; $html .= '<dd>' . tree($object->children, false) . '</dd>'; $html .= '</dl>'; } } else { $html .= '<dl class="object">'; foreach (get_object_vars($object) as $property => $values) { $html .= '<dt>' . htmlspecialchars($property) . '</dt>'; $html .= '<dd>' . tree($values, $link || in_array($property, array_merge(\Jkphl\Micrometa\Item::$urlProperties, array('rels')))) . '</dd>'; } $html .= '</dl>'; } // Else: If it's an (ordered) list } elseif (is_array($object)) { $html .= '<ol>'; foreach ($object as $value) { $value = tree($value, $link || in_array($value, array('rels'))); $html .= '<li>' . ($link ? '<a href="' . $value . '" target="_blank">' . $value . '</a>' : $value) . '</li>'; } $html .= '</ol>'; // Else: If it's an empty value } elseif (!strlen($object)) { $html .= '—'; // Else: It's a scalar } else { $html .= htmlspecialchars($object); } return $html; }
function tree($directory) { $mydir = dir($directory); echo "<ul>\n"; while ($file = $mydir->read()) { if (is_dir("{$directory}/{$file}") and $file != "." and $file != "..") { echo "<li><font color=\"#ff00cc\"><b>{$file}</b></font></li>\n"; tree("{$directory}/{$file}"); } else { echo "<li>{$file}</li>\n"; } } echo "</ul>\n"; $mydir->close(); }
function tree($dir = '.', $files = true) { if (!isset($dossiers[0]) || $dossiers[0] != $dir) { $dossiers[0] = $dir; } if (!is_dir($dir) && $files) { return array($dir); } elseif (!is_dir($dir) && !$files) { return array(); } $list = _glob(addslash_if_needed($dir)); foreach ($list as $dossier) { $dossiers = array_merge($dossiers, tree($dossier, $files)); } return $dossiers; }
/** * Created an nested unordered list from a multidimensional array * * @param array * @return string */ function tree(array $nodes, Closure $render = null) { $output = '<ul class="no-bullet">'; foreach ($nodes as $node) { // Get name $name = is_null($render) ? $node['name'] : $render($node); // Render node $output .= '<li>' . $name; // Render children if ($node['children']) { $output .= tree($node['children'], $render); } $output .= '</li>'; } return $output . '</ul>'; }
function tree($array, $parentId = 0, $level = 0, $symbol = '-') { $data = array(); foreach ($array as $value) { if ($value['parent_id'] == $parentId) { if ($parentId != 0) { $value['html'] = str_repeat(' ', $level); $value['html'] .= '|'; $value['html'] .= str_repeat($symbol, $level); } $sub = tree($array, $value['id'], $level + 1); $data[] = $value; $data = array_merge($data, $sub); } } return $data; }
function display_tree($array) { $root = NULL; foreach ($array as $child) { if ($child['lft'] == '1') { $root = 'class="ignore"'; } echo "<li {$root} id=\"" . $child['lft'] . "\">\n"; echo "<div class=\"item\">" . $child['lft'] . ' : ' . $child['title'] . ' : ' . $child['rgt'] . anchor('delete', 'Delete') . " " . anchor('edit', 'Edit') . " " . anchor('move', 'Move', 'class="drop"') . "</div>"; if (isset($child['children'])) { echo "<ul class=\"pagetree\">\n"; tree($child['children']); echo "</ul>\n"; } echo "\t</li>\n"; } }
function tree($items) { echo '<ul>'; foreach ($items as $item) { $url1 = URL::site('category/edit?id=' . $item['id']); $url2 = URL::site('category/add?pid=' . $item['id']); echo '<li><span>' . $item['name'] . '</span>'; echo '<div class="pull-right" style="margin-top: 10px;_display: none">'; echo '<a href="' . $url1 . '" class="btn btn-info btn-xs ajax-click _ajax-modal-sm">修改</a> '; echo '<a href="' . $url2 . '" class="btn btn-info btn-xs ajax-click _ajax-modal-sm">+子类</a></div>'; if (isset($item['children']) && is_array($item['children'])) { tree($item['children']); } echo '</li>'; } echo '</ul>'; }
function tree($path, $n = 0) { foreach (scandir($path) as $name) { if (canStop($n)) { return; } if ('.' === $name || '..' === $name) { continue; } $f = $path . DIRECTORY_SEPARATOR . $name; if (is_dir($f)) { displayDir($name, $n); tree($f, $n + 1); } else { displayFile($name, $n); } } }
function tree($directory) { $arr = array(); $mydir = dir($directory); while ($file = $mydir->read()) { if (is_dir("{$directory}/{$file}") && $file != "." && $file != ".." && $file != "smarty") { $res = tree("{$directory}/{$file}"); $arr = array_merge($arr, $res); } else { if ($file != "." && $file != "..") { $file_path = $directory . "/" . $file; $arr[] = $file_path; } } } $mydir->close(); return $arr; }
/** * Display the subtree of a category. * * @param int $id * @return Response */ public function show($id) { // Make sure resource exists $this->resource = $this->resource->findOrFail($id); $this->subtitle = $this->resource; // Get subcategories $subcategories = $this->resource->getDescendants(); // Get pages this category $pages = $this->resource->pages()->orderBy('name')->get(); // Get pages of subcategories $subpages = Page::whereIn('category_id', $subcategories->lists('id'))->orderBy('name')->get(); // Function to render a tree node $render = function (array $node) { return link_to_route('category.show', $node['name'], [$node['id']]); }; // Build subcategories tree $tree = tree($subcategories->toHierarchy()->toArray(), $render); view()->share(compact('pages', 'subpages', 'subcategories', 'tree')); return parent::show($id); }
function tree($categories, $level = 1) { global $categories_tree; foreach ($categories as $category) { //echo $category->name . "\n"; //echo $level . "\n"; //echo str_repeat("-", $level).$category->name."<br>"; $category_tree = new stdClass(); $category_tree->id = $category->id; if (!$category->parent_id) { $category_tree->parent = "#"; } else { $category_tree->parent = $category->parent_id; } $category_tree->text = $category->name . " (" . $category->count . ")"; $categories_tree[] = $category_tree; tree($category->subcategories, $level + 1); } return $categories_tree; }
function tree($dir, $filter = '', &$result = array(), $deep = false) { $files = new DirectoryIterator($dir); foreach ($files as $file) { $filename = $file->getFilename(); if ($filename[0] === '.') { continue; } if ($file->isDir()) { tree($dir . DS . $filename, $filter, $result, $deep); } else { if (!empty($filter) && !\preg_match($filter, $filename)) { continue; } if ($deep) { $result[$dir] = $filename; } else { $result[] = $dir . DS . $filename; } } } return $result; }
function tree($query, $parent = NULL, $level = 1) { $count = 0; foreach($query->result() as $row) { if($row->ctr_parent == $parent) { $count++; for($i=0;$i<$level;$i++){ //echo "->"; } ?> <div class="da-form-row" > <p> <?php echo $row->ctr_value; ?> </p> </div> <?php tree($query, $row->ctr_id, $level+1); } else if($count == $query->num_rows()) { return 0; } } } ?>
function show_tree() { global $fm_current_root, $path_info, $setflag, $islinux, $cookie_cache_time; html_header("\r\n <script language=\"Javascript\" type=\"text/javascript\">\r\n <!--\r\n function saveFrameSize(){\r\n if (getFrameSize()){\r\n var exp = new Date();\r\n exp.setTime(exp.getTime()+{$cookie_cache_time});\r\n setCookie('leftFrameWidth',frameWidth,exp);\r\n }\r\n }\r\n window.onresize = saveFrameSize;\r\n //-->\r\n </script>"); echo "<body marginwidth=\"0\" marginheight=\"0\">\n"; echo "\r\n <script language=\"Javascript\" type=\"text/javascript\">\r\n <!--\r\n // Disable text selection, binding the onmousedown, but not for some elements, it must work.\r\n function disableTextSelection(e){\r\n\t\t\tvar type = String(e.target.type);\r\n\t\t\treturn (type.indexOf('select') != -1 || type.indexOf('button') != -1 || type.indexOf('input') != -1 || type.indexOf('radio') != -1);\r\n\t\t}\r\n function enableTextSelection(){return true}\r\n if (is.ie) document.onselectstart=new Function('return false')\r\n else {\r\n document.body.onmousedown=disableTextSelection\r\n document.body.onclick=enableTextSelection\r\n }\r\n var flag = " . ($setflag ? "true" : "false") . "\r\n function set_flag(arg) {\r\n flag = arg;\r\n }\r\n function go_dir(arg) {\r\n var setflag;\r\n setflag = (flag)?1:0;\r\n document.location.href='" . addslashes($path_info["basename"]) . "?frame=2&setflag='+setflag+'¤t_dir=" . addslashes($current_dir) . "&ec_dir='+arg;\r\n }\r\n function go(arg) {\r\n if (flag) {\r\n parent.frame3.set_dir_dest(arg+'/');\r\n flag = false;\r\n } else {\r\n parent.frame3.location.href='" . addslashes($path_info["basename"]) . "?frame=3¤t_dir='+arg+'/';\r\n }\r\n }\r\n function set_fm_current_root(arg){\r\n document.location.href='" . addslashes($path_info["basename"]) . "?frame=2&set_fm_current_root='+escape(arg);\r\n }\r\n function atualizar(){\r\n document.location.href='" . addslashes($path_info["basename"]) . "?frame=2';\r\n }\r\n //-->\r\n </script>\r\n "; echo "<table width=\"100%\" height=\"100%\" border=0 cellspacing=0 cellpadding=5>\n"; echo "<form><tr valign=top height=10><td>"; if (!$islinux) { echo "<select name=drive onchange=\"set_fm_current_root(this.value)\">"; $aux = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for ($x = 0; $x < strlen($aux); $x++) { if ($handle = opendir($aux[$x] . ":/")) { @closedir($handle); if (strstr(uppercase($fm_current_root), $aux[$x] . ":/")) { $is_sel = "selected"; } else { $is_sel = ""; } echo "<option {$is_sel} value=\"" . $aux[$x] . ":/\">" . $aux[$x] . ":/"; } } echo "</select> "; } echo "<input type=button value=" . et('Refresh') . " onclick=\"atualizar()\"></tr></form>"; echo "<tr valign=top><td>"; clearstatcache(); tree($fm_current_root, $fm_current_root, -1, 0); echo "</td></tr>"; echo "\r\n <form name=\"login_form\" action=\"" . $path_info["basename"] . "\" method=\"post\" target=\"_parent\">\r\n <input type=hidden name=action value=1>\r\n <tr>\r\n <td height=10 colspan=2><input type=submit value=\"" . et('Leave') . "\">\r\n </tr>\r\n </form>\r\n "; echo "</table>\n"; echo "</body>\n</html>"; }
case 'remove': tree_remove(); header("Location: tree.php"); break; case 'edit': include_once("./include/top_header.php"); tree_edit(); include_once("./include/bottom_footer.php"); break; default: include_once("./include/top_header.php"); tree(); include_once("./include/bottom_footer.php"); break; } /* -------------------------- The Save Function -------------------------- */ function form_save() { if (isset($_POST["save_component_tree"])) { $save["id"] = $_POST["id"]; $save["name"] = form_input_validate($_POST["name"], "name", "", false, 3); $save["sort_type"] = form_input_validate($_POST["sort_type"], "sort_type", "", true, 3); if (!is_error_message()) {
function tree($directory) { global $filearray; $mydir=dir($directory); while($file=$mydir->read()) { if((is_dir("$directory/$file")) AND ($file!=".") AND ($file!="..")) { tree("$directory/$file"); } else if (($file!=".") AND ($file!="..")) { $filearray[]=$directory.'/'.$file; } } $mydir->close(); }
$parent2 = $j; //$today=mktime(0,0,0,date("m",time()),date("d",time()),date("Y",time())); while ($r1 = mysql_fetch_array($res1)) { print "<a href=\"products.php?id={$r1['ProductID']}\" style='display:block' id=\"menu" . $j . "parent" . $parent2 . "\" title='{$products}'>- {$r1['Name']}</a>"; } } print "<br>"; $i++; $j++; } } } if ($type == "products") { print "<tr><td width=\"36\"> </td><td>"; print "<font color=199FF8><h3>Продукты:</h3></font><br>"; tree(1, 1, 1, 1, 0, '', '', '', 0); print "</td></tr>"; } else { $res = runsql("select MaterialID,Date,Headline_{$lang} as Headline, Name_{$lang} as Title, Message_{$lang} as Message, Small from ut_materials where TypeID=7 order by Date desc limit 0,3"); while ($r = mysql_fetch_array($res)) { print "\r\n \t<tr>\r\n \t \t<td width=\"36\"> </td>\r\n \t\t<td width=\"230\" class=\"lnews\"><a href=\"{$site_url}" . "news.php?id={$r['MaterialID']}\"><h2>" . $r[Title] . "</h2></a>\r\n \t\t<p><img src=\"{$img_url}?id={$r['MaterialID']}&record=2\" alt=\"\" width=\"69\" align=\"left\" style=\"margin-right: 6px;\">" . $r[Headline] . "</p></td>\r\n \t</tr>\r\n \t<tr>\r\n \t\t<td colspan=\"2\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"details\">\r\n \t<tr>\r\n \t<td width=\"193\"><img src=\"images/left/h-ln-details.gif\" alt=\"{$r['Title']}\" width=\"193\" height=\"15\"></td>\r\n \t<td valign=\"top\"><a href=\"{$site_url}" . "news.php?id={$r['MaterialID']}\">подробнее</a></td>\r\n \t</tr>\r\n </table></td>\r\n </tr>\r\n\t"; } } ?> </table> <?php if ($id == 2 || $first_page == 1) { ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr>
function tree($dir, $depth) { $json = new stdClass(); $scan = scandir($dir); $files = array(); foreach ($scan as $f) { if (substr($f, 0, 1) == ".") { // Skip hidden files (UNIX defination) continue; } if (is_dir("{$dir}/{$f}")) { if ($depth < 10) { // Max folder depth, this is to prevent a infinte loop $json->{$f} = tree("{$dir}/{$f}", $depth + 1); } else { $json->{$f} = array("Error: Too Deep" => array("Infinite loop prevention" => array())); } } else { array_push($files, $f); } } if (count($files) > 0) { $json->{"/"} = $files; } return $json; }