Stud.IP  5.4
Icon Class Reference

Public Member Functions

 __construct ($shape, $role=Icon::DEFAULT_ROLE, array $attributes=[])
 
 getShape ()
 
 getRole ()
 
 getAttributes ()
 
 signalsAttention ()
 
 __toString ()
 
 asImg ($size=null, $view_attributes=[])
 
 asInput ($size=null, $view_attributes=[])
 
 asCSS ($size=null)
 
 asImagePath ()
 
 copyWithShape ($shape)
 
 copyWithRole ($role)
 
 copyWithAttributes ($attributes)
 

Static Public Member Functions

static colorToRoles ($color)
 
static create ($shape, $role=Icon::DEFAULT_ROLE, $attributes=[])
 

Data Fields

const SVG = 1
 
const CSS_BACKGROUND = 4
 
const INPUT = 256
 
const DEFAULT_SIZE = 16
 
const DEFAULT_COLOR = 'blue'
 
const DEFAULT_ROLE = 'clickable'
 
const ROLE_INFO = 'info'
 
const ROLE_CLICKABLE = 'clickable'
 
const ROLE_ACCEPT = 'accept'
 
const ROLE_STATUS_GREEN = 'status-green'
 
const ROLE_INACTIVE = 'inactive'
 
const ROLE_NAVIGATION = 'navigation'
 
const ROLE_NEW = 'new'
 
const ROLE_ATTENTION = 'attention'
 
const ROLE_STATUS_RED = 'status-red'
 
const ROLE_INFO_ALT = 'info_alt'
 
const ROLE_SORT = 'sort'
 
const ROLE_STATUS_YELLOW = 'status-yellow'
 

Protected Member Functions

 get_asset_svg ()
 
 get_size ($size)
 

Protected Attributes

 $shape
 
 $role
 
 $attributes = []
 

Detailed Description

Icon class is used to create icon objects which can be rendered as svg. Output will be html. Optionally, the icon can be rendered as a css background.

Author
Jan-Hendrik Willms tleil.nosp@m.ax+s.nosp@m.tudip.nosp@m.@gma.nosp@m.il.co.nosp@m.m
Since
3.2

Constructor & Destructor Documentation

◆ __construct()

__construct (   $shape,
  $role = Icon::DEFAULT_ROLE,
array  $attributes = [] 
)

Constructor of the object.

Parameters
String$shapeShape of the icon, may contain a mixed definition like 'seminar'
String$roleRole of the icon, defaults to Icon::DEFAULT_ROLE
Array$attributesAdditional attributes like 'title'; only use semantic ones describing this icon regardless of its later rendering in a view

Member Function Documentation

◆ __toString()

__toString ( )

Function to be called whenever the object is converted to string. Internally the same as calling Icon::asImg

Returns
String representation

◆ asCSS()

asCSS (   $size = null)

Renders the icon as a set of css background rules.

Parameters
int$sizeOptional; Defines the size in px of the rendered icon
Returns
String containing the html representation for css backgrounds

◆ asImagePath()

asImagePath ( )

Returns a path to the SVG matching the icon.

Returns
String containing the html representation for css backgrounds

◆ asImg()

asImg (   $size = null,
  $view_attributes = [] 
)

Renders the icon inside an img html tag.

Parameters
int$sizeOptional; Defines the dimension in px of the rendered icon; FALSE prevents any width or height attributes
Array$view_attributesOptional; Additional attributes to pass into the rendered output
Returns
String containing the html representation for the icon.

◆ asInput()

asInput (   $size = null,
  $view_attributes = [] 
)

Renders the icon inside an input html tag.

Parameters
int$sizeOptional; Defines the dimension in px of the rendered icon; FALSE prevents any width or height attributes
Array$view_attributesOptional; Additional attributes to pass into the rendered output
Returns
String containing the html representation for the icon.

◆ colorToRoles()

static colorToRoles (   $color)
static

◆ copyWithAttributes()

copyWithAttributes (   $attributes)

Returns a new Icon with new attributes

Parameters
mixed$attributesNew value of attributes
Returns
Icon A new Icon with a new attributes

◆ copyWithRole()

copyWithRole (   $role)

Returns a new Icon with a changed role

Parameters
mixed$roleNew value of role
Returns
Icon A new Icon with a new role

◆ copyWithShape()

copyWithShape (   $shape)

Returns a new Icon with a changed shape

Parameters
mixed$shapeNew value of shape
Returns
Icon A new Icon with a new shape

◆ create()

static create (   $shape,
  $role = Icon::DEFAULT_ROLE,
  $attributes = [] 
)
static

Create a new Icon object.

This is just a factory method. You could easily just call the constructor instead.

Parameters
String$shapeShape of the icon, may contain a mixed definition like 'seminar'
String$roleRole of the icon, defaults to Icon::DEFAULT_ROLE
Array$attributesAdditional attributes like 'title'; only use semantic ones describing this icon regardless of its later rendering in a view
Returns
Icon object

◆ get_asset_svg()

get_asset_svg ( )
protected

Get the correct asset for an SVG icon.

Returns
String containing the url of the corresponding asset

◆ get_size()

get_size (   $size)
protected

Get the size of the icon. If a size was passed as a parameter and inside the attributes array during icon construction, the size from the attributes will be used.

Parameters
int$sizesize of the icon
Returns
int Size of the icon in pixels

◆ getAttributes()

getAttributes ( )

Returns the semantic attributes of this instance, e.g. the title of this Icon

Returns
Array the semantic attribiutes of the Icon

◆ getRole()

getRole ( )

Returns the role – the string describing the role of this instance.

Returns
String the role of this Icon

◆ getShape()

getShape ( )

Returns the shape – the string describing the shape of this instance.

Returns
String the shape of this Icon

◆ signalsAttention()

signalsAttention ( )

Returns whether this icon intends to signal attention.

Returns
bool
Since
Stud.IP 5.0

Field Documentation

◆ $attributes

$attributes = []
protected

◆ $role

$role
protected

◆ $shape

$shape
protected

◆ CSS_BACKGROUND

const CSS_BACKGROUND = 4

◆ DEFAULT_COLOR

const DEFAULT_COLOR = 'blue'

◆ DEFAULT_ROLE

const DEFAULT_ROLE = 'clickable'

◆ DEFAULT_SIZE

const DEFAULT_SIZE = 16

◆ INPUT

const INPUT = 256

◆ ROLE_ACCEPT

const ROLE_ACCEPT = 'accept'

◆ ROLE_ATTENTION

const ROLE_ATTENTION = 'attention'

◆ ROLE_CLICKABLE

else ROLE_CLICKABLE = 'clickable'

◆ ROLE_INACTIVE

else ROLE_INACTIVE = 'inactive'

◆ ROLE_INFO

else ROLE_INFO = 'info'

◆ ROLE_INFO_ALT

const ROLE_INFO_ALT = 'info_alt'

◆ ROLE_NAVIGATION

const ROLE_NAVIGATION = 'navigation'

◆ ROLE_NEW

const ROLE_NEW = 'new'

◆ ROLE_SORT

const ROLE_SORT = 'sort'

◆ ROLE_STATUS_GREEN

default ROLE_STATUS_GREEN = 'status-green'

◆ ROLE_STATUS_RED

case ROLE_STATUS_RED = 'status-red'

◆ ROLE_STATUS_YELLOW

const ROLE_STATUS_YELLOW = 'status-yellow'

◆ SVG

const SVG = 1

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