aboutsummaryrefslogtreecommitdiff
path: root/views/default/admin/appearance/default_widgets.php
blob: 1bf5791ac1288acb52ec1a1c38a48c76d9c0a766 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
 * Default widgets landing page.
 *
 * @package Elgg.Core
 * @subpackage Administration.DefaultWidgets
 */

$object = elgg_get_entities(array(
	'type' => 'object',
	'subtype' => 'moddefaultwidgets',
	'limit' => 1,
));

if ($object) {
	echo elgg_view('output/url', array(
		'text' => elgg_echo('upgrade'),
		'href' => 'action/widgets/upgrade',
		'is_action' => true,
		'is_trusted' => true,
		'class' => 'elgg_button elgg-button-submit',
		'title' => 'Upgrade your default widgets to work on Elgg 1.8',
	));
}

elgg_push_context('default_widgets');
$widget_context = get_input('widget_context');
$list = elgg_trigger_plugin_hook('get_list', 'default_widgets', null, array());

// default to something if we can
if (!$widget_context && $list) {
	$widget_context = $list[0]['widget_context'];
}

$current_info = null;
$tabs = array();
foreach ($list as $info) {
	$url = "admin/appearance/default_widgets?widget_context={$info['widget_context']}";
	$selected = false;
	if ($widget_context == $info['widget_context']) {
		$selected = true;
		$current_info = $info;
	}

	$tabs[] = array(
		'title' => $info['name'],
		'url' => $url,
		'selected' => $selected
	);
}

$tabs_vars = array(
	'tabs' => $tabs
);

echo elgg_view('navigation/tabs', $tabs_vars);

echo elgg_view('output/longtext', array('value' => elgg_echo('admin:default_widgets:instructions')));

if (!$current_info) {
	$content = elgg_echo('admin:default_widgets:unknown_type');
} else {
	// default widgets are owned and saved to the site.
	elgg_set_page_owner_guid(elgg_get_config('site_guid'));
	elgg_push_context($current_info['widget_context']);

	$default_widgets_input = elgg_view('input/hidden', array(
		'name' => 'default_widgets',
		'value' => 1
	));

	$params = array(
		'content' => $default_widgets_input,
		'num_columns' => $current_info['widget_columns'],
	);

	$content = elgg_view_layout('widgets', $params);
	elgg_pop_context();
}
elgg_pop_context();

echo $content;