function renderTree($sections, $level = 0, $tableId) { $content = ''; $level = (int) $level; foreach ($sections as $section) { $bSubmenu = $section["dynamic"]; $bSectionActive = $section["open"]; $icon = isset($section["icon"]) && $section["icon"] != "" ? '<span class="adm-submenu-item-link-icon ' . $section["icon"] . '"></span>' : ''; $id = $tableId . '_section_' . $section['id']; $onclick = ''; if ($bSubmenu) { $onclick = $tableId . "_helper.toggleDynSection(" . getTreeOffsetWidth($level) . ", this.parentNode.parentNode, '" . (int) $section["id"] . "', '" . ($level + 1) . "')"; } $content .= '<div class="adm-sub-submenu-block' . ($level > 0 ? ' adm-submenu-level-' . ($level + 1) : '') . ($bSectionActive ? ' adm-sub-submenu-open' : '') . ($section["active"] ? ' adm-submenu-item-active' : '') . '"> <div class="adm-submenu-item-name' . (!$bSubmenu ? ' adm-submenu-no-children' : '') . '" id="' . $id . '" data-level="' . $level . '" data-offset="' . getTreeOffsetWidth($level) . '" tabindex="2"><span class="adm-submenu-item-arrow"' . ($level > 0 ? ' style="width:' . getTreeOffsetWidth($level) . 'px;"' : '') . ($onclick ? ' onclick="' . $onclick . '"' : '') . '> <span class="adm-submenu-item-arrow-icon"></span></span><a class="adm-submenu-item-name-link"' . ($level > 0 ? ' style="padding-left:' . (getTreeOffsetWidth($level) + 8) . 'px;"' : '') . ' href="#" . " onclick="return ' . $tableId . '_helper.onSectionClick(\'' . $section["id"] . '\')">' . $icon . ' <span class="adm-submenu-item-name-link-text">' . $section["text"] . '</span></a></div>'; $content .= '<div class="adm-sub-submenu-block-children">' . ($bSubmenu ? renderTree($section["items"], $level + 1, $tableId) : '') . '</div>'; $content .= '</div>'; } return $content; }
/** * * @param array $tree * @return string */ function renderTree(array $tree) { $html = '<ul>'; foreach ($tree as $e) { $inp = '<span><input type="checkbox" id="g' . $e['id'] . '"></span>'; $html .= '<li>' . $inp . $e['name']; if (count($e['children']) > 0) { $html .= renderTree($e['children']); } $html .= '</li>'; } $html .= '</ul>'; return $html; }
/** * Display a list of directories * * @param Array $dirs * @param String $rootpath * @return */ function renderTree($dirs, $rootpath) { $html = "\t\t<ul>\n"; foreach ($dirs as $key => $value) { $html .= "\t\t\t<li><a href=\"" . $rootpath . $key . "/" . '" class="folder">' . $key . '</a>'; if (count($dirs[$key]) > 0) { $html .= "\n" . renderTree($dirs[$key], $rootpath . $key . "/") . "\t\t"; } $html .= "</li>\n"; } $html .= "\t\t</ul>\n"; return $html; }
/** * Display a list of directories * * @param Array $dirs * @param String $rootpath * @return */ function renderTree($dirs, $rootpath) { $html = '<ul>'; foreach ($dirs as $key => $value) { $html .= '<li><a href="' . $rootpath . $key . "/" . '" class="folder">' . $key . '</a>'; if (count($dirs[$key]) > 0) { $level++; $html .= renderTree($dirs[$key], $rootpath . $key . "/"); } $html .= '</li>'; } $html .= '</ul>'; return $html; }
<?php require_once 'functions.php'; // Rootname is name of uploadfolder $rootname = array_pop(explode("/", trim($uploadpath, "/"))); // Get folders from uploadpath and create a list $dirs = getDirTree(STARTINGPATH, false); //Print treeview to screen echo '<ul class="treeview"> <li class="selected"><a class="root" href="' . $uploadpath . '">' . $rootname . "</a>\n"; echo renderTree($dirs, $uploadpath); echo " </li>\r\n </ul>\n";
</div> {!! link_to_route('members.edit', 'Edit', array($obj->id), array('class' => 'btn btn-info')) !!} {!! Form::submit('Delete', array('class' => 'btn btn-danger btn-delete')) !!} {!! Form::close() !!} </li> @endforeach </ul> @endif </div> <div class='right_col' style='float:none;margin-top:-20px;'> <h2>Browse by Category</h2> · <a href='/members/nochild'>Browse no child</a> <br> · <a href='/members/uncategorized'>Browse uncategorized</a> <br><br> <?php renderTree($parentChildArr, $categoriesArr, 'members'); ?> </div> @include('admin/partials/_footer') @endsection
@foreach( $categoriesObj as $obj ) <li class='cat_row'> {!! Form::open(array('class' => 'form-inline', 'method' => 'DELETE', 'route' => array('categories.destroy', $obj->slug))) !!} <div class='category_label'>{{ $obj->display_name }}</div> {!! link_to_route('categories.edit', 'Edit', array($obj->slug), array('class' => 'btn btn-info')) !!} {!! Form::submit('Delete', array('class' => 'btn btn-danger btn-delete')) !!} {!! Form::close() !!} </li> @endforeach </ul> @endif </div> <div class='right_col'> <h2>Hierarchy</h2> <?php renderTree($parentChildArr, $categoriesArr); ?> </div> @include('admin/partials/_footer') @endsection