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' media='screen and (min-width: 1300px)' href='view/theme/vier/wide.css' />";
32 $a->page['htmlhead'] .= <<< EOT
33 <link rel='stylesheet' media='screen and (max-width: 1100px)' href='view/theme/vier/narrow.css' />
34 <script type="text/javascript">
36 function insertFormatting(comment,BBcode,id) {
38 var tmpStr = $("#comment-edit-text-" + id).val();
39 if(tmpStr == comment) {
41 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
42 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
43 openMenu("comment-edit-submit-wrapper-" + id);
44 $("#comment-edit-text-" + id).val(tmpStr);
47 textarea = document.getElementById("comment-edit-text-" +id);
48 if (document.selection) {
50 selected = document.selection.createRange();
52 selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
54 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
55 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
56 var start = textarea.selectionStart;
57 var end = textarea.selectionEnd;
59 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
61 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
67 function showThread(id) {
68 $("#collapsed-comments-" + id).show()
69 $("#collapsed-comments-" + id + " .collapsed-comments").show()
71 function hideThread(id) {
72 $("#collapsed-comments-" + id).hide()
73 $("#collapsed-comments-" + id + " .collapsed-comments").hide()
77 function cmtBbOpen(id) {
78 $("#comment-edit-bb-" + id).show();
80 function cmtBbClose(id) {
81 $("#comment-edit-bb-" + id).hide();
86 // Hide the left menu bar
87 if (($a->page['aside'] == "") AND in_array($a->argv[0], array("community", "events", "help", "manage", "notifications", "probe", "webfinger", "login")))
88 $a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
91 function get_vier_config($key, $default = false, $admin = false) {
92 if (local_user() AND !$admin) {
93 $result = get_pconfig(local_user(), "vier", $key);
94 if ($result !== false)
98 $result = get_config("vier", $key);
99 if ($result !== false)
105 function vier_community_info() {
108 $show_pages = get_vier_config("show_pages", 1);
109 $show_profiles = get_vier_config("show_profiles", 1);
110 $show_helpers = get_vier_config("show_helpers", 1);
111 $show_services = get_vier_config("show_services", 1);
112 $show_friends = get_vier_config("show_friends", 1);
113 $show_lastusers = get_vier_config("show_lastusers", 1);
116 $url = $a->get_baseurl($ssl_state);
117 $aside['$url'] = $url;
122 $r = suggestion_query(local_user(), 0, 9);
124 $tpl = get_markup_template('ch_directory_item.tpl');
127 $aside['$comunity_profiles_title'] = t('Community Profiles');
128 $aside['$comunity_profiles_items'] = array();
131 $entry = replace_macros($tpl,array(
133 //'$profile_link' => zrl($rr['url']),
134 '$profile_link' => $a->get_baseurl().'/follow/?url='.urlencode($rr['url']),
135 '$photo' => proxy_url($rr['photo']),
136 '$alt_text' => $rr['name'],
138 $aside['$comunity_profiles_items'][] = $entry;
144 if($show_lastusers) {
145 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 ");
146 $order = " ORDER BY `register_date` DESC ";
148 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
149 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
150 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ",
153 $tpl = get_markup_template('ch_directory_item.tpl');
156 $aside['$lastusers_title'] = t('Last users');
157 $aside['$lastusers_items'] = array();
160 $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
161 $entry = replace_macros($tpl,array(
163 '$profile_link' => $profile_link,
164 '$photo' => $a->get_cached_avatar_image($rr['thumb']),
165 '$alt_text' => $rr['name']));
166 $aside['$lastusers_items'][] = $entry;
171 //right_aside FIND FRIENDS
172 if ($show_friends AND local_user()) {
174 $nv['title'] = Array("", t('Find Friends'), "", "");
175 $nv['directory'] = Array('directory', t('Local Directory'), "", "");
176 $nv['global_directory'] = Array(get_server(), t('Global Directory'), "", "");
177 $nv['match'] = Array('match', t('Similar Interests'), "", "");
178 $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
179 $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
181 $nv['search'] = '<form name="simple_bar" method="get" action="'.$a->get_baseurl().'/dirfind">
182 <span class="sbox_l"></span>
184 <input type="text" name="search" size="13" maxlength="50">
186 <span class="sbox_r" id="srch_clear"></span>';
191 //Community_Pages at right_aside
192 if($show_pages AND local_user()) {
196 $contacts = q("SELECT `id`, `url`, `name`, `micro` FROM `contact`
197 WHERE `network`= '%s' AND `forum` AND `uid` = %d AND
198 NOT `hidden` AND NOT `blocked` AND
199 NOT `archive` AND NOT `pending` AND
200 `success_update` > `failure_update`
201 ORDER BY `name` ASC",
202 dbesc(NETWORK_DFRN), intval($a->user['uid']));
206 // Look if the profile is a community page
207 foreach($contacts as $contact) {
208 $pageD[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
215 <h3>'.t("Community Pages").'</h3>
216 <div id="forum-list-right">';
218 foreach($contacts as $contact) {
219 $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>";
223 $aside['$page'] = $page;
232 $helperlist = get_config("vier", "helperlist");
234 $helpers = explode(",",$helperlist);
238 foreach ($helpers AS $index=>$helper) {
242 $query .= "'".dbesc(normalise_link(trim($helper)))."'";
245 $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
248 foreach ($r AS $index => $helper)
249 $r[$index]["url"] = zrl($helper["url"]);
251 $r[] = Array("url" => "help/Quick-Start-guide", "name" => t("Quick Start"));
253 $tpl = get_markup_template('ch_helpers.tpl');
258 $helpers['title'] = Array("", t('Help'), "", "");
260 $aside['$helpers_items'] = array();
263 $entry = replace_macros($tpl,array(
264 '$url' => $rr['url'],
265 '$title' => $rr['name'],
267 $aside['$helpers_items'][] = $entry;
270 $aside['$helpers'] = $helpers;
275 //connectable services
276 if ($show_services) {
280 if (nodeinfo_plugin_enabled("appnet"))
281 $r[] = array("photo" => "images/appnet.png", "name" => "App.net");
283 if (nodeinfo_plugin_enabled("buffer"))
284 $r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
286 if (nodeinfo_plugin_enabled("blogger"))
287 $r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
289 if (nodeinfo_plugin_enabled("dwpost"))
290 $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
292 if (nodeinfo_plugin_enabled("fbpost"))
293 $r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
295 if (nodeinfo_plugin_enabled("statusnet"))
296 $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
298 if (nodeinfo_plugin_enabled("gpluspost"))
299 $r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
301 //if (nodeinfo_plugin_enabled("ijpost"))
302 // $r[] = array("photo" => "images/", "name" => "");
304 if (nodeinfo_plugin_enabled("libertree"))
305 $r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
307 //if (nodeinfo_plugin_enabled("ljpost"))
308 // $r[] = array("photo" => "images/", "name" => "");
310 if (nodeinfo_plugin_enabled("pumpio"))
311 $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
313 if (nodeinfo_plugin_enabled("tumblr"))
314 $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
316 if (nodeinfo_plugin_enabled("twitter"))
317 $r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
319 if (nodeinfo_plugin_enabled("wppost"))
320 $r[] = array("photo" => "images/wordpress", "name" => "Wordpress");
322 if(function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only"))
323 $r[] = array("photo" => "images/mail", "name" => "E-Mail");
325 $tpl = get_markup_template('ch_connectors.tpl');
329 $con_services = array();
330 $con_services['title'] = Array("", t('Connect Services'), "", "");
331 $aside['$con_services'] = $con_services;
334 $entry = replace_macros($tpl,array(
336 '$photo' => $rr['photo'],
337 '$alt_text' => $rr['name'],
339 $aside['$connector_items'][] = $entry;
344 //end connectable services
347 $tpl = get_markup_template('communityhome.tpl');
348 $a->page['right_aside'] = replace_macros($tpl, $aside);