plugin.ajax.php 870 B

12345678910111213141516171819202122232425262728293031323334
  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. \Chamilo\CoreBundle\Framework\Container::$legacyTemplate = '@ChamiloTheme/Layout/no_layout.html.twig';
  11. switch ($action) {
  12. case 'md_to_html':
  13. $plugin = isset($_GET['plugin']) ? $_GET['plugin'] : '';
  14. $appPlugin = new AppPlugin();
  15. $pluginInfo = $appPlugin->getPluginInfo($plugin);
  16. $html = '';
  17. if (!empty($pluginInfo)) {
  18. $file = api_get_path(SYS_PLUGIN_PATH).$plugin.'/README.md';
  19. if (file_exists($file)) {
  20. $content = file_get_contents($file);
  21. $html = MarkdownExtra::defaultTransform($content);
  22. }
  23. }
  24. echo $html;
  25. break;
  26. }