Elgg  Version master
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 
14 
15 $featured_menu_names = elgg_get_config('site_featured_menu_names');
16 
18 /* @var $item \ElggMenuItem */
19 foreach ($menu_items as $item) {
20  $dropdown_values[$item->getName()] = $item->getText();
21 }
22 
23 $dropdown_values[' '] = elgg_echo('none');
24 
25 $configure = elgg_view('output/longtext', [
26  'value' => elgg_echo('admin:menu_items:description'),
27  'class' => 'elgg-text-help',
28 ]);
29 
30 $fields = [];
31 for ($i = 0; $i < $num_featured_items; $i++) {
32  if ($featured_menu_names && array_key_exists($i, $featured_menu_names)) {
33  $current_value = $featured_menu_names[$i];
34  } else {
35  $current_value = ' ';
36  }
37 
38  $fields[] = [
39  '#type' => 'select',
40  'options_values' => $dropdown_values,
41  'name' => 'featured_menu_names[]',
42  'value' => $current_value,
43  ];
44 }
45 
47  '#type' => 'fieldset',
48  'class' => 'elgg-fieldset-wrap',
49  'align' => 'horizontal',
50  'fields' => $fields,
51 ]);
52 
53 echo elgg_view_module('info', elgg_echo('admin:menu_items:configure'), $configure);
54 
55 $add_menu = elgg_view('output/longtext', [
56  'value' => elgg_echo('admin:add_menu_item:description'),
57  'class' => 'elgg-text-help',
58 ]);
59 
60 $custom_items = (array) elgg_get_config('site_custom_menu_items');
61 $custom_items[''] = ''; // add empty option
62 
63 $name_str = elgg_echo('name');
64 $url_str = elgg_echo('admin:plugins:label:website');
65 
66 foreach ($custom_items as $title => $url) {
68  '#type' => 'fieldset',
69  'align' => 'horizontal',
70  'fields' => [
71  [
72  '#type' => 'text',
73  '#label' => $name_str,
74  'name' => 'custom_menu_titles[]',
75  'value' => $title,
76  ],
77  [
78  '#type' => 'text',
79  '#label' => $url_str,
80  'name' => 'custom_menu_urls[]',
81  'value' => $url,
82  ]
83  ],
84  ]);
85 }
86 
87 echo elgg_view_module('info', elgg_echo('admin:add_menu_item'), $add_menu);
88 
90  '#type' => 'submit',
91  'value' => elgg_echo('save'),
92 ]);
93 
if(!$items) $item
Definition: delete.php:13
$dropdown_values
Definition: save.php:17
elgg_view_module(string $type, string $title, string $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:940
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1133
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
$custom_items
Definition: save.php:60
$title
Definition: generic.php:50
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$num_featured_items
Definition: save.php:13
$footer
Definition: save.php:89
$name_str
Definition: save.php:63
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
$featured_menu_names
Definition: save.php:15
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:177
elgg_set_form_footer(string $footer= '')
Sets form footer and defers its rendering until the form view and extensions have been rendered...
Definition: views.php:1067
$menu_items
Definition: save.php:11
$fields
Definition: save.php:30
$menu
Form body for setting up site menu.
Definition: save.php:7
$add_menu
Definition: save.php:55
$configure
Definition: save.php:25
$vars['type']
Plugin user settings.
Definition: save.php:8
foreach($plugin_guids as $guid) if(empty($deactivated_plugins)) $url
Definition: deactivate.php:39
var elgg
Definition: elgglib.js:4
$url_str
Definition: save.php:64