FOSSology  4.4.0
Open Source License Compliance by Open Source Software
common-menu.php File Reference

Common menu functions. More...

Go to the source code of this file.

Classes

class  menu
 Code for creating a menu list (2D linked list) from a set of plugins. More...
 

Functions

 MenuPage ($Page, $TotalPage, $Uri='')
 Create a "First Prev 1 2 ... Next Last" page links for paged output. More...
 
 MenuEndlessPage ($Page, $Next=1, $Uri='')
 Create a "First Prev 1 2 ... Next" page links for paged output. More...
 
 menu_cmp ($a, $b)
 Compare two menu items for sorting. More...
 
 menu_insert_r (&$menuItems, $path, $pathRemainder, $LastOrder, $Target, $URI, $HTML, &$Title)
 Given a Path, order level for the last item, and a plugin name, insert the menu item. More...
 
 menu_insert ($Path, $LastOrder=0, $URI=NULL, $Title=NULL, $Target=NULL, $HTML=NULL)
 Given a Path, order level for the last item, and optional plugin name, insert the menu item. More...
 
 menu_find ($Name, &$MaxDepth, $Menu=NULL)
 Given a top-level menu name, find the list of sub-menus below it and max depth of menu. More...
 
 menu_to_1html ($Menu, $ShowRefresh=1, $ShowTraceback=0, $ShowAll=1)
 Take a menu and render it as one HTML line. More...
 
 getFullNameAddition (menu $menu)
 
 menu_to_1list ($Menu, &$Parm, $Pre="", $Post="", $ShowAll=1, $upload_id="")
 Take a menu and render it as one HTML line with items in a "[name]" list. More...
 
 menu_print (&$Menu, $Indent)
 Debugging code for printing the menu. More...
 
 menu_remove ($Menu, $RmName)
 Remove a menu object (based on an object name) from a menu list. More...
 

Variables

const MENU_PATH_SEPARATOR = "::"
 Separator used between menu paths.
 
const MENU_BREAK = "[BREAK]"
 Break menu at this.
 
 $MenuList = array()
 Global menu list array.
 
 $MenuMaxDepth = 0
 How deep is the tree (for UI display)
 
 $menu_to_1html_counter = 0
 Counter used by menu_to_1html()
 

Detailed Description

Common menu functions.

Definition in file common-menu.php.

Function Documentation

◆ getFullNameAddition()

getFullNameAddition ( menu  $menu)

Get the additional string for menu full name

Parameters
menu$menumenu
Returns
string

Definition at line 416 of file common-menu.php.

◆ menu_cmp()

menu_cmp (   $a,
  $b 
)

Compare two menu items for sorting.

Parameters
&$amenu a
&$bmenu b
Returns
-1 a > b
1 a < b
0 a->Order = b->Order and a->Name = b->Name

Definition at line 157 of file common-menu.php.

◆ menu_find()

menu_find (   $Name,
$MaxDepth,
  $Menu = NULL 
)

Given a top-level menu name, find the list of sub-menus below it and max depth of menu.

Note
this this function returns the sub menus of $Name, NOT the menu specified by $Name.
Todo:
Rename this function to menu_find_submenus.
Parameters
string$NameTop-level menu name, may be a "::" separated list.
[out]int&$MaxDepthMax depth of menu, returned value
menu$Menumenu object array (default is global $MenuList)
Returns
Array of sub-menus. $MaxDepth is also returned

Definition at line 291 of file common-menu.php.

◆ menu_insert()

menu_insert (   $Path,
  $LastOrder = 0,
  $URI = NULL,
  $Title = NULL,
  $Target = NULL,
  $HTML = NULL 
)

Given a Path, order level for the last item, and optional plugin name, insert the menu item.

Parameters
string$PathPath of the new menu item
int$LastOrderIs used for grouping items in order.
string$URIURL link of the new menu item
string$TitleTitle of the new menu item
string$TargetTarget of the new menu item
string$HTMLHTML of the new menu item
Examples
/home/runner/work/fossology/fossology/src/www/ui/ui-picker.php.

Definition at line 269 of file common-menu.php.

◆ menu_insert_r()

menu_insert_r ( $menuItems,
  $path,
  $pathRemainder,
  $LastOrder,
  $Target,
  $URI,
  $HTML,
$Title 
)

Given a Path, order level for the last item, and a plugin name, insert the menu item.

This is VERY recursive and returns the new menu. If $URI is blank, nothing is added.

Parameters
[in,out]array&$menuItemsArray of menu items. If null is passed, new array is created.
array$pathPath of the menu item
string$pathRemainder
int$LastOrderOrder (position) of last menu item
string$TargetName of the Menu target
string$URIURI of the menu
string$HTMLHTML of the menu
string&$TitleTitle of the menu
Returns
int The max depth of menu

Definition at line 187 of file common-menu.php.

◆ menu_print()

menu_print ( $Menu,
  $Indent 
)

Debugging code for printing the menu.

Note
This is recursive.
Parameters
menu&$Menumenu list to be printed
int$IndentIndentations to add

Definition at line 483 of file common-menu.php.

◆ menu_remove()

menu_remove (   $Menu,
  $RmName 
)

Remove a menu object (based on an object name) from a menu list.

For example,

$mymenu = menu_find("Browse-Pfile", $MenuDepth);
$myNewMenu = menu_remove($mymenu, "Compare");
menu_remove($Menu, $RmName)
Remove a menu object (based on an object name) from a menu list.
menu_find($Name, &$MaxDepth, $Menu=NULL)
Given a top-level menu name, find the list of sub-menus below it and max depth of menu.
Parameters
menu$Menumenu list the menu item remove from
string$RmNameRemove name of menu
Returns
A new menu list without $RmName

Definition at line 534 of file common-menu.php.

◆ menu_to_1html()

menu_to_1html (   $Menu,
  $ShowRefresh = 1,
  $ShowTraceback = 0,
  $ShowAll = 1 
)

Take a menu and render it as one HTML line.

This ignores submenus! This is commonly called the "micro-menu".

Parameters
menu$Menumenu list need to show as HTML
bool$ShowRefreshIf true, show Refresh
bool$ShowTracebackIf true, show Tracback
bool$ShowAllIf false, then items without hyperlinks are hidden.
Returns
HTML string

Definition at line 329 of file common-menu.php.

◆ menu_to_1list()

menu_to_1list (   $Menu,
$Parm,
  $Pre = "",
  $Post = "",
  $ShowAll = 1,
  $upload_id = "" 
)

Take a menu and render it as one HTML line with items in a "[name]" list.

Note
This ignores submenus!
Parameters
menu$Menumenu list need to show as list
string&$ParmA list of parameters to add to the URL.
string$PreString before "[name]"
string$PostString after "[name]"
bool$ShowAllIf false, then items without hyperlinks are hidden.
int$upload_idUpload id
Returns
one HTML line with items in a "[name]" list

Definition at line 437 of file common-menu.php.

◆ MenuEndlessPage()

MenuEndlessPage (   $Page,
  $Next = 1,
  $Uri = '' 
)

Create a "First Prev 1 2 ... Next" page links for paged output.

Parameters
int$PagePage number of the current page
bool$NextTrue display "Next" and false don't display
string$UriURL of the page being displayed. "&page=" will be appended to the URL
Returns
String containing menu HTML

Definition at line 111 of file common-menu.php.

◆ MenuPage()

MenuPage (   $Page,
  $TotalPage,
  $Uri = '' 
)

Create a "First Prev 1 2 ... Next Last" page links for paged output.

Parameters
int$PagePage number of the current page
int$TotalPageLast page number
string$UriURL of the page being displayed. "&page=" will be appended to the URL
Returns
String containing menu HTML

Definition at line 60 of file common-menu.php.