1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<?php
/**
* Generic icon view.
*
* @package Elgg
* @subpackage Core
*
* @uses $vars['entity'] The entity the icon represents - uses getIconURL() method
* @uses $vars['size'] topbar, tiny, small, medium (default), large, master
* @uses $vars['href'] Optional override for link
*/
$entity = $vars['entity'];
/* @var ElggObject $entity */
$sizes = array('small', 'medium', 'large', 'tiny', 'master', 'topbar');
$img_width = array('tiny' => 25, 'small' => 40, 'medium' => 100, 'large' => 200);
// Get size
if (!in_array($vars['size'], $sizes)) {
$size = "medium";
} else {
$size = $vars['size'];
}
if (isset($entity->name)) {
$title = $entity->name;
} else {
$title = $entity->title;
}
$url = $entity->getURL();
if (isset($vars['href'])) {
$url = $vars['href'];
}
$img_src = $entity->getIconURL($vars['size']);
$img = "<img src=\"$img_src\" alt=\"$title\" width=\"{$img_width[$size]}\" />";
if ($url) {
echo elgg_view('output/url', array(
'href' => $url,
'text' => $img,
));
} else {
echo $img;
}
|