-
Notifications
You must be signed in to change notification settings - Fork 988
/
AdminTheme.php
69 lines (61 loc) · 2.23 KB
/
AdminTheme.php
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
* LimeSurvey
* Copyright (C) 2007-2015 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
/**
* Admin Theme Model
*
*
* @package LimeSurvey
* @subpackage Backend
*/
class AdminTheme extends CFormModel
{
public $name;
public $path;
public $config;
/**
* Return the necessary datas to load the admin theme
*/
public function setAdminTheme()
{
// We retrieve the admin theme in config ( {{settings_global}} or config-defaults.php )
$sAdminThemeName = Yii::app()->getConfig('admintheme');
$sAdminTemplateRootDir=Yii::app()->getConfig("styledir");
// If the template doesn't exist, set to Default
$sAdminThemeName = ($this->isStandardAdminTheme($sAdminThemeName))?$sAdminThemeName:'default';
// If the required admin theme doesn't exist, Sea_Green will be used
// TODO : check also for upload directory
$this->name = (is_dir($sAdminTemplateRootDir.DIRECTORY_SEPARATOR.$sAdminThemeName))?$sAdminThemeName:'Sea_Green';
// The path of the template files eg : /var/www/limesurvey/styles/Sea_Green
// TODO : add the upload directory for user template
$this->path = $sAdminTemplateRootDir.DIRECTORY_SEPARATOR.$this->name;
// The template configuration.
$this->config = simplexml_load_file($this->path.'/config.xml');
return $this;
}
private function isStandardAdminTheme($sAdminThemeName)
{
return in_array($sAdminThemeName,
array(
'Apple_Blossom',
'Bay_of_Many',
'Black_Pearl',
'Dark_Sky',
'Free_Magenta',
'Purple_Tentacle',
'Sea_Green',
'Sunset_Orange',
)
);
}
}