Elgg  Version master
crop_messages.php
Go to the documentation of this file.
1 <?php
10 $icon_type = elgg_extract('icon_type', $vars, 'icon');
11 $show_icon_cropper_messages = (bool) elgg_extract('cropper_show_messages', $vars, $icon_type === 'icon');
13  return;
14 }
15 
16 // placeholder for messages
17 $errors = [];
18 
19 $min_width = (int) elgg_extract('cropper_min_width', $vars);
20 if ($min_width > 0) {
21  $errors[] = elgg_format_element('span', [
22  'class' => [
23  'elgg-entity-edit-icon-crop-error-width',
24  'hidden',
25  ],
26  'data-min-width' => $min_width,
27  ], elgg_echo('entity:edit:icon:crop_messages:width', [$min_width]) . '&nbsp;');
28 }
29 
30 $min_height = (int) elgg_extract('cropper_min_height', $vars);
31 if ($min_height > 0) {
32  $errors[] = elgg_format_element('span', [
33  'class' => [
34  'elgg-entity-edit-icon-crop-error-height',
35  'hidden',
36  ],
37  'data-min-height' => $min_height,
38  ], elgg_echo('entity:edit:icon:crop_messages:height', [$min_height]));
39 }
40 
41 if (empty($errors)) {
42  return;
43 }
44 
45 // add generic message
46 array_unshift($errors, elgg_format_element('div', [
47  'class' => [
48  'elgg-entity-edit-icon-crop-error-generic',
49  'hidden',
50  ]
51 ], elgg_echo('entity:edit:icon:crop_messages:generic')));
52 
53 // build output
54 $message = elgg_view('output/longtext', [
55  'value' => implode('', $errors),
56  'sanitize' => false,
57 ]);
59  'class' => [
60  'elgg-entity-edit-icon-crop-messages',
61  'hidden',
62  ],
63 ];
64 
65 echo elgg_view_message('warning', $message, $message_vars);
if($min_width > 0) $min_height
$icon_type
Show warning about size constraints when uploading/cropping an icon.
$message
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$message_vars
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_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
$show_icon_cropper_messages
if(!$show_icon_cropper_messages) $errors
$vars
Definition: theme.php:5
elgg_view_message(string $type, string $body, array $vars=[])
Wrapper function for the message display pattern.
Definition: views.php:940
$min_width
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145