5 * Author: Fabio <http://kirgroup.com/profile/fabrixxm>
6 * Author: Ike <http://pirati.ca/profile/heluecht>
7 * Author: Beanow <https://fc.oscp.info/profile/beanow>
8 * Maintainer: Ike <http://pirati.ca/profile/heluecht>
9 * Description: "Vier" is a very compact and modern theme. It uses the font awesome font library: http://fortawesome.github.com/Font-Awesome/
12 require_once("include/plugin.php");
13 require_once("include/socgraph.php");
14 require_once("mod/proxy.php");
16 function vier_init(&$a) {
18 $a->theme_events_in_profile = false;
20 set_template_engine($a, 'smarty3');
22 $baseurl = $a->get_baseurl();
24 $a->theme_info = array();
26 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()) {
27 vier_community_info();
29 $a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
32 if ($a->is_mobile || $a->is_tablet) {
33 $a->page['htmlhead'] .= '<meta name=viewport content="width=device-width, initial-scale=1">'."\n";
34 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen"/>'."\n";
36 // deactivated since it doesn't work with desktop browsers at the moment (To-Do)
37 //$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
39 $a->page['htmlhead'] .= <<< EOT
40 <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
41 <script type="text/javascript">
43 function insertFormatting(comment,BBcode,id) {
45 var tmpStr = $("#comment-edit-text-" + id).val();
46 if(tmpStr == comment) {
48 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
49 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
50 openMenu("comment-edit-submit-wrapper-" + id);
51 $("#comment-edit-text-" + id).val(tmpStr);
54 textarea = document.getElementById("comment-edit-text-" +id);
55 if (document.selection) {
57 selected = document.selection.createRange();
59 selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
61 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
62 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
63 var start = textarea.selectionStart;
64 var end = textarea.selectionEnd;
66 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
68 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
74 function showThread(id) {
75 $("#collapsed-comments-" + id).show()
76 $("#collapsed-comments-" + id + " .collapsed-comments").show()
78 function hideThread(id) {
79 $("#collapsed-comments-" + id).hide()
80 $("#collapsed-comments-" + id + " .collapsed-comments").hide()
84 function cmtBbOpen(id) {
85 $("#comment-edit-bb-" + id).show();
87 function cmtBbClose(id) {
88 $("#comment-edit-bb-" + id).hide();
97 if ($a->is_mobile || $a->is_tablet){
98 $a->page['htmlhead'] .= <<< EOT
100 $(document).ready(function() {
101 $(".mobile-aside-toggle a").click(function(e){
103 $("aside").toggleClass("show");
105 $(".tabs").click(function(e){
106 $(this).toggleClass("show");
114 // Hide the left menu bar
115 if (($a->page['aside'] == "") AND in_array($a->argv[0], array("community", "events", "help", "manage", "notifications",
116 "probe", "webfinger", "login", "invite", "credits")))
117 $a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
120 function get_vier_config($key, $default = false, $admin = false) {
121 if (local_user() AND !$admin) {
122 $result = get_pconfig(local_user(), "vier", $key);
123 if ($result !== false)
127 $result = get_config("vier", $key);
128 if ($result !== false)
134 function vier_community_info() {
137 $show_pages = get_vier_config("show_pages", 1);
138 $show_profiles = get_vier_config("show_profiles", 1);
139 $show_helpers = get_vier_config("show_helpers", 1);
140 $show_services = get_vier_config("show_services", 1);
141 $show_friends = get_vier_config("show_friends", 1);
142 $show_lastusers = get_vier_config("show_lastusers", 1);
145 $url = $a->get_baseurl($ssl_state);
146 $aside['$url'] = $url;
151 $r = suggestion_query(local_user(), 0, 9);
153 $tpl = get_markup_template('ch_directory_item.tpl');
156 $aside['$comunity_profiles_title'] = t('Community Profiles');
157 $aside['$comunity_profiles_items'] = array();
160 $entry = replace_macros($tpl,array(
162 //'$profile_link' => zrl($rr['url']),
163 '$profile_link' => $a->get_baseurl().'/follow/?url='.urlencode($rr['url']),
164 '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO),
165 '$alt_text' => $rr['name'],
167 $aside['$comunity_profiles_items'][] = $entry;
173 if($show_lastusers) {
174 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 ");
175 $order = " ORDER BY `register_date` DESC ";
177 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
178 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
179 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ",
182 $tpl = get_markup_template('ch_directory_item.tpl');
185 $aside['$lastusers_title'] = t('Last users');
186 $aside['$lastusers_items'] = array();
189 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
190 $entry = replace_macros($tpl,array(
192 '$profile_link' => $profile_link,
193 '$photo' => $a->get_cached_avatar_image($rr['thumb']),
194 '$alt_text' => $rr['name']));
195 $aside['$lastusers_items'][] = $entry;
200 //right_aside FIND FRIENDS
201 if ($show_friends AND local_user()) {
203 $nv['title'] = Array("", t('Find Friends'), "", "");
204 $nv['directory'] = Array('directory', t('Local Directory'), "", "");
205 $nv['global_directory'] = Array(get_server(), t('Global Directory'), "", "");
206 $nv['match'] = Array('match', t('Similar Interests'), "", "");
207 $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
208 $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
210 $nv['search'] = '<form name="simple_bar" method="get" action="'.$a->get_baseurl().'/dirfind">
211 <span class="sbox_l"></span>
213 <input type="text" name="search" size="13" maxlength="50">
215 <span class="sbox_r" id="srch_clear"></span>';
220 //Community_Pages at right_aside
221 if($show_pages AND local_user()) {
223 require_once('include/forums.php');
225 if(x($_GET['cid']) && intval($_GET['cid']) != 0)
228 //sort by last updated item
231 $contacts = get_forumlist($a->user['uid'],true,$lastitem, true);
232 $total = count($contacts);
233 $visible_forums = 10;
235 if(count($contacts)) {
239 foreach($contacts as $contact) {
241 $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
244 'url' => z_root() . '/network?f=&cid=' . $contact['id'],
245 'external_url' => z_root() . '/redir/' . $contact['id'],
246 'name' => $contact['name'],
247 'cid' => $contact['id'],
248 'selected' => $selected,
249 'micro' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
256 $tpl = get_markup_template('widget_forumlist_right.tpl');
258 $page .= replace_macros($tpl,array(
259 '$title' => t('Forums'),
260 '$forums' => $entries,
261 '$link_desc' => t('External link to forum'),
263 '$visible_forums' => $visible_forums,
264 '$showmore' => t('show more'),
267 $aside['$page'] = $page;
276 $helperlist = get_config("vier", "helperlist");
278 $helpers = explode(",",$helperlist);
282 foreach ($helpers AS $index=>$helper) {
286 $query .= "'".dbesc(normalise_link(trim($helper)))."'";
289 $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
292 foreach ($r AS $index => $helper)
293 $r[$index]["url"] = zrl($helper["url"]);
295 $r[] = Array("url" => "help/Quick-Start-guide", "name" => t("Quick Start"));
297 $tpl = get_markup_template('ch_helpers.tpl');
302 $helpers['title'] = Array("", t('Help'), "", "");
304 $aside['$helpers_items'] = array();
307 $entry = replace_macros($tpl,array(
308 '$url' => $rr['url'],
309 '$title' => $rr['name'],
311 $aside['$helpers_items'][] = $entry;
314 $aside['$helpers'] = $helpers;
319 //connectable services
320 if ($show_services) {
324 if (plugin_enabled("appnet"))
325 $r[] = array("photo" => "images/appnet.png", "name" => "App.net");
327 if (plugin_enabled("buffer"))
328 $r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
330 if (plugin_enabled("blogger"))
331 $r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
333 if (plugin_enabled("dwpost"))
334 $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
336 if (plugin_enabled("fbpost"))
337 $r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
339 if (plugin_enabled("ifttt"))
340 $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
342 if (plugin_enabled("statusnet"))
343 $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
345 if (plugin_enabled("gpluspost"))
346 $r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
348 //if (plugin_enabled("ijpost"))
349 // $r[] = array("photo" => "images/", "name" => "");
351 if (plugin_enabled("libertree"))
352 $r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
354 //if (plugin_enabled("ljpost"))
355 // $r[] = array("photo" => "images/", "name" => "");
357 if (plugin_enabled("pumpio"))
358 $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
360 if (plugin_enabled("tumblr"))
361 $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
363 if (plugin_enabled("twitter"))
364 $r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
366 if (plugin_enabled("wppost"))
367 $r[] = array("photo" => "images/wordpress", "name" => "Wordpress");
369 if(function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only"))
370 $r[] = array("photo" => "images/mail", "name" => "E-Mail");
372 $tpl = get_markup_template('ch_connectors.tpl');
376 $con_services = array();
377 $con_services['title'] = Array("", t('Connect Services'), "", "");
378 $aside['$con_services'] = $con_services;
381 $entry = replace_macros($tpl,array(
383 '$photo' => $rr['photo'],
384 '$alt_text' => $rr['name'],
386 $aside['$connector_items'][] = $entry;
391 //end connectable services
394 $tpl = get_markup_template('communityhome.tpl');
395 $a->page['right_aside'] = replace_macros($tpl, $aside);