Elgg  Version 5.1
numentities.php
Go to the documentation of this file.
1 <?php
8 $user = elgg_extract('entity', $vars, elgg_get_page_owner_entity()); // page owner for BC reasons
9 if (!$user instanceof ElggUser) {
10  return;
11 }
12 
14 if (empty($entity_stats)) {
15  return;
16 }
17 
18 $rows = [];
19 foreach ($entity_stats as $type => $subtypes) {
20  foreach ($subtypes as $subtype => $count) {
21  $cells = [];
22 
23  $label = "{$type} {$subtype}";
24  if (elgg_language_key_exists("collection:{$type}:{$subtype}")) {
25  $label = elgg_echo("collection:{$type}:{$subtype}");
26  } elseif (elgg_language_key_exists("item:{$type}:{$subtype}")) {
27  $label = elgg_echo("item:{$type}:{$subtype}");
28  }
29 
30  $cells[] = elgg_format_element('td', [], elgg_format_element('b', [], "{$label}:"));
31  $cells[] = elgg_format_element('td', [], $count);
32 
34  $rows[] = elgg_format_element('tr', [], implode(PHP_EOL, $cells));
35  }
36  }
37 }
38 
39 if (empty($rows)) {
40  return;
41 }
42 
43 if ($user->guid === elgg_get_logged_in_user_guid()) {
44  $title = elgg_echo('usersettings:statistics:label:numentities');
45 } else {
46  $title = elgg_echo('usersettings:statistics:numentities:user', [$user->getDisplayName()]);
47 }
48 
49 $content = elgg_format_element('table', ['class' => 'elgg-table-alt'], implode(PHP_EOL, $rows));
50 
51 echo elgg_view_module('info', $title, $content);
elgg_view_module(string $type, string $title, string $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:940
$user
Elgg statistics screen.
Definition: numentities.php:8
if($view &&elgg_view_exists($view)) $label
Definition: field.php:26
elgg_get_entity_statistics(int $owner_guid=0)
Return an array reporting the number of various entities in the system.
Definition: entities.php:657
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:52
$title
Definition: generic.php:50
$content
Definition: numentities.php:49
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$type
Definition: delete.php:22
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof\ElggRelationship) elseif(is_callable([$item, 'getType']))
Definition: item.php:48
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
$rows
Definition: numentities.php:31
$count
Definition: ban.php:24
elgg_get_page_owner_entity()
Gets the owner entity for the current page.
Definition: pageowner.php:23
$vars
Definition: theme.php:5
$subtype
Definition: delete.php:23
$subtypes
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
elgg_entity_has_capability(string $type, string $subtype, string $capability, bool $default=false)
Checks if a capability is enabled for a specified type/subtype.
Definition: entities.php:698
$entity_stats
Definition: numentities.php:3
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
Definition: sessions.php:34