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("mod/nodeinfo.php");
13 require_once("mod/proxy.php");
14 require_once("include/socgraph.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();
90 $(document).ready(function() {
91 $(".mobile-aside-toggle a").click(function(e){
93 $("aside").toggleClass("show");
95 $(".tabs").click(function(e){
96 $(this).toggleClass("show");
103 // Hide the left menu bar
104 if (($a->page['aside'] == "") AND in_array($a->argv[0], array("community", "events", "help", "manage", "notifications",
105 "probe", "webfinger", "login", "invite", "credits")))
106 $a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
109 function get_vier_config($key, $default = false, $admin = false) {
110 if (local_user() AND !$admin) {
111 $result = get_pconfig(local_user(), "vier", $key);
112 if ($result !== false)
116 $result = get_config("vier", $key);
117 if ($result !== false)
123 function vier_community_info() {
126 $show_pages = get_vier_config("show_pages", 1);
127 $show_profiles = get_vier_config("show_profiles", 1);
128 $show_helpers = get_vier_config("show_helpers", 1);
129 $show_services = get_vier_config("show_services", 1);
130 $show_friends = get_vier_config("show_friends", 1);
131 $show_lastusers = get_vier_config("show_lastusers", 1);
134 $url = $a->get_baseurl($ssl_state);
135 $aside['$url'] = $url;
140 $r = suggestion_query(local_user(), 0, 9);
142 $tpl = get_markup_template('ch_directory_item.tpl');
145 $aside['$comunity_profiles_title'] = t('Community Profiles');
146 $aside['$comunity_profiles_items'] = array();
149 $entry = replace_macros($tpl,array(
151 //'$profile_link' => zrl($rr['url']),
152 '$profile_link' => $a->get_baseurl().'/follow/?url='.urlencode($rr['url']),
153 '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO),
154 '$alt_text' => $rr['name'],
156 $aside['$comunity_profiles_items'][] = $entry;
162 if($show_lastusers) {
163 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 ");
164 $order = " ORDER BY `register_date` DESC ";
166 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
167 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
168 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ",
171 $tpl = get_markup_template('ch_directory_item.tpl');
174 $aside['$lastusers_title'] = t('Last users');
175 $aside['$lastusers_items'] = array();
178 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
179 $entry = replace_macros($tpl,array(
181 '$profile_link' => $profile_link,
182 '$photo' => $a->get_cached_avatar_image($rr['thumb']),
183 '$alt_text' => $rr['name']));
184 $aside['$lastusers_items'][] = $entry;
189 //right_aside FIND FRIENDS
190 if ($show_friends AND local_user()) {
192 $nv['title'] = Array("", t('Find Friends'), "", "");
193 $nv['directory'] = Array('directory', t('Local Directory'), "", "");
194 $nv['global_directory'] = Array(get_server(), t('Global Directory'), "", "");
195 $nv['match'] = Array('match', t('Similar Interests'), "", "");
196 $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
197 $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
199 $nv['search'] = '<form name="simple_bar" method="get" action="'.$a->get_baseurl().'/dirfind">
200 <span class="sbox_l"></span>
202 <input type="text" name="search" size="13" maxlength="50">
204 <span class="sbox_r" id="srch_clear"></span>';
209 //Community_Pages at right_aside
210 if($show_pages AND local_user()) {
214 $contacts = q("SELECT `id`, `url`, `name`, `micro` FROM `contact`
215 WHERE `network`= '%s' AND `uid` = %d AND (`forum` OR `prv`) AND
216 NOT `hidden` AND NOT `blocked` AND
217 NOT `archive` AND NOT `pending` AND
218 `success_update` > `failure_update`
219 ORDER BY `name` ASC",
220 dbesc(NETWORK_DFRN), intval($a->user['uid']));
224 // Look if the profile is a community page
225 foreach($contacts as $contact) {
226 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
233 <h3>'.t("Community Pages").'</h3>
234 <div id="forum-list-right">';
236 foreach($contacts as $contact) {
237 $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>";
241 $aside['$page'] = $page;
250 $helperlist = get_config("vier", "helperlist");
252 $helpers = explode(",",$helperlist);
256 foreach ($helpers AS $index=>$helper) {
260 $query .= "'".dbesc(normalise_link(trim($helper)))."'";
263 $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
266 foreach ($r AS $index => $helper)
267 $r[$index]["url"] = zrl($helper["url"]);
269 $r[] = Array("url" => "help/Quick-Start-guide", "name" => t("Quick Start"));
271 $tpl = get_markup_template('ch_helpers.tpl');
276 $helpers['title'] = Array("", t('Help'), "", "");
278 $aside['$helpers_items'] = array();
281 $entry = replace_macros($tpl,array(
282 '$url' => $rr['url'],
283 '$title' => $rr['name'],
285 $aside['$helpers_items'][] = $entry;
288 $aside['$helpers'] = $helpers;
293 //connectable services
294 if ($show_services) {
298 if (nodeinfo_plugin_enabled("appnet"))
299 $r[] = array("photo" => "images/appnet.png", "name" => "App.net");
301 if (nodeinfo_plugin_enabled("buffer"))
302 $r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
304 if (nodeinfo_plugin_enabled("blogger"))
305 $r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
307 if (nodeinfo_plugin_enabled("dwpost"))
308 $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
310 if (nodeinfo_plugin_enabled("fbpost"))
311 $r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
313 if (nodeinfo_plugin_enabled("ifttt"))
314 $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
316 if (nodeinfo_plugin_enabled("statusnet"))
317 $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
319 if (nodeinfo_plugin_enabled("gpluspost"))
320 $r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
322 //if (nodeinfo_plugin_enabled("ijpost"))
323 // $r[] = array("photo" => "images/", "name" => "");
325 if (nodeinfo_plugin_enabled("libertree"))
326 $r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
328 //if (nodeinfo_plugin_enabled("ljpost"))
329 // $r[] = array("photo" => "images/", "name" => "");
331 if (nodeinfo_plugin_enabled("pumpio"))
332 $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
334 if (nodeinfo_plugin_enabled("tumblr"))
335 $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
337 if (nodeinfo_plugin_enabled("twitter"))
338 $r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
340 if (nodeinfo_plugin_enabled("wppost"))
341 $r[] = array("photo" => "images/wordpress", "name" => "Wordpress");
343 if(function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only"))
344 $r[] = array("photo" => "images/mail", "name" => "E-Mail");
346 $tpl = get_markup_template('ch_connectors.tpl');
350 $con_services = array();
351 $con_services['title'] = Array("", t('Connect Services'), "", "");
352 $aside['$con_services'] = $con_services;
355 $entry = replace_macros($tpl,array(
357 '$photo' => $rr['photo'],
358 '$alt_text' => $rr['name'],
360 $aside['$connector_items'][] = $entry;
365 //end connectable services
368 $tpl = get_markup_template('communityhome.tpl');
369 $a->page['right_aside'] = replace_macros($tpl, $aside);