From f2123cdc42c8da21a297158fbb655f72bc92edce Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 5 Jan 2011 04:36:07 +0000 Subject: 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 --- views/default/admin/components/plugin.php | 246 +++++++++++++++++++----------- 1 file changed, 156 insertions(+), 90 deletions(-) (limited to 'views/default/admin/components/plugin.php') 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 = '' . elgg_echo('top') . ''; - - $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 = '' . elgg_echo('up') . ''; +$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 = '' . elgg_echo('down') . ''; - - $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 = '' . elgg_echo('bottom') . ''; +// 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 = '' . elgg_echo('disable') . ''; +// 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 = '' . elgg_echo('enable') . ''; + $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[] = "" . htmlspecialchars($category) . ''; } - $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 .= "
  • "; + $screenshot_src = $plugin->getPath() . $screenshot['path']; + $screenshots .= "
  • "; $limit--; } } +// metadata +$description = elgg_view('output/longtext', array('value' => $plugin->manifest->getDescription())); +$author = '' . elgg_echo('admin:plugins:label:author') . ': ' + . 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())); + ?>
    - +
    -
    +
    - [". elgg_echo('settings') ."]"; - } - ?> -

    - getID() . '/edit'; +if (elgg_view_exists($settings_view)) { + $link = elgg_get_site_url() . "pg/admin/plugin_settings/" . $plugin->getID(); + $settings_link = "[" . elgg_echo('settings') . "]"; +} +?> +

    manifest->getName() . " $version $settings_link"; ?>

    +
    +

    + + manifest->getApiVersion() < 1.8) { + $reqs = $plugin->manifest->getRequires(); + if (!$reqs) { + $message = elgg_echo('admin:plugins:warning:elgg_version_unknown'); + echo "

    $message

    "; + } + } - if ($manifest) { + if (!$can_activate) { + $message = elgg_echo('admin:plugins:warning:unmet_dependencies'); + echo "

    $message

    "; + } ?> -
    $manifest['description'])); ?>
    -

    : ". htmlspecialchars($manifest['author']) ?>

    -

    : ". htmlspecialchars($manifest['version']) ?>

    \ No newline at end of file -- cgit v1.2.3