]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #2950: Cleanup of plugin-related view structure
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 22 Feb 2011 00:12:17 +0000 (00:12 +0000)
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 22 Feb 2011 00:12:17 +0000 (00:12 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8394 36083f99-b078-4883-b0ff-0f9b5a30f544

13 files changed:
engine/lib/admin.php
views/default/admin/plugin_settings.php [moved from views/default/admin/components/plugin_settings.php with 100% similarity]
views/default/admin/plugins/advanced.php
views/default/core/settings/tools.php
views/default/core/settings/tools/plugin.php [deleted file]
views/default/forms/admin/plugins/simple_update_states.php
views/default/forms/plugins/usersettings/save.php
views/default/js/admin.php
views/default/object/plugin.php
views/default/object/plugin/advanced.php [moved from views/default/admin/components/plugin.php with 91% similarity]
views/default/object/plugin/elements/dependencies.php [moved from views/default/admin/components/plugin_dependencies.php with 100% similarity]
views/default/object/plugin/invalid.php [moved from views/default/admin/components/invalid_plugin.php with 93% similarity]
views/default/object/plugin/simple.php [new file with mode: 0644]

index f53001b71507d47f1fed044c082169d2c927596b..564c1225b39daf2c51e0784555849b1752d45118 100644 (file)
@@ -303,9 +303,11 @@ function admin_settings_page_handler($page) {
        if ($page[0] == 'plugin_settings' && isset($page[1])
                && elgg_view_exists("settings/{$page[1]}/edit")) {
 
-               $view = '/admin/components/plugin_settings';
+               $view = 'admin/plugin_settings';
                $plugin = elgg_get_plugin_from_id($page[1]);
                $vars['plugin'] = $plugin;
+               
+               // @todo ???
                $title = elgg_echo("admin:plugin_settings:{$page[1]}");
                $title = elgg_echo("admin:{$page[0]}");
        } else {
index 6b32035f31e6767e4219cb6d9cfa7d6067c64b7c..8b12cd899a8e2b4ba2f1464204f9e98572d3bbed 100644 (file)
@@ -82,12 +82,7 @@ $buttons .= $category_form;
 <div id="elgg-plugin-list">
 <?php
 
-// Display list of plugins
-foreach ($installed_plugins as $plugin) {
-       $view = ($plugin->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); 
+
 ?>
 </div>
\ No newline at end of file
index 73af8d738b80a7fd90766b90a45b5ed30986c405..3836b7ef1dbbc45406dbfca1f265792b77b0a72c 100644 (file)
@@ -9,9 +9,10 @@
  */
 
 // Description of what's going on
-echo "<div class='user-settings margin-top'>"
-       . elgg_view('output/longtext', array('value' => elgg_echo("usersettings:plugins:description")))
-       . "</div>";
+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 (file)
index 88d366a..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/**
- * This displays a plugin's user settings.
- *
- * @uses ElggPlugin $vars['plugin'] The plugin to show settings for.
- *
- * @package Elgg.Core
- * @subpackage Plugins.Settings
- */
-
-
-$plugin = $vars['plugin'];
-$plugin_id = $plugin->getID();
-$user_guid = $vars['user_guid'];
-
-if (!$user_guid) {
-       $user_guid = elgg_get_logged_in_user_guid();
-}
-
-if (elgg_view("usersettings/$plugin_id/edit")) {
-?>
-
-<div class="elgg-module elgg-module-info">
-       <div class="elgg-head">
-               <h3><?php echo $plugin->manifest->getName(); ?></h3>
-       </div>
-       <div class="elgg-body">
-               <div id="<?php echo $plugin_id; ?>_settings">
-                       <?php echo elgg_view("object/plugin", array(
-                               'plugin' => $plugin,
-                               'entity' => elgg_get_all_plugin_user_settings($plugin_id, $user_guid),
-                               'type' => 'user'
-                       ));
-                       ?>
-               </div>
-       </div>
-</div>
-<?php
-}
\ No newline at end of file
index bf9f4e4c18ef2335974eb5b008b5ea050aa761d2..938eddb263bda136fd19a0291bf893a600f083a1 100644 (file)
@@ -24,78 +24,6 @@ foreach ($installed_plugins as $plugin) {
 
 ksort($plugin_list);
 
-echo <<<___END
-       <ul>
-___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 .= '<p>' . elgg_echo('admin:plugins:simple:cannot_activate') . '</p>';
-       }
-
-       $description = elgg_view('output/longtext', array('value' => $description));
-
-       $plugin_footer = '<ul class="elgg-menu elgg-menu-footer">';
-       
-       if ($author) {
-               $plugin_footer .= '<li>' . elgg_echo('admin:plugins:author', array($author)) . '</li>';
-       }
-
-       if ($version) {
-               $plugin_footer .= '<li>' . elgg_echo('admin:plugins:version', array($version)) . '</li>';
-       }
-
-       if ($website) {
-               $plugin_footer .= "<li><a href=\"$website\">" . elgg_echo('admin:plugins:plugin_website') . '</a></li>';
-       }
-
-       if (elgg_view_exists("settings/$plugin_id/edit")) {
-               $settings_href = elgg_get_site_url() . "pg/admin/plugin_settings/$plugin_id";
-               $plugin_footer .= "<li><a class='plugin_settings link' href='$settings_href'>" . elgg_echo('settings') . "</a></li>";
-       }
-       
-       $plugin_footer .= "</ul>";
-
-       echo <<<___END
-       <li class="elgg-plugin $active_class">
-               <div class="elgg-grid">
-                       <div class="elgg-col elgg-col-1of5">
-                               <input type="checkbox" id="$plugin_guid" $checked $disabled name="active_plugin_guids[]" value="$plugin_guid"/>
-                               <label for="$plugin_guid">$name</label>
-                       </div>
-                       <div class="elgg-col elgg-col-4of5">
-                               $description
-                               $plugin_footer
-                       </div>
-               </div>
-       </li>
-___END;
-}
-
-echo '</ul>';
+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')));
index 8532cdfd1a0c8486a432f143e56367722f90d603..bf243ae6ba807a9ca373093a6fd8ca86f38590ae 100644 (file)
@@ -1,4 +1,5 @@
 <?php
 $vars['type'] = 'user';
 
+// Can't use elgg_view_form() because it overrides the $vars['action'] parameter
 echo elgg_view('forms/plugins/settings/save', $vars);
\ No newline at end of file
index 603d0f06667f1e9d0b07a6ee2cdcf52512d7b63c..c146597e5b79d175448be0890f57102042199c85 100644 (file)
@@ -8,19 +8,13 @@
 elgg.provide('elgg.admin');
 
 elgg.admin.init = function () {
-       // display manifest info
-       <?php //@todo Use elgg-toggler pattern ?>
-       $('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,
index e9cacca3574879eeaf95258eecb34bfe3523fff9..af1ccd677d5b82e8f4715862db246d5bf49af49c 100644 (file)
@@ -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);
 }
-
-?>
-<div>
-       <?php echo elgg_view_form("plugins/{$type}settings/save", array(), $vars); ?>
-</div>
\ No newline at end of file
similarity index 91%
rename from views/default/admin/components/plugin.php
rename to views/default/object/plugin/advanced.php
index 7549ea8ca94cb53c8412d263fac48a21d40724a6..f6a760af4b6b1b0e93b0ae18cbebad8ef022d943 100644 (file)
@@ -9,7 +9,7 @@
  * @subpackage Plugins
  */
 
-$plugin = $vars['plugin'];
+$plugin = $vars['entity'];
 $priority = $plugin->getPriority();
 $active = $plugin->isActive();
 
@@ -152,12 +152,12 @@ $license = elgg_view('output/text', array('value' => $plugin->manifest->getLicen
 
 ?>
 
-<div id="elgg-plugin-<?php echo $plugin->guid; ?>" class="elgg-state-draggable elgg-plugin <?php echo $active_class ?>">
+<div class="elgg-state-draggable elgg-plugin <?php echo $active_class ?>" id="elgg-plugin-<?php echo $plugin->guid; ?>">
        <div class="elgg-image-block">
                <div class="elgg-image-alt">
-                       <div class="elgg-list-metadata">
+                       <ul class="elgg-list-metadata">
                                <?php echo "$links"; ?>
-                       </div>
+                       </ul>
                        <div class="clearfloat right mtm">
                                <?php echo $action_button; ?>
                        </div>
@@ -170,7 +170,9 @@ if (elgg_view_exists($settings_view)) {
        $settings_link = "<a class='plugin_settings small link' href='$link'>[" . elgg_echo('settings') . "]</a>";
 }
 ?>
-                       <h3 class="elgg-head"><?php echo $plugin->manifest->getName() . " $version $settings_link"; ?></h3>
+                       <div class="elgg-head">
+                               <h3><?php echo $plugin->manifest->getName(). " $version $settings_link"; ?></h3>
+                       </div>
                        <?php
                        if ($plugin->manifest->getApiVersion() < 1.8) {
                                $reqs = $plugin->manifest->getRequires();
@@ -189,10 +191,10 @@ if (elgg_view_exists($settings_view)) {
                        <div class="plugin_description"><?php echo $description; ?></div>
                        <p class="plugin_author"><?php echo $author . ' - ' . $website; ?></p>
        
-                       <div class="pts"><a class="elgg-toggle" id="elgg-toggler-plugin-manifest-<?php echo $plugin->getID(); ?>"><?php echo elgg_echo("admin:plugins:label:moreinfo"); ?></a></div>
+                       <div class="pts"><a class="elgg-toggler elgg-toggles-elgg-plugin-manifest-<?php echo $plugin->getID(); ?>"><?php echo elgg_echo("admin:plugins:label:moreinfo"); ?></a></div>
                </div>
        </div>
-       <div class="hidden manifest_file" id="elgg-togglee-plugin-manifest-<?php echo $plugin->getID(); ?>">
+       <div class="hidden manifest_file" id="elgg-plugin-manifest-<?php echo $plugin->getID(); ?>">
 
                <?php
                if ($screenshots_html) {
similarity index 93%
rename from views/default/admin/components/invalid_plugin.php
rename to views/default/object/plugin/invalid.php
index 97c1bacf40ca72c7ee4fa6bd7107f78b7196b9bd..7fd5d6f5edd46f1135e7c030a8c835ea30b04ae0 100644 (file)
@@ -10,7 +10,8 @@
  * @subpackage Plugins
  */
 
-$plugin = elgg_extract('plugin', $vars);
+$plugin = $vars['entity'];
+
 $id = $plugin->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 (file)
index 0000000..49ef583
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+$plugin = $vars['entity'];
+
+$plugin_guid = $plugin->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 .= '<p>' . elgg_echo('admin:plugins:simple:cannot_activate') . '</p>';
+}
+
+$description = elgg_view('output/longtext', array('value' => $description));
+
+$plugin_footer = '<ul class="elgg-menu elgg-menu-footer">';
+
+if ($author) {
+       $plugin_footer .= '<li>' . elgg_echo('admin:plugins:author', array($author)) . '</li>';
+}
+
+if ($version) {
+       $plugin_footer .= '<li>' . elgg_echo('admin:plugins:version', array($version)) . '</li>';
+}
+
+if ($website) {
+       $plugin_footer .= "<li><a href=\"$website\">" . elgg_echo('admin:plugins:plugin_website') . '</a></li>';
+}
+
+if (elgg_view_exists("settings/$plugin_id/edit")) {
+       $settings_href = elgg_get_site_url() . "pg/admin/plugin_settings/$plugin_id";
+       $plugin_footer .= "<li><a class='plugin_settings link' href='$settings_href'>" . elgg_echo('settings') . "</a></li>";
+}
+
+$plugin_footer .= "</ul>";
+
+echo <<<___END
+       <div class="elgg-plugin $active_class elgg-grid">
+               <div class="elgg-col elgg-col-1of5">
+                       <input type="checkbox" id="$plugin_guid" $checked $disabled name="active_plugin_guids[]" value="$plugin_guid"/>
+                       <label for="$plugin_guid">$name</label>
+               </div>
+               <div class="elgg-col elgg-col-4of5">
+                       $description
+                       $plugin_footer
+               </div>
+       </div>
+___END;