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/
14 require_once "include/plugin.php";
15 require_once "include/socgraph.php";
16 require_once "mod/proxy.php";
18 function vier_init(App $a) {
20 $a->theme_events_in_profile = false;
22 set_template_engine($a, 'smarty3');
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 /// @todo deactivated since it doesn't work with desktop browsers at the moment
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(BBcode, id) {
42 var tmpStr = $("#comment-edit-text-" + id).val();
44 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
45 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
46 openMenu("comment-edit-submit-wrapper-" + id);
49 textarea = document.getElementById("comment-edit-text-" +id);
50 if (document.selection) {
52 selected = document.selection.createRange();
53 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
54 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
55 var start = textarea.selectionStart;
56 var end = textarea.selectionEnd;
57 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
63 function showThread(id) {
64 $("#collapsed-comments-" + id).show()
65 $("#collapsed-comments-" + id + " .collapsed-comments").show()
67 function hideThread(id) {
68 $("#collapsed-comments-" + id).hide()
69 $("#collapsed-comments-" + id + " .collapsed-comments").hide()
72 function cmtBbOpen(id) {
73 $("#comment-edit-bb-" + id).show();
75 function cmtBbClose(id) {
76 $("#comment-edit-bb-" + id).hide();
81 if ($a->is_mobile || $a->is_tablet){
82 $a->page['htmlhead'] .= <<< EOT
84 $(document).ready(function() {
85 $(".mobile-aside-toggle a").click(function(e){
87 $("aside").toggleClass("show");
89 $(".tabs").click(function(e){
90 $(this).toggleClass("show");
97 // Hide the left menu bar
98 /// @TODO maybe move this static array out where it should belong?
99 if (($a->page['aside'] == "") AND in_array($a->argv[0], array("community", "events", "help", "manage", "notifications",
100 "probe", "webfinger", "login", "invite", "credits"))) {
101 $a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
105 function get_vier_config($key, $default = false, $admin = false) {
106 if (local_user() AND !$admin) {
107 $result = get_pconfig(local_user(), "vier", $key);
108 if ($result !== false) {
113 $result = get_config("vier", $key);
114 if ($result !== false) {
121 function vier_community_info() {
124 $show_pages = get_vier_config("show_pages", 1);
125 $show_profiles = get_vier_config("show_profiles", 1);
126 $show_helpers = get_vier_config("show_helpers", 1);
127 $show_services = get_vier_config("show_services", 1);
128 $show_friends = get_vier_config("show_friends", 1);
129 $show_lastusers = get_vier_config("show_lastusers", 1);
132 $url = App::get_baseurl($ssl_state);
133 $aside['$url'] = $url;
136 if ($show_profiles) {
138 $r = suggestion_query(local_user(), 0, 9);
140 $tpl = get_markup_template('ch_directory_item.tpl');
141 if (dbm::is_result($r)) {
143 $aside['$comunity_profiles_title'] = t('Community Profiles');
144 $aside['$comunity_profiles_items'] = array();
146 foreach ($r as $rr) {
147 $entry = replace_macros($tpl,array(
149 //'$profile_link' => zrl($rr['url']),
150 '$profile_link' => 'follow/?url='.urlencode($rr['url']),
151 '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO),
152 '$alt_text' => $rr['name'],
154 $aside['$comunity_profiles_items'][] = $entry;
160 if ($show_lastusers) {
161 $publish = (get_config('system', 'publish_all') ? '' : " AND `publish` = 1 ");
162 $order = " ORDER BY `register_date` DESC ";
164 $tpl = get_markup_template('ch_directory_item.tpl');
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 if (dbm::is_result($r)) {
173 $aside['$lastusers_title'] = t('Last users');
174 $aside['$lastusers_items'] = array();
176 foreach ($r as $rr) {
177 $profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
178 $entry = replace_macros($tpl,array(
180 '$profile_link' => $profile_link,
181 '$photo' => $a->remove_baseurl($rr['thumb']),
182 '$alt_text' => $rr['name']));
183 $aside['$lastusers_items'][] = $entry;
188 //right_aside FIND FRIENDS
189 if ($show_friends AND local_user()) {
191 $nv['title'] = array("", t('Find Friends'), "", "");
192 $nv['directory'] = array('directory', t('Local Directory'), "", "");
193 $nv['global_directory'] = Array(get_server(), t('Global Directory'), "", "");
194 $nv['match'] = array('match', t('Similar Interests'), "", "");
195 $nv['suggest'] = array('suggest', t('Friend Suggestions'), "", "");
196 $nv['invite'] = array('invite', t('Invite Friends'), "", "");
198 $nv['search'] = '<form name="simple_bar" method="get" action="dirfind">
199 <span class="sbox_l"></span>
201 <input type="text" name="search" size="13" maxlength="50">
203 <span class="sbox_r" id="srch_clear"></span>';
208 //Community_Pages at right_aside
209 if ($show_pages AND local_user()) {
211 require_once 'include/ForumManager.php';
213 if (x($_GET, 'cid') && intval($_GET['cid']) != 0) {
217 //sort by last updated item
220 $contacts = ForumManager::get_list($a->user['uid'],true,$lastitem, true);
221 $total = count($contacts);
222 $visible_forums = 10;
224 if (count($contacts)) {
228 foreach ($contacts as $contact) {
230 $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
233 'url' => 'network?f=&cid=' . $contact['id'],
234 'external_url' => 'redir/' . $contact['id'],
235 'name' => $contact['name'],
236 'cid' => $contact['id'],
237 'selected' => $selected,
238 'micro' => App::remove_baseurl(proxy_url($contact['micro'], false, PROXY_SIZE_MICRO)),
245 $tpl = get_markup_template('widget_forumlist_right.tpl');
247 $page .= replace_macros($tpl, array(
248 '$title' => t('Forums'),
249 '$forums' => $entries,
250 '$link_desc' => t('External link to forum'),
252 '$visible_forums' => $visible_forums,
253 '$showmore' => t('show more'),
256 $aside['$page'] = $page;
259 // END Community Page
265 $helperlist = get_config("vier", "helperlist");
267 $helpers = explode(",",$helperlist);
271 foreach ($helpers AS $index=>$helper) {
275 $query .= "'".dbesc(normalise_link(trim($helper)))."'";
278 $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
281 foreach ($r AS $index => $helper)
282 $r[$index]["url"] = zrl($helper["url"]);
284 $r[] = array("url" => "help/Quick-Start-guide", "name" => t("Quick Start"));
286 $tpl = get_markup_template('ch_helpers.tpl');
291 $helpers['title'] = array("", t('Help'), "", "");
293 $aside['$helpers_items'] = array();
295 foreach ($r as $rr) {
296 $entry = replace_macros($tpl,array(
297 '$url' => $rr['url'],
298 '$title' => $rr['name'],
300 $aside['$helpers_items'][] = $entry;
303 $aside['$helpers'] = $helpers;
308 // connectable services
309 if ($show_services) {
311 /// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
314 if (plugin_enabled("appnet")) {
315 $r[] = array("photo" => "images/appnet.png", "name" => "App.net");
318 if (plugin_enabled("buffer")) {
319 $r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
322 if (plugin_enabled("blogger")) {
323 $r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
326 if (plugin_enabled("dwpost")) {
327 $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
330 if (plugin_enabled("fbpost")) {
331 $r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
334 if (plugin_enabled("ifttt")) {
335 $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
338 if (plugin_enabled("statusnet")) {
339 $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
342 if (plugin_enabled("gpluspost")) {
343 $r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
346 /// @TODO old-lost code (and below)?
347 //if (plugin_enabled("ijpost")) {
348 // $r[] = array("photo" => "images/", "name" => "");
351 if (plugin_enabled("libertree")) {
352 $r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
355 //if (plugin_enabled("ljpost")) {
356 // $r[] = array("photo" => "images/", "name" => "");
359 if (plugin_enabled("pumpio")) {
360 $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
363 if (plugin_enabled("tumblr")) {
364 $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
367 if (plugin_enabled("twitter")) {
368 $r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
371 if (plugin_enabled("wppost")) {
372 $r[] = array("photo" => "images/wordpress.png", "name" => "Wordpress");
375 if (function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only")) {
376 $r[] = array("photo" => "images/mail.png", "name" => "E-Mail");
379 $tpl = get_markup_template('ch_connectors.tpl');
381 if (dbm::is_result($r)) {
383 $con_services = array();
384 $con_services['title'] = array("", t('Connect Services'), "", "");
385 $aside['$con_services'] = $con_services;
387 foreach ($r as $rr) {
388 $entry = replace_macros($tpl,array(
390 '$photo' => $rr['photo'],
391 '$alt_text' => $rr['name'],
393 $aside['$connector_items'][] = $entry;
398 //end connectable services
401 $tpl = get_markup_template('communityhome.tpl');
402 $a->page['right_aside'] = replace_macros($tpl, $aside);