Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
default.php
Go to the documentation of this file.
1 <?php
15 $entity = $vars['entity'];
16 /* @var ElggEntity $entity */
17 
19 // Get size
20 $size = elgg_extract('size', $vars, 'medium');
21 if (!array_key_exists($size, $icon_sizes)) {
22  $size = "medium";
23 }
24 $vars['size'] = $size;
25 
26 $class = elgg_extract('img_class', $vars, '');
27 
28 if (isset($entity->name)) {
29  $title = $entity->name;
30 } else {
31  $title = $entity->title;
32 }
33 $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8', false);
34 
35 $url = $entity->getURL();
36 if (isset($vars['href'])) {
37  $url = $vars['href'];
38 }
39 
40 if (!isset($vars['width'])) {
41  $vars['width'] = $size != 'master' ? $icon_sizes[$size]['w'] : null;
42 }
43 if (!isset($vars['height'])) {
44  $vars['height'] = $size != 'master' ? $icon_sizes[$size]['h'] : null;
45 }
46 
47 $img_params = array(
48  'src' => $entity->getIconURL($size),
49  'alt' => $title,
50 );
51 
52 if (!empty($class)) {
53  $img_params['class'] = $class;
54 }
55 
56 if (!empty($vars['width'])) {
57  $img_params['width'] = $vars['width'];
58 }
59 
60 if (!empty($vars['height'])) {
61  $img_params['height'] = $vars['height'];
62 }
63 
64 $img = elgg_view('output/img', $img_params);
65 
66 if ($url) {
67  $params = array(
68  'href' => $url,
69  'text' => $img,
70  'is_trusted' => true,
71  );
72  $class = elgg_extract('link_class', $vars, '');
73  if ($class) {
74  $params['class'] = $class;
75  }
76 
77  echo elgg_view('output/url', $params);
78 } else {
79  echo $img;
80 }
$icon_sizes
Definition: default.php:18
if(isset($vars['href'])) if(!isset($vars['width'])) if(!isset($vars['height'])) $img_params
Definition: default.php:47
elgg_get_icon_sizes($entity_type=null, $entity_subtype=null, $type= 'icon')
Returns a configuration array of icon sizes.
$class
Definition: default.php:26
$params
Definition: default.php:39
$url
Definition: default.php:35
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:342
if(!array_key_exists($size, $icon_sizes)) $vars['size']
Definition: default.php:24
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1310
$size
Definition: default.php:20
$entity
Definition: default.php:15
$title
Definition: default.php:33
if(!empty($class)) if(!empty($vars['width'])) if(!empty($vars['height'])) $img
Definition: default.php:64