forked from nielsnuebel/kicktemp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmagic.php
144 lines (130 loc) · 4.35 KB
/
magic.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
<?php defined('_JEXEC') or die;
// variables
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$params = $app->getParams();
$templateparams = $app->getTemplate(true)->params;
$headdata = $doc->getHeadData();
$menu = $app->getMenu();
$active = $app->getMenu()->getActive();
$pageclass = $params->get('pageclass_sfx');
$tpath = $this->baseurl.'/templates/'.$this->template;
$assets = $tpath . '/assets';
$isFrontpage = false;
$active_alias = '';
if ($active)
{
$defaultmenuitems = array($menu->getDefault()->id, $menu->getDefault(JFactory::getLanguage()->getTag())->id);
$isFrontpage = in_array($active->id, $defaultmenuitems);
$active_alias = $active->alias;
}
// parameter
$codekit = $templateparams->get('codekit');
$googlefont = $templateparams->get('googlefont');
$bootstrap = $templateparams->get('bootstrap');
$fontawesome = $templateparams->get('fontawesome');
$modernizr = $templateparams->get('modernizr');
$pagetype = $templateparams->get('pagetype', 'multipage');
$hidecontentwrapper = $templateparams->get('hidecontentwrapper', 0);
$showsystemoutput = $templateparams->get('showsystemoutput', 1);
// advanced parameter
if ($app->isSite()) {
// disable js
if ( $templateparams->get('disablejs') ) {
$fnjs=$templateparams->get('fnjs');
if (trim($fnjs) != '') {
$filesjs=explode(',', $fnjs);
$head = (array) $headdata['scripts'];
$newhead = array();
foreach($head as $key => $elm) {
$add = true;
foreach ($filesjs as $dis) {
if (strpos($key,$dis) !== false) {
$add=false;
break;
}
}
if ($add) $newhead[$key] = $elm;
}
$headdata['scripts'] = $newhead;
}
}
// disable css
if ( $templateparams->get('disablecss') ) {
$fncss=$templateparams->get('fncss');
if (trim($fncss) != '') {
$filescss=explode(',', $fncss);
$head = (array) $headdata['styleSheets'];
$newhead = array();
foreach($head as $key => $elm) {
$add = true;
foreach ($filescss as $dis) {
if (strpos($key,$dis) !== false) {
$add=false;
break;
}
}
if ($add) $newhead[$key] = $elm;
}
$headdata['styleSheets'] = $newhead;
}
}
$doc->setHeadData($headdata);
}
// generator tag
$this->setGenerator(null);
// force latest IE & chrome frame
$doc->setMetadata('x-ua-compatible', 'IE=edge,chrome=1');
$modernizrpath = $tpath.'/js/modernizr-2.8.1.js';
if(!$codekit)
{
// add javascripts
if ($modernizr==1) {
$doc->addScript($tpath.'/js/modernizr-2.8.1.js');
}
$doc->addScript($tpath.'/js/jquery-1.11.1.min.js');
$doc->addScript($tpath.'/js/jquery-noconflict.js');
$doc->addScript($tpath.'/js/jquery-migrate.min.js');
if ($bootstrap==1) $doc->addScript($tpath.'/js/bootstrap.min.js');
$doc->addScript($tpath.'/js/script.js');
// load jQuery first
$jquerypath = $tpath.'/js/jquery-1.11.1.min.js';
$tmpScripts = array();
$tmpScripts = $doc->_scripts;
unset( $tmpScripts[$this->baseurl.'/media/widgetkit/js/jquery.js'] );
unset( $tmpScripts[$this->baseurl.'/media/jui/js/jquery.min.js'] );
unset( $tmpScripts[$this->baseurl.'/media/jui/js/jquery-migrate.min.js'] );
unset( $tmpScripts[$this->baseurl.'/media/jui/js/jquery-noconflict.js'] );
}
else
{
$doc->addScript($tpath.'/js/kickstart.js');
$tmpScripts = $doc->_scripts;
unset( $tmpScripts[$this->baseurl.'/media/jui/js/jquery.min.js'] );
unset( $tmpScripts[$this->baseurl.'/media/jui/js/bootstrap.min.js'] );
$jquerypath = $tpath.'/js/kickstart.js';
}
$neuScript = array();
if ($modernizr==1) $neuScript[$modernizrpath] = $tmpScripts[$modernizrpath];
$neuScript[$jquerypath] = $tmpScripts[$jquerypath];
foreach($tmpScripts as $key=> $value)
{
if($key != $jquerypath and $key != $modernizrpath)
{
$neuScript[$key] = $value;
}
}
$doc->_scripts = $neuScript;
if(!$codekit)
{
if ($bootstrap==1) $doc->addStyleSheet($tpath.'/css/bootstrap.min.css');
if ($fontawesome==1 and $bootstrap ==1) $doc->addStyleSheet($tpath.'/css/font-awesome.min.css');
if ($googlefont !='') $doc->addStyleSheet("https://fonts.googleapis.com/css?family=".$googlefont);
// add template sheet
$doc->addStyleSheet($tpath.'/css/template.css');
}
else {
if ($googlefont !='') $doc->addStyleSheet("https://fonts.googleapis.com/css?family=".$googlefont);
$doc->addStyleSheet($tpath.'/css/kickstart.css');
}
?>