From 5c0ca92a2e3b9f50eba034c345295df8bb690d75 Mon Sep 17 00:00:00 2001 From: Awilum Date: Tue, 25 Dec 2018 20:46:07 +0300 Subject: [PATCH] Themes: getPartials() method added --- flextype/Themes.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/flextype/Themes.php b/flextype/Themes.php index f6b17194..e793b95d 100644 --- a/flextype/Themes.php +++ b/flextype/Themes.php @@ -114,6 +114,33 @@ class Themes return new View($template, $variables); } + /** + * Get partials for current theme + * + * @access public + * @return array + */ + public static function getPartials() : array + { + $partials = []; + + // Get templates files + $_partials = Filesystem::getFilesList(PATH['themes'] . '/' . Registry::get('settings.theme') . '/views/partials/', 'php'); + + // If there is any template file then go... + if (count($_partials) > 0) { + foreach ($_partials as $partial) { + if (!is_bool(Themes::_strrevpos($partial, '/partials/'))) { + $partial_name = str_replace('.php', '', substr($partial, Themes::_strrevpos($partial, '/partials/')+strlen('/partials/'))); + $partials[$partial_name] = $partial_name; + } + } + } + + // return partials + return $partials; + } + /** * Get templates for current theme *