Elgg  Version 3.0
save.php
Go to the documentation of this file.
1 <?php
6 // get site menu items
7 $menu = elgg()->menus->getUnpreparedMenu('site', [
8  'sort_by' => 'name',
9 ]);
10 
11 $menu_items = $menu->getItems();
12 
13 $num_featured_items = elgg_extract('num_featured_items', $vars, count($menu_items));
14 
15 $featured_menu_names = elgg_get_config('site_featured_menu_names');
16 
18 foreach ($menu_items as $item) {
19  $dropdown_values[$item->getName()] = $item->getText();
20 }
21 $dropdown_values[' '] = elgg_echo('none');
22 
23 $configure = elgg_view('output/longtext', [
24  'value' => elgg_echo('admin:menu_items:description'),
25  'class' => 'elgg-text-help',
26 ]);
27 
28 $fields = [];
29 for ($i = 0; $i < $num_featured_items; $i++) {
30  if ($featured_menu_names && array_key_exists($i, $featured_menu_names)) {
31  $current_value = $featured_menu_names[$i];
32  } else {
33  $current_value = ' ';
34  }
35 
36  $fields[] = [
37  '#type' => 'select',
38  '#class' => 'is-3',
39  'options_values' => $dropdown_values,
40  'name' => 'featured_menu_names[]',
41  'value' => $current_value,
42  ];
43 }
44 
46  '#type' => 'fieldset',
47  'align' => 'horizontal',
48  'fields' => $fields,
49 ]);
50 
51 echo elgg_view_module('info', elgg_echo('admin:menu_items:configure'), $configure);
52 
53 $add_menu = elgg_view('output/longtext', [
54  'value' => elgg_echo('admin:add_menu_item:description'),
55  'class' => 'elgg-text-help',
56 ]);
57 
58 $custom_items = (array) elgg_get_config('site_custom_menu_items');
59 $custom_items[''] = ''; // add empty option
60 
61 $name_str = elgg_echo('name');
62 $url_str = elgg_echo('admin:plugins:label:website');
63 
64 foreach ($custom_items as $title => $url) {
66  '#type' => 'fieldset',
67  'align' => 'horizontal',
68  'fields' => [
69  [
70  '#type' => 'text',
71  '#label' => $name_str,
72  'name' => 'custom_menu_titles[]',
73  'value' => $title,
74  ],
75  [
76  '#type' => 'text',
77  '#label' => $url_str,
78  'name' => 'custom_menu_urls[]',
79  'value' => $url,
80  ]
81  ],
82  ]);
83 }
84 
85 echo elgg_view_module('info', elgg_echo('admin:add_menu_item'), $add_menu);
86 
88  '#type' => 'submit',
89  'value' => elgg_echo('save'),
90 ]);
91 
$dropdown_values
Definition: save.php:17
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1395
if(!$items) $item
Definition: delete.php:13
$custom_items
Definition: save.php:58
$num_featured_items
Definition: save.php:13
$footer
Definition: save.php:87
$name_str
Definition: save.php:61
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_set_form_footer($footer= '')
Sets form footer and defers its rendering until the form view and extensions have been rendered...
Definition: views.php:1331
$featured_menu_names
Definition: save.php:15
$title
Definition: user.php:20
$menu_items
Definition: save.php:11
elgg_view_module($type, $title, $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:1198
elgg echo
Translates a string.
Definition: languages.js:43
$url
Definition: default.php:33
$fields
Definition: save.php:28
$menu
Form body for setting up site menu.
Definition: save.php:7
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
$add_menu
Definition: save.php:53
$configure
Definition: save.php:23
$vars['type']
Definition: save.php:11
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
var elgg
Definition: elgglib.js:4
elgg_get_config($name, $default=null)
Get an Elgg configuration value.
$url_str
Definition: save.php:62