-
Notifications
You must be signed in to change notification settings - Fork 1
/
theme_shortcodes.php
298 lines (231 loc) · 8.42 KB
/
theme_shortcodes.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* e107 Bootstrap Theme Shortcodes.
*
*/
class theme_shortcodes extends e_shortcode
{
/**
* Return raw HTML-usable values from page fields.
* @experimental subject to change without notice.
* @param null $parm
* @return mixed
*/
function sc_bootstrap_usernav($parm = '')
{
include_lan(e_PLUGIN . "login_menu/languages/" . e_LANGUAGE . ".php");
$tp = e107::getParser();
// $login_menu_shortcodes
require(e_PLUGIN . "login_menu/login_menu_shortcodes.php"); // don't use 'require_once'.
$userReg = defset('USER_REGISTRATION');
if(!USERID) // Logged Out.
{
$text = '';
if($userReg == 1)
{
$signuplink = '<li><a class="nav-link" href="' . e_SIGNUP . '">' . LAN_LOGINMENU_3 . '</a></li>';
}
$socialActive = e107::pref('core', 'social_login_active');
if(!empty($userReg) || !empty($socialActive)) // e107 or social login is active.
{
$loginlink = '
<a class="dropdown-toggle" href="#" id="dropdownLoginLink" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="true" title="' . LAN_LOGINMENU_51 . '"> ' . LAN_LOGINMENU_51 . '</a>';
$sociallogin = '{SOCIAL_LOGIN: size=2x&label=1}';
}
else
{
return '';
}
if(!empty($userReg)) // value of 1 or 2 = login okay.
{
// global $sc_style; // never use global - will impact signup/usersettings pages.
// $sc_style = array(); // remove any wrappers.
$loginform = '
<form method="post" onsubmit="hashLoginPassword(this);return true" action="' . e_REQUEST_HTTP . '" accept-charset="UTF-8">
<p>{LM_USERNAME_INPUT}</p>
<p>{LM_PASSWORD_INPUT}</p>
<div class="form-group"></div>
{LM_IMAGECODE_NUMBER}
{LM_IMAGECODE_BOX}
<div class="checkbox">
<label class="string optional" for="autologin"><input style="margin-right: 10px;" type="checkbox" name="autologin" id="autologin" value="1">
' . LAN_LOGINMENU_6 . '</label>
</div>
<input class="btn btn-primary btn-block" type="submit" name="userlogin" id="userlogin" value="' . LAN_LOGINMENU_51 . '">
';
$loginform .= '
<a href="{LM_FPW_LINK=href}" class="btn btn-default btn-sm btn-block">' . LAN_LOGINMENU_4 . '</a>
<a href="{LM_RESEND_LINK=href}" class="btn btn-default btn-sm btn-block">' . LAN_LOGINMENU_40 . '</a>
';
$loginform .= "<p></p>
</form>
";
}
$text = ' ' .
$signuplink .
'<li class="divider-vertical"></li>
<li class="dropdown">
' . $loginlink . $sociallogin . '
<div class="dropdown-menu" aria-labelledby="dropdownLoginLink" style="min-width:250px; padding: 15px; padding-bottom: 0px;">
' . $loginform . '
</div>
</li>';
$text .= '';
return $tp->parseTemplate($text, true, $login_menu_shortcodes);
}
// Logged in.
//TODO Generic LANS. (not theme LANs)
if(ADMIN)
{
$adminlink = '<li><a href="' . e_ADMIN_ABS . '"><span class="fa fa-cogs"></span> ' . LAN_LOGINMENU_11 . '</a></li>';
}
else
{
$adminlink = '';
}
$text = '
<li class="dropdown">{PM_NAV}</li>
<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">{SETIMAGE: w=20} {USER_AVATAR: shape=circle} ' . USERNAME . ' <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="{LM_USERSETTINGS_HREF}"><span class="fa fa-cog"></span> ' . LAN_SETTINGS . '</a></li>
<li><a href="{LM_PROFILE_HREF}"><span class="fa fa-user"></span> ' . LAN_LOGINMENU_13 . '</a></li>
' . $adminlink . '
<li><a href="' . e_HTTP . 'index.php?logout"><span class="fa fa-sign-out"></span> ' . LAN_LOGOUT . '</a></li>
</ul>';
return $tp->parseTemplate($text, true, $login_menu_shortcodes);
}
/**
* TODO Replace with a core shortcode. {BOOK_MENUS}
* @return string
*/
function sc_portfolioitems()
{
// return e107::getParser()->parseTemplate("{CHAPTER_MENUS: name=portfolio}",true);
$template = e107::getCoreTemplate('chapter', 'portfolio');
$sc = e107::getScBatch('page', null, 'cpage');
// TO GET ID OF BOOK WITH PORTFOLIO
$where = "chapter_visibility IN (" . USERCLASS_LIST . ") AND chapter_template = 'portfolio'";
$book_id = e107::getDb()->retrieve('page_chapters', 'chapter_id', $where);
// TO GET ALL PAGES, WITH THEIR CHAPTERS WITH BOOK PORTFOLIO
$query = "SELECT * FROM #page AS p LEFT JOIN #page_chapters as ch ON p.page_chapter=ch.chapter_id WHERE ch.chapter_parent = " . intval($book_id) . " ORDER BY p.page_order DESC ";
if($pageArray = e107::getDb()->retrieve($query, true))
{
$sc->setVars($pageArray[0]); // set so book/chapter info is available to 'start' template.
$text = e107::getParser()->parseTemplate($template['listItems']['start'], true, $sc);
foreach($pageArray as $page)
{
$sc->setVars($page);
$text .= e107::getParser()->parseTemplate($template['listItems']['item'], true, $sc);
}
}
else
{
$text = LAN_AG_THEME_14;
}
$text .= e107::getParser()->parseTemplate($template['listItems']['end'], true, $sc);
return $text;
}
/**
* TODO Replace with a core shortcode.
* @return string
*/
function sc_modalportfolio()
{
$template = e107::getCoreTemplate('chapter', 'modalportfolio');
$sc = e107::getScBatch('page', null, 'cpage');
// TO GET ID OF BOOK WITH PORTFOLIO
$where = "chapter_visibility IN (" . USERCLASS_LIST . ") AND chapter_template = 'portfolio'";
$book_id = e107::getDb()->retrieve('page_chapters', 'chapter_id', $where);
// TO GET ALL PAGES, WITH THEIR CHAPTERS WITH BOOK PORTFOLIO
$query = "SELECT * FROM #page AS p LEFT JOIN #page_chapters as ch ON p.page_chapter=ch.chapter_id WHERE ch.chapter_parent = " . intval($book_id) . " ORDER BY p.page_order DESC ";
$text = e107::getParser()->parseTemplate($template['listItems']['start'], true, $sc);
if($pageArray = e107::getDb()->retrieve($query, true))
{
foreach($pageArray as $page)
{
$sc->setVars($page);
$text .= e107::getParser()->parseTemplate($template['listItems']['item'], true, $sc);
}
}
else
{
$text = null; // $text = LAN_AG_THEME_14;
}
$text .= e107::getParser()->parseTemplate($template['listItems']['end'], true, $sc);
return $text;
}
/**
* @return string
*/
function sc_timeline_inverted()
{
global $pairing; //fixme don't use globals.
$pairing = !$pairing;
return ($pairing ? '' : 'class= "timeline-inverted" ');
}
function sc_timeline_footer()
{
return e107::pref('theme', 'timelineendtext', '');
}
function sc_sitedisclaimer($copyYear = null)
{
$default = "Proudly powered by <a href='http://e107.org'>e107</a> which is released under the terms of the GNU GPL License.";
$sitedisclaimer = deftrue('SITEDISCLAIMER', $default);
$copyYear = vartrue($copyYear, '2013');
$curYear = date('Y');
$text = '© ' . $copyYear . (($copyYear != $curYear) ? ' - ' . $curYear : '');
$text .= ' ' . $sitedisclaimer;
return e107::getParser()->toHtml($text, true, 'SUMMARY');
}
/**
* @todo add menu template for contact-menu plugin to avoid the need for this.
* @param string $parm
* @return null
*/
function sc_agency_contactform($parm = '')
{
if((e107::getPref('sitecontacts')== e_UC_NOBODY) && trim(SITECONTACTINFO) == "")
{
return "";
}
else
{
e107::lan('core', 'contact');
$head = '<form id="contact-menu" action="'.e_HTTP.'contact.php" method="post" >';
$template = e107::getCoreTemplate('contact', 'homepage');
$contact_shortcodes = e107::getScBatch('contact');
$foot = '</form>';
$text = e107::getParser()->parseTemplate($head . $template . $foot, true, $contact_shortcodes);
return e107::getRender()->tablerender(LANCONTACT_00, $text, 'contact-menu');
}
}
//to have one header
// {THEME_NAVBARTYPE}
function sc_theme_navbartype() {
// for multipage purpose
$navbartype = 'navbar-inverse';
if(THEME_LAYOUT == 'homepage' )
{
$navbartype = "navbar-default ";
}
return $navbartype;
}
function sc_theme_pref($parm = array())
{
$name = $parm['name'];
if(!isset($name))
{
return "";
}
$default = varset($parm['default'], '');
$value = e107::pref('theme', 'textafterteam', $default);
return $value;
}
}