|
Odyssey
|
Public Member Functions | |
| __construct ($HB_ENV=[]) | |
| isCuAndUser () | |
| makeMenu ($params=[]) | |
| makeSingleMenuNode ($node_id='', $params=[], $full_node=false) | |
Protected Member Functions | |
| findNode ($node_id) | |
| recursivelyWalkArray ($node_id, $item) | |
| recurseDigArray ($node_id, $sub_array) | |
| setMenuArray ($params=[]) | |
| jsonPathParam ($params) | |
| isValidConfig ($arr=[]) | |
| setMenuParams ($params=[]) | |
| makeMenuHtml () | |
| createMenuToggleElement () | |
| walkMenuItems ($items=[]) | |
| createElementHtml ($arr=[], $close_tag=true) | |
| getElementId ($element=[]) | |
| isAssociativeArray ($arr=[]) | |
| hasDisplayValue ($id, $element=[]) | |
| hasUserDisplayValue ($id, $display) | |
| openHtmlElement ($element=[]) | |
| closeHtmlElement ($element=[]) | |
| addIndent ($tag) | |
| addNewLine ($tag) | |
| closeElementOpen ($element=[]) | |
| addElementAttributes ($id, $element=[]) | |
| translateValuesIfRequired ($attr, $value) | |
| isAttributeMember ($element=[]) | |
| addElementClasses ($id, $element=[]) | |
| setMemberValue ($id, $value, $key_to_find, $element=[]) | |
| setSubValue ($id, $key_to_find, $element=[]) | |
| isKeyInArray ($id, $key_to_find, $input_string, $element=[]) | |
| isClassMember ($element=[]) | |
| addElementContent ($id, $element=[]) | |
| userContentOverride ($id) | |
| isContentMember ($element=[]) | |
| returnMenuHtml () | |
| filterInputValue ($value) | |
| composeErrors () | |
| isErrors () | |
Protected Attributes | |
| $HB_ENV = [] | |
| $params = [] | |
| $menu_array = [] | |
| $menu_html = '' | |
| $errors = [] | |
CreateMenu class
An abstract class to extend and create menus from any JSON file (possibly other formats, such as HTML templates, in future versions.)
Usage: See Documentation at the bottom of this file.
Definition at line 12 of file CreateMenu.php.
| CreateMenu::__construct | ( | $HB_ENV = [] | ) |
|
protected |
Walk the attributes array and add all attributes EXCEPT class, special handling.
| string | $id | |
| array | $element |
Definition at line 503 of file CreateMenu.php.
|
protected |
Add classes to the HTML element.
| string | $id | |
| array | $element |
Definition at line 560 of file CreateMenu.php.
|
protected |
Add content members. This method is called recursively for nested content members.
| string | id, container id | |
| array | $element |
Definition at line 685 of file CreateMenu.php.
|
protected |
Add indents after some elements @TODO let's see if we can better format output?
| $tag |
Definition at line 453 of file CreateMenu.php.
|
protected |
Add newlines after some elements @TODO let's see if we can better format output?
| $tag |
Definition at line 468 of file CreateMenu.php.
|
protected |
Return the ending carat for an opened HTML tag.
| array | $element |
Definition at line 482 of file CreateMenu.php.
|
protected |
Output the closing tag for any opened element. Only outputs for valid tags, allowing raw content members to output.
| array | $element |
Definition at line 436 of file CreateMenu.php.
|
protected |
Compose error HTML from $this->errors array.
Definition at line 769 of file CreateMenu.php.
|
protected |
The meat of the meal, output an HTML element. As we encounter content elements, this method is called recursively, allowing deeply nested elements to output.
| array | $arr | |
| bool | $close_tag | - container needs to be closed after items done. |
Definition at line 329 of file CreateMenu.php.
|
protected |
Create the "non menu" toggle element if it exists. It is still contained by the parent wrapper but not in the menu element list.
Definition at line 294 of file CreateMenu.php.
|
protected |
Basic filter (could use improvement, but all values should be internal)
| mixed | $value |
Definition at line 760 of file CreateMenu.php.
|
protected |
Helper for makeSingleMenuNode(), find the node in the array identified by $node_id.
| string | $node_id |
Definition at line 102 of file CreateMenu.php.
|
protected |
Get the ID of an element if it exists.
| array | $element |
Definition at line 360 of file CreateMenu.php.
|
protected |
See if an element has an explicitly set display value. Default to true.
| string | $id | |
| array | $element |
Definition at line 389 of file CreateMenu.php.
|
protected |
See if there is a display value set on the member.
| string | $id | |
| bool | $display |
Definition at line 404 of file CreateMenu.php.
|
protected |
Helper for recursively walking array, looking for ID.
| array | $arr |
Definition at line 374 of file CreateMenu.php.
|
protected |
Helper for addElementAttributes, is this an attributes array member?
| array | $element |
Definition at line 547 of file CreateMenu.php.
|
protected |
Helper for addElementClasses, is this a class array member?
| array | $element |
Definition at line 672 of file CreateMenu.php.
|
protected |
Helper for addElementContent, is this a content member in the array?
| array | $element |
Definition at line 735 of file CreateMenu.php.
| CreateMenu::isCuAndUser | ( | ) |
If we have no CU and user, no need to output anything.
Definition at line 46 of file CreateMenu.php.
|
protected |
|
protected |
Recursively dig into the element array looking for a match on the dot syntax string. If found, return true and we will use the input substitution value for the existing array value.
| string | $id,the | element container ID attribute |
| string | $key_to_find,the | current member key we are looking for |
| string | $input_string,the | dot-syntax input string |
| array | $element,current | element array |
Definition at line 630 of file CreateMenu.php.
|
protected |
Check that the array decoded from JSON has valid array members.
| array | $arr |
Definition at line 223 of file CreateMenu.php.
|
protected |
Get the JSON file path from params.
| $params |
Definition at line 209 of file CreateMenu.php.
| CreateMenu::makeMenu | ( | $params = [] | ) |
Main entry point, convert the JSON array to a menu, substituting any values required and return final HTML.
| array | $params |
Definition at line 62 of file CreateMenu.php.
|
protected |
Make the menu and store in $this->menu_html.
Definition at line 270 of file CreateMenu.php.
| CreateMenu::makeSingleMenuNode | ( | $node_id = '', |
|
$params = [], |
|||
$full_node = false |
|||
| ) |
Using the same methods above, return the content of a single node in the array. Digs recursively into the array until it finds $node_id and depending on the wrapper flag, returns the full node or its content only.
| string | $node_id | |
| array | $params | |
| bool | $full_node | - give us the element as is in the array false = just its content |
Definition at line 81 of file CreateMenu.php.
|
protected |
Open a valid HTML element.
| array | $element |
Definition at line 419 of file CreateMenu.php.
|
protected |
Helper for recursivelyWalkArray(), if we have a numerically indexed array, walk it and look for the node identified by $node_id.
| string | $node_id | |
| array | $sub_array |
Definition at line 162 of file CreateMenu.php.
|
protected |
Helper for findNode(). Recursively dig into the array and attempt to locate the array identified by $node_id.
| string | $node_id | |
| array | $item |
Definition at line 125 of file CreateMenu.php.
|
protected |
Return the response, whether it's errors or the menu.
Definition at line 746 of file CreateMenu.php.
|
protected |
Set substitution value if found, otherwise return what's already in the array.
| string | $id,the | element ID |
| mixed | $value,existing | value in array |
| string | $key_to_find,the | current member we are looking for if found in input |
| array | $element |
Definition at line 588 of file CreateMenu.php.
|
protected |
Extract the JSON file path and convert to an array. Or try to.
| array | $params |
Definition at line 185 of file CreateMenu.php.
|
protected |
Extract substitution values from input and set them as input params as an internal property.
| array | $params |
Definition at line 246 of file CreateMenu.php.
|
protected |
If there is a substitution value in input params, return it.
| string | $id | |
| string | $key_to_find,the | current member we are looking for if found in input |
| array | $element |
Definition at line 606 of file CreateMenu.php.
|
protected |
|
protected |
Users may override content, such as a dynamically created link text or other content. The first and last elements (container id and identifier 'content') are all we need in this case. if the ID and identifier match, return user-provided content.
| string | $id |
Definition at line 714 of file CreateMenu.php.
|
protected |
Helper for makeMenuHtml(), walk the menu items and compose the HTML string.
| array | $items |
Definition at line 311 of file CreateMenu.php.
1.8.15