Elgg  Version master
numentities.php
Go to the documentation of this file.
1 <?php
2 // Get entity statistics
4 
7 });
10  'wheres' => [
11  function(QueryBuilder $qb, $main_alias) {
12  return $qb->compare("{$main_alias}.deleted", '=', 'yes', ELGG_VALUE_STRING);
13  },
14  ],
15  ]);
16 });
17 
19 $other = [];
20 
21 foreach ($entity_stats as $type => $subtypes) {
22  foreach ($subtypes as $subtype => $value) {
23  $name = "{$type} - {$subtype}";
24  if (elgg_language_key_exists("collection:{$type}:{$subtype}")) {
25  $name = elgg_echo("collection:{$type}:{$subtype}");
26  } elseif (elgg_language_key_exists("item:{$type}:{$subtype}")) {
27  $name = elgg_echo("item:{$type}:{$subtype}");
28  }
29 
30  if (elgg_entity_has_capability($type, $subtype, 'searchable')) {
31  $searchable[$name] = [
32  $value,
34  ];
35  } else {
36  $other[$name] = [
37  $value,
39  ];
40  }
41  }
42 }
43 
44 arsort($searchable);
45 arsort($other);
46 
47 $header = elgg_format_element('th', [], elgg_echo('admin:statistics:numentities:type'));
48 $header .= elgg_format_element('th', [], elgg_echo('total'));
49 
50 $header = elgg_format_element('thead', [], elgg_format_element('tr', [], $header));
51 
52 // searchable entity stats
53 $rows = [];
54 foreach ($searchable as $name => $value) {
55  $cells = [];
56  $cells[] = elgg_format_element('td', [], $name);
57 
58  $number = $value[0] . ($value[1] ? elgg_format_element('span', ['class' => ['elgg-quiet', 'mls']], elgg_echo('status:trashed') . ': ' . $value[1]) : null);
59  $cells[] = elgg_format_element('td', [], $number);
60 
61  $rows[] = elgg_format_element('tr', [], implode('', $cells));
62 }
63 
64 $rows = elgg_format_element('tbody', [], implode(PHP_EOL, $rows));
65 
66 $body = elgg_format_element('table', ['class' => 'elgg-table'], $header . $rows);
67 echo elgg_view_module('info', elgg_echo('admin:statistics:numentities:searchable'), $body);
68 
69 // remaining entity stats
70 $rows = [];
71 foreach ($other as $name => $value) {
72  $cells = [];
73  $cells[] = elgg_format_element('td', [], $name);
74 
75  $number = $value[0] . ($value[1] ? elgg_format_element('span', ['class' => ['elgg-quiet', 'mls']], elgg_echo('status:trashed') . ': ' . $value[1]) : null);
76  $cells[] = elgg_format_element('td', [], $number);
77 
78  $rows[] = elgg_format_element('tr', [], implode('', $cells));
79 }
80 
81 $rows = elgg_format_element('tbody', [], implode(PHP_EOL, $rows));
82 
83 $body = elgg_format_element('table', ['class' => 'elgg-table'], $header . $rows);
84 echo elgg_view_module('info', elgg_echo('admin:statistics:numentities:other'), $body);
$other
Definition: numentities.php:19
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:304
elgg_view_module(string $type, string $title, string $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:919
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
$trashed_stats
Definition: numentities.php:8
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
Database abstraction query builder.
$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
$body
Definition: numentities.php:66
elgg_get_entity_statistics(array $options=[])
Return an array reporting the number of various entities in the system.
Definition: entities.php:661
$value
Definition: generic.php:51
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:53
$header
Definition: numentities.php:47
compare(string $x, string $comparison, $y=null, string $type=null, bool $case_sensitive=null)
Build value comparison clause.
const ELGG_SHOW_DELETED_ENTITIES
Definition: constants.php:136
$searchable
Definition: numentities.php:18
const ELGG_VALUE_STRING
Definition: constants.php:112
$subtype
Definition: delete.php:22
$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:717
$entity_stats
Definition: numentities.php:5
$qb
Definition: queue.php:12