Skip to content

Commit 30192a1

Browse files
Merge pull request #8475 from christianbeeznest/fixes-plugin-searchcourse01
Plugin: Improve SearchCourse plugin integration
2 parents 84d0f6a + 24ab8c7 commit 30192a1

9 files changed

Lines changed: 573 additions & 474 deletions

File tree

public/main/admin/settings.lib.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ function getStablePluginAllowList(): array
333333
'UserRemoteService',
334334
'MigrationMoodle',
335335
'EmbedRegistry',
336+
'SearchCourse',
336337
];
337338
}
338339

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
Search courses plugin
22
===
33

4-
Search courses in the main catalogue and register.
4+
This plugin provides a course catalogue search page and can also be rendered as a portal/home block through Chamilo plugin regions.
5+
6+
Usage
7+
---
8+
9+
1. Install and activate the plugin.
10+
2. Go to `Administration > Settings > Plugins > Plugin regions`.
11+
3. Assign `SearchCourse` to a visible region such as `content_top`, `main_top` or `main_bottom`.
12+
4. The region renders a search box. Submitting the form opens `/plugin/SearchCourse/index.php` with the search results.
13+
14+
The plugin does not create a course tool because it searches courses globally. It should be used as a portal/home block, not inside a specific course.
Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,55 @@
11
<?php
2+
/* For licensing terms, see /license.txt */
23

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();
Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
<?php
2-
/**
3-
* @copyright (c) 2012 University of Geneva
4-
* @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html
5-
* @author Laurent Opprecht <laurent@opprecht.info>
6-
*/
2+
/* For licensing terms, see /license.txt */
3+
74
$strings['plugin_title'] = 'Search Course';
8-
$strings['plugin_comment'] = 'Allow to search the course catalog and register to courses.';
5+
$strings['plugin_comment'] = 'Allow users to search the course catalog and subscribe to available courses.';
6+
$strings['CourseCatalog'] = 'Course catalog';
7+
$strings['Search courses'] = 'Search courses';
8+
$strings['SearchCourseIntro'] = 'Search public and available platform courses by title, code or teacher.';
9+
$strings['SearchByCourseTitleCodeOrTeacher'] = 'Course title, code or teacher';
10+
$strings['SearchResults'] = 'Search results';
11+
$strings['Search results for:'] = 'Search results for: %s';
12+
$strings['CoursesFound'] = '%d course(s) found.';
13+
$strings['Already subscribed'] = 'Already subscribed';
14+
$strings['Subscribing not allowed'] = 'Subscribing not allowed';
15+
$strings['Public'] = 'Public';
16+
$strings['PlatformUsers'] = 'Platform users';
17+
$strings['RegistrationAllowed'] = 'Registration allowed';
18+
$strings['SearchCourseRegionHelp'] = 'Type a keyword to open the course search page with matching results.';
Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
<?php
2-
/**
3-
* @copyright (c) 2012 University of Geneva
4-
* @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html
5-
* @author Laurent Opprecht <laurent@opprecht.info>
6-
*/
2+
/* For licensing terms, see /license.txt */
3+
74
$strings['plugin_title'] = 'Buscar curso';
8-
$strings['plugin_comment'] = 'Permite buscar en el catálogo de cursos e inscribirse en cursos.';
5+
$strings['plugin_comment'] = 'Permite a los usuarios buscar en el catálogo de cursos e inscribirse en cursos disponibles.';
6+
$strings['CourseCatalog'] = 'Catálogo de cursos';
7+
$strings['Search courses'] = 'Buscar cursos';
8+
$strings['SearchCourseIntro'] = 'Busca cursos públicos y disponibles de la plataforma por título, código o profesor.';
9+
$strings['SearchByCourseTitleCodeOrTeacher'] = 'Título, código o profesor del curso';
10+
$strings['SearchResults'] = 'Resultados de búsqueda';
11+
$strings['Search results for:'] = 'Resultados de búsqueda para: %s';
12+
$strings['CoursesFound'] = '%d curso(s) encontrado(s).';
13+
$strings['Already subscribed'] = 'Ya inscrito';
14+
$strings['Subscribing not allowed'] = 'Inscripción no permitida';
15+
$strings['Public'] = 'Público';
16+
$strings['PlatformUsers'] = 'Usuarios de la plataforma';
17+
$strings['RegistrationAllowed'] = 'Inscripción permitida';
18+
$strings['SearchCourseRegionHelp'] = 'Escribe una palabra clave para abrir la página de búsqueda de cursos con resultados relacionados.';

0 commit comments

Comments
 (0)