Elgg  Version 6.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  'owner_guid' => $user->guid,
15 ];
16 
18  $options['type_subtype_pairs'] = elgg_entity_types_with_capability('searchable');
19 }
20 
22 if (empty($entity_stats)) {
23  return;
24 }
25 
26 $rows = [];
27 foreach ($entity_stats as $type => $subtypes) {
28  foreach ($subtypes as $subtype => $count) {
29  $cells = [];
30 
31  $label = "{$type} {$subtype}";
32  if (elgg_language_key_exists("collection:{$type}:{$subtype}")) {
33  $label = elgg_echo("collection:{$type}:{$subtype}");
34  } elseif (elgg_language_key_exists("item:{$type}:{$subtype}")) {
35  $label = elgg_echo("item:{$type}:{$subtype}");
36  }
37 
38  $cells[] = elgg_format_element('td', [], elgg_format_element('b', [], "{$label}:"));
39  $cells[] = elgg_format_element('td', [], $count);
40 
41  $rows[] = elgg_format_element('tr', [], implode(PHP_EOL, $cells));
42  }
43 }
44 
45 if (empty($rows)) {
46  return;
47 }
48 
49 if ($user->guid === elgg_get_logged_in_user_guid()) {
50  $title = elgg_echo('usersettings:statistics:label:numentities');
51 } else {
52  $title = elgg_echo('usersettings:statistics:numentities:user', [$user->getDisplayName()]);
53 }
54 
55 $content = elgg_format_element('table', ['class' => 'elgg-table-alt'], implode(PHP_EOL, $rows));
56 
57 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:919
$user
Elgg statistics screen.
Definition: numentities.php:8
if($view &&elgg_view_exists($view)) $label
Definition: field.php:26
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:55
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:21
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof\ElggRelationship) elseif(is_callable([$item, 'getType']))
Definition: item.php:48
elgg_get_entity_statistics(array $options=[])
Return an array reporting the number of various entities in the system.
Definition: entities.php:661
if(!$user instanceof\ElggUser) $options
Definition: numentities.php:13
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_language_key_exists(string $key, string $language= 'en')
Check if a given language key exists.
Definition: languages.php:44
$rows
Definition: numentities.php:53
$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:22
$subtypes
elgg_entity_types_with_capability(string $capability)
Returns an array of type/subtypes with the requested capability enabled.
Definition: entities.php:757
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
$entity_stats
Definition: numentities.php:5
elgg_get_logged_in_user_guid()
Return the current logged in user by guid.
Definition: sessions.php:34