2017-01-03 12:01:25 +01:00
|
|
|
<?php
|
|
|
|
|
2018-12-03 00:46:04 +01:00
|
|
|
namespace Shaarli\Render;
|
2017-01-03 12:01:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
2017-09-19 20:21:28 +02:00
|
|
|
$tplDir = rtrim($tplDir, '/');
|
2020-09-22 20:25:47 +02:00
|
|
|
$allTheme = glob($tplDir . '/*', GLOB_ONLYDIR);
|
2017-01-03 12:01:25 +01:00
|
|
|
$themes = [];
|
|
|
|
foreach ($allTheme as $value) {
|
2020-09-22 20:25:47 +02:00
|
|
|
$themes[] = str_replace($tplDir . '/', '', $value);
|
2017-01-03 12:01:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $themes;
|
|
|
|
}
|
|
|
|
}
|