-
-
Notifications
You must be signed in to change notification settings - Fork 814
/
template.php
149 lines (125 loc) · 3.95 KB
/
template.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/**
* Kunena Component
*
* @package Kunena.Template.Crypsis
* @subpackage Template
*
* @copyright Copyright (C) 2008 - 2016 Kunena Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link https://www.kunena.org
**/
defined('_JEXEC') or die;
/**
* Crypsis template.
*
* @since K4.0
*/
class KunenaTemplateCrypsis extends KunenaTemplate
{
/**
* List of parent template names.
*
* This template will automatically search for missing files from listed parent templates.
* The feature allows you to create one base template and only override changed files.
*
* @var array
* @since Kunena
*/
protected $default = array('crypsis');
/**
* Template initialization.
*
* @return void
* @since Kunena
*/
public function initialize()
{
// Template requires Bootstrap javascript
JHtml::_('bootstrap.framework');
JHtml::_('bootstrap.tooltip', '[data-toggle="tooltip"]');
// Template also requires jQuery framework.
JHtml::_('jquery.framework');
JHtml::_('bootstrap.modal');
// Load JavaScript.
$this->addScript('assets/js/main.js');
$this->ktemplate = KunenaFactory::getTemplate();
$storage = $this->ktemplate->params->get('storage');
if ($storage)
{
$this->addScript('assets/js/localstorage.js');
}
// Compile CSS from LESS files.
$this->compileLess('assets/less/crypsis.less', 'kunena.css');
$this->addStyleSheet('kunena.css');
$filenameless = JPATH_SITE . '/components/com_kunena/template/crypsis/assets/less/custom.less';
if (file_exists($filenameless) && 0 != filesize($filenameless))
{
$this->compileLess('assets/less/custom.less', 'kunena-custom.css');
$this->addStyleSheet('kunena-custom.css');
}
$filename = JPATH_SITE . '/components/com_kunena/template/crypsis/assets/css/custom.css';
if (file_exists($filename))
{
$this->addStyleSheet('assets/css/custom.css');
}
$bootstrap = $this->ktemplate->params->get('bootstrap');
$doc = JFactory::getDocument();
if ($bootstrap)
{
$doc->addStyleSheet(JUri::base(true) . '/media/jui/css/bootstrap.min.css');
$doc->addStyleSheet(JUri::base(true) . '/media/jui/css/bootstrap-extended.css');
$doc->addStyleSheet(JUri::base(true) . '/media/jui/css/bootstrap-responsive.min.css');
if ($this->ktemplate->params->get('icomoon'))
{
$doc->addStyleSheet(JUri::base(true) . '/media/jui/css/icomoon.css');
}
}
$fontawesome = $this->ktemplate->params->get('fontawesome');
if ($fontawesome)
{
$doc->addStyleSheet("https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css");
}
// Load template colors settings
$styles = <<<EOF
/* Kunena Custom CSS */
EOF;
$iconcolor = $this->ktemplate->params->get('IconColor');
if ($iconcolor)
{
$styles .= <<<EOF
.layout#kunena [class*="category"] i,
.layout#kunena .glyphicon-topic,
.layout#kunena h3 i,
.layout#kunena #kwho i.icon-users,
.layout#kunena#kstats i.icon-bars { color: {$iconcolor}; }
EOF;
}
$iconcolornew = $this->ktemplate->params->get('IconColorNew');
if ($iconcolornew)
{
$styles .= <<<EOF
.layout#kunena [class*="category"] .knewchar { color: {$iconcolornew} !important; }
.layout#kunena sup.knewchar { color: {$iconcolornew} !important; }
.layout#kunena .topic-item-unread { border-left-color: {$iconcolornew} !important;}
.layout#kunena .topic-item-unread .icon { color: {$iconcolornew} !important;}
.layout#kunena .topic-item-unread i.fa { color: {$iconcolornew} !important;}
EOF;
}
$document = JFactory::getDocument();
$document->addStyleDeclaration($styles);
parent::initialize();
}
/**
* @param $filename
* @param string $group
*
* @return JDocument
* @since Kunena
*/
public function addStyleSheet($filename, $group = 'forum')
{
$filename = $this->getFile($filename, false, '', "media/kunena/cache/{$this->name}/css");
return JFactory::getDocument()->addStyleSheet(JUri::root(true) . "/{$filename}");
}
}