Elgg  Version 2.3
save.php
Go to the documentation of this file.
1 <?php
6 $num_featured_items = elgg_extract('num_featured_items', $vars, 6);
7 
8 // get site menu items
9 $menu = elgg()->menus->getUnpreparedMenu('site', [
10  'sort_by' => 'name',
11 ]);
12 
13 $menu_items = $menu->getItems();
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', ['value' => elgg_echo('admin:menu_items:description')]);
24 
25 for ($i=0; $i < $num_featured_items; $i++) {
26  if ($featured_menu_names && array_key_exists($i, $featured_menu_names)) {
27  $current_value = $featured_menu_names[$i];
28  } else {
29  $current_value = ' ';
30  }
31 
32  $configure .= elgg_view('input/select', [
33  'options_values' => $dropdown_values,
34  'name' => 'featured_menu_names[]',
35  'value' => $current_value,
36  ]);
37 }
38 
39 echo elgg_view_module('inline', elgg_echo('admin:menu_items:configure'), $configure);
40 
41 $custom_items = elgg_get_config('site_custom_menu_items');
42 
43 $name_str = elgg_echo('name');
44 $url_str = elgg_echo('admin:plugins:label:website');
45 
47 if (is_array($custom_items)) {
48  foreach ($custom_items as $title => $url) {
49  $name_input = elgg_view('input/text', [
50  'name' => 'custom_menu_titles[]',
51  'value' => $title,
52  ]);
53 
54  $url_input = elgg_view('input/text', [
55  'name' => 'custom_menu_urls[]',
56  'value' => $url,
57  ]);
58 
59  $add_menu_items .= elgg_format_element('li', [], "$name_str: $name_input $url_str: $url_input $delete");
60  }
61 }
62 
63 $new = elgg_echo('new');
64 $name_input = elgg_view('input/text', ['name' => 'custom_menu_titles[]']);
65 
66 $url_input = elgg_view('input/text', ['name' => 'custom_menu_urls[]']);
67 
69  '#tag_name' => 'li',
70  'class' => 'custom_menuitem',
71  '#text' => "$name_str: $name_input $url_str: $url_input",
72 ]);
73 
74 $add_menu = elgg_view('output/longtext', ['value' => elgg_echo('admin:add_menu_item:description')]);
75 $add_menu .= elgg_format_element('ul', ['class' => 'elgg-list elgg-list-simple'], $add_menu_items);
76 
77 echo elgg_view_module('inline', elgg_echo('admin:add_menu_item'), $add_menu);
78 
79 echo elgg_view('input/submit', ['value' => elgg_echo('save')]);
$dropdown_values
Definition: save.php:17
elgg
Definition: install.js:23
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
if(!$items) $item
Definition: delete.php:17
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$custom_items
Definition: save.php:41
$name_input
Definition: save.php:64
$url_input
Definition: save.php:66
$num_featured_items
Form body for setting up site menu.
Definition: save.php:6
$name_str
Definition: save.php:43
$url
Definition: exceptions.php:24
$title
Definition: save.php:22
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:208
$featured_menu_names
Definition: save.php:15
$menu_items
Definition: save.php:13
if(is_array($custom_items)) $new
Definition: save.php:63
elgg echo
Translates a string.
Definition: languages.js:48
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:336
$menu
Definition: save.php:9
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:1375
elgg_view_module($type, $title, $body, array $vars=array())
Wrapper function for the module display pattern.
Definition: views.php:1250
$add_menu
Definition: save.php:74
$vars['type']
Definition: save.php:11
$add_menu_items
Definition: save.php:46
$url_str
Definition: save.php:44
$configure
Definition: save.php:23