-
Notifications
You must be signed in to change notification settings - Fork 65
/
index.php
205 lines (172 loc) · 9.08 KB
/
index.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php include 'core/app/initialize.php'; ?>
<!doctype html>
<!--
####################################
Created with:
__ __ __ __
/ / \ (_ |\/| / \
\__ \__/ __) | | \__/
http://www.cosmocms.org/
v1.0.0-beta.6
####################################
-->
<html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="main" ng-controller="HTMLCtrl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--[if lte IE 9]>
<script>
if(window.location.href.indexOf('#!') === -1)
window.location.href = window.location.protocol + '//' + window.location.host + '/#!' + encodeURLComponet(window.location.pathname);
</script>
<script src="core/js/3rd-party/html5.js"></script>
<![endif]-->
<!--[if lte IE 8]>
<script src="core/js/3rd-party/json2.js"></script>
<br /><br />Your broswer is incompatible with this site. Please upgrade to a <a href="http://www.browsehappy.com">newer browser.</a>
<![endif]-->
<link rel="shortcut icon" href="<?php echo $settings['favicon']; ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<!-- Meta Tags -->
<title ng-bind-template="{{title}}"><?php echo $content['title']; ?></title>
<meta name="description" content="<?php echo $content['description']; ?>">
<meta property="og:title" content="<?php echo $content['title']; ?>" />
<meta property="og:description" content="<?php echo $content['description']; ?>" />
<meta property="og:type" content="article" />
<meta property="og:url" content="<?php echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>" />
<?php if(isset($content['extras']['featured']) && $content['extras']['featured']): ?>
<?php $requestURI = explode('/', $_SERVER['REQUEST_URI']); ?>
<meta property="og:image" content="<?php echo 'http://' . $_SERVER['HTTP_HOST'] . $requestURI[0] . '/' . json_decode($content['extras']['featured'])->src; ?>" />
<?php endif; ?>
<base href="/<?php echo FOLDER; ?>" />
<script src="<?php echo $minifyScripts; ?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $minifyCSS; ?>">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:600italic,400,300,600' rel='stylesheet' type='text/css'>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
<?php echo $scripts; ?>
<?php echo $CSS; ?>
<script>
// Setup main module with HTML5 URLs
angular.module('main', [
'cosmo',
'pascalprecht.translate',
'ngRoute',
'ngAnimate',
'ui.tree',
'angularFileUpload',
'ngResource',
'ngTouch'<?php echo $angularModules; ?>
])
.config(['$routeProvider', '$locationProvider', '$translateProvider', function($routeProvider, $locationProvider, $translateProvider) {
// Configure standard URLs
$routeProvider.
when('/admin', { template: '<div></div>' }).
when('/reset/:userID/:token', { controller: 'resetPasswordCtrl', template: '<div></div>' }).
when('/', { controller: 'urlCtrl', template: '<div ng-include="template" ng-cloak></div>' }).
when('/:url', { controller: 'urlCtrl', template: '<div ng-include="template" ng-cloak></div>' });
// Enable HTML5 urls
$locationProvider.html5Mode(true).hashPrefix('!');
// Load files from the core/languages folder
$translateProvider.useStaticFilesLoader({
prefix: 'core/languages/',
suffix: '.json'
});
// Set the default language
$translateProvider.preferredLanguage('<?php echo $settings['language'];?>');
}])
// Initialize JS variables
.run(['Users', '$http', '$templateCache', '$rootScope', 'Page', '$timeout', function(Users, $http, $templateCache, $rootScope, Page, $timeout) {
Users.username = '<?php echo $username; ?>';<?php if(isset($usersID) && $usersID): ?>
Users.id = <?php echo $usersID; ?>;<?php endif; ?>
Users.role = '<?php echo isset($role) ? $role: ''; ?>';<?php if($directives): ?>
Page.directives = <?php echo json_encode($directives); ?>;<?php endif; ?>
Page.classes = "<?php echo $classes; ?>";
Page.themePages = <?php echo json_encode($themeJSON->pages); ?>;
Page.folder = '<?php echo FOLDER; ?>';<?php if($menus):?>
Page.menus = <?php echo json_encode($menus); ?>;<?php endif; ?>
Page.settings = <?php echo json_encode($settings); ?>;
Page.theme = '<?php echo $theme; ?>';
// If the user has permissions, show the sidebar.
if(Users.role === 'admin' || Users.role === 'editor' || Users.role === 'contributor' || Users.id){
Users.admin = true;
$rootScope.$broadcast('adminLogin');
}
// Get the user's role number
switch(Users.role){
case 'admin':
Users.roleNum = 1;
break;
case 'editor':
Users.roleNum = 2;
break;
case 'contributor':
Users.roleNum = 3;
break;
default:
Users.roleNum = 4;
break;
}
// Initialize headers for authorizing API calls
$http.defaults.headers.common['usersID'] = '<?php echo isset($usersID) ? $usersID : ''; ?>';
$http.defaults.headers.common['username'] = '<?php echo $username; ?>';
$http.defaults.headers.common['token'] = '<?php echo isset($token) ? $token : ''; ?>';
function cacheTemplate(url){
$http.get(url).success(function(data){
$templateCache.put(url, data);
});
};
// Cache all template pages. Wait 1 second for the current page to load first
$timeout(function() {
angular.forEach(Page.themePages, function(page){
cacheTemplate('themes/<?php echo $theme; ?>/'+page);
});
}, 1000);
// Cache all admin pages
if(Users.admin) {
var adminPanelPages = [
'core/html/archives.html',
'core/html/blocks.html',
'core/html/content-list.html',
'core/html/files.html',
'core/html/icons.html',
'core/html/login.html',
'core/html/menu.html',
'core/html/modal.html',
'core/html/modules.html',
'core/html/page.html',
'core/html/password-reset.html',
'core/html/profile.html',
'core/html/revisions.html',
'core/html/roles.html',
'core/html/settings.html',
'core/html/sidebar.html',
'core/html/theme.html',
'core/html/toolbar.html',
'core/html/users.html',
'core/html/wysiwyg.html',
'core/html/partials/comments.html',
'core/html/partials/link.html',
'core/html/partials/menu-links.html',
'core/html/partials/results.html',
'core/html/partials/user-login.html',
'core/html/partials/user-registration.html'
];
// Let the rest of the page load first
$timeout(function() {
angular.forEach(adminPanelPages, function(page){
cacheTemplate(page);
});
}, 5000);
}
}]);
</script>
</head>
<body>
<div>
<div ng-include="'core/html/admin-panel.html'"></div>
<div cs-wysiwyg></div>
</div>
<div ng-view class="cosmo-theme"><?php echo $content['body']; ?></div>
<div cs-notification></div>
</body>
</html>