Stud.IP  4.0
 All Data Structures Namespaces Files Functions Variables Groups
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 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 (   $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 ( )

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

Returns
String representation
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 ( )

Returns a path to the SVG matching the icon.

Returns
String containing the html representation for css backgrounds
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 (   $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.
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 (   $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 (   $shape)

Returns a new Icon with a changed shape

Parameters
mixed$shapeNew value of shape
Returns
Icon A new Icon with a new shape
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 ( )
protected

Get the correct asset for an SVG icon.

Returns
String containing the url of the corresponding asset
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 ( )

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

Returns
Array the semantic attribiutes of the Icon
getRole ( )

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

Returns
String the role of this Icon
getShape ( )

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

Returns
String the shape of this Icon
signalsAttention ( )

Returns whether this icon intends to signal attention.

Returns
bool
Since
Stud.IP 5.0

Field Documentation

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

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