PHP 트레잇 NestedCollection, vanilla

부터: 2.3
저자: Becky Van Bussel ([email protected])
파일 보기 프로젝트 열기: vanilla/vanilla

공개 프로퍼티들

프로퍼티 타입 설명
$activeCssClass The css class to add to active items and groups.
$dividerCssClassPrefix CSS prefix for a divider item.
$headerCssClassPrefix CSS prefix for a header item.
$items List of items to sort.
$linkCssClassPrefix CSS prefix for a link item.
$useCssPrefix Whether to use CSS prefixes on the generated CSS classes for the items.

보호된 프로퍼티들

프로퍼티 타입 설명
$allowedItemModifiers The item modifiers allowed to be passed in the modifiers array.

공개 메소드들

메소드 설명
addDivider ( string $key = '', string $cssClass = '', array | integer $sort = [] ) : object Add a divider to the items array.
addDividerIf ( boolean | string | array $isAllowed = true, string $key = '', string $cssClass = '', array | integer $sort = [] ) : object Add a divider to the items array if it satisfies the $isAllowed condition.
addGroup ( string $text = '', string $key = '', string $cssClass = '', array | integer $sort = [], array $modifiers = [] ) : SortableModule Add a group to the items array.
addGroupIf ( boolean | string | array $isAllowed = true, string $text = '', string $key = '', string $cssClass = '', array | integer $sort = [], array $modifiers = [] ) : object Add a group to the items array if it satisfies the $isAllowed condition.
addItemModifiers ( array &$item, array $modifiers ) Adds the attributes in the modifiers array to the item.
addLink ( string $text, string $url, string $key = '', string $cssClass = '', array | integer $sort = [], array $modifiers = [], boolean $disabled = false ) Add a link to the items array.
addLinkIf ( boolean | string | array $isAllowed = true, string $text, string $url, string $key = '', string $cssClass = '', array | integer $sort = [], array $modifiers = [], boolean $disabled = false ) : object Add a link to the items array if it satisfies the $isAllowed condition.
getHighlightRoute ( ) : string
prepare ( ) : boolean Prepares the items array for output by sorting and optionally flattening.
removeItem ( string $key ) Remove an item from the nested set.
setForceDivider ( boolean $forceDivider )
setHighlightRoute ( string $highlightRoute )

보호된 메소드들

메소드 설명
addItem ( string $type, array $item ) Add an item to the items array.
buildCssClass ( string $prefix, array $item ) : string Builds a CSS class for an item, based on the 'key' property of the item.
flattenArray ( array $items ) : array Creates a flattened array of menu items.
isActive ( array $item ) : boolean Checks whether the current request url matches an item's link url.
isAllowed ( boolean | string | array $isAllowed ) : boolean Checks whether an item can be added to the items list by returning it if it is already a boolean, or checking the permission if it is a string or array.
prepareData ( array &$items ) Performs post-sort operations to the items array.
sortItems ( array &$items ) Recursive function to sort the items in a given array.
sortItemsOrder ( array $item, array $items, integer $depth ) : number Get the sort order of an item in the items array.
touchKey ( array &$item ) Generate a key for an item if one does not exist, and add the property to the item.

메소드 상세

addDivider() 공개 메소드

Add a divider to the items array.
public addDivider ( string $key = '', string $cssClass = '', array | integer $sort = [] ) : object
$key string The item's key (for sorting and CSS targeting).
$cssClass string The divider's CSS class.
$sort array | integer Either a numeric sort position or and array in the style: array('before|after', 'key').
리턴 object $this The calling object.

addDividerIf() 공개 메소드

Add a divider to the items array if it satisfies the $isAllowed condition.
public addDividerIf ( boolean | string | array $isAllowed = true, string $key = '', string $cssClass = '', array | integer $sort = [] ) : object
$isAllowed boolean | string | array Either a boolean to indicate whether to actually add the item or a permission string or array of permission strings (full match) to check.
$key string The item's key (for sorting and CSS targeting).
$cssClass string The divider's CSS class.
$sort array | integer Either a numeric sort position or and array in the style: array('before|after', 'key').
리턴 object $this The calling object.

addGroup() 공개 메소드

Add a group to the items array.
public addGroup ( string $text = '', string $key = '', string $cssClass = '', array | integer $sort = [], array $modifiers = [] ) : SortableModule
$text string The display text for the group header.
$key string The item's key (for sorting and CSS targeting).
$cssClass string The group header's CSS class.
$sort array | integer Either a numeric sort position or and array in the style: array('before|after', 'key').
$modifiers array List of attribute => value, where the attribute is in $this->allowedItemModifiers. - **popinRel**: string - Endpoint for a popin. - **badge**: string - Info to put into a badge, usually a number. - **icon**: string - Name of the icon for the item, excluding the 'icon-' prefix.
리턴 SortableModule $this The calling object.

addGroupIf() 공개 메소드

Add a group to the items array if it satisfies the $isAllowed condition.
public addGroupIf ( boolean | string | array $isAllowed = true, string $text = '', string $key = '', string $cssClass = '', array | integer $sort = [], array $modifiers = [] ) : object
$isAllowed boolean | string | array Either a boolean to indicate whether to actually add the item or a permission string or array of permission strings (full match) to check.
$text string The display text for the group header.
$key string The item's key (for sorting and CSS targeting).
$cssClass string The group header's CSS class.
$sort array | integer Either a numeric sort position or and array in the style: array('before|after', 'key').
$modifiers array List of attribute => value, where the attribute is in $this->allowedItemModifiers. - **popinRel**: string - Endpoint for a popin. - **badge**: string - Info to put into a badge, usually a number. - **icon**: string - Name of the icon for the item, excluding the 'icon-' prefix.
리턴 object $this The calling object.

addItem() 보호된 메소드

Add an item to the items array.
protected addItem ( string $type, array $item )
$type string The type of the item: link, group or divider.
$item array The item to add to the array.

addItemModifiers() 공개 메소드

Constrains the modifier to those defined in $this->allowedItemModifiers.
public addItemModifiers ( array &$item, array $modifiers )
$item array The item to modify.
$modifiers array The modifiers to add to the item.

addLinkIf() 공개 메소드

Add a link to the items array if it satisfies the $isAllowed condition.
public addLinkIf ( boolean | string | array $isAllowed = true, string $text, string $url, string $key = '', string $cssClass = '', array | integer $sort = [], array $modifiers = [], boolean $disabled = false ) : object
$isAllowed boolean | string | array Either a boolean to indicate whether to actually add the item or a permission string or array of permission strings (full match) to check.
$text string The display text for the link.
$url string The destination url for the link.
$key string The item's key (for sorting and CSS targeting).
$cssClass string The link's CSS class.
$sort array | integer Either a numeric sort position or and array in the style: array('before|after', 'key').
$modifiers array List of attribute => value, where the attribute is in $this->allowedItemModifiers. - **popinRel**: string - Endpoint for a popin. - **badge**: string - Info to put into a badge, usually a number. - **icon**: string - Name of the icon for the item, excluding the 'icon-' prefix.
$disabled boolean Whether to disable the link.
리턴 object $this The calling object.

buildCssClass() 보호된 메소드

Optionally prepends a prefix to generated class names.
protected buildCssClass ( string $prefix, array $item ) : string
$prefix string The optional prefix to add to class name.
$item array The item to generate CSS class for.
리턴 string The generated CSS class.

flattenArray() 보호된 메소드

Useful for lists like dropdown menu, where nesting lists is not necessary.
protected flattenArray ( array $items ) : array
$items array The item list to flatten.
리턴 array The flattened items list.

getHighlightRoute() 공개 메소드

public getHighlightRoute ( ) : string
리턴 string

isActive() 보호된 메소드

Checks whether the current request url matches an item's link url.
protected isActive ( array $item ) : boolean
$item array The item to check.
리턴 boolean Whether the current request url matches an item's link url.

isAllowed() 보호된 메소드

Checks whether an item can be added to the items list by returning it if it is already a boolean, or checking the permission if it is a string or array.
protected isAllowed ( boolean | string | array $isAllowed ) : boolean
$isAllowed boolean | string | array Either a boolean to indicate whether to actually add the item or a permission string or array of permission strings (full match) to check.
리턴 boolean Whether the item has permission to be added to the items list.

prepare() 공개 메소드

Prepares the items array for output by sorting and optionally flattening.
public prepare ( ) : boolean
리턴 boolean Whether to render the module.

prepareData() 보호된 메소드

Removes empty groups, removes the '_sort' and 'key' attributes and bubbles up the active css class.
protected prepareData ( array &$items )
$items array The item list to parse.

removeItem() 공개 메소드

Remove an item from the nested set.
public removeItem ( string $key )
$key string The key of the item to remove, separated by dots.

setForceDivider() 공개 메소드

public setForceDivider ( boolean $forceDivider )
$forceDivider boolean Whether to separate groups with a
element. Only supported for flattened lists.

setHighlightRoute() 공개 메소드

public setHighlightRoute ( string $highlightRoute )
$highlightRoute string

sortItems() 보호된 메소드

Recursive function to sort the items in a given array.
protected sortItems ( array &$items )
$items array The items to sort.

sortItemsOrder() 보호된 메소드

This function looks at the following keys: - **sort (numeric)**: A specific numeric sort was provided. - **sort array('before|after', 'key')**: You can specify that the item is before or after another item. - **_sort**: The order the item was added is used.
protected sortItemsOrder ( array $item, array $items, integer $depth ) : number
$item array The item to get the sort order from.
$items array The entire list of items.
$depth integer The current recursive depth used to prevent infinite recursion.
리턴 number

touchKey() 보호된 메소드

Generate a key for an item if one does not exist, and add the property to the item.
protected touchKey ( array &$item )
$item array The item to generate and add a key for.

프로퍼티 상세

$activeCssClass 공개적으로 프로퍼티

The css class to add to active items and groups.
public $activeCssClass

$allowedItemModifiers 보호되어 있는 프로퍼티

The item modifiers allowed to be passed in the modifiers array.
protected $allowedItemModifiers

$dividerCssClassPrefix 공개적으로 프로퍼티

CSS prefix for a divider item.
public $dividerCssClassPrefix

$headerCssClassPrefix 공개적으로 프로퍼티

CSS prefix for a header item.
public $headerCssClassPrefix

$items 공개적으로 프로퍼티

List of items to sort.
public $items

$linkCssClassPrefix 공개적으로 프로퍼티

CSS prefix for a link item.
public $linkCssClassPrefix

$useCssPrefix 공개적으로 프로퍼티

Whether to use CSS prefixes on the generated CSS classes for the items.
public $useCssPrefix