aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/ThemeUtils.php
blob: 16f2f6a2742c701f79d671bcf4d89359584fc4d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?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)
    {
        $tplDir = rtrim($tplDir, '/');
        $allTheme = glob($tplDir.'/*', GLOB_ONLYDIR);
        $themes = [];
        foreach ($allTheme as $value) {
            $themes[] = str_replace($tplDir.'/', '', $value);
        }

        return $themes;
    }
}