ThemeUtils.php 676 B

123456789101112131415161718192021222324252627282930313233
  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. $allTheme = glob($tplDir.'/*', GLOB_ONLYDIR);
  24. $themes = [];
  25. foreach ($allTheme as $value) {
  26. $themes[] = str_replace($tplDir.'/', '', $value);
  27. }
  28. return $themes;
  29. }
  30. }