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 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
38 $a->page['htmlhead'] .= <<< EOT
39 <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
40 <script type="text/javascript">
42 function insertFormatting(comment,BBcode,id) {
44 var tmpStr = $("#comment-edit-text-" + id).val();
45 if(tmpStr == comment) {
47 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
48 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
49 openMenu("comment-edit-submit-wrapper-" + id);
50 $("#comment-edit-text-" + id).val(tmpStr);
53 textarea = document.getElementById("comment-edit-text-" +id);
54 if (document.selection) {
56 selected = document.selection.createRange();
58 selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
60 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
61 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
62 var start = textarea.selectionStart;
63 var end = textarea.selectionEnd;
65 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
67 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
73 function showThread(id) {
74 $("#collapsed-comments-" + id).show()
75 $("#collapsed-comments-" + id + " .collapsed-comments").show()
77 function hideThread(id) {
78 $("#collapsed-comments-" + id).hide()
79 $("#collapsed-comments-" + id + " .collapsed-comments").hide()
83 function cmtBbOpen(id) {
84 $("#comment-edit-bb-" + id).show();
86 function cmtBbClose(id) {
87 $("#comment-edit-bb-" + id).hide();
96 if ($a->is_mobile || $a->is_tablet){
97 $a->page['htmlhead'] .= <<< EOT
99 $(document).ready(function() {
100 $(".mobile-aside-toggle a").click(function(e){
102 $("aside").toggleClass("show");
104 $(".tabs").click(function(e){
105 $(this).toggleClass("show");
113 // Hide the left menu bar
114 if (($a->page['aside'] == "") AND in_array($a->argv[0], array("community", "events", "help", "manage", "notifications",
115 "probe", "webfinger", "login", "invite", "credits")))
116 $a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
119 function get_vier_config($key, $default = false, $admin = false) {
120 if (local_user() AND !$admin) {
121 $result = get_pconfig(local_user(), "vier", $key);
122 if ($result !== false)
126 $result = get_config("vier", $key);
127 if ($result !== false)
133 function vier_community_info() {
136 $show_pages = get_vier_config("show_pages", 1);
137 $show_profiles = get_vier_config("show_profiles", 1);
138 $show_helpers = get_vier_config("show_helpers", 1);
139 $show_services = get_vier_config("show_services", 1);
140 $show_friends = get_vier_config("show_friends", 1);
141 $show_lastusers = get_vier_config("show_lastusers", 1);
144 $url = $a->get_baseurl($ssl_state);
145 $aside['$url'] = $url;
150 $r = suggestion_query(local_user(), 0, 9);
152 $tpl = get_markup_template('ch_directory_item.tpl');
155 $aside['$comunity_profiles_title'] = t('Community Profiles');
156 $aside['$comunity_profiles_items'] = array();
159 $entry = replace_macros($tpl,array(
161 //'$profile_link' => zrl($rr['url']),
162 '$profile_link' => $a->get_baseurl().'/follow/?url='.urlencode($rr['url']),
163 '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO),
164 '$alt_text' => $rr['name'],
166 $aside['$comunity_profiles_items'][] = $entry;
172 if($show_lastusers) {
173 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 ");
174 $order = " ORDER BY `register_date` DESC ";
176 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
177 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
178 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ",
181 $tpl = get_markup_template('ch_directory_item.tpl');
184 $aside['$lastusers_title'] = t('Last users');
185 $aside['$lastusers_items'] = array();
188 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
189 $entry = replace_macros($tpl,array(
191 '$profile_link' => $profile_link,
192 '$photo' => $a->get_cached_avatar_image($rr['thumb']),
193 '$alt_text' => $rr['name']));
194 $aside['$lastusers_items'][] = $entry;
199 //right_aside FIND FRIENDS
200 if ($show_friends AND local_user()) {
202 $nv['title'] = Array("", t('Find Friends'), "", "");
203 $nv['directory'] = Array('directory', t('Local Directory'), "", "");
204 $nv['global_directory'] = Array(get_server(), t('Global Directory'), "", "");
205 $nv['match'] = Array('match', t('Similar Interests'), "", "");
206 $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
207 $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
209 $nv['search'] = '<form name="simple_bar" method="get" action="'.$a->get_baseurl().'/dirfind">
210 <span class="sbox_l"></span>
212 <input type="text" name="search" size="13" maxlength="50">
214 <span class="sbox_r" id="srch_clear"></span>';
219 //Community_Pages at right_aside
220 if($show_pages AND local_user()) {
224 $contacts = q("SELECT `id`, `url`, `name`, `micro` FROM `contact`
225 WHERE `network`= '%s' AND `uid` = %d AND (`forum` OR `prv`) AND
226 NOT `hidden` AND NOT `blocked` AND
227 NOT `archive` AND NOT `pending` AND
228 `success_update` > `failure_update`
229 ORDER BY `name` ASC",
230 dbesc(NETWORK_DFRN), intval($a->user['uid']));
234 // Look if the profile is a community page
235 foreach($contacts as $contact) {
236 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
243 <h3>'.t("Community Pages").'</h3>
244 <div id="forum-list-right">';
246 foreach($contacts as $contact) {
247 $page .= '<div role="menuitem"><a href="' . $a->get_baseurl() . '/redir/' . $contact["id"] . '" title="'.t('External link to forum').'" class="label sparkle" target="_blank"><img class="forumlist-img" height="20" width="20" src="' . $contact['micro'] .'" alt="'.t('External link to forum').'" /></a> <a href="' . $a->get_baseurl() . '/network?f=&cid=' . $contact['id'] . '" >' . $contact["name"]."</a></div>";
251 $aside['$page'] = $page;
260 $helperlist = get_config("vier", "helperlist");
262 $helpers = explode(",",$helperlist);
266 foreach ($helpers AS $index=>$helper) {
270 $query .= "'".dbesc(normalise_link(trim($helper)))."'";
273 $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
276 foreach ($r AS $index => $helper)
277 $r[$index]["url"] = zrl($helper["url"]);
279 $r[] = Array("url" => "help/Quick-Start-guide", "name" => t("Quick Start"));
281 $tpl = get_markup_template('ch_helpers.tpl');
286 $helpers['title'] = Array("", t('Help'), "", "");
288 $aside['$helpers_items'] = array();
291 $entry = replace_macros($tpl,array(
292 '$url' => $rr['url'],
293 '$title' => $rr['name'],
295 $aside['$helpers_items'][] = $entry;
298 $aside['$helpers'] = $helpers;
303 //connectable services
304 if ($show_services) {
308 if (plugin_enabled("appnet"))
309 $r[] = array("photo" => "images/appnet.png", "name" => "App.net");
311 if (plugin_enabled("buffer"))
312 $r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
314 if (plugin_enabled("blogger"))
315 $r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
317 if (plugin_enabled("dwpost"))
318 $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
320 if (plugin_enabled("fbpost"))
321 $r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
323 if (plugin_enabled("ifttt"))
324 $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
326 if (plugin_enabled("statusnet"))
327 $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
329 if (plugin_enabled("gpluspost"))
330 $r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
332 //if (plugin_enabled("ijpost"))
333 // $r[] = array("photo" => "images/", "name" => "");
335 if (plugin_enabled("libertree"))
336 $r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
338 //if (plugin_enabled("ljpost"))
339 // $r[] = array("photo" => "images/", "name" => "");
341 if (plugin_enabled("pumpio"))
342 $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
344 if (plugin_enabled("tumblr"))
345 $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
347 if (plugin_enabled("twitter"))
348 $r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
350 if (plugin_enabled("wppost"))
351 $r[] = array("photo" => "images/wordpress", "name" => "Wordpress");
353 if(function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only"))
354 $r[] = array("photo" => "images/mail", "name" => "E-Mail");
356 $tpl = get_markup_template('ch_connectors.tpl');
360 $con_services = array();
361 $con_services['title'] = Array("", t('Connect Services'), "", "");
362 $aside['$con_services'] = $con_services;
365 $entry = replace_macros($tpl,array(
367 '$photo' => $rr['photo'],
368 '$alt_text' => $rr['name'],
370 $aside['$connector_items'][] = $entry;
375 //end connectable services
378 $tpl = get_markup_template('communityhome.tpl');
379 $a->page['right_aside'] = replace_macros($tpl, $aside);