aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/admin.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-04-25 18:12:10 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-04-25 18:12:10 +0000
commit113b813b5a5ec8b93ee72d4f259d8e38f9a9c5e4 (patch)
tree1148cbb2db3811082755710097ae1e1504b4535b /engine/lib/admin.php
parent822496eed6a0b1b7e53f5b4104bfa47369f3aaf7 (diff)
downloadelgg-113b813b5a5ec8b93ee72d4f259d8e38f9a9c5e4.tar.gz
elgg-113b813b5a5ec8b93ee72d4f259d8e38f9a9c5e4.tar.bz2
Fixes #2899, #2870. Added README.txt, CHANGES.txt, COPYRIGHT.txt, LICENSE.txt, and INSTALL.txt as markdown files for plugins. Added page handler to parse and serve them. Added links in plugin admin. Refs #3236. Problems with displaying parsed markdown because of missing parts of the admin theme's CSS.
git-svn-id: http://code.elgg.org/elgg/trunk@9022 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/admin.php')
-rw-r--r--engine/lib/admin.php70
1 files changed, 69 insertions, 1 deletions
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index a9a0382cc..06418c44f 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -303,6 +303,7 @@ function admin_init() {
elgg_register_page_handler('admin', 'admin_settings_page_handler');
elgg_register_page_handler('admin_plugin_screenshot', 'admin_plugin_screenshot_page_handler');
+ elgg_register_page_handler('admin_plugin_text_file', 'admin_markdown_page_handler');
}
/**
@@ -446,7 +447,8 @@ function admin_settings_page_handler($page) {
* @return true
*/
function admin_plugin_screenshot_page_handler($pages) {
- admin_gatekeeper(); // only admins can use this - security feature
+ // only admins can use this for security
+ admin_gatekeeper();
$plugin_id = elgg_extract(0, $pages);
// only thumbnail or full.
@@ -485,6 +487,72 @@ function admin_plugin_screenshot_page_handler($pages) {
}
/**
+ * Formats and serves out markdown files from plugins.
+ *
+ * URLs in format like admin_plugin_text_file/<plugin_id>/filename.ext
+ *
+ * The only valid files are:
+ * * README.txt
+ * * CHANGES.txt
+ * * INSTALL.txt
+ * * COPYRIGHT.txt
+ * * LICENSE.txt
+ *
+ * @param type $page
+ */
+function admin_markdown_page_handler($pages) {
+ admin_gatekeeper();
+
+ elgg_set_context('admin');
+
+ elgg_unregister_css('elgg');
+ $url = elgg_get_simplecache_url('js', 'admin');
+ elgg_register_js('elgg.admin', $url);
+ elgg_load_js('elgg.admin');
+ elgg_load_library('elgg:markdown');
+
+ $plugin_id = elgg_extract(0, $pages);
+ $plugin = elgg_get_plugin_from_id($plugin_id);
+ $filename = elgg_extract(1, $pages);
+
+ $error = false;
+
+ if (!$plugin) {
+ $error = elgg_echo('admin:plugins:markdown:unknown_plugin');
+ }
+
+ $text_files = $plugin->getAvailableTextFiles();
+
+ if (!array_key_exists($filename, $text_files)) {
+ $error = elgg_echo('admin:plugins:markdown:unknown_file');
+ }
+
+ $file = $text_files[$filename];
+ $file_contents = file_get_contents($file);
+
+ if (!$file_contents) {
+ $error = elgg_echo('admin:plugins:markdown:unknown_file');
+ }
+
+ if ($error) {
+ $title = $error;
+ $body = elgg_view_layout('admin', array('content' => $error, 'title' => $title));
+ echo elgg_view_page($title, $body, 'admin');
+ return true;
+ }
+
+ $title = $plugin->manifest->getName() . ": $filename";
+ $text = Markdown($file_contents);
+
+ $body = elgg_view_layout('admin', array(
+ 'content' => $text,
+ 'title' => $title
+ ));
+
+ echo elgg_view_page($title, $body, 'admin');
+}
+
+/**
* Adds default admin widgets to the admin dashboard.
*
* @return void