|
1 | 1 | <?php |
| 2 | +/* For licensing terms, see /license.txt */ |
2 | 3 |
|
3 | | -$widget = new SearchCourseWidget(); |
4 | | -$widget->run(); |
| 4 | +if (!function_exists('api_get_path')) { |
| 5 | + require_once __DIR__.'/../../main/inc/global.inc.php'; |
| 6 | +} |
| 7 | + |
| 8 | +require_once __DIR__.'/lib/search_course_plugin.class.php'; |
| 9 | +require_once __DIR__.'/lib/register_course_widget.class.php'; |
| 10 | +require_once __DIR__.'/lib/search_course_widget.class.php'; |
| 11 | + |
| 12 | +$plugin = SearchCoursePlugin::create(); |
| 13 | +$widget = SearchCourseWidget::factory(); |
| 14 | + |
| 15 | +$isDirectRequest = isset($_SERVER['SCRIPT_FILENAME']) |
| 16 | + && realpath((string) $_SERVER['SCRIPT_FILENAME']) === realpath(__FILE__); |
| 17 | + |
| 18 | +$isRenderingOwnFullPage = defined('SEARCH_COURSE_FULL_PAGE_RENDERING') |
| 19 | + && SEARCH_COURSE_FULL_PAGE_RENDERING; |
| 20 | + |
| 21 | +if (!$plugin->isEnabled()) { |
| 22 | + if ($isDirectRequest && !$isRenderingOwnFullPage) { |
| 23 | + api_not_allowed(true); |
| 24 | + } |
| 25 | + |
| 26 | + return; |
| 27 | +} |
| 28 | + |
| 29 | +if ($isRenderingOwnFullPage) { |
| 30 | + return; |
| 31 | +} |
| 32 | + |
| 33 | +if (!$isDirectRequest) { |
| 34 | + echo $widget->renderBlock(); |
| 35 | + |
| 36 | + return; |
| 37 | +} |
| 38 | + |
| 39 | +define('SEARCH_COURSE_FULL_PAGE_RENDERING', true); |
| 40 | + |
| 41 | +$content = ' |
| 42 | + <style> |
| 43 | + body.search-course-full-page [data-search-course-region-block="1"] { |
| 44 | + display: none !important; |
| 45 | + } |
| 46 | + </style> |
| 47 | + <script> |
| 48 | + document.body.classList.add("search-course-full-page"); |
| 49 | + </script>'; |
| 50 | +$content .= $widget->run(); |
| 51 | + |
| 52 | +$template = new Template($plugin->get_title()); |
| 53 | +$template->assign('header', $plugin->get_title()); |
| 54 | +$template->assign('content', $content); |
| 55 | +$template->display_one_col_template(); |
0 commit comments