|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class CourseBlockPlugin. |
|
7
|
|
|
*/ |
|
8
|
|
|
class CourseBlockPlugin extends Plugin |
|
9
|
|
|
{ |
|
10
|
|
|
public $isCoursePlugin = true; |
|
11
|
|
|
public $addCourseTool = false; |
|
12
|
|
|
|
|
13
|
|
|
// When creating a new course this settings are added to the course |
|
14
|
|
|
public $course_settings = [ |
|
15
|
|
|
[ |
|
16
|
|
|
'name' => 'course_block_pre_footer', |
|
17
|
|
|
'type' => 'textarea', |
|
18
|
|
|
], |
|
19
|
|
|
[ |
|
20
|
|
|
'name' => 'course_block_footer_left', |
|
21
|
|
|
'type' => 'textarea', |
|
22
|
|
|
], |
|
23
|
|
|
[ |
|
24
|
|
|
'name' => 'course_block_footer_center', |
|
25
|
|
|
'type' => 'textarea', |
|
26
|
|
|
], |
|
27
|
|
|
[ |
|
28
|
|
|
'name' => 'course_block_footer_right', |
|
29
|
|
|
'type' => 'textarea', |
|
30
|
|
|
], |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
protected function __construct() |
|
34
|
|
|
{ |
|
35
|
|
|
parent::__construct( |
|
36
|
|
|
'0.1', |
|
37
|
|
|
'Julio Montoya', |
|
38
|
|
|
[ |
|
39
|
|
|
'tool_enable' => 'boolean', |
|
40
|
|
|
] |
|
41
|
|
|
); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return CourseBlockPlugin |
|
46
|
|
|
*/ |
|
47
|
|
|
public static function create() |
|
48
|
|
|
{ |
|
49
|
|
|
static $result = null; |
|
50
|
|
|
|
|
51
|
|
|
return $result ?: $result = new self(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function install() |
|
55
|
|
|
{ |
|
56
|
|
|
// Installing course settings |
|
57
|
|
|
$this->install_course_fields_in_all_courses(false); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function uninstall() |
|
61
|
|
|
{ |
|
62
|
|
|
// Deleting course settings |
|
63
|
|
|
$this->uninstall_course_fields_in_all_courses(); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param string $region |
|
68
|
|
|
* |
|
69
|
|
|
* @return string |
|
70
|
|
|
*/ |
|
71
|
|
|
public function renderRegion($region) |
|
72
|
|
|
{ |
|
73
|
|
|
$content = ''; |
|
74
|
|
|
switch ($region) { |
|
75
|
|
|
case 'footer_left': |
|
76
|
|
|
$content = api_get_course_setting('course_block_footer_left'); |
|
77
|
|
|
$content = -1 === $content ? '' : $content; |
|
78
|
|
|
|
|
79
|
|
|
break; |
|
80
|
|
|
case 'footer_center': |
|
81
|
|
|
$content = api_get_course_setting('course_block_footer_center'); |
|
82
|
|
|
$content = -1 === $content ? '' : $content; |
|
83
|
|
|
|
|
84
|
|
|
break; |
|
85
|
|
|
case 'footer_right': |
|
86
|
|
|
$content = api_get_course_setting('course_block_footer_right'); |
|
87
|
|
|
$content = -1 === $content ? '' : $content; |
|
88
|
|
|
|
|
89
|
|
|
break; |
|
90
|
|
|
case 'pre_footer': |
|
91
|
|
|
$content = api_get_course_setting('course_block_pre_footer'); |
|
92
|
|
|
$content = -1 === $content ? '' : $content; |
|
93
|
|
|
|
|
94
|
|
|
break; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
return $content; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
public function get_name() |
|
101
|
|
|
{ |
|
102
|
|
|
return 'CourseBlock'; |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|