3
* Xibo - Digital Signage - http://www.xibo.org.uk
4
* Copyright (C) 2006-2013 Daniel Garner
6
* This file is part of Xibo.
8
* Xibo is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU Affero General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
13
* Xibo is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Affero General Public License for more details.
18
* You should have received a copy of the GNU Affero General Public License
19
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
21
namespace Xibo\Helper;
25
use Xibo\Exception\ConfigurationException;
26
use Xibo\Factory\MenuFactory;
31
private static $instance = null;
34
private $config = null;
36
public function __construct($theme = NULL)
38
// What is the currently selected theme?
39
$globalTheme = ($theme == NULL) ? Config::GetSetting('GLOBAL_THEME_NAME', 'default') : $theme;
41
// Is this theme valid?
42
if (!is_dir(PROJECT_ROOT . '/web/theme/' . $globalTheme))
43
throw new ConfigurationException(__('The theme "%s" does not exist', $globalTheme));
45
// Store the theme name for later
46
$this->name = $globalTheme;
49
if (!file_exists(PROJECT_ROOT . '/web/theme/' . $this->name . '/config.php'))
50
throw new Exception(__('The theme "%s" config file does not exist', $globalTheme));
52
require(PROJECT_ROOT . '/web/theme/' . $this->name . '/config.php');
53
$this->config = $config;
54
$this->config['themeCode'] = $this->name;
56
self::$instance = $this;
60
* GetInstance of Theme
62
public static function getInstance()
64
if (!isset(self::$instance))
65
self::$instance = new Theme();
67
return self::$instance;
71
* Get Theme Specific Settings
72
* @param null $settingName
73
* @param null $default
76
public static function getConfig($settingName = null, $default = null)
78
$theme = Theme::getInstance();
80
if ($settingName == null)
81
return $theme->config;
83
if (isset($theme->config[$settingName]))
84
return $theme->config[$settingName];
95
public static function uri($uri, $local = false)
97
$rootUri = ($local) ? '' : Slim::getInstance()->rootUri;
99
// Serve the appropriate theme file
100
if (is_dir(PROJECT_ROOT . '/web/theme/' . self::getInstance()->name . '/' . $uri)) {
101
return $rootUri . 'theme/' . self::getInstance()->name . '/' . $uri;
103
else if (file_exists(PROJECT_ROOT . '/web/theme/' . self::getInstance()->name . '/' . $uri)) {
104
return $rootUri . 'theme/' . self::getInstance()->name . '/' . $uri;
107
return $rootUri . 'theme/default/' . $uri;
111
public static function rootUri()
113
return Slim::getInstance()->rootUri;