requireUIFile("jquery-ui-nestedsortable.js"); $AF->requireUIFile("EditNav.js"); # get plugin $SecondaryNavPlugin = SecondaryNavigation::getInstance(); # get tree $ToPrint = $SecondaryNavPlugin->getTree($NavMenu); # print all NavItems using the tree print "
"; printItems($ToPrint); print "
"; # output the javascript to wire-in the jquery-ui-nestedsortable print "
"; } /** * Print items in an unordered list for nestedsortable sorting * @param array $Items to print, in tree structure */ function printItems(array $Items): void { print "

"; foreach ($Items as $Info) { print "
- ". "
  ".htmlspecialchars($Info["Label"]). "
  ".getItemButtons($Info["Id"])."
  ". "
"; } print "

"; } /** * Get the rename and delete buttons for nav items * put here so printItems() isn't too cluttered (and copying format of MFO) * @param int $NavItemId ID of NavItem to print buttons for * @return string html buttons to print */ function getItemButtons(int $NavItemId): string { $EditButton = new HtmlButton("Edit"); $EditButton->setIcon("Pencil.svg"); $EditButton->setSize(HtmlButton::SIZE_SMALL); $EditButton->addClass("mv-menu-sort-button"); $EditButton->setLink("index.php?P=P_SecondaryNavigation_EditItem&NI=$NavItemId"); $DeleteButton = new HtmlButton("Delete"); $DeleteButton->setIcon("Delete.svg"); $DeleteButton->setSize(HtmlButton::SIZE_SMALL); $DeleteButton->addClass("mv-menu-sort-button"); $DeleteButton->addSemanticClass("btn-danger"); $DeleteButton->setValue("DeleteItem,$NavItemId"); $DeleteButton->setTitle("Delete this link"); # render the edit button if this is not a system generated item # (i.e., it's created by a user) $NavItem = new NavItem($NavItemId); return ($NavItem->createdByUser() ? $EditButton->getHtml() : "") . $DeleteButton->getHtml(); } /** * Print the list of offered items * @param array $OfferedItems label/link pairs to display (keyed on link) */ function printOfferedItems(array $OfferedItems): void { $TooltipId = 0; print "

"; foreach ($OfferedItems as $Link => $Item) { ob_start(); ApplicationFramework::getInstance()->getInterfaceSetting("TooltipsUseDialogs") ? FormUI::displayDialogHelp($Item["Label"], $Item["Description"], $TooltipId++) : FormUI::displayHoverHelp($Item["Description"]); $Description = ob_get_clean(); $AddButton = new HtmlButton("Add"); $AddButton->setIcon("Plus.svg"); $AddButton->setSize(HtmlButton::SIZE_SMALL); $AddButton->addClass("mv-menu-sort-button"); $AddButton->setValue("AddOffered,$Link"); $AddButton->setTitle("Add this link"); print "
- " . "
  " . $Description . "" . $Item["Label"] . "" . "
  " . "
  " . $AddButton->getHtml() . "
  " . "
"; } print "

"; } # ----- SETUP ---------------------------------------------------------------- $AF = ApplicationFramework::getInstance(); $AF->requireUIFile("jquery-ui.js"); $AF->requireUIFile("jquery-ui.css"); $AddButton = new HtmlButton("Add"); $AddButton->setIcon("Plus.svg"); $AddButton->setSize(HtmlButton::SIZE_SMALL); $AddButton->setValue("Add Item"); # ----- DISPLAY -------------------------------------------------------------- $AF->setPageTitle("Edit Your Menu"); ?>

".$Error.""; } ?>

Changes to menu order saved

## Edit Your Menu

Tip: drag objects to reorder them.

## Available Menu Items

## Add Item Manually

Label: Link: getHtml(); ?>