Elgg  Version master
categories.php
Go to the documentation of this file.
1 <?php
2 
3 $active_filter = elgg_extract('active_filter', $vars);
4 $categories = (array) elgg_extract('categories', $vars);
5 if (empty($categories)) {
6  return;
7 }
8 
9 asort($categories);
10 
12  'all' => elgg_echo('admin:plugins:category:all'),
13  'active' => elgg_echo('admin:plugins:category:active'),
14  'inactive' => elgg_echo('admin:plugins:category:inactive'),
15 ];
16 
18 
20 foreach ($categories as $key => $category) {
21  if (empty($key)) {
22  continue;
23  }
24 
25  $key = preg_replace('/[^a-z0-9-]/i', '-', elgg_strtolower($key));
26 
27  $list_items .= elgg_view('output/url', [
28  'href' => false,
29  'text' => $category,
30  'rel' => $key,
31  'class' => ($key === $active_filter) ? 'elgg-state-selected' : null,
32  ]);
33 }
34 
35 $body = elgg_format_element('div', ['class' => 'elgg-admin-plugins-categories'], $list_items);
36 
37 echo elgg_view_module('', elgg_echo('filter'), $body);
elgg_view_module(string $type, string $title, string $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:919
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_strtolower()
Wrapper function for mb_strtolower().
Definition: mb_wrapper.php:125
foreach($categories as $key=> $category) $body
Definition: categories.php:35
$common_categories
Definition: categories.php:11
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
$categories
Definition: categories.php:4
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
$list_items
Definition: categories.php:19
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
$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
$active_filter
Definition: categories.php:3