]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Added support for screenshots in the advanced plugin admin.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 4 Feb 2011 23:03:32 +0000 (23:03 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 4 Feb 2011 23:03:32 +0000 (23:03 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8021 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/admin.php
views/default/admin/components/plugin.php
views/default/css/admin.php

index c3dfb7b847761e403188d12b4d50950003d0af18..0e6eab0cf3e1c4abd4f94252d8409c0d1b13ea19 100644 (file)
@@ -87,9 +87,9 @@ function admin_init() {
 
        elgg_register_action('admin/site/update_basic', '', 'admin');
        elgg_register_action('admin/site/update_advanced', '', 'admin');
-       
+
        elgg_register_action('admin/menu/save', '', 'admin');
-       
+
        elgg_register_action('admin/plugins/simple_update_states', '', 'admin');
 
        elgg_register_action('profile/fields/reset', '', 'admin');
@@ -145,6 +145,7 @@ function admin_init() {
        }
 
        register_page_handler('admin', 'admin_settings_page_handler');
+       register_page_handler('admin_plugin_screenshot', 'admin_plugin_screenshot_page_handler');
 }
 
 /**
@@ -223,6 +224,52 @@ function admin_settings_page_handler($page) {
        echo elgg_view_page($title, $body, 'admin');
 }
 
+/**
+ * Serves up screenshots for plugins from
+ * elgg/pg/admin_plugin_ss/<plugin_id>/<size>/<ss_name>.<ext>
+ *
+ * @param array $pages The pages array
+ * @return true
+ */
+function admin_plugin_screenshot_page_handler($pages) {
+       admin_gatekeeper();
+
+       $plugin_id = elgg_get_array_value(0, $pages);
+       // only thumbnail or full.
+       $size = elgg_get_array_value(1, $pages, 'thumbnail');
+
+       // the rest of the string is the filename
+       $filename_parts = array_slice($pages, 2);
+       $filename = implode('/', $filename_parts);
+       $filename = sanitise_filepath($filename, false);
+
+       $plugin = new ElggPlugin($plugin_id);
+       if (!$plugin) {
+               $file = elgg_get_root_dir() . '_graphics/icons/default/medium.png';
+       } else {
+               $file = $plugin->getPath() . $filename;
+               if (!file_exists($file)) {
+                       $file = elgg_get_root_dir() . '_graphics/icons/default/medium.png';
+               }
+       }
+
+       header("Content-type: image/jpeg");
+
+       // resize to 100x100 for thumbnails
+       switch ($size) {
+               case 'thumbnail':
+                       echo get_resized_image_from_existing_file($file, 100, 100, true);
+                       break;
+
+               case 'full':
+               default:
+                       echo file_get_contents($file);
+                       break;
+       }
+
+       return true;
+}
+
 /**
  * Write a persistent message to the admin view.
  * Useful to alert the admin to take a certain action.
index 4c6a8b756592f8c6c25ced137a757cf6ff4ee519..0185ba0ff92cecc3df7cf48aca23dabec8ffea41 100644 (file)
@@ -124,20 +124,15 @@ if ($categories) {
 
 // @todo We need to make a page handler to read these files in.
 // this is broken.
-$screenshot_html = '';
+$screenshots_html = '';
 $screenshots = $plugin->manifest->getScreenshots();
 if ($screenshots) {
        $base_url = elgg_get_plugins_path() . $plugin->getID() . '/';
-       $limit = 4;
        foreach ($screenshots as $screenshot) {
-               if ($limit <= 0) {
-                       break;
-               }
-
-               $screenshot_src = $plugin->getPath() . $screenshot['path'];
-               $screenshots .= "<li class=\"plugin-screenshot\"><a href=\"$screenshot_src\"><img src=\"$screenshot_src\"></a></li>";
+               $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']}";
 
-               $limit--;
+               $screenshots_html .= "<li class=\"elgg-plugin-screenshot prm ptm\"><a href=\"$screenshot_full\"><img src=\"$screenshot_src\"></a></li>";
        }
 }
 
@@ -189,7 +184,7 @@ if (elgg_view_exists($settings_view)) {
                }
                ?>
 
-               <p><a class="manifest_details small link"><?php echo elgg_echo("admin:plugins:label:moreinfo"); ?></a></p>
+               <div class="pts"><a class="manifest_details small link"><?php echo elgg_echo("admin:plugins:label:moreinfo"); ?></a></div>
 
                <div class="manifest_file hidden">
 
@@ -201,9 +196,9 @@ if (elgg_view_exists($settings_view)) {
                        <?php
                }
 
-               if ($screenshots) {
+               if ($screenshots_html) {
                        ?>
-                       <div><ul><?php echo $screenshots; ?></ul></div>
+                       <div><ul><?php echo $screenshots_html; ?></ul></div>
                        <?php
                }
                ?>
index 4376ca41a7fb7440c7a8d0c7226c3f840da21ed7..99ac0f455b8e4fd7900884a71bc59f845faea640 100644 (file)
@@ -128,7 +128,7 @@ table.mceLayout {
        width:100% !important;
 }
 
-.clearfloat { 
+.clearfloat {
        clear:both;
 }
 
@@ -960,6 +960,9 @@ ul.admin_plugins {
 .elgg-unsatisfied-dependency {
        font-weight: bold;
 }
+.elgg-plugin-screenshot {
+       display: inline;
+}
 .active {
        border:1px solid #999999;
        background:white;