CourseBlockPlugin.php 2.4 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 = array(
  12. array(
  13. 'name' => 'course_block_pre_footer',
  14. 'type' => 'textarea'
  15. ),
  16. array(
  17. 'name' => 'course_block_footer_left',
  18. 'type' => 'textarea'
  19. ),
  20. array(
  21. 'name' => 'course_block_footer_center',
  22. 'type' => 'textarea'
  23. ),
  24. array(
  25. 'name' => 'course_block_footer_right',
  26. 'type' => 'textarea'
  27. )
  28. );
  29. /**
  30. * @return CourseBlockPlugin
  31. */
  32. public static function create()
  33. {
  34. static $result = null;
  35. return $result ? $result : $result = new self();
  36. }
  37. /**
  38. *
  39. */
  40. protected function __construct()
  41. {
  42. parent::__construct(
  43. '0.1',
  44. 'Julio Montoya',
  45. array(
  46. 'tool_enable' => 'boolean'
  47. )
  48. );
  49. }
  50. public function install()
  51. {
  52. // Installing course settings
  53. $this->install_course_fields_in_all_courses(false);
  54. }
  55. public function uninstall()
  56. {
  57. // Deleting course settings
  58. $this->uninstall_course_fields_in_all_courses();
  59. }
  60. /**
  61. * @param string $region
  62. * @return string
  63. */
  64. public function renderRegion($region)
  65. {
  66. $content = '';
  67. switch ($region) {
  68. case 'footer_left':
  69. $content = api_get_course_setting('course_block_footer_left');
  70. $content = $content === -1 ? '' : $content;
  71. break;
  72. case 'footer_center':
  73. $content = api_get_course_setting('course_block_footer_center');
  74. $content = $content === -1 ? '' : $content;
  75. break;
  76. case 'footer_right':
  77. $content = api_get_course_setting('course_block_footer_right');
  78. $content = $content === -1 ? '' : $content;
  79. break;
  80. case 'pre_footer':
  81. $content = api_get_course_setting('course_block_pre_footer');
  82. $content = $content === -1 ? '' : $content;
  83. break;
  84. }
  85. return $content;
  86. }
  87. }