forked from theclimber/Bilboplanet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtpl.php
176 lines (163 loc) · 5.11 KB
/
tpl.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
<?php
/******* BEGIN LICENSE BLOCK *****
* BilboPlanet - An Open Source RSS feed aggregator written in PHP
* Copyright (C) 2010 By French Dev Team : Dev BilboPlanet
* Contact : dev@bilboplanet.com
* Website : www.bilboplanet.com
* Tracker : http://chili.kiwais.com/projects/bilboplanet
* Blog : www.bilboplanet.com
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
***** END LICENSE BLOCK *****/
?>
<?php
if (!isset($styles)) {
$styles = array();
}
if (!isset($scripts)) {
$scripts = array();
}
$params = array(
'title'=>$blog_settings->get('planet_title')
);
#######################
# RENDER MENU
#######################
if ($blog_settings->get('planet_vote')) {
$core->tpl->render('menu.votes');
}
if ($blog_settings->get('planet_contact_page')) {
$core->tpl->render('menu.contact');
}
if ($blog_settings->get('planet_subscription')) {
$core->tpl->render('menu.subscription');
}
if ($core->auth->sessionExists() ) {
$login = array(
'username' => $core->auth->userID()
);
$core->tpl->setVar('login', $login);
if ($core->hasRole('manager')) {
$core->tpl->render('page.loginadmin');
}
$core->tpl->render('page.loginbox');
}
#######################
# RENDER SIDEBAR
#######################
global $current_page;
if ($current_page == "list") {
if ($blog_settings->get('planet_msg_info')) {
$core->tpl->render('sidebar.alert');
}
if($blog_settings->get('planet_vote')) {
$core->tpl->render('sidebar.popular');
}
$sql_side = "SELECT
user_fullname as fullname,
".$core->prefix."user.user_id as id,
".$core->prefix."site.site_url as site_url,
".$core->prefix."site.site_name as site_name
FROM ".$core->prefix."user, ".$core->prefix."site
WHERE ".$core->prefix."user.user_id = ".$core->prefix."site.user_id
AND user_status = '1'
ORDER BY lower(user_fullname)";
$rs_side = $core->con->select($sql_side);
while ($rs_side->fetch()) {
$user_info = array(
"id" => urlencode($rs_side->f('id')),
"fullname" => $rs_side->f('fullname'),
"site_url" => $rs_side->f('site_url')
);
$core->tpl->setVar("user", $user_info);
$core->tpl->render("sidebar.users.list");
}
$core->tpl->render('postlist.state');
$core->tpl->render('memberlist.box');
}
if ($current_page != "users") {
$core->tpl->render('search.box');
$core->tpl->render("content.sidebar");
}
#####################
# RENDER WIDGETS
#####################
//TODO : it would be more reliable if we put in the settings table the widgets to load and where
// if we put a json dict in the database with for each element in the list:
// * the place where we want to place the widget (sidebar, footer)
// * the file to load
// * the order in which is have to load
// After that we need to check, before loading the tpl, if the widget function is returning a well formatted array
// * if yes => show it
// * if not => show an error in the widget place
$widget_path = dirname(__FILE__).'/widgets';
$widget_files = json_decode($blog_settings->get('planet_widget_files'));
if (is_array($widget_files)) {
foreach ($widget_files as $file){
if (is_dir($widget_path) && is_file($widget_path.'/'.$file->{'name'})) {
# Build an array of available widgets
require_once($widget_path.'/'.$file->{'name'});
$wgt = getWidget();
foreach ($wgt['styles'] as $sty) {
$styles[] = $sty;
}
foreach ($wgt['scripts'] as $spt) {
$scripts[] = $spt;
}
if ($file->{'position'} == "sidebar") {
$core->tpl->setVar("sidebar-widget", array(
'title' => $wgt['title'],
'html' => $wgt['html'],
'id' => $wgt['id']));
$core->tpl->render('sidebar.widget');
}
if ($file->{"position"} == "footer") {
$core->tpl->setVar("footer-widget", array(
'title' => $wgt['title'],
'html' => $wgt['html'],
'id' => $wgt['id']));
$core->tpl->render('footer.widget');
}
}
}
}
#####################
# RENDER FOOTER
#####################
$core->tpl->setVar('footer1', array(
'text' => T_('Powered by Bilboplanet'),
'url' => 'http://www.bilboplanet.com'));
$core->tpl->setVar('footer2', array(
'text' => T_('Valid CSS - Xhtml'),
'url' => 'http://validator.w3.org/check?verbose=1&uri='.$blog_settings->get('planet_url')));
$core->tpl->setVar('footer3', array(
'text' => T_('Designed by BilboPlanet'),
'url' => 'http://www.bilboplanet.com'));
######################
# RENDER STYLES
######################
foreach ($styles as $css) {
$core->tpl->setVar('css_file', $css);
$core->tpl->render('css.import');
}
######################
# RENDER JAVASCRIPT
######################
foreach ($scripts as $js) {
$core->tpl->setVar('js_file', $js);
$core->tpl->render('js.import');
}
?>