<html> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="index.css" type="text/css"> <script src="../jquery-1.11.3.min.js"></script> <script src="index.js"></script> <title>Groups</title> </head> <body> <p><a href="<?php echo BASE_URL; ?> /">Home</a></p> <div id="messages"></div> <div id="groups"> <h2>Groups</h2> <div id="menubar"> <a href="add.php" id="add">Add</a> <a href="edit.php" id="edit">Edit</a> <a href="#" id="delete">Delete</a> </div><br> <div id="tree"> <?php echo renderTree2($groups); ?> </div> </div> <div id="details"></div> </body> </html>
echo $menu_to_edit['status'] == Menus::MENU_STATUS_ACTIVE ? ' checked="checked"' : ''; ?> >Active<br> <input type="radio" name="menu_status" value="inactive"<?php echo $menu_to_edit['status'] == Menus::MENU_STATUS_INACTIVE ? ' checked="checked"' : ''; ?> >Inactive </div> <div> <input type="hidden" id="menu_parent" name="menu_parent" value="<?php echo $is_post ? safeToDisplay($_POST['menu_parent']) : safeToDisplay($menu_to_edit['parent_id']); ?> "> </div> <input type="submit" value="Save"> </form> </div> <div id="parent"> Menu parent <div id="tree"> <?php $menus = turnResources2ATree_V2($pm->getMenus()->getAllMenus()); echo renderTree2($menus, 'radio', 'gp'); ?> </div> </div> </body> </html>
echo $group_to_edit['status'] == Groups::GROUP_STATUS_ACTIVE ? ' checked="checked"' : ''; ?> >Active<br> <input type="radio" name="group_status" value="inactive"<?php echo $group_to_edit['status'] == Groups::GROUP_STATUS_INACTIVE ? ' checked="checked"' : ''; ?> >Inactive </div> <div> <input type="hidden" id="group_parent" name="group_parent" value="<?php echo $is_post ? safeToDisplay($_POST['group_parent']) : safeToDisplay($group_to_edit['parent_id']); ?> "> </div> <input type="submit" value="Save"> </form> </div> <div id="parent"> Group parent <div id="tree"> <?php $groups = turnResources2ATree_V2($pm->getGroups()->getAllGroups()); echo renderTree2($groups, 'radio', 'gp'); ?> </div> </div> </body> </html>
/** * * @param array $tree * @return string */ function renderTree2(array $tree, $input_type = 'checkbox', $input_name = '', $children_tag = 'children', $class_for_active = 'active', $class_for_inactive = 'inactive') { $html = '<ul>'; foreach ($tree as $e) { $inp = '<span'; if ($e['status'] == 1) { $inp .= ' class="' . $class_for_active . '"'; } else { $inp .= ' class="' . $class_for_inactive . '"'; } $inp .= '><input type="' . $input_type . '" id="g' . $e['id'] . '"'; if ($input_name != '') { $inp .= ' name="' . $input_name . '"'; $inp .= ' value="' . $e['id'] . '"'; } $inp .= '>' . $e['name'] . '</span>'; $html .= '<li>' . $inp; if (count($e[$children_tag]) > 0) { $html .= renderTree2($e[$children_tag], $input_type, $input_name, $children_tag, $class_for_active, $class_for_inactive); } $html .= '</li>'; } $html .= '</ul>'; return $html; }
<meta charset="UTF-8"> <link rel="stylesheet" href="index.css" type="text/css"> <script src="../jquery-1.11.3.min.js"></script> <script src="index.js"></script> <title>Menus</title> </head> <body> <p><a href="<?php echo BASE_URL; ?> /">Home</a></p> <div id="messages"></div> <div id="menus"> <h2>Menus</h2> <div id="menubar"> <a href="add.php" id="add">Add</a> <a href="edit.php" id="edit">Edit</a> <a href="#" id="delete">Delete</a> | <a href="groupRelations.php" id="groupRelations">Add/Remove to/from groups</a> </div><br> <div id="tree"> <?php echo renderTree2($menus); ?> </div> </div> <div id="details"></div> </body> </html>