]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/ThemeUtils.php
Updater: keep custom theme preference with the new theme setting
[github/shaarli/Shaarli.git] / application / ThemeUtils.php
diff --git a/application/ThemeUtils.php b/application/ThemeUtils.php
new file mode 100644 (file)
index 0000000..2718ed1
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+namespace Shaarli;
+
+/**
+ * Class ThemeUtils
+ *
+ * Utility functions related to theme management.
+ *
+ * @package Shaarli
+ */
+class ThemeUtils
+{
+    /**
+     * Get a list of available themes.
+     *
+     * It will return the name of any directory present in the template folder.
+     *
+     * @param string $tplDir Templates main directory.
+     *
+     * @return array List of theme names.
+     */
+    public static function getThemes($tplDir)
+    {
+        $allTheme = glob($tplDir.'/*', GLOB_ONLYDIR);
+        $themes = [];
+        foreach ($allTheme as $value) {
+            $themes[] = str_replace($tplDir.'/', '', $value);
+        }
+
+        return $themes;
+    }
+}