From 00ea6e1ddd446c61c6ccd956989b4b9a1cd60119 Mon Sep 17 00:00:00 2001 From: ewinslow Date: Tue, 22 Feb 2011 00:12:17 +0000 Subject: Refs #2950: Cleanup of plugin-related view structure git-svn-id: http://code.elgg.org/elgg/trunk@8394 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/default/admin/components/invalid_plugin.php | 23 --- views/default/admin/components/plugin.php | 221 -------------------- .../admin/components/plugin_dependencies.php | 49 ----- views/default/admin/components/plugin_settings.php | 25 --- views/default/admin/plugin_settings.php | 25 +++ views/default/admin/plugins/advanced.php | 9 +- views/default/core/settings/tools.php | 18 +- views/default/core/settings/tools/plugin.php | 39 ---- .../forms/admin/plugins/simple_update_states.php | 74 +------ views/default/forms/plugins/usersettings/save.php | 1 + views/default/js/admin.php | 12 +- views/default/object/plugin.php | 18 +- views/default/object/plugin/advanced.php | 223 +++++++++++++++++++++ .../object/plugin/elements/dependencies.php | 49 +++++ views/default/object/plugin/invalid.php | 24 +++ views/default/object/plugin/simple.php | 63 ++++++ 16 files changed, 409 insertions(+), 464 deletions(-) delete mode 100644 views/default/admin/components/invalid_plugin.php delete mode 100644 views/default/admin/components/plugin.php delete mode 100644 views/default/admin/components/plugin_dependencies.php delete mode 100644 views/default/admin/components/plugin_settings.php create mode 100644 views/default/admin/plugin_settings.php delete mode 100644 views/default/core/settings/tools/plugin.php create mode 100644 views/default/object/plugin/advanced.php create mode 100644 views/default/object/plugin/elements/dependencies.php create mode 100644 views/default/object/plugin/invalid.php create mode 100644 views/default/object/plugin/simple.php (limited to 'views') diff --git a/views/default/admin/components/invalid_plugin.php b/views/default/admin/components/invalid_plugin.php deleted file mode 100644 index 97c1bacf4..000000000 --- a/views/default/admin/components/invalid_plugin.php +++ /dev/null @@ -1,23 +0,0 @@ -getID(); -$path = htmlspecialchars($plugin->getPath()); -$message = elgg_echo('admin:plugins:warning:invalid', array($id)); - -?> - -
-

-

-
diff --git a/views/default/admin/components/plugin.php b/views/default/admin/components/plugin.php deleted file mode 100644 index 7549ea8ca..000000000 --- a/views/default/admin/components/plugin.php +++ /dev/null @@ -1,221 +0,0 @@ -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 && $can_activate) ? 'elgg-state-active' : 'elgg-state-inactive'; - -// 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 - )) . "
  • "; -} - -// 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 - )) . "
  • "; -} - -// activate / deactivate links -if ($can_activate) { - if ($active) { - $action = 'deactivate'; - $class = 'elgg-button-cancel'; - } else { - $action = 'activate'; - $class = 'elgg-button-submit'; - } - - $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 { - $action_button = elgg_view('output/url', array( - 'text' => elgg_echo('admin:plugins:cannot_activate'), - 'disabled' => 'disabled', - 'class' => "elgg-button-action elgg-state-disabled" - )); -} - -// Display categories -$categories_html = ''; -if ($categories) { - $categories_arr = array(); - $base_url = elgg_get_site_url() . "pg/admin/plugins?category="; - - foreach ($categories as $category) { - $url = $base_url . urlencode($category); - $categories_arr[] = "" . htmlspecialchars($category) . ''; - } - - $categories_html = implode(', ', $categories_arr); -} - -$screenshots_html = ''; -$screenshots = $plugin->manifest->getScreenshots(); -if ($screenshots) { - $base_url = elgg_get_plugins_path() . $plugin->getID() . '/'; - foreach ($screenshots as $screenshot) { - $desc = elgg_echo($screenshot['description']); - $alt = htmlentities($desc, ENT_QUOTES, 'UTF-8'); - $screenshot_full = "{$vars['url']}pg/admin_plugin_screenshot/{$plugin->getID()}/full/{$screenshot['path']}"; - $screenshot_src = "{$vars['url']}pg/admin_plugin_screenshot/{$plugin->getID()}/thumbnail/{$screenshot['path']}"; - - $screenshots_html .= "
  • " - . "\"$alt\"
  • "; - } -} - -// 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())); - -?> - -
    -
    -
    - -
    - -
    -
    -
    -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 (!$can_activate) { - $message = elgg_echo('admin:plugins:warning:unmet_dependencies'); - echo "

    $message

    "; - } - ?> - -
    -

    - -
    -
    -
    - -
    \ No newline at end of file diff --git a/views/default/admin/components/plugin_dependencies.php b/views/default/admin/components/plugin_dependencies.php deleted file mode 100644 index ea2b3a188..000000000 --- a/views/default/admin/components/plugin_dependencies.php +++ /dev/null @@ -1,49 +0,0 @@ -package->checkDependencies(true); - -$columns = array('type', 'name', 'expected_value', 'local_value', 'comment'); - -echo ' - -'; - -foreach ($columns as $column) { - $column = elgg_echo("admin:plugins:dependencies:$column"); - echo ""; -} - -echo ''; - -$row = 'odd'; -foreach ($deps as $dep) { - $fields = elgg_get_plugin_dependency_strings($dep); - $type = $dep['type']; - - if ($dep['status']) { - $class = "elgg-state-success elgg-dependency-$type"; - } else { - $class = "elgg-state-error elgg-dependency-$type"; - } - - echo ""; - - foreach ($columns as $column) { - echo ""; - } - - echo ''; - - $row = ($row == 'odd') ? 'even' : 'odd'; -} - -echo '
    $column
    {$fields[$column]}
    '; \ No newline at end of file diff --git a/views/default/admin/components/plugin_settings.php b/views/default/admin/components/plugin_settings.php deleted file mode 100644 index c2801cec3..000000000 --- a/views/default/admin/components/plugin_settings.php +++ /dev/null @@ -1,25 +0,0 @@ -getID(); - -// required for plugin settings backward compatibility -$vars['entity'] = $plugin; - -if (elgg_view_exists("settings/$plugin_id/edit")) { - - $title = $plugin->manifest->getName(); - - $params = array('id' => "$plugin_id-settings"); - $body = elgg_view_form("plugins/settings/save", $params, $vars); - - echo elgg_view_module('info', $title, $body); -} \ No newline at end of file diff --git a/views/default/admin/plugin_settings.php b/views/default/admin/plugin_settings.php new file mode 100644 index 000000000..c2801cec3 --- /dev/null +++ b/views/default/admin/plugin_settings.php @@ -0,0 +1,25 @@ +getID(); + +// required for plugin settings backward compatibility +$vars['entity'] = $plugin; + +if (elgg_view_exists("settings/$plugin_id/edit")) { + + $title = $plugin->manifest->getName(); + + $params = array('id' => "$plugin_id-settings"); + $body = elgg_view_form("plugins/settings/save", $params, $vars); + + echo elgg_view_module('info', $title, $body); +} \ No newline at end of file diff --git a/views/default/admin/plugins/advanced.php b/views/default/admin/plugins/advanced.php index 6b32035f3..8b12cd899 100644 --- a/views/default/admin/plugins/advanced.php +++ b/views/default/admin/plugins/advanced.php @@ -82,12 +82,7 @@ $buttons .= $category_form;
    isValid()) ? 'admin/components/plugin' : 'admin/components/invalid_plugin'; - echo elgg_view($view, array( - 'plugin' => $plugin - )); -} + echo elgg_view_entity_list($installed_plugins, 0, 0, 0, true, false, false); + ?>
    \ No newline at end of file diff --git a/views/default/core/settings/tools.php b/views/default/core/settings/tools.php index 73af8d738..3836b7ef1 100644 --- a/views/default/core/settings/tools.php +++ b/views/default/core/settings/tools.php @@ -9,9 +9,10 @@ */ // Description of what's going on -echo "
    " - . elgg_view('output/longtext', array('value' => elgg_echo("usersettings:plugins:description"))) - . "
    "; +echo elgg_view('output/longtext', array( + 'value' => elgg_echo("usersettings:plugins:description"), + 'class' => 'user-settings mtm', +)); $limit = get_input('limit', 10); $offset = get_input('offset', 0); @@ -20,10 +21,13 @@ $offset = get_input('offset', 0); $installed_plugins = $vars['installed_plugins']; $count = count($installed_plugins); -// Display list of plugins -$n = 0; + +// Display all plugins' usersettings forms foreach ($installed_plugins as $plugin) { - if ($plugin->isActive()) { - echo elgg_view("core/settings/tools/plugin", array('plugin' => $plugin)); + $plugin_id = $plugin->getID(); + if ($plugin->isActive() && elgg_view_exists("usersettings/$plugin_id/edit")) { + $title = $plugin->manifest->getName(); + $body = elgg_view_form('plugins/usersettings/save', array(), array('entity' => $plugin)); + echo elgg_view_module('info', $title, $body); } } \ No newline at end of file diff --git a/views/default/core/settings/tools/plugin.php b/views/default/core/settings/tools/plugin.php deleted file mode 100644 index 88d366a8a..000000000 --- a/views/default/core/settings/tools/plugin.php +++ /dev/null @@ -1,39 +0,0 @@ -getID(); -$user_guid = $vars['user_guid']; - -if (!$user_guid) { - $user_guid = elgg_get_logged_in_user_guid(); -} - -if (elgg_view("usersettings/$plugin_id/edit")) { -?> - -
    -
    -

    manifest->getName(); ?>

    -
    -
    -
    - $plugin, - 'entity' => elgg_get_all_plugin_user_settings($plugin_id, $user_guid), - 'type' => 'user' - )); - ?> -
    -
    -
    - -___END; - -$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 = 'elgg-state-active'; - $checked = 'checked="checked"'; - } else { - $active_class = 'elgg-state-inactive'; - $checked = ''; - } - - if ($can_activate) { - $disabled = ''; - } else { - $disabled = 'disabled="disabled"'; - $description .= '

    ' . elgg_echo('admin:plugins:simple:cannot_activate') . '

    '; - } - - $description = elgg_view('output/longtext', array('value' => $description)); - - $plugin_footer = '"; - - echo <<<___END -
  • -
    -
    - - -
    -
    - $description - $plugin_footer -
    -
    -
  • -___END; -} - -echo ''; +echo elgg_view_entity_list($plugin_list, 0, 0, 0, false, false, false); echo elgg_view('input/submit', array('value' => elgg_echo('save'))); echo elgg_view('input/reset', array('value' => elgg_echo('reset'))); diff --git a/views/default/forms/plugins/usersettings/save.php b/views/default/forms/plugins/usersettings/save.php index 8532cdfd1..bf243ae6b 100644 --- a/views/default/forms/plugins/usersettings/save.php +++ b/views/default/forms/plugins/usersettings/save.php @@ -1,4 +1,5 @@ - $('a.manifest_details.link').click(function() { - elgg_slide_toggle($(this), '.elgg-plugin', '.manifest_file'); - }); - // plugin screenshot modal $('.elgg-plugin-screenshot a').click(elgg.admin.displayPluginScreenshot); // draggable plugin reordering - $('#elgg-plugin-list').sortable({ - items: 'div.elgg-state-draggable', - handle: 'h3.elgg-head', + $('#elgg-plugin-list > ul').sortable({ + items: 'li:has(> .elgg-state-draggable)', + handle: '.elgg-head', forcePlaceholderSize: true, placeholder: 'elgg-widget-placeholder', opacity: 0.8, diff --git a/views/default/object/plugin.php b/views/default/object/plugin.php index e9cacca35..af1ccd677 100644 --- a/views/default/object/plugin.php +++ b/views/default/object/plugin.php @@ -5,18 +5,14 @@ * @package Elgg.Core * @subpackage Plugins * - * @todo This view really should be used to display visualization on the admin panel, \ - * rather than emitting the settings forms */ -// Do we want to show admin settings or user settings -$type = elgg_extract('type', $vars, ''); +$plugin = $vars['entity']; -if ($type != 'user') { - $type = ''; +if (!$plugin->isValid()) { + echo elgg_view('object/plugin/invalid', $vars); +} elseif ($vars['full']) { + echo elgg_view('object/plugin/advanced', $vars); +} else { + echo elgg_view('object/plugin/simple', $vars); } - -?> -
    - -
    \ No newline at end of file diff --git a/views/default/object/plugin/advanced.php b/views/default/object/plugin/advanced.php new file mode 100644 index 000000000..f6a760af4 --- /dev/null +++ b/views/default/object/plugin/advanced.php @@ -0,0 +1,223 @@ +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 && $can_activate) ? 'elgg-state-active' : 'elgg-state-inactive'; + +// 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 + )) . "
  • "; +} + +// 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 + )) . "
  • "; +} + +// activate / deactivate links +if ($can_activate) { + if ($active) { + $action = 'deactivate'; + $class = 'elgg-button-cancel'; + } else { + $action = 'activate'; + $class = 'elgg-button-submit'; + } + + $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 { + $action_button = elgg_view('output/url', array( + 'text' => elgg_echo('admin:plugins:cannot_activate'), + 'disabled' => 'disabled', + 'class' => "elgg-button-action elgg-state-disabled" + )); +} + +// Display categories +$categories_html = ''; +if ($categories) { + $categories_arr = array(); + $base_url = elgg_get_site_url() . "pg/admin/plugins?category="; + + foreach ($categories as $category) { + $url = $base_url . urlencode($category); + $categories_arr[] = "" . htmlspecialchars($category) . ''; + } + + $categories_html = implode(', ', $categories_arr); +} + +$screenshots_html = ''; +$screenshots = $plugin->manifest->getScreenshots(); +if ($screenshots) { + $base_url = elgg_get_plugins_path() . $plugin->getID() . '/'; + foreach ($screenshots as $screenshot) { + $desc = elgg_echo($screenshot['description']); + $alt = htmlentities($desc, ENT_QUOTES, 'UTF-8'); + $screenshot_full = "{$vars['url']}pg/admin_plugin_screenshot/{$plugin->getID()}/full/{$screenshot['path']}"; + $screenshot_src = "{$vars['url']}pg/admin_plugin_screenshot/{$plugin->getID()}/thumbnail/{$screenshot['path']}"; + + $screenshots_html .= "
  • " + . "\"$alt\"
  • "; + } +} + +// 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())); + +?> + +
    +
    +
    + +
    + +
    +
    +
    +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 (!$can_activate) { + $message = elgg_echo('admin:plugins:warning:unmet_dependencies'); + echo "

    $message

    "; + } + ?> + +
    +

    + +
    +
    +
    + +
    \ No newline at end of file diff --git a/views/default/object/plugin/elements/dependencies.php b/views/default/object/plugin/elements/dependencies.php new file mode 100644 index 000000000..ea2b3a188 --- /dev/null +++ b/views/default/object/plugin/elements/dependencies.php @@ -0,0 +1,49 @@ +package->checkDependencies(true); + +$columns = array('type', 'name', 'expected_value', 'local_value', 'comment'); + +echo ' + +'; + +foreach ($columns as $column) { + $column = elgg_echo("admin:plugins:dependencies:$column"); + echo ""; +} + +echo ''; + +$row = 'odd'; +foreach ($deps as $dep) { + $fields = elgg_get_plugin_dependency_strings($dep); + $type = $dep['type']; + + if ($dep['status']) { + $class = "elgg-state-success elgg-dependency-$type"; + } else { + $class = "elgg-state-error elgg-dependency-$type"; + } + + echo ""; + + foreach ($columns as $column) { + echo ""; + } + + echo ''; + + $row = ($row == 'odd') ? 'even' : 'odd'; +} + +echo '
    $column
    {$fields[$column]}
    '; \ No newline at end of file diff --git a/views/default/object/plugin/invalid.php b/views/default/object/plugin/invalid.php new file mode 100644 index 000000000..7fd5d6f5e --- /dev/null +++ b/views/default/object/plugin/invalid.php @@ -0,0 +1,24 @@ +getID(); +$path = htmlspecialchars($plugin->getPath()); +$message = elgg_echo('admin:plugins:warning:invalid', array($id)); + +?> + +
    +

    +

    +
    diff --git a/views/default/object/plugin/simple.php b/views/default/object/plugin/simple.php new file mode 100644 index 000000000..49ef58313 --- /dev/null +++ b/views/default/object/plugin/simple.php @@ -0,0 +1,63 @@ +guid; +$plugin_id = $plugin->getID(); +$active = $plugin->isActive(); +$can_activate = $plugin->canActivate(); +$name = $plugin->manifest->getName(); +$author = $plugin->manifest->getAuthor(); +$version = $plugin->manifest->getVersion(); +$website = $plugin->manifest->getWebsite(); +$description = $plugin->manifest->getDescription(); + +if ($active) { + $active_class = 'elgg-state-active'; + $checked = 'checked="checked"'; +} else { + $active_class = 'elgg-state-inactive'; + $checked = ''; +} + +if ($can_activate) { + $disabled = ''; +} else { + $disabled = 'disabled="disabled"'; + $description .= '

    ' . elgg_echo('admin:plugins:simple:cannot_activate') . '

    '; +} + +$description = elgg_view('output/longtext', array('value' => $description)); + +$plugin_footer = '"; + +echo <<<___END +
    +
    + + +
    +
    + $description + $plugin_footer +
    +
    +___END; -- cgit v1.2.3