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