CourseBlockPlugin.php 2.3 KB

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