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 $a->theme_info = array();
24 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()) {
25 vier_community_info();
27 $a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
30 if ($a->is_mobile || $a->is_tablet) {
31 $a->page['htmlhead'] .= '<meta name=viewport content="width=device-width, initial-scale=1">'."\n";
32 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen"/>'."\n";
34 // deactivated since it doesn't work with desktop browsers at the moment (To-Do)
35 //$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
37 $a->page['htmlhead'] .= <<< EOT
38 <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
39 <script type="text/javascript">
41 function insertFormatting(comment,BBcode,id) {
43 var tmpStr = $("#comment-edit-text-" + id).val();
44 if(tmpStr == comment) {
46 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
47 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
48 openMenu("comment-edit-submit-wrapper-" + id);
49 $("#comment-edit-text-" + id).val(tmpStr);
52 textarea = document.getElementById("comment-edit-text-" +id);
53 if (document.selection) {
55 selected = document.selection.createRange();
57 selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
59 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
60 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
61 var start = textarea.selectionStart;
62 var end = textarea.selectionEnd;
64 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
66 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
72 function showThread(id) {
73 $("#collapsed-comments-" + id).show()
74 $("#collapsed-comments-" + id + " .collapsed-comments").show()
76 function hideThread(id) {
77 $("#collapsed-comments-" + id).hide()
78 $("#collapsed-comments-" + id + " .collapsed-comments").hide()
82 function cmtBbOpen(id) {
83 $("#comment-edit-bb-" + id).show();
85 function cmtBbClose(id) {
86 $("#comment-edit-bb-" + id).hide();
95 if ($a->is_mobile || $a->is_tablet){
96 $a->page['htmlhead'] .= <<< EOT
98 $(document).ready(function() {
99 $(".mobile-aside-toggle a").click(function(e){
101 $("aside").toggleClass("show");
103 $(".tabs").click(function(e){
104 $(this).toggleClass("show");
112 // Hide the left menu bar
113 if (($a->page['aside'] == "") AND in_array($a->argv[0], array("community", "events", "help", "manage", "notifications",
114 "probe", "webfinger", "login", "invite", "credits")))
115 $a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
118 function get_vier_config($key, $default = false, $admin = false) {
119 if (local_user() AND !$admin) {
120 $result = get_pconfig(local_user(), "vier", $key);
121 if ($result !== false)
125 $result = get_config("vier", $key);
126 if ($result !== false)
132 function vier_community_info() {
135 $show_pages = get_vier_config("show_pages", 1);
136 $show_profiles = get_vier_config("show_profiles", 1);
137 $show_helpers = get_vier_config("show_helpers", 1);
138 $show_services = get_vier_config("show_services", 1);
139 $show_friends = get_vier_config("show_friends", 1);
140 $show_lastusers = get_vier_config("show_lastusers", 1);
143 $url = $a->get_baseurl($ssl_state);
144 $aside['$url'] = $url;
149 $r = suggestion_query(local_user(), 0, 9);
151 $tpl = get_markup_template('ch_directory_item.tpl');
154 $aside['$comunity_profiles_title'] = t('Community Profiles');
155 $aside['$comunity_profiles_items'] = array();
158 $entry = replace_macros($tpl,array(
160 //'$profile_link' => zrl($rr['url']),
161 '$profile_link' => 'follow/?url='.urlencode($rr['url']),
162 '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO),
163 '$alt_text' => $rr['name'],
165 $aside['$comunity_profiles_items'][] = $entry;
171 if($show_lastusers) {
172 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 ");
173 $order = " ORDER BY `register_date` DESC ";
175 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
176 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
177 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ",
180 $tpl = get_markup_template('ch_directory_item.tpl');
183 $aside['$lastusers_title'] = t('Last users');
184 $aside['$lastusers_items'] = array();
187 $profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
188 $entry = replace_macros($tpl,array(
190 '$profile_link' => $profile_link,
191 '$photo' => $a->remove_baseurl($rr['thumb']),
192 '$alt_text' => $rr['name']));
193 $aside['$lastusers_items'][] = $entry;
198 //right_aside FIND FRIENDS
199 if ($show_friends AND local_user()) {
201 $nv['title'] = Array("", t('Find Friends'), "", "");
202 $nv['directory'] = Array('directory', t('Local Directory'), "", "");
203 $nv['global_directory'] = Array(get_server(), t('Global Directory'), "", "");
204 $nv['match'] = Array('match', t('Similar Interests'), "", "");
205 $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
206 $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
208 $nv['search'] = '<form name="simple_bar" method="get" action="dirfind">
209 <span class="sbox_l"></span>
211 <input type="text" name="search" size="13" maxlength="50">
213 <span class="sbox_r" id="srch_clear"></span>';
218 //Community_Pages at right_aside
219 if($show_pages AND local_user()) {
221 require_once('include/ForumManager.php');
223 if(x($_GET['cid']) && intval($_GET['cid']) != 0)
226 //sort by last updated item
229 $contacts = ForumManager::get_list($a->user['uid'],true,$lastitem, true);
230 $total = count($contacts);
231 $visible_forums = 10;
233 if(count($contacts)) {
237 foreach($contacts as $contact) {
239 $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
242 'url' => 'network?f=&cid=' . $contact['id'],
243 'external_url' => 'redir/' . $contact['id'],
244 'name' => $contact['name'],
245 'cid' => $contact['id'],
246 'selected' => $selected,
247 'micro' => App::remove_baseurl(proxy_url($contact['micro'], false, PROXY_SIZE_MICRO)),
254 $tpl = get_markup_template('widget_forumlist_right.tpl');
256 $page .= replace_macros($tpl,array(
257 '$title' => t('Forums'),
258 '$forums' => $entries,
259 '$link_desc' => t('External link to forum'),
261 '$visible_forums' => $visible_forums,
262 '$showmore' => t('show more'),
265 $aside['$page'] = $page;
274 $helperlist = get_config("vier", "helperlist");
276 $helpers = explode(",",$helperlist);
280 foreach ($helpers AS $index=>$helper) {
284 $query .= "'".dbesc(normalise_link(trim($helper)))."'";
287 $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
290 foreach ($r AS $index => $helper)
291 $r[$index]["url"] = zrl($helper["url"]);
293 $r[] = Array("url" => "help/Quick-Start-guide", "name" => t("Quick Start"));
295 $tpl = get_markup_template('ch_helpers.tpl');
300 $helpers['title'] = Array("", t('Help'), "", "");
302 $aside['$helpers_items'] = array();
305 $entry = replace_macros($tpl,array(
306 '$url' => $rr['url'],
307 '$title' => $rr['name'],
309 $aside['$helpers_items'][] = $entry;
312 $aside['$helpers'] = $helpers;
317 //connectable services
318 if ($show_services) {
322 if (plugin_enabled("appnet"))
323 $r[] = array("photo" => "images/appnet.png", "name" => "App.net");
325 if (plugin_enabled("buffer"))
326 $r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
328 if (plugin_enabled("blogger"))
329 $r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
331 if (plugin_enabled("dwpost"))
332 $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
334 if (plugin_enabled("fbpost"))
335 $r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
337 if (plugin_enabled("ifttt"))
338 $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
340 if (plugin_enabled("statusnet"))
341 $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
343 if (plugin_enabled("gpluspost"))
344 $r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
346 //if (plugin_enabled("ijpost"))
347 // $r[] = array("photo" => "images/", "name" => "");
349 if (plugin_enabled("libertree"))
350 $r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
352 //if (plugin_enabled("ljpost"))
353 // $r[] = array("photo" => "images/", "name" => "");
355 if (plugin_enabled("pumpio"))
356 $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
358 if (plugin_enabled("tumblr"))
359 $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
361 if (plugin_enabled("twitter"))
362 $r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
364 if (plugin_enabled("wppost"))
365 $r[] = array("photo" => "images/wordpress.png", "name" => "Wordpress");
367 if(function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only"))
368 $r[] = array("photo" => "images/mail.png", "name" => "E-Mail");
370 $tpl = get_markup_template('ch_connectors.tpl');
374 $con_services = array();
375 $con_services['title'] = Array("", t('Connect Services'), "", "");
376 $aside['$con_services'] = $con_services;
379 $entry = replace_macros($tpl,array(
381 '$photo' => $rr['photo'],
382 '$alt_text' => $rr['name'],
384 $aside['$connector_items'][] = $entry;
389 //end connectable services
392 $tpl = get_markup_template('communityhome.tpl');
393 $a->page['right_aside'] = replace_macros($tpl, $aside);