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(App &$a) {
18 $a->theme_events_in_profile = false;
20 set_template_engine($a, 'smarty3');
22 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()) {
23 vier_community_info();
25 $a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
28 if ($a->is_mobile || $a->is_tablet) {
29 $a->page['htmlhead'] .= '<meta name=viewport content="width=device-width, initial-scale=1">'."\n";
30 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen"/>'."\n";
32 /// @todo deactivated since it doesn't work with desktop browsers at the moment
33 //$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
35 $a->page['htmlhead'] .= <<< EOT
36 <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
37 <script type="text/javascript">
39 function insertFormatting(BBcode, id) {
40 var tmpStr = $("#comment-edit-text-" + id).val();
42 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
43 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
44 openMenu("comment-edit-submit-wrapper-" + id);
45 $("#comment-edit-text-" + id).val(tmpStr);
48 textarea = document.getElementById("comment-edit-text-" +id);
49 if (document.selection) {
51 selected = document.selection.createRange();
52 if (BBcode == "url") {
53 selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
55 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
57 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
58 var start = textarea.selectionStart;
59 var end = textarea.selectionEnd;
60 if (BBcode == "url") {
61 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
63 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
70 function showThread(id) {
71 $("#collapsed-comments-" + id).show()
72 $("#collapsed-comments-" + id + " .collapsed-comments").show()
74 function hideThread(id) {
75 $("#collapsed-comments-" + id).hide()
76 $("#collapsed-comments-" + id + " .collapsed-comments").hide()
79 function cmtBbOpen(id) {
80 $("#comment-edit-bb-" + id).show();
82 function cmtBbClose(id) {
83 $("#comment-edit-bb-" + id).hide();
88 if ($a->is_mobile || $a->is_tablet){
89 $a->page['htmlhead'] .= <<< EOT
91 $(document).ready(function() {
92 $(".mobile-aside-toggle a").click(function(e){
94 $("aside").toggleClass("show");
96 $(".tabs").click(function(e){
97 $(this).toggleClass("show");
104 // Hide the left menu bar
105 if (($a->page['aside'] == "") AND in_array($a->argv[0], array("community", "events", "help", "manage", "notifications",
106 "probe", "webfinger", "login", "invite", "credits"))) {
107 $a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
111 function get_vier_config($key, $default = false, $admin = false) {
112 if (local_user() AND !$admin) {
113 $result = get_pconfig(local_user(), "vier", $key);
114 if ($result !== false)
118 $result = get_config("vier", $key);
119 if ($result !== false)
125 function vier_community_info() {
128 $show_pages = get_vier_config("show_pages", 1);
129 $show_profiles = get_vier_config("show_profiles", 1);
130 $show_helpers = get_vier_config("show_helpers", 1);
131 $show_services = get_vier_config("show_services", 1);
132 $show_friends = get_vier_config("show_friends", 1);
133 $show_lastusers = get_vier_config("show_lastusers", 1);
136 $url = App::get_baseurl($ssl_state);
137 $aside['$url'] = $url;
140 if ($show_profiles) {
142 $r = suggestion_query(local_user(), 0, 9);
144 $tpl = get_markup_template('ch_directory_item.tpl');
145 if (dbm::is_result($r)) {
147 $aside['$comunity_profiles_title'] = t('Community Profiles');
148 $aside['$comunity_profiles_items'] = array();
150 foreach ($r as $rr) {
151 $entry = replace_macros($tpl,array(
153 //'$profile_link' => zrl($rr['url']),
154 '$profile_link' => 'follow/?url='.urlencode($rr['url']),
155 '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO),
156 '$alt_text' => $rr['name'],
158 $aside['$comunity_profiles_items'][] = $entry;
164 if ($show_lastusers) {
165 $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 ");
166 $order = " ORDER BY `register_date` DESC ";
168 $tpl = get_markup_template('ch_directory_item.tpl');
170 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
171 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
172 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ",
175 if (dbm::is_result($r)) {
177 $aside['$lastusers_title'] = t('Last users');
178 $aside['$lastusers_items'] = array();
180 foreach ($r as $rr) {
181 $profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
182 $entry = replace_macros($tpl,array(
184 '$profile_link' => $profile_link,
185 '$photo' => $a->remove_baseurl($rr['thumb']),
186 '$alt_text' => $rr['name']));
187 $aside['$lastusers_items'][] = $entry;
192 //right_aside FIND FRIENDS
193 if ($show_friends AND local_user()) {
195 $nv['title'] = Array("", t('Find Friends'), "", "");
196 $nv['directory'] = Array('directory', t('Local Directory'), "", "");
197 $nv['global_directory'] = Array(get_server(), t('Global Directory'), "", "");
198 $nv['match'] = Array('match', t('Similar Interests'), "", "");
199 $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
200 $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
202 $nv['search'] = '<form name="simple_bar" method="get" action="dirfind">
203 <span class="sbox_l"></span>
205 <input type="text" name="search" size="13" maxlength="50">
207 <span class="sbox_r" id="srch_clear"></span>';
212 //Community_Pages at right_aside
213 if ($show_pages AND local_user()) {
215 require_once('include/ForumManager.php');
217 if (x($_GET['cid']) && intval($_GET['cid']) != 0)
220 //sort by last updated item
223 $contacts = ForumManager::get_list($a->user['uid'],true,$lastitem, true);
224 $total = count($contacts);
225 $visible_forums = 10;
227 if (count($contacts)) {
231 foreach($contacts as $contact) {
233 $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
236 'url' => 'network?f=&cid=' . $contact['id'],
237 'external_url' => 'redir/' . $contact['id'],
238 'name' => $contact['name'],
239 'cid' => $contact['id'],
240 'selected' => $selected,
241 'micro' => App::remove_baseurl(proxy_url($contact['micro'], false, PROXY_SIZE_MICRO)),
248 $tpl = get_markup_template('widget_forumlist_right.tpl');
250 $page .= replace_macros($tpl,array(
251 '$title' => t('Forums'),
252 '$forums' => $entries,
253 '$link_desc' => t('External link to forum'),
255 '$visible_forums' => $visible_forums,
256 '$showmore' => t('show more'),
259 $aside['$page'] = $page;
268 $helperlist = get_config("vier", "helperlist");
270 $helpers = explode(",",$helperlist);
274 foreach ($helpers AS $index=>$helper) {
278 $query .= "'".dbesc(normalise_link(trim($helper)))."'";
281 $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
284 foreach ($r AS $index => $helper)
285 $r[$index]["url"] = zrl($helper["url"]);
287 $r[] = Array("url" => "help/Quick-Start-guide", "name" => t("Quick Start"));
289 $tpl = get_markup_template('ch_helpers.tpl');
294 $helpers['title'] = Array("", t('Help'), "", "");
296 $aside['$helpers_items'] = array();
298 foreach ($r as $rr) {
299 $entry = replace_macros($tpl,array(
300 '$url' => $rr['url'],
301 '$title' => $rr['name'],
303 $aside['$helpers_items'][] = $entry;
306 $aside['$helpers'] = $helpers;
311 //connectable services
312 if ($show_services) {
314 /// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
317 if (plugin_enabled("appnet")) {
318 $r[] = array("photo" => "images/appnet.png", "name" => "App.net");
321 if (plugin_enabled("buffer")) {
322 $r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
325 if (plugin_enabled("blogger")) {
326 $r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
329 if (plugin_enabled("dwpost")) {
330 $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
333 if (plugin_enabled("fbpost")) {
334 $r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
337 if (plugin_enabled("ifttt")) {
338 $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
341 if (plugin_enabled("statusnet")) {
342 $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
345 if (plugin_enabled("gpluspost")) {
346 $r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
349 //if (plugin_enabled("ijpost")) {
350 // $r[] = array("photo" => "images/", "name" => "");
353 if (plugin_enabled("libertree")) {
354 $r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
357 //if (plugin_enabled("ljpost")) {
358 // $r[] = array("photo" => "images/", "name" => "");
361 if (plugin_enabled("pumpio")) {
362 $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
365 if (plugin_enabled("tumblr")) {
366 $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
369 if (plugin_enabled("twitter")) {
370 $r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
373 if (plugin_enabled("wppost")) {
374 $r[] = array("photo" => "images/wordpress.png", "name" => "Wordpress");
377 if (function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only")) {
378 $r[] = array("photo" => "images/mail.png", "name" => "E-Mail");
381 $tpl = get_markup_template('ch_connectors.tpl');
383 if (dbm::is_result($r)) {
385 $con_services = array();
386 $con_services['title'] = Array("", t('Connect Services'), "", "");
387 $aside['$con_services'] = $con_services;
389 foreach ($r as $rr) {
390 $entry = replace_macros($tpl,array(
392 '$photo' => $rr['photo'],
393 '$alt_text' => $rr['name'],
395 $aside['$connector_items'][] = $entry;
400 //end connectable services
403 $tpl = get_markup_template('communityhome.tpl');
404 $a->page['right_aside'] = replace_macros($tpl, $aside);