/** * 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 array $pages * @return bool * @access private */ function _elgg_admin_markdown_page_handler($pages) { elgg_admin_gatekeeper(); _elgg_admin_add_plugin_settings_menu(); elgg_set_context('admin'); elgg_unregister_css('elgg'); elgg_load_js('elgg.admin'); elgg_load_js('jquery.jeditable'); 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'); $body = elgg_view_layout('admin', array('content' => $error, 'title' => $error)); echo elgg_view_page($error, $body, 'admin'); return true; } $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->getManifest()->getName() . ": {$filename}"; $text = Markdown($file_contents); $body = elgg_view_layout('admin', array('content' => '<div class="elgg-markdown">' . $text . '</div>', 'title' => $title)); echo elgg_view_page($title, $body, 'admin'); return true; }
* * @package Elgg * @subpackage Core * * @uses $vars['head'] Parameters for the <head> element * @uses $vars['body_attrs'] Attributes of the <body> tag * @uses $vars['body'] The main content of the page * @uses $vars['sysmessages'] A 2d array of various message registers, passed from system_messages() */ // backward compatability support for plugins that are not using the new approach // of routing through admin. See reportedcontent plugin for a simple example. if (elgg_get_context() == 'admin') { if (get_input('handler') != 'admin') { elgg_deprecated_notice("admin plugins should route through 'admin'.", 1.8); } _elgg_admin_add_plugin_settings_menu(); elgg_unregister_css('elgg'); echo elgg_view('page/admin', $vars); return true; } // render content before head so that JavaScript and CSS can be loaded. See #4032 $messages = elgg_view('page/elements/messages', array('object' => $vars['sysmessages'])); $header = elgg_view('page/elements/header', $vars); $content = elgg_view('page/elements/body', $vars); $footer = elgg_view('page/elements/footer', $vars); $body = <<<__BODY <div class="elgg-page elgg-page-default"> \t<div class="elgg-page-messages"> \t\t{$messages} \t</div> __BODY;
/** * Handle admin pages. Expects corresponding views as admin/section/subsection * * @param array $page Array of pages * * @return bool * @access private */ function _elgg_admin_page_handler($page) { elgg_admin_gatekeeper(); _elgg_admin_add_plugin_settings_menu(); elgg_set_context('admin'); elgg_unregister_css('elgg'); elgg_require_js('elgg/admin'); elgg_load_js('jquery.jeditable'); // default to dashboard if (!isset($page[0]) || empty($page[0])) { $page = array('dashboard'); } // was going to fix this in the page_handler() function but // it's commented to explicitly return a string if there's a trailing / if (empty($page[count($page) - 1])) { array_pop($page); } $vars = array('page' => $page); // special page for plugin settings since we create the form for them if ($page[0] == 'plugin_settings') { if (isset($page[1]) && (elgg_view_exists("settings/{$page[1]}/edit") || elgg_view_exists("plugins/{$page[1]}/settings"))) { $view = 'admin/plugin_settings'; $plugin = elgg_get_plugin_from_id($page[1]); $vars['plugin'] = $plugin; $title = elgg_echo("admin:{$page[0]}"); } else { forward('', '404'); } } else { $view = 'admin/' . implode('/', $page); $title = elgg_echo("admin:{$page[0]}"); if (count($page) > 1) { $title .= ' : ' . elgg_echo('admin:' . implode(':', $page)); } } // gets content and prevents direct access to 'components' views if ($page[0] == 'components' || !($content = elgg_view($view, $vars))) { $title = elgg_echo('admin:unknown_section'); $content = elgg_echo('admin:unknown_section'); } $body = elgg_view_layout('admin', array('content' => $content, 'title' => $title)); echo elgg_view_page($title, $body, 'admin'); return true; }