aboutsummaryrefslogtreecommitdiff
path: root/views/default/admin/plugins_opt/plugin.php
blob: 7a7b10f63b7d3264bae8a4b7aa35a6a21c9323bc (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/**
 * Elgg plugin manifest class
 *
 * This file renders a plugin for the admin screen, including active/deactive, manifest details & display plugin
 * settings.
 *
 * @package Elgg
 * @subpackage Core
 * @author Curverider Ltd
 * @link http://elgg.org/
 */

$plugin = $vars['plugin'];
$details = $vars['details'];

$active = $details['active'];
$manifest = $details['manifest'];

$plugin_pretty_name = (isset($manifest['name'])) ? $manifest['name'] : $plugin;

// Check elgg version if available
$version_check_valid = false;
if ($manifest['elgg_version']) {
	$version_check_valid = check_plugin_compatibility($manifest['elgg_version']);
}

$ts = time();
$token = generate_action_token($ts);
$active_class = ($active) ? 'active' : 'not_active';

$top_url = $up_url = $down_url = $bottom_url = '';
if ($vars['order'] > 10) {
	$top_url = "{$vars['url']}action/admin/plugins/reorder?plugin={$plugin}&order=1&__elgg_token=$token&__elgg_ts=$ts";
	$top_link = '<a href="' . elgg_format_url($top_url) . '">' . elgg_echo('top') . '</a>';

	$order = $vars['order'] - 11;

	$up_url = "{$vars['url']}action/admin/plugins/reorder?plugin={$plugin}&order=$order&__elgg_token=$token&__elgg_ts=$ts";
	$up_link = '<a href="' . elgg_format_url($up_url) . '">' . elgg_echo('up') . '</a>';
}

if ($vars['order'] < $vars['maxorder']) {
	$order =  $vars['order'] + 11;
	$down_url = "{$vars['url']}action/admin/plugins/reorder?plugin={$plugin}&order=$order&__elgg_token=$token&__elgg_ts=$ts";
	$down_link = '<a href="' . elgg_format_url($down_url) . '">' . elgg_echo('down') . '</a>';

	$order = $vars['maxorder'] + 11;
	$bottom_url = "{$vars['url']}action/admin/plugins/reorder?plugin={$plugin}&order=$order&__elgg_token=$token&__elgg_ts=$ts";
	$bottom_link = '<a href="' . elgg_format_url($bottom_url) . '">' . elgg_echo('bottom') . '</a>';
}

if ($active) {
	$url = "{$vars['url']}action/admin/plugins/disable?plugin=$plugin&__elgg_token=$token&__elgg_ts=$ts";
	$enable_disable = '<a class="cancel_button" href="' . elgg_format_url($url) . '">' . elgg_echo('disable') . '</a>';
} else {
	$url = "{$vars['url']}action/admin/plugins/enable?plugin=$plugin&__elgg_token=$token&__elgg_ts=$ts";
	$enable_disable = '<a class="submit_button" href="' . elgg_format_url($url) . '">' . elgg_echo('enable') . '</a>';
}


$categories_list = '';
if ($manifest['category']) {
	$categories_arr = array();
	$base_url = "{$vars['url']}pg/admin/plugins?category=";

	foreach($manifest['category'] as $category) {
		$url = $base_url . urlencode($category);
		$categories_arr[] = "<a href=\"$url\">" . htmlspecialchars($category) . '</a>';
	}

	$categories_list = implode(', ', $categories_arr);
}

$screenshots = '';
if ($manifest['screenshot']) {
	$base_url = "{$vars['url']}mod/";

	$limit = 4;
	foreach ($manifest['screenshot'] as $screenshot) {
		if ($limit <= 0) {
			break;
		}

		$screenshot_src = $base_url . $plugin . "/$screenshot";
		$screenshots .= "<li class=\"plugin_screenshot\"><a href=\"$screenshot_src\"><img src=\"$screenshot_src\"></a></li>";

		$limit--;
	}
}

?>

<div class="plugin_details <?php echo $active_class ?>">
	<div class="admin_plugin_reorder">
	<?php echo "$top_link $up_link $down_link $bottom_link"; ?>
	</div>

	<h3><?php echo "$plugin_pretty_name $settings_link"; ?></h3>

	<div class="clearfloat"></div>
	<div class="admin_plugin_enable_disable"><?php echo $enable_disable; ?></div>

	<?php
	if (elgg_view_exists("settings/{$plugin}/edit")) {
		?>
		<a class="plugin_settings small link">['<?php echo elgg_echo('settings'); ?>']</a>';
		<div class="pluginsettings hidden">
			<div id="$plugin_settings">
				<?php echo elgg_view("object/plugin", array('plugin' => $plugin, 'entity' => find_plugin_settings($plugin))); ?>
			</div>
		</div>
		<?php
	}
	if ($manifest) {
		?>
		<div class="plugin_description"><?php echo elgg_view('output/longtext',array('value' => $manifest['description'])); ?></div>
		<div><span class="plugin_label"><?php echo elgg_echo('admin:plugins:label:author') . "</span>: ". htmlspecialchars($manifest['author']) ?></div>
		<div><span class="plugin_label"><?php echo elgg_echo('admin:plugins:label:version') . "</span>: ". htmlspecialchars($manifest['version']) ?></div>

		<p><a class="manifest_details small link"><?php echo elgg_echo("admin:plugins:label:moreinfo"); ?></a></p>

		<div class="manifest_file hidden">

		<?php
		if ((!$version_check_valid) || (!isset($manifest['elgg_version']))) {
			?>
			<div id="version_check">
				<?php
					if (!isset($manifest['elgg_version'])) {
						echo elgg_echo('admin:plugins:warning:elggversionunknown');
					} else {
						echo elgg_echo('admin:plugins:warning:elggtoolow');
					}
				?>
			</div>
			<?php
		}

		?>
		<div><?php echo elgg_echo('admin:plugins:label:directory') . ": ". htmlspecialchars($plugin) ?></div>
		<?php
		if ($categories_list) {
			?>
			<div><?php echo elgg_echo('admin:plugins:label:categories') . ": ". $categories_list ?></div>
			<?php
		}
		if ($screenshots) {
			?>
			<div><ul><?php echo $screenshots; ?></ul></div>
			<?php
		}
		?>
		<div><?php echo elgg_echo('admin:plugins:label:copyright') . ": ". htmlspecialchars($manifest['copyright']) ?></div>
		<div><?php echo elgg_echo('admin:plugins:label:licence') . ": ". htmlspecialchars($manifest['licence'] . $manifest['license']) ?></div>
		<div><?php echo elgg_echo('admin:plugins:label:website') . ": "; ?><a href="<?php echo $manifest['website']; ?>"><?php echo $manifest['website']; ?></a></div>
	<?php } ?>
	</div>
</div>