PageRenderTime 37ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/theme/formal_white/lib.php

https://github.com/mylescarrick/moodle
PHP | 92 lines | 52 code | 8 blank | 32 comment | 9 complexity | 2ada744b8fd0bee8b17138fa6c14fa6b MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1, BSD-3-Clause
  1. <?php
  2. /**
  3. * Makes our changes to the CSS
  4. *
  5. * @param string $css
  6. * @param theme_config $theme
  7. * @return string
  8. */
  9. function formalwhite_process_css($css, $theme) {
  10. // Set the background color
  11. if (!empty($theme->settings->backgroundcolor)) {
  12. $backgroundcolor = $theme->settings->backgroundcolor;
  13. } else {
  14. $backgroundcolor = null;
  15. }
  16. $css = formalwhite_set_backgroundcolor($css, $backgroundcolor);
  17. // Set the region width
  18. if (!empty($theme->settings->regionwidth)) {
  19. $regionwidth = $theme->settings->regionwidth;
  20. } else {
  21. $regionwidth = null;
  22. }
  23. $css = formalwhite_set_regionwidth($css, $regionwidth);
  24. // Set the custom CSS
  25. if (!empty($theme->settings->customcss)) {
  26. $customcss = $theme->settings->customcss;
  27. } else {
  28. $customcss = null;
  29. }
  30. $css = formalwhite_set_customcss($css, $customcss);
  31. // Return the CSS
  32. return $css;
  33. }
  34. /**
  35. * Sets the background colour variable in CSS
  36. *
  37. * @param string $css
  38. * @param mixed $backgroundcolor
  39. * @return string
  40. */
  41. function formalwhite_set_backgroundcolor($css, $backgroundcolor) {
  42. $tag = '[[setting:backgroundcolor]]';
  43. $replacement = $backgroundcolor;
  44. if (is_null($replacement)) {
  45. $replacement = '#F7F6F1';
  46. }
  47. $css = str_replace($tag, $replacement, $css);
  48. return $css;
  49. }
  50. /**
  51. * Sets the region width variable in CSS
  52. *
  53. * @param string $css
  54. * @param mixed $regionwidth
  55. * @return string
  56. */
  57. function formalwhite_set_regionwidth($css, $regionwidth) {
  58. $tag = '[[setting:regionwidth]]';
  59. $doubletag = '[[setting:regionwidthdouble]]';
  60. $replacement = $regionwidth;
  61. if (is_null($replacement)) {
  62. $replacement = 200;
  63. }
  64. $css = str_replace($tag, $replacement.'px', $css);
  65. $css = str_replace($doubletag, ($replacement*2).'px', $css);
  66. $css = str_replace($tag, ($replacement+10).'px', $css);
  67. return $css;
  68. }
  69. /**
  70. * Sets the custom css variable in CSS
  71. *
  72. * @param string $css
  73. * @param mixed $customcss
  74. * @return string
  75. */
  76. function formalwhite_set_customcss($css, $customcss) {
  77. $tag = '[[setting:customcss]]';
  78. $replacement = $customcss;
  79. if (is_null($replacement)) {
  80. $replacement = '';
  81. }
  82. $css = str_replace($tag, $replacement, $css);
  83. return $css;
  84. }