PHP 클래스 MediaItemModule, vanilla

A media item usually renders a item with an image, a title, and a description. This modules supports a media item that may have one image, one dropdown menu, any number of buttons, and any number of meta items. There are three views that you can choose to render: media-addon, media-callout, or media-sm. See these variants in the dashboard styleguide.
부터: 2.3
저자: Becky Van Bussel ([email protected])
상속: extends Gdn_Module
파일 보기 프로젝트 열기: vanilla/vanilla 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$view The view to render. Supported views are media-addon, media-callout, or media-sm.

공개 메소드들

메소드 설명
__construct ( string $title = '', string $titleUrl = '', string $description = '', string $tag = 'div', array $attributes = [] ) MediaItemModule constructor.
addButton ( string $text, string $url, $attributes ) : MediaItemModule Adds a button to the buttons array.
addButtonIf ( boolean | string | array $isAllowed, string $text, string $url, $attributes ) : MediaItemModule Adds a button to the buttons array if it satisfies the $isAllowed condition.
addCssClass ( $key, $class ) : MediaItemModule Adds a css class to the cssClass array. This is useful for adding an arbitrary css class to a media item view.
addMeta ( string $meta ) : MediaItemModule Adds a HTML-formatted string to the meta array. It's up to the view to concatinate this array, using something like implode(' | ', $meta)
addMetaIf ( boolean | string | array $isAllowed, string $meta ) : MediaItemModule Adds a HTML-formatted string to the meta array if it satisfies the $isAllowed condition.
addOption ( string $key, string $value ) : MediaItemModule Adds a HTML-formatted string to the meta array. It's up to the view to add the info in the options.
addOptionIf ( boolean | string | array $isAllowed, string $key, string $value ) : MediaItemModule Adds a HTML-formatted string to the meta array if it satisfies the $isAllowed condition.
getAttributes ( ) : array
getButtons ( ) : array
getCssClasses ( ) : array
getDescription ( ) : string
getDropdown ( ) : DropdownModule
getImageHtml ( ) : string Renders the html for an image with the image* properties.
getImageSource ( ) : string
getMeta ( ) : array
getOptions ( ) : array
getTitle ( ) : string
getTitleUrl ( ) : string
getToggle ( ) : array
getToggleHtml ( ) : string Rendering helper for the toggle.
prepare ( ) : boolean Prepares the media item for rendering.
setAttributes ( array $attributes ) : MediaItemModule
setDescription ( string $description ) : MediaItemModule
setDropdown ( DropdownModule $dropdown ) : MediaItemModule
setImage ( string $source = '', string $url = '', string $cssClass = '', string $alt = '' ) : MediaItemModule Sets the image. The function DOES NOT handle the url()-ing.
setImageIf ( boolean | string | array $isAllowed, string $source = '', string $url = '', string $cssClass = '', string $alt = '' ) : MediaItemModule Sets the image if it satisfies the $isAllowed condition. The function DOES NOT handle the url()-ing.
setMeta ( array $meta ) : MediaItemModule THIS REPLACES THE META ARRAY If you want to add a meta item, use the addMeta method.
setTitle ( string $title ) : MediaItemModule
setTitleUrl ( string $titleUrl ) : MediaItemModule
setToggle ( string $key, boolean $enabled, string $url, string $label, string $cssClass = '', string $anchorCssClass = 'Hijack' ) Sets up a anchor-style toggle.
setView ( string $view ) : MediaItemModule

메소드 상세

__construct() 공개 메소드

MediaItemModule constructor.
public __construct ( string $title = '', string $titleUrl = '', string $description = '', string $tag = 'div', array $attributes = [] )
$title string The media item heading.
$titleUrl string If the heading is an anchor, the anchor url (the view handles url()-ing).
$description string The media item description text.
$tag string The root-level tag of the media item, usually a div or li.
$attributes array The root-level attributes for the Media Item.

addButton() 공개 메소드

Adds a button to the buttons array.
public addButton ( string $text, string $url, $attributes ) : MediaItemModule
$text string The text to display on the button.
$url string The url of the button.
$attributes The button attributes.
리턴 MediaItemModule $this

addButtonIf() 공개 메소드

Adds a button to the buttons array if it satisfies the $isAllowed condition.
public addButtonIf ( boolean | string | array $isAllowed, string $text, string $url, $attributes ) : MediaItemModule
$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 text to display on the button.
$url string The url of the button.
$attributes The button attributes.
리턴 MediaItemModule $this

addCssClass() 공개 메소드

Adds a css class to the cssClass array. This is useful for adding an arbitrary css class to a media item view.
public addCssClass ( $key, $class ) : MediaItemModule
$key
$class
리턴 MediaItemModule $this

addMeta() 공개 메소드

THIS ADDS AN ITEM TO THE META ARRAY
public addMeta ( string $meta ) : MediaItemModule
$meta string An HTML-formatted string.
리턴 MediaItemModule $this

addMetaIf() 공개 메소드

It's up to the view to concatinate the contents of this array, using something like implode(' | ', $meta)
public addMetaIf ( boolean | string | array $isAllowed, string $meta ) : MediaItemModule
$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.
$meta string An HTML-formatted string.
리턴 MediaItemModule $this

addOption() 공개 메소드

Adds a HTML-formatted string to the meta array. It's up to the view to add the info in the options.
public addOption ( string $key, string $value ) : MediaItemModule
$key string A key to access the data.
$value string An HTML-formatted string.
리턴 MediaItemModule $this

addOptionIf() 공개 메소드

It's up to the view to concatinate the contents of this array, using something like implode(' | ', $meta)
public addOptionIf ( boolean | string | array $isAllowed, string $key, string $value ) : MediaItemModule
$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 A key to access the data.
$value string An HTML-formatted string.
리턴 MediaItemModule $this

getAttributes() 공개 메소드

public getAttributes ( ) : array
리턴 array

getButtons() 공개 메소드

public getButtons ( ) : array
리턴 array

getCssClasses() 공개 메소드

public getCssClasses ( ) : array
리턴 array The css classes.

getDescription() 공개 메소드

public getDescription ( ) : string
리턴 string

getDropdown() 공개 메소드

public getDropdown ( ) : DropdownModule
리턴 DropdownModule

getImageHtml() 공개 메소드

Renders the html for an image with the image* properties.
public getImageHtml ( ) : string
리턴 string The html for an image.

getImageSource() 공개 메소드

public getImageSource ( ) : string
리턴 string

getMeta() 공개 메소드

public getMeta ( ) : array
리턴 array

getOptions() 공개 메소드

public getOptions ( ) : array
리턴 array

getTitle() 공개 메소드

public getTitle ( ) : string
리턴 string

getTitleUrl() 공개 메소드

public getTitleUrl ( ) : string
리턴 string

getToggle() 공개 메소드

public getToggle ( ) : array
리턴 array

getToggleHtml() 공개 메소드

Rendering helper for the toggle.
public getToggleHtml ( ) : string
리턴 string An HTML-formatted string for a toggle.

prepare() 공개 메소드

Prepares the media item for rendering.
public prepare ( ) : boolean
리턴 boolean Whether to render the module.

setAttributes() 공개 메소드

public setAttributes ( array $attributes ) : MediaItemModule
$attributes array
리턴 MediaItemModule $this

setDescription() 공개 메소드

public setDescription ( string $description ) : MediaItemModule
$description string
리턴 MediaItemModule $this

setDropdown() 공개 메소드

public setDropdown ( DropdownModule $dropdown ) : MediaItemModule
$dropdown DropdownModule
리턴 MediaItemModule $this

setImage() 공개 메소드

Sets the image. The function DOES NOT handle the url()-ing.
public setImage ( string $source = '', string $url = '', string $cssClass = '', string $alt = '' ) : MediaItemModule
$source string The image source url. The function DOES NOT handle the url()-ing.
$url string The image anchor link, if the image is an anchor. The function DOES NOT handle the url()-ing.
$cssClass string The CSS class for the image.
$alt string The image alt.
리턴 MediaItemModule $this

setImageIf() 공개 메소드

Sets the image if it satisfies the $isAllowed condition. The function DOES NOT handle the url()-ing.
public setImageIf ( boolean | string | array $isAllowed, string $source = '', string $url = '', string $cssClass = '', string $alt = '' ) : MediaItemModule
$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.
$source string The image source url. The function DOES NOT handle the url()-ing.
$url string The image anchor link, if the image is an anchor. The function DOES NOT handle the url()-ing.
$cssClass string The CSS class for the image.
$alt string The image alt.
리턴 MediaItemModule $this

setMeta() 공개 메소드

THIS REPLACES THE META ARRAY If you want to add a meta item, use the addMeta method.
public setMeta ( array $meta ) : MediaItemModule
$meta array
리턴 MediaItemModule $this

setTitle() 공개 메소드

public setTitle ( string $title ) : MediaItemModule
$title string
리턴 MediaItemModule $this

setTitleUrl() 공개 메소드

public setTitleUrl ( string $titleUrl ) : MediaItemModule
$titleUrl string Url for title, the view handles url()-ing.
리턴 MediaItemModule $this

setToggle() 공개 메소드

Sets up a anchor-style toggle.
public setToggle ( string $key, boolean $enabled, string $url, string $label, string $cssClass = '', string $anchorCssClass = 'Hijack' )
$key string The toggle key/slug
$enabled boolean Whether the toggle is enabled.
$url string The endpoint the toggle hits.
$label string The aria-label for the toggle.
$cssClass string The toggle css class.
$anchorCssClass string The css class for the anchor. Should probably have 'Hijack' in there.

setView() 공개 메소드

public setView ( string $view ) : MediaItemModule
$view string
리턴 MediaItemModule $this

프로퍼티 상세

$view 공개적으로 프로퍼티

The view to render. Supported views are media-addon, media-callout, or media-sm.
public $view