Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
An action menu. More...
Public Member Functions | |
__construct (array $actions=array()) | |
Constructs the action menu with the given items. | |
add ($action) | |
Adds an action to this action menu. | |
add_primary_action ($action) | |
Adds a primary action to the action menu. | |
add_secondary_action ($action) | |
Adds a secondary action to the action menu. | |
add_secondary_subpanel (subpanel $subpanel) | |
Adds a secondary subpanel. | |
do_not_enhance () | |
If you call this method the action menu will be displayed but will not be enhanced. | |
export_for_template (renderer_base $output) | |
Export for template. | |
get_primary_actions (core_renderer $output=null) | |
Returns the primary actions ready to be rendered. | |
get_secondary_actions () | |
Returns the secondary actions ready to be rendered. | |
initialise_js (moodle_page $page) | |
Initialises JS required fore the action menu. | |
is_empty () | |
Return true if there is at least one visible link in the menu. | |
set_action_label ($label) | |
Sets the label for the menu trigger. | |
set_additional_classes (string $class='') | |
Add classes to the action menu for an easier styling. | |
set_alignment ($dialogue, $button) | |
Sets the alignment of the dialogue in relation to button used to toggle it. | |
set_boundary (string $boundary) | |
Set the overflow constraint boundary of the dropdown menu. | |
set_constraint ($ancestorselector) | |
Sets a constraint for the dialogue. | |
set_kebab_trigger (?string $triggername=null, ?core_renderer $output=null, ?string $extraclasses='') | |
Setup trigger as in the kebab menu. | |
set_menu_left () | |
Aligns the left corner of the dropdown. | |
set_menu_trigger ($trigger, $extraclasses='') | |
Sets the menu trigger text. | |
set_nowrap_on_items ($value=true) | |
Sets nowrap on items. | |
set_owner_selector ($selector) | |
Sets the selector that should be used to find the owning node of this menu. | |
will_be_enhanced () | |
Returns true if this action menu will be enhanced. | |
Public Attributes | |
pix_icon | $actionicon |
An icon to use for the toggling the secondary menu (dropdown). | |
array | $actionlabel = null |
The string to use for the accessible label for the menu. | |
array | $actiontext = null |
The string to use next to the icon for the action icon relating to the secondary (dropdown) menu. | |
array | $attributes = array() |
An array of attributes added to the container of the action menu. | |
array | $attributesprimary = array() |
An array of attributes added to the container of the primary actions. | |
array | $attributessecondary = array() |
An array of attributes added to the container of the secondary actions. | |
string | $dropdownalignment = '' |
Dropdown menu alignment class. | |
string | $menutrigger = '' |
Any text to use for the toggling the secondary menu (dropdown). | |
bool | $prioritise = false |
Place the action menu before all other actions. | |
array | $triggerattributes = [] |
An array of attributes added to the trigger element of the secondary menu. | |
string | $triggerextraclasses = '' |
Any extra classes for toggling to the secondary menu. | |
const | BL = 3 |
Top right alignment. | |
const | BR = 4 |
Top right alignment. | |
const | DEFAULT_KEBAB_TRIGGER_CLASSES = 'btn btn-icon d-flex align-items-center justify-content-center no-caret' |
Classes for the trigger menu. | |
const | TL = 1 |
Top right alignment. | |
const | TR = 2 |
Top right alignment. | |
Protected Member Functions | |
export_primary_actions_for_template (renderer_base $output) | |
Export the primary actions for the template. | |
export_secondary_actions_for_template (renderer_base $output) | |
Export the secondary actions for the template. | |
get_align_string ($align) | |
Returns a string to describe the alignment. | |
Protected Attributes | |
int | $instance = 0 |
The instance number. | |
array | $primaryactions = array() |
An array of primary actions. | |
array | $secondaryactions = array() |
An array of secondary actions. | |
An action menu.
This action menu component takes a series of primary and secondary actions. The primary actions are displayed permanently and the secondary attributes are displayed within a drop down menu.
action_menu::__construct | ( | array | $actions = array() | ) |
Constructs the action menu with the given items.
array | $actions | An array of actions (action_menu_link|pix_icon|string). |
action_menu::add | ( | $action | ) |
Adds an action to this action menu.
action_link | pix_icon | subpanel | string | $action |
action_menu::add_primary_action | ( | $action | ) |
Adds a primary action to the action menu.
action_menu_link | action_link | pix_icon | string | $action |
action_menu::add_secondary_action | ( | $action | ) |
Adds a secondary action to the action menu.
action_link | pix_icon | string | $action |
action_menu::add_secondary_subpanel | ( | subpanel | $subpanel | ) |
Adds a secondary subpanel.
subpanel | $subpanel |
action_menu::do_not_enhance | ( | ) |
If you call this method the action menu will be displayed but will not be enhanced.
By not displaying the menu enhanced all items will be displayed in a single row.
action_menu::export_for_template | ( | renderer_base | $output | ) |
Export for template.
renderer_base | $output | The renderer. |
stdClass |
Implements templatable.
|
protected |
|
protected |
Export the secondary actions for the template.
renderer_base | $output |
stdClass |
|
protected |
Returns a string to describe the alignment.
int | $align | One of action_menu\TL, action_menu\TR, action_menu\BL, action_menu\BR. |
string |
action_menu::get_primary_actions | ( | core_renderer | $output = null | ) |
Returns the primary actions ready to be rendered.
core_renderer | $output | The renderer to use for getting icons. |
array |
action_menu::get_secondary_actions | ( | ) |
Returns the secondary actions ready to be rendered.
array |
action_menu::initialise_js | ( | moodle_page | $page | ) |
Initialises JS required fore the action menu.
The JS is only required once as it manages all action menu's on the page.
moodle_page | $page |
action_menu::is_empty | ( | ) |
Return true if there is at least one visible link in the menu.
bool |
action_menu::set_action_label | ( | $label | ) |
Sets the label for the menu trigger.
string | $label | The text |
action_menu::set_additional_classes | ( | string | $class = '' | ) |
Add classes to the action menu for an easier styling.
string | $class | The class to add to attributes. |
action_menu::set_alignment | ( | $dialogue, | |
$button ) |
Sets the alignment of the dialogue in relation to button used to toggle it.
int | $dialogue | One of action_menu\TL, action_menu\TR, action_menu\BL, action_menu\BR. |
int | $button | One of action_menu\TL, action_menu\TR, action_menu\BL, action_menu\BR. |
action_menu::set_boundary | ( | string | $boundary | ) |
Set the overflow constraint boundary of the dropdown menu.
string | $boundary | Accepts the values of 'viewport', 'window', or 'scrollParent'. |
coding_exception |
action_menu::set_constraint | ( | $ancestorselector | ) |
Sets a constraint for the dialogue.
The constraint is applied when the dialogue is shown and limits the display of the dialogue to within the element the constraint identifies.
This is required whenever the action menu is displayed inside any CSS element with the .no-overflow class (flexible_table and any of it's child classes are a likely candidate).
string | $ancestorselector | A snippet of CSS used to identify the ancestor to contrain the dialogue to. |
action_menu::set_kebab_trigger | ( | ?string | $triggername = null, |
?core_renderer | $output = null, | ||
?string | $extraclasses = '' ) |
Setup trigger as in the kebab menu.
string | null | $triggername | |
core_renderer | null | $output | |
string | null | $extraclasses | extra classes for the trigger { |
coding_exception |
action_menu::set_menu_trigger | ( | $trigger, | |
$extraclasses = '' ) |
Sets the menu trigger text.
string | $trigger | The text |
string | $extraclasses | Extra classes to style the secondary menu toggle. |
action_menu::set_nowrap_on_items | ( | $value = true | ) |
Sets nowrap on items.
If true menu items should not wrap lines if they are longer than the available space.
This property can be useful when the action menu is displayed within a parent element that is either floated or relatively positioned. In that situation the width of the menu is determined by the width of the parent element which may not be large enough for the menu items without them wrapping. This disables the wrapping so that the menu takes on the width of the longest item.
bool | $value | If true nowrap gets set, if false it gets removed. Defaults to true. |
action_menu::set_owner_selector | ( | $selector | ) |
Sets the selector that should be used to find the owning node of this menu.
string | $selector | A CSS/YUI selector to identify the owner of the menu. |
action_menu::will_be_enhanced | ( | ) |
Returns true if this action menu will be enhanced.
bool |
array action_menu::$attributes = array() |
An array of attributes added to the container of the action menu.
Initialised with defaults during construction.
array action_menu::$attributesprimary = array() |
An array of attributes added to the container of the primary actions.
Initialised with defaults during construction.
array action_menu::$attributessecondary = array() |
An array of attributes added to the container of the secondary actions.
Initialised with defaults during construction.
|
protected |
The instance number.
This is unique to this instance of the action menu.
|
protected |
An array of primary actions.
Please use action_menu::add_primary_action() to add actions.
|
protected |
An array of secondary actions.
Please use action_menu::add_secondary_action() to add actions.