CourseBlockPlugin.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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
  51. public function install()
  52. {
  53. // Installing course settings
  54. $this->install_course_fields_in_all_courses(false);
  55. }
  56. public function uninstall()
  57. {
  58. // Deleting course settings
  59. $this->uninstall_course_fields_in_all_courses();
  60. }
  61. /**
  62. * @param string $region
  63. * @return string
  64. */
  65. public function renderRegion($region)
  66. {
  67. $content = '';
  68. switch ($region) {
  69. case 'footer_left':
  70. $content = api_get_course_setting('course_block_footer_left');
  71. $content = $content === -1 ? '' : $content;
  72. break;
  73. case 'footer_center':
  74. $content = api_get_course_setting('course_block_footer_center');
  75. $content = $content === -1 ? '' : $content;
  76. break;
  77. case 'footer_right':
  78. $content = api_get_course_setting('course_block_footer_right');
  79. $content = $content === -1 ? '' : $content;
  80. break;
  81. case 'pre_footer':
  82. $content = api_get_course_setting('course_block_pre_footer');
  83. $content = $content === -1 ? '' : $content;
  84. break;
  85. }
  86. return $content;
  87. }
  88. }