admin_renderer.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. // This file is part of The Bootstrap 3 Moodle theme
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * Renderers to align Moodle's HTML with that expected by Bootstrap
  18. *
  19. * @package theme_bootstrap
  20. * @copyright 2012
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. defined('MOODLE_INTERNAL') || die();
  24. require_once($CFG->dirroot . "/admin/renderer.php");
  25. class theme_bootstrap_core_admin_renderer extends core_admin_renderer {
  26. protected function maturity_info($maturity) {
  27. if ($maturity == MATURITY_STABLE) {
  28. return ''; // No worries.
  29. }
  30. if ($maturity == MATURITY_ALPHA) {
  31. $level = 'notifyproblem';
  32. } else {
  33. $level = 'notifywarning';
  34. }
  35. $maturitylevel = get_string('maturity' . $maturity, 'admin');
  36. $warningtext = get_string('maturitycoreinfo', 'admin', $maturitylevel);
  37. $doclink = $this->doc_link('admin/versions', get_string('morehelp'));
  38. return $this->notification($warningtext . ' ' . $doclink, $level);
  39. }
  40. protected function maturity_warning($maturity) {
  41. if ($maturity == MATURITY_STABLE) {
  42. return ''; // No worries.
  43. }
  44. $maturitylevel = get_string('maturity' . $maturity, 'admin');
  45. $maturitywarning = get_string('maturitycorewarning', 'admin', $maturitylevel);
  46. $maturitywarning .= $this->doc_link('admin/versions', get_string('morehelp'));
  47. return $this->notification($maturitywarning, 'notifyproblem');
  48. }
  49. protected function warning($message, $type = 'warning') {
  50. if ($type == 'warning') {
  51. return $this->notification($message, 'notifywarning');
  52. } else if ($type == 'error') {
  53. return $this->notification($message, 'notifyproblem');
  54. }
  55. }
  56. protected function test_site_warning($testsite) {
  57. if (!$testsite) {
  58. return '';
  59. }
  60. $warningtext = get_string('testsiteupgradewarning', 'admin', $testsite);
  61. return $this->notification($warningtext, 'notifyproblem');
  62. }
  63. protected function release_notes_link() {
  64. $releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases');
  65. return $this->notification($releasenoteslink, 'notifymessage');
  66. }
  67. public function plugins_check_table(core_plugin_manager $pluginman, $version, array $options = array()) {
  68. $html = parent::plugins_check_table($pluginman, $version, $options);
  69. $replacements = array(
  70. 'generaltable' => 'table table-striped',
  71. 'status-missing' => 'danger',
  72. 'status-downgrade' => 'danger',
  73. 'status-upgrade' => 'info',
  74. 'status-delete' => 'info',
  75. 'status-new' => 'success',
  76. );
  77. $find = array_keys($replacements);
  78. $replace = array_values($replacements);
  79. return str_replace($find, $replace, $html);
  80. }
  81. public function environment_check_table($result, $environment) {
  82. $html = parent::environment_check_table($result, $environment);
  83. $replacements = array(
  84. '<span class="ok">' => '<span class="label label-success">',
  85. '<span class="warn">' => '<span class="label label-warning">',
  86. '<span class="error">' => '<span class="label label-danger">',
  87. '<p class="ok">' => '<p class="text-success">',
  88. '<p class="warn">' => '<p class="text-warning">',
  89. '<p class="error">' => '<p class="text-danger">',
  90. );
  91. $find = array_keys($replacements);
  92. $replace = array_values($replacements);
  93. return str_replace($find, $replace, $html);
  94. }
  95. }