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. // When creating a new course this settings are added to the course
  10. public $course_settings = array(
  11. array(
  12. 'name' => 'course_block_pre_footer',
  13. 'type' => 'textarea'
  14. ),
  15. array(
  16. 'name' => 'course_block_footer_left',
  17. 'type' => 'textarea'
  18. ),
  19. array(
  20. 'name' => 'course_block_footer_center',
  21. 'type' => 'textarea'
  22. ),
  23. array(
  24. 'name' => 'course_block_footer_right',
  25. 'type' => 'textarea'
  26. )
  27. );
  28. /**
  29. * @return CourseBlockPlugin
  30. */
  31. public static function create()
  32. {
  33. static $result = null;
  34. return $result ? $result : $result = new self();
  35. }
  36. /**
  37. *
  38. */
  39. protected function __construct()
  40. {
  41. parent::__construct(
  42. '0.1',
  43. 'Julio Montoya',
  44. array(
  45. 'tool_enable' => 'boolean'
  46. )
  47. );
  48. }
  49. ///public function
  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. }