aboutsummaryrefslogtreecommitdiff
path: root/views/default
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-01-05 04:36:07 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-01-05 04:36:07 +0000
commitf2123cdc42c8da21a297158fbb655f72bc92edce (patch)
tree6eb8c0a4492e5dddd29a87ad68a4ecadc7f01230 /views/default
parent252c054437ac1d3ad43aca1e71ebb936b55d60d2 (diff)
downloadelgg-f2123cdc42c8da21a297158fbb655f72bc92edce.tar.gz
elgg-f2123cdc42c8da21a297158fbb655f72bc92edce.tar.bz2
Fixes #2760. Refs #2759. Updated plugin admin actions to use the new system. Added plugin dependency views in admin. ElggPluginPackage->checkDependencies() now returns the detected value.
git-svn-id: http://code.elgg.org/elgg/trunk@7838 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default')
-rw-r--r--views/default/admin/components/plugin.php246
-rw-r--r--views/default/admin/components/plugin_dependencies.php45
-rw-r--r--views/default/admin/plugins/advanced.php43
-rw-r--r--views/default/admin/plugins/simple.php78
4 files changed, 266 insertions, 146 deletions
diff --git a/views/default/admin/components/plugin.php b/views/default/admin/components/plugin.php
index ae611af07..d190e94a5 100644
--- a/views/default/admin/components/plugin.php
+++ b/views/default/admin/components/plugin.php
@@ -2,152 +2,218 @@
/**
* Elgg plugin manifest class
*
- * This file renders a plugin for the admin screen, including active/deactive, manifest details & display plugin
- * settings.
+ * This file renders a plugin for the admin screen, including active/deactive,
+ * manifest details & display plugin settings.
*
- * @package Elgg
- * @subpackage Core
+ * @package Elgg.Core
+ * @subpackage Plugins
*/
$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']);
-}
+$priority = $plugin->getPriority();
+$active = $plugin->isActive();
+$name = $plugin->manifest->getName();
+$can_activate = $plugin->canActivate();
+$max_priority = elgg_get_max_plugin_priority();
+$actions_base = '/action/admin/plugins/';
$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 = elgg_get_site_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 = elgg_get_site_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>';
+$active_class = ($active && $can_activate) ? 'active' : 'not_active';
+
+// build reordering links
+$links = '';
+
+// top and up link only if not at top
+if ($priority > 1) {
+ $top_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
+ 'plugin_guid' => $plugin->guid,
+ 'priority' => 'first',
+ 'is_action' => true
+ ));
+
+ $links .= elgg_view('output/url', array(
+ 'href' => $top_url,
+ 'text' => elgg_echo('top'),
+ 'is_action' => true
+ ));
+
+ $up_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
+ 'plugin_guid' => $plugin->guid,
+ 'priority' => '-1',
+ 'is_action' => true
+ ));
+
+ $links .= elgg_view('output/url', array(
+ 'href' => $up_url,
+ 'text' => elgg_echo('up'),
+ 'is_action' => true
+ ));
}
-if ($vars['order'] < $vars['maxorder']) {
- $order = $vars['order'] + 11;
- $down_url = elgg_get_site_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 = elgg_get_site_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>';
+// down and bottom links only if not at bottom
+if ($priority < $max_priority) {
+ $down_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
+ 'plugin_guid' => $plugin->guid,
+ 'priority' => '+1',
+ 'is_action' => true
+ ));
+
+ $links .= elgg_view('output/url', array(
+ 'href' => $down_url,
+ 'text' => elgg_echo('down'),
+ 'is_action' => true
+ ));
+
+ $bottom_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
+ 'plugin_guid' => $plugin->guid,
+ 'priority' => 'last',
+ 'is_action' => true
+ ));
+
+ $links .= elgg_view('output/url', array(
+ 'href' => $bottom_url,
+ 'text' => elgg_echo('bottom'),
+ 'is_action' => true
+ ));
}
-if ($active) {
- $url = elgg_get_site_url()."action/admin/plugins/disable?plugin=$plugin&__elgg_token=$token&__elgg_ts=$ts";
- $enable_disable = '<a class="elgg-button elgg-cancel-button" href="' . elgg_format_url($url) . '">' . elgg_echo('disable') . '</a>';
+// activate / deactivate links
+if ($can_activate) {
+ if ($active) {
+ $action = 'deactivate';
+ $class = 'elgg-cancel-button';
+ } else {
+ $action = 'activate';
+ $class = 'elgg-submit-button';
+ }
+
+ $url = elgg_http_add_url_query_elements($actions_base . $action, array(
+ 'plugin_guids[]' => $plugin->guid,
+ 'is_action' => true
+ ));
+
+ $action_button = elgg_view('output/url', array(
+ 'href' => $url,
+ 'text' => elgg_echo($action),
+ 'is_action' => true,
+ 'class' => "elgg-button $class"
+ ));
} else {
- $url = elgg_get_site_url()."action/admin/plugins/enable?plugin=$plugin&__elgg_token=$token&__elgg_ts=$ts";
- $enable_disable = '<a class="elgg-button elgg-submit-button" href="' . elgg_format_url($url) . '">' . elgg_echo('enable') . '</a>';
+ $action_button = elgg_view('output/url', array(
+ 'text' => elgg_echo('admin:plugins:cannot_activate'),
+ 'disabled' => 'disabled',
+ 'class' => "elgg-action-button disabled"
+ ));
}
-
-$categories_list = '';
-if ($manifest['category']) {
+// Display categories
+$categories = $plugin->manifest->getCategories();
+$categories_html = '';
+if ($categories) {
$categories_arr = array();
- $base_url = elgg_get_site_url()."pg/admin/plugins?category=";
+ $base_url = elgg_get_site_url() . "pg/admin/plugins?category=";
- foreach($manifest['category'] as $category) {
+ foreach ($categories as $category) {
$url = $base_url . urlencode($category);
$categories_arr[] = "<a href=\"$url\">" . htmlspecialchars($category) . '</a>';
}
- $categories_list = implode(', ', $categories_arr);
+ $categories_html = implode(', ', $categories_arr);
}
-$screenshots = '';
-if ($manifest['screenshot']) {
- $base_url = elgg_get_site_url()."mod/";
-
+// @todo We need to make a page handler to read these files in.
+// this is broken.
+$screenshot_html = '';
+$screenshots = $plugin->manifest->getScreenshots();
+if ($screenshots) {
+ $base_url = elgg_get_plugin_path() . $plugin->getID() . '/';
$limit = 4;
- foreach ($manifest['screenshot'] as $screenshot) {
+ foreach ($screenshots 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>";
+ $screenshot_src = $plugin->getPath() . $screenshot['path'];
+ $screenshots .= "<li class=\"plugin-screenshot\"><a href=\"$screenshot_src\"><img src=\"$screenshot_src\"></a></li>";
$limit--;
}
}
+// metadata
+$description = elgg_view('output/longtext', array('value' => $plugin->manifest->getDescription()));
+$author = '<span>' . elgg_echo('admin:plugins:label:author') . '</span>: '
+ . elgg_view('output/text', array('value' => $plugin->manifest->getAuthor()));
+$version = htmlspecialchars($plugin->manifest->getVersion());
+$website = elgg_view('output/url', array(
+ 'href' => $plugin->manifest->getWebsite(),
+ 'text' => $plugin->manifest->getWebsite()
+));
+
+$copyright = elgg_view('output/text', array('value' => $plugin->manifest->getCopyright()));
+$license = elgg_view('output/text', array('value' => $plugin->manifest->getLicense()));
+
?>
<div class="plugin_details <?php echo $active_class ?>">
<div class="admin_plugin_reorder">
- <?php echo "$top_link $up_link $down_link $bottom_link"; ?>
+ <?php echo "$links"; ?>
</div><div class="clearfloat"></div>
- <div class="admin_plugin_enable_disable"><?php echo $enable_disable; ?></div>
+ <div class="admin_plugin_enable_disable"><?php echo $action_button; ?></div>
- <?php
- if (elgg_view_exists("settings/{$plugin}/edit")) {
- $link = elgg_get_site_url()."pg/admin/plugin_settings/$plugin";
- $settings_link = "<a class='plugin_settings small link' href='$link'>[". elgg_echo('settings') ."]</a>";
- }
- ?>
- <h3><?php echo "$plugin_pretty_name $settings_link"; ?></h3>
- <?php
- echo $settings_panel;
+<?php
+$settings_view = 'settings/' . $plugin->getID() . '/edit';
+if (elgg_view_exists($settings_view)) {
+ $link = elgg_get_site_url() . "pg/admin/plugin_settings/" . $plugin->getID();
+ $settings_link = "<a class='plugin_settings small link' href='$link'>[" . elgg_echo('settings') . "]</a>";
+}
+?>
+ <h3><?php echo $plugin->manifest->getName() . " $version $settings_link"; ?></h3>
+ <div class="plugin_description"><?php echo $description; ?></div>
+ <p class="plugin_author"><?php echo $author . ' - ' . $website; ?></p>
+
+ <?php
+ if ($plugin->manifest->getApiVersion() < 1.8) {
+ $reqs = $plugin->manifest->getRequires();
+ if (!$reqs) {
+ $message = elgg_echo('admin:plugins:warning:elgg_version_unknown');
+ echo "<p class=\"plugin-cannot-activate\">$message</p>";
+ }
+ }
- if ($manifest) {
+ if (!$can_activate) {
+ $message = elgg_echo('admin:plugins:warning:unmet_dependencies');
+ echo "<p class=\"plugin-cannot-activate\">$message</p>";
+ }
?>
- <div class="plugin_description"><?php echo elgg_view('output/longtext',array('value' => $manifest['description'])); ?></div>
- <p class="plugin_author"><span><?php echo elgg_echo('admin:plugins:label:author') . "</span>: ". htmlspecialchars($manifest['author']) ?></p>
- <p class="plugin_version"><span><?php echo elgg_echo('admin:plugins:label:version') . "</span>: ". htmlspecialchars($manifest['version']) ?></p>
<p><a class="manifest_details small link"><?php echo elgg_echo("admin:plugins:label:moreinfo"); ?></a></p>
<div class="manifest_file hidden">
+ <div><?php echo elgg_echo('admin:plugins:label:location') . ": " . htmlspecialchars($plugin->getPath()) ?></div>
<?php
- if ((!$version_check_valid) || (!isset($manifest['elgg_version']))) {
+ if ($categories_html) {
?>
- <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>
+ <div><?php echo elgg_echo('admin:plugins:label:categories') . ": " . $categories_html; ?></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><?php echo elgg_echo('admin:plugins:label:copyright') . ": " . $copyright; ?></div>
+ <div><?php echo elgg_echo('admin:plugins:label:licence') . ": " . $license; ?></div>
+
+ <div><?php echo elgg_echo('admin:plugins:label:dependencies'); ?>:
+ <?php
+ echo elgg_view('admin/components/plugin_dependencies', array('plugin' => $plugin));
+ ?>
+ </div>
</div>
</div> \ No newline at end of file
diff --git a/views/default/admin/components/plugin_dependencies.php b/views/default/admin/components/plugin_dependencies.php
new file mode 100644
index 000000000..9e0e284f1
--- /dev/null
+++ b/views/default/admin/components/plugin_dependencies.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Shows a table of plugin dependecies for ElggPlugin in $vars['plugin'].
+ *
+ * This uses a table because it's a table of data.
+ *
+ * @package Elgg.Core
+ * @subpackage Admin.Plugins
+ */
+
+$plugin = elgg_get_array_value('plugin', $vars, false);
+$deps = $plugin->package->checkDependencies(true);
+
+$columns = array('type', 'name', 'value', 'local_value', 'comment');
+
+echo '<table class="elgg-plugins-dependencies styled">
+ <tr>
+';
+
+foreach ($columns as $column) {
+ $column = elgg_echo("admin:plugins:dependencies:$column");
+ echo "<th>$column</th>";
+}
+
+echo '<tr/>';
+
+foreach ($deps as $dep) {
+ $fields = elgg_get_plugin_dependency_strings($dep);
+
+ if ($dep['status']) {
+ $class = 'elgg-satisfied-dependency';
+ } else {
+ $class = 'elgg-unsatisfied-dependency';
+ }
+
+ echo "<tr class=\"$class\">";
+
+ foreach ($columns as $column) {
+ echo "<td class=\"pam \">{$fields[$column]}</td>";
+ }
+
+ echo '</tr>';
+}
+
+echo '</table>'; \ No newline at end of file
diff --git a/views/default/admin/plugins/advanced.php b/views/default/admin/plugins/advanced.php
index ead930090..1138ace4f 100644
--- a/views/default/admin/plugins/advanced.php
+++ b/views/default/admin/plugins/advanced.php
@@ -4,25 +4,25 @@
*
* Shows a list of all plugins sorted by load order.
*
- * @package Elgg
- * @subpackage Core
+ * @package Elgg.Core
+ * @subpackage Admin.Plugins
*/
-regenerate_plugin_list();
-$installed_plugins = get_installed_plugins();
-$plugin_list = array();
-$show_category = get_input('category', NULL);
+elgg_generate_plugin_entities();
+$installed_plugins = elgg_get_plugins('any');
+$show_category = get_input('category', null);
// Get a list of the all categories
// and trim down the plugin list if we're not viewing all categories.
// @todo this could be cached somewhere after have the manifest loaded
$categories = array();
-foreach ($installed_plugins as $id => $plugin) {
- $plugin_categories = $plugin['manifest']['category'];
+foreach ($installed_plugins as $plugin) {
+ $plugin_categories = $plugin->manifest->getCategories();
// handle plugins that don't declare categories
- if ((!$plugin_categories && $show_category) || ($show_category && !in_array($show_category, $plugin_categories))) {
+ // unset them here because this is the list we foreach
+ if ($show_category && !in_array($show_category, $plugin_categories)) {
unset($installed_plugins[$id]);
}
@@ -57,9 +57,13 @@ $category_form = elgg_view('input/form', array(
// Page Header elements
$title = elgg_view_title(elgg_echo('admin:plugins'));
-// @todo Until "en/disable all" means "All plugins on this page" hide when not looking at all.
+// @todo Until "en/deactivate all" means "All plugins on this page" hide when not looking at all.
if (!isset($show_category) || empty($show_category)) {
- $buttons = "<a class='elgg-action-button' href=\"{$CONFIG->url}action/admin/plugins/enableall?__elgg_token=$token&amp;__elgg_ts=$ts\">".elgg_echo('enableall')."</a> <a class='elgg-action-button disabled' href=\"{$CONFIG->url}action/admin/plugins/disableall?__elgg_token=$token&amp;__elgg_ts=$ts\">".elgg_echo('disableall')."</a> ";
+ $activate_url = "{$CONFIG->url}action/admin/plugins/activate_all?__elgg_token=$token&amp;__elgg_ts=$ts";
+ $deactivate_url = "{$CONFIG->url}action/admin/plugins/deactivate_all?__elgg_token=$token&amp;__elgg_ts=$ts";
+
+ $buttons = "<a class='elgg-action-button' href=\"$activate_url\">" . elgg_echo('admin:plugins:activate_all') . '</a> ';
+ $buttons .= "<a class='elgg-action-button disabled' href=\"$deactivate_url\">" . elgg_echo('admin:plugins:deactivate_all') . '</a> ';
$buttons .= "<br /><br />";
} else {
$buttons = '';
@@ -76,25 +80,12 @@ $buttons .= $category_form;
<br />
<?php
-$limit = get_input('limit', 10);
-$offset = get_input('offset', 0);
-
-$plugin_list = get_plugin_list();
-$max = 0;
-foreach($plugin_list as $key => $foo) {
- if ($key > $max) $max = $key;
-}
-
// Display list of plugins
-$n = 0;
-foreach ($installed_plugins as $plugin => $data) {
+foreach ($installed_plugins as $plugin) {
echo elgg_view('admin/components/plugin', array(
'plugin' => $plugin,
- 'details' => $data,
- 'maxorder' => $max,
- 'order' => array_search($plugin, $plugin_list)
+ 'max_priority' => $max_priority
));
- $n++;
}
?>
<script type="text/javascript">
diff --git a/views/default/admin/plugins/simple.php b/views/default/admin/plugins/simple.php
index e53ecb0c1..d9be51a29 100644
--- a/views/default/admin/plugins/simple.php
+++ b/views/default/admin/plugins/simple.php
@@ -8,22 +8,20 @@
* @subpackage Core
*/
-regenerate_plugin_list();
-$installed_plugins = get_installed_plugins();
+elgg_generate_plugin_entities();
+$installed_plugins = elgg_get_plugins('any');
$plugin_list = array();
$title = elgg_view_title(elgg_echo('admin:plugins'));
-foreach ($installed_plugins as $installed_name => $plugin) {
- if (!isset($plugin['manifest']['admin_interface']) || $plugin['manifest']['admin_interface'] == 'advanced') {
- continue;
+foreach ($installed_plugins as $plugin) {
+ $interface = $plugin->manifest->getAdminInterface();
+ if ($interface == 'simple') {
+ $plugin_list[$plugin->manifest->getName()] = $plugin;
}
-
- $plugin['installed_name'] = $installed_name;
-
- $plugin_list[$plugin['manifest']['name']] = $plugin;
}
ksort($plugin_list);
+
$form_body .= <<<___END
<div id="content_header" class="clearfix">
<div class="content-header-title">$title</div>
@@ -31,10 +29,21 @@ $form_body .= <<<___END
<ul class="admin_plugins margin-top">
___END;
-foreach ($plugin_list as $name => $info) {
- $manifest = $info['manifest'];
- $version_valid = (isset($manifest['elgg_version'])) ? check_plugin_compatibility($manifest['elgg_version']) : FALSE;
- if ($info['active']) {
+$actions_base = '/action/admin/plugins/';
+$ts = time();
+$token = generate_action_token($ts);
+
+foreach ($plugin_list as $name => $plugin) {
+ $plugin_guid = $plugin->guid;
+ $plugin_id = $plugin->getID();
+ $active = $plugin->isActive();
+ $can_activate = $plugin->canActivate();
+ $author = $plugin->manifest->getAuthor();
+ $version = $plugin->manifest->getVersion();
+ $website = $plugin->manifest->getWebsite();
+ $description = $plugin->manifest->getDescription();
+
+ if ($active) {
$active_class = 'active';
$checked = 'checked="checked"';
} else {
@@ -42,41 +51,50 @@ foreach ($plugin_list as $name => $info) {
$checked = '';
}
- $author = $link = $version = $settings = '';
+ if ($can_activate) {
+ $disabled = '';
+ } else {
+ $disabled = 'disabled="disabled"';
+ $description .= '<p>' . elgg_echo('admin:plugins:simple:cannot_activate') . '</p>';
+ }
+
+ $description = elgg_view('output/longtext', array('value' => $description));
+
+ $author_html = $link_html = $version_html = $settings_html = '';
- if (isset($manifest['author'])) {
- $author = elgg_echo('admin:plugins:author', array($manifest['author']));
+ if ($author) {
+ $author_html = elgg_echo('admin:plugins:author', array($author));
}
- if (isset($manifest['version'])) {
- $version = ' | ' . elgg_echo('admin:plugins:version', array($manifest['version']));
+ if ($version) {
+ $version_html = ' | ' . elgg_echo('admin:plugins:version', array($version));
}
- if (isset($manifest['website'])) {
- $link = " | <a href=\"{$manifest['website']}\">" . elgg_echo('admin:plugins:plugin_website') . '</a>';
+ if ($website) {
+ $link_html = " | <a href=\"$website\">" . elgg_echo('admin:plugins:plugin_website') . '</a>';
}
- if (elgg_view_exists("settings/{$info['installed_name']}/edit")) {
- $settings_href = elgg_get_site_url()."pg/admin/plugin_settings/{$info['installed_name']}";
- $settings = " | <a class='plugin_settings link' href='$settings_href'>". elgg_echo('settings') ."</a>";
+ if (elgg_view_exists("settings/$plugin_id/edit")) {
+ $settings_href = elgg_get_site_url() . "pg/admin/plugin_settings/$plugin_id";
+ $settings_html = " | <a class='plugin_settings link' href='$settings_href'>" . elgg_echo('settings') . "</a>";
}
$form_body .= <<<___END
<li class="plugin_details $active_class">
<span class="plugin_controls">
- <input type="checkbox" id="{$info['installed_name']}" class="plugin_enabled" $checked name="enabled_plugins[]" value="{$info['installed_name']}"/>
- <label for="{$info['installed_name']}">$name</label>
+ <input type="checkbox" id="$plugin_guid" class="plugin_enabled" $checked $disabled name="active_plugin_guids[]" value="$plugin_guid"/>
+ <label for="$plugin_guid">$name</label>
</span>
<span class="plugin_info">
<span class="plugin_description">
- {$manifest['description']}
+ $description
</span>
<span class="plugin_metadata small">
- $author
- $version
- $link
- $settings
+ $author_html
+ $version_html
+ $link_html
+ $settings_html
</span>
</span>
</li>