aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-04 23:03:32 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-04 23:03:32 +0000
commit2062a91d9ca2f31ccf4cd1eaa338c5190bffe56d (patch)
treea6e2be0a8de0455d11b7091136095fa88a70b8a8 /engine/lib
parent72efb16917eb7c8f4e86b4fdc01eb86e83d5568d (diff)
downloadelgg-2062a91d9ca2f31ccf4cd1eaa338c5190bffe56d.tar.gz
elgg-2062a91d9ca2f31ccf4cd1eaa338c5190bffe56d.tar.bz2
Added support for screenshots in the advanced plugin admin.
git-svn-id: http://code.elgg.org/elgg/trunk@8021 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/admin.php51
1 files changed, 49 insertions, 2 deletions
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index c3dfb7b84..0e6eab0cf 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -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');
}
/**
@@ -224,6 +225,52 @@ function admin_settings_page_handler($page) {
}
/**
+ * 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.
* The id is a unique ID that can be cleared once the admin