plugin.ajax.php 766 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use \Michelf\MarkdownExtra;
  4. /**
  5. * Responses to AJAX calls
  6. */
  7. require_once __DIR__.'/../global.inc.php';
  8. api_block_anonymous_users();
  9. $action = $_REQUEST['a'];
  10. switch ($action) {
  11. case 'md_to_html':
  12. $plugin = isset($_GET['plugin']) ? $_GET['plugin'] : '';
  13. $appPlugin = new AppPlugin();
  14. $pluginInfo = $appPlugin->getPluginInfo($plugin);
  15. $html = '';
  16. if (!empty($pluginInfo)) {
  17. $file = api_get_path(SYS_PLUGIN_PATH).$plugin.'/README.md';
  18. if (file_exists($file)) {
  19. $content = file_get_contents($file);
  20. $html = MarkdownExtra::defaultTransform($content);
  21. }
  22. }
  23. echo $html;
  24. break;
  25. }