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