Elgg  Version 6.3
numentities.php
Go to the documentation of this file.
1 <?php
7 
10 });
13  'wheres' => [
14  function(QueryBuilder $qb, $main_alias) {
15  return $qb->compare("{$main_alias}.deleted", '=', 'yes', ELGG_VALUE_STRING);
16  },
17  ],
18  ]);
19 });
20 
22 $other = [];
23 
24 foreach ($entity_stats as $type => $subtypes) {
25  foreach ($subtypes as $subtype => $value) {
26  $name = "{$type} - {$subtype}";
27  if (elgg_language_key_exists("collection:{$type}:{$subtype}")) {
28  $name = elgg_echo("collection:{$type}:{$subtype}");
29  } elseif (elgg_language_key_exists("item:{$type}:{$subtype}")) {
30  $name = elgg_echo("item:{$type}:{$subtype}");
31  }
32 
33  if (elgg_entity_has_capability($type, $subtype, 'searchable')) {
34  $searchable[$name] = [
35  $value,
37  ];
38  } else {
39  $other[$name] = [
40  $value,
42  ];
43  }
44  }
45 }
46 
47 arsort($searchable);
48 arsort($other);
49 
50 $header = elgg_format_element('th', [], elgg_echo('admin:statistics:numentities:type'));
51 $header .= elgg_format_element('th', [], elgg_echo('total'));
52 
53 $header = elgg_format_element('thead', [], elgg_format_element('tr', [], $header));
54 
55 // searchable entity stats
56 $rows = [];
57 foreach ($searchable as $name => $value) {
58  $cells = [];
59  $cells[] = elgg_format_element('td', [], $name);
60 
61  $entity_total = elgg_number_format($value[0]);
62  $entity_trashed = elgg_number_format($value[1] ?? 0);
63 
64  $number = $entity_total . ($entity_trashed ? elgg_format_element('span', ['class' => ['elgg-quiet', 'mls']], elgg_echo('status:trashed') . ': ' . $entity_trashed) : null);
65  $cells[] = elgg_format_element('td', [], $number);
66 
67  $rows[] = elgg_format_element('tr', [], implode('', $cells));
68 }
69 
70 $rows = elgg_format_element('tbody', [], implode(PHP_EOL, $rows));
71 
72 $body = elgg_format_element('table', ['class' => 'elgg-table'], $header . $rows);
73 echo elgg_view_module('info', elgg_echo('admin:statistics:numentities:searchable'), $body);
74 
75 // remaining entity stats
76 $rows = [];
77 foreach ($other as $name => $value) {
78  $cells = [];
79  $cells[] = elgg_format_element('td', [], $name);
80 
81  $entity_total = elgg_number_format($value[0]);
82  $entity_trashed = elgg_number_format($value[1] ?? 0);
83 
84  $number = $entity_total . ($entity_trashed ? elgg_format_element('span', ['class' => ['elgg-quiet', 'mls']], elgg_echo('status:trashed') . ': ' . $entity_trashed) : null);
85  $cells[] = elgg_format_element('td', [], $number);
86 
87  $rows[] = elgg_format_element('tr', [], implode('', $cells));
88 }
89 
90 $rows = elgg_format_element('tbody', [], implode(PHP_EOL, $rows));
91 
92 $body = elgg_format_element('table', ['class' => 'elgg-table'], $header . $rows);
93 echo elgg_view_module('info', elgg_echo('admin:statistics:numentities:other'), $body);
if(! $user||! $user->canDelete()) $name
Definition: delete.php:22
$subtype
Definition: delete.php:22
$type
Definition: delete.php:21
$body
Definition: numentities.php:72
$rows
Definition: numentities.php:56
$entity_stats
Definition: numentities.php:8
$header
Definition: numentities.php:50
$trashed_stats
Definition: numentities.php:11
$other
Definition: numentities.php:22
$searchable
Definition: numentities.php:21
Database abstraction query builder.
$subtypes
const ELGG_VALUE_STRING
Definition: constants.php:112
const ELGG_SHOW_DELETED_ENTITIES
Definition: constants.php:127
if($item instanceof \ElggEntity) elseif($item instanceof \ElggRiverItem) elseif($item instanceof \ElggRelationship) elseif(is_callable([ $item, 'getType']))
Definition: item.php:48
elgg_call(int $flags, Closure $closure)
Calls a callable autowiring the arguments using public DI services and applying logic based on flags.
Definition: elgglib.php:290
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:240
elgg_get_entity_statistics(array $options=[])
Return an array reporting the number of various entities in the system.
Definition: entities.php:661
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:717
$value
Definition: generic.php:51
elgg_language_key_exists(string $key, string $language='en')
Check if a given language key exists.
Definition: languages.php:44
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_view_module(string $type, string $title, string $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:922
elgg_format_element(string $tag_name, array $attributes=[], string $text='', array $options=[])
Format an HTML element.
Definition: output.php:145
elgg_number_format(float $number, int $decimals=0)
Format a number with grouped thousands using language specific separators.
Definition: output.php:368
$qb
Definition: queue.php:14