Stud.IP  5.4
LinkElement Class Reference
Inheritance diagram for LinkElement:
WidgetElement

Public Member Functions

 __construct ($label, $url, \Icon $icon=null, $attributes=[])
 
 setActive ($active=true)
 
 asDialog ($state='')
 
 asButton ($state=true)
 
 setTarget ($target)
 
 addClass ($class)
 
 setDisabled ($state=true)
 
 isDisabled ()
 
 render ()
 
- Public Member Functions inherited from WidgetElement
 __construct ($content='')
 
 render ()
 

Static Public Member Functions

static fromHTML ($html, \Icon $icon=null)
 

Data Fields

 $url
 
 $label
 
 $icon
 
 $active = false
 
 $as_button = false
 

Protected Member Functions

 renderButton ()
 
 isURL ($url)
 

Static Protected Member Functions

static parseAttributes ($text)
 

Additional Inherited Members

- Protected Attributes inherited from WidgetElement
 $content
 

Detailed Description

Author
Jan-Hendrik Willms tleil.nosp@m.ax+s.nosp@m.tudip.nosp@m.@gma.nosp@m.il.co.nosp@m.m GPL2 or any later version

Constructor & Destructor Documentation

◆ __construct()

__construct (   $label,
  $url,
\Icon  $icon = null,
  $attributes = [] 
)

create a link for a widget

Parameters
String$labelLabel/content of the link
String$urlURL/Location of the link (raw url, no entities)
Icon$iconIcon for the link
array$attributesHTML-attributes for the a-tag in an associative array.

Member Function Documentation

◆ addClass()

addClass (   $class)

Adds a css class to the rendered element.

Parameters
string$clasCSS class to add
Returns
LinkElement instance to allow chaining

◆ asButton()

asButton (   $state = true)

Defines whether the link should be rendered as a button/form with POST method.

Parameters
bool$activeState (optional, defaults to true)
Returns
LinkElement instance to allow chaining

◆ asDialog()

asDialog (   $state = '')

Sets the dialog options for the element. Passing false as $state will reset the dialog options to "none".

Parameters
mixed$activeDialog options (optional, defaults to blank/standard dialog)
Returns
LinkElement instance to allow chaining

◆ fromHTML()

static fromHTML (   $html,
\Icon  $icon = null 
)
static

Create link by parsing a html chunk.

Parameters
String$htmlHTML chunk to parse
Icon$iconOptional icon
Returns
LinkElement Link element from parsed html
Exceptions
Exceptionif html can not be parsed

◆ isDisabled()

isDisabled ( )

Returns whether the element is disabled.

Returns
bool

◆ isURL()

isURL (   $url)
protected

Returns whether the given url is valid.

Parameters
string$urlURL to test
Returns
bool

◆ parseAttributes()

static parseAttributes (   $text)
staticprotected

Parse a string of html attributes into an associative array.

Parameters
String$textString of html attributes
Returns
Array parsed attributes as key => value pairs
See also
https://gist.github.com/rodneyrehm/3070128

◆ render()

render ( )

Renders the element.

Returns
string

◆ renderButton()

renderButton ( )
protected

Renders the element as a button/form.

Returns
string

◆ setActive()

setActive (   $active = true)

Sets the active state of the element.

Parameters
bool$activeActive state (optional, defaults to true)
Returns
LinkElement instance to allow chaining

◆ setDisabled()

setDisabled (   $state = true)

Set disabled state

Parameters
boolean$stateDisabled state
Returns
LinkElement instance to allow chaining

◆ setTarget()

setTarget (   $target)

Sets the target attribute of the element.

Parameters
string$targetTarget attribute
Returns
LinkElement instance to allow chaining

Field Documentation

◆ $active

$active = false

◆ $as_button

$as_button = false

◆ $icon

$icon

◆ $label

$label

◆ $url

$url

The documentation for this class was generated from the following file: