Elgg  Version 6.1
profile.php
Go to the documentation of this file.
1 <?php
9 $entity = elgg_extract('entity', $vars);
10 if (!$entity instanceof \ElggUser) {
11  return;
12 }
13 
14 $fields = elgg()->fields->get('user', 'user');
15 if (empty($fields)) {
16  echo elgg_view('page/components/no_results', [
17  'no_results' => elgg_echo('admin:users:details:profile:no_fields'),
18  ]);
19  return;
20 }
21 
23  'mobile' => 'tel p-tel',
24  'phone' => 'tel p-tel',
25  'website' => 'url u-url',
26  'contactemail' => 'email u-email',
27 ];
28 $microformats = array_merge($microformats, (array) elgg_extract('microformats', $vars, []));
29 
30 $output = '';
31 foreach ($fields as $field) {
32  $shortname = $field['name'];
33  $valtype = $field['#type'];
34 
35  $value = $entity->getProfileData($shortname);
36  if (elgg_is_empty($value)) {
37  continue;
38  }
39 
40  // validate urls
41  if ($valtype === 'url' && is_string($value) && !preg_match('~^https?\://~i', $value)) {
42  $value = "http://{$value}";
43  }
44 
45  $output .= elgg_view('object/elements/field', [
46  'label' => elgg_extract('#label', $field),
47  'value' => elgg_format_element('span', [
48  'class' => elgg_extract($shortname, $microformats),
49  ], elgg_view("output/{$valtype}", [
50  'value' => $value,
51  ])),
52  'name' => $shortname,
53  ]);
54 }
55 
56 if (empty($output)) {
57  echo elgg_view('page/components/no_results', [
58  'no_results' => elgg_echo('admin:users:details:profile:no_information'),
59  ]);
60  return;
61 }
62 
63 echo $output;
elgg
Definition: install.js:27
$entity
Show user profile information in admin listings.
Definition: profile.php:9
if(empty($fields)) $microformats
Definition: profile.php:22
$output
Definition: profile.php:30
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
if(elgg_extract('input_type', $vars)) if(elgg_extract('required', $vars)) if(elgg_extract('disabled', $vars)) $field
Definition: field.php:42
$value
Definition: generic.php:51
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:256
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
if(!$entity instanceof\ElggUser) $fields
Definition: profile.php:14
$vars
Definition: theme.php:5
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145