Elgg  Version master
remove.php
Go to the documentation of this file.
1 <?php
12 if (elgg_extract('show_remove', $vars, true) === false) {
13  return;
14 }
15 
16 $entity = elgg_extract('entity', $vars);
17 if (!$entity instanceof ElggEntity) {
18  // no way to check for icon
19  return;
20 }
21 
22 $icon_type = elgg_extract('icon_type', $vars, 'icon');
23 if (!$entity->hasIcon('master', $icon_type)) {
24  // no icon uploaded
25  return;
26 }
27 
28 $name = elgg_extract('remove_name', $vars);
29 if (elgg_is_empty($name)) {
30  // make name based on file name
31  $name = elgg_extract('name', $vars, 'icon') . '_remove';
32 }
33 
34 if (elgg_language_key_exists("entity:edit:{$icon_type}:remove:label")) {
35  $label = elgg_echo("entity:edit:{$icon_type}:remove:label");
36 } else {
37  $label = elgg_echo('entity:edit:icon:remove:label');
38 }
39 
40 echo elgg_view_field([
41  '#type' => 'switch',
42  '#label' => $label,
43  '#class' => 'elgg-entity-edit-icon-remove',
44  'name' => $name,
45 ]);
if(elgg_extract('show_remove', $vars, true)===false) $entity
Show a remove icon toggle.
Definition: remove.php:16
if($view &&elgg_view_exists($view)) $label
Definition: field.php:26
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1112
if(!$entity instanceof ElggEntity) $icon_type
Definition: remove.php:22
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
if(!$entity->hasIcon('master', $icon_type)) $name
Definition: remove.php:28
elgg_is_empty($value)
Check if a value isn&#39;t empty, but allow 0 and &#39;0&#39;.
Definition: input.php:176
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
elgg_language_key_exists(string $key, string $language= 'en')
Check if a given language key exists.
Definition: languages.php:44
$vars
Definition: theme.php:5