Icon class is used to create icon objects which can be rendered as svg or png. 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
- Copyright
- Stud.IP Core Group @license GPL2 or any later version
- Since
- 3.2
◆ __construct()
Constructor of the object.
- Parameters
-
| String | $source | Name of the icon, may contain a mixed definition like 'icons/16/blue/add/seminar.png' due to compatibility issues with Assets::img(). |
| int | $size | Size of the icon, defaults to fixed default icon size |
| String | $color | Color of the icon, defaults to fixed default icon color |
| Array | $attributes | Additional attributes to pass the rendered output |
| bool | $static | Defines whether the icon is static (not from assets folder) |
◆ __toString()
Function to be called whenever the object is converted to string.
- Returns
- String representation
◆ create()
- Parameters
-
| String | $source | Name of the icon, may contain a mixed definition like 'icons/16/blue/add/seminar.png' due to compatibility issues with Assets::img(). |
| int | $size | Size of the icon, defaults to fixed default icon size |
| String | $color | Color of the icon, defaults to fixed default icon color |
| mixed | $icon | Extra icon to apply to the icon, default is none |
| Array | $attributes | Additional attributes to pass the rendered output |
- Returns
- Icon object
◆ get_asset()
Get the correct asset for the icon.
- Parameters
-
| int | $type | Either svg or png, no other assets are defined. |
- Returns
- String containing the url of the corresponding asset
- Exceptions
-
| Exception | if an invalid type was passed |
◆ get_size()
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.
- Returns
- int Size of the icon in pixels
◆ rearrange()
| static rearrange |
( |
|
$input, |
|
|
|
$defaults = array(), |
|
|
|
$extra = false |
|
) |
| |
|
staticprotected |
Rearranges passed parameters. Tries to detect given size, color and extra icon.
- Parameters
-
| mixed | $input | Either a relative or absolute url or an array |
| Array | $defaults | Default values for size, color and extra icon |
| mixed | $extra | Extra icon to apply to the icon, defaults to none |
- Returns
- Array with the guessed values
◆ render()
Renders the icon as svg, png or css background.
- Parameters
-
| int | $type | Defines in which manner the icon should be rendered, defaults to svg. |
- Returns
- String containing the rendered output
- Exceptions
-
| Exception | if no valid type was passed |
◆ render_css_background()
| render_css_background |
( |
| ) |
|
|
protected |
Renders the icon as a set of css background rules.
- Returns
- String containing the html representation for css backgrounds
◆ render_img()
| render_img |
( |
|
$type, |
|
|
|
$as_input |
|
) |
| |
|
protected |
Renders the icon inside a img html tag.
- Parameters
-
| int | $type | Defines in which manner the icon should be rendered, should be either Icon::SVG or Icon::PNG. |
- Returns
- String containing the html representation for the icon.
◆ tag_options()
Renders an array of options as html attributes.
- Parameters
-
| Array | $options | 1-dimensional associative array of options |
- Returns
- String containing the representation of the options as html tag attributes.
◆ $attributes
◆ $color
◆ $icon
◆ $icon_colors
Initial value:= array(
'black', 'blue', 'green', 'grey', 'lightblue', 'red', 'white', 'yellow',
)
◆ $size
◆ $static
◆ CSS_BACKGROUND
◆ DEFAULT_COLOR
| const DEFAULT_COLOR = 'blue' |
◆ DEFAULT_SIZE
◆ INPUT
◆ PNG
◆ SVG
The documentation for this class was generated from the following file: