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
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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