ThemeUtils.php 715 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Shaarli;
  3. /**
  4. * Class ThemeUtils
  5. *
  6. * Utility functions related to theme management.
  7. *
  8. * @package Shaarli
  9. */
  10. class ThemeUtils
  11. {
  12. /**
  13. * Get a list of available themes.
  14. *
  15. * It will return the name of any directory present in the template folder.
  16. *
  17. * @param string $tplDir Templates main directory.
  18. *
  19. * @return array List of theme names.
  20. */
  21. public static function getThemes($tplDir)
  22. {
  23. $tplDir = rtrim($tplDir, '/');
  24. $allTheme = glob($tplDir.'/*', GLOB_ONLYDIR);
  25. $themes = [];
  26. foreach ($allTheme as $value) {
  27. $themes[] = str_replace($tplDir.'/', '', $value);
  28. }
  29. return $themes;
  30. }
  31. }