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/
13 use Friendica\Core\Config;
14 use Friendica\Core\PConfig;
15 use Friendica\Core\System;
16 use Friendica\Database\DBM;
18 require_once "include/plugin.php";
19 require_once "include/socgraph.php";
20 require_once "mod/proxy.php";
22 function vier_init(App $a) {
24 $a->theme_events_in_profile = false;
26 $a->set_template_engine('smarty3');
28 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) {
29 vier_community_info();
31 $a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
34 if ($a->is_mobile || $a->is_tablet) {
35 $a->page['htmlhead'] .= '<meta name=viewport content="width=device-width, initial-scale=1">'."\n";
36 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen"/>'."\n";
38 /// @todo deactivated since it doesn't work with desktop browsers at the moment
39 //$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
41 $a->page['htmlhead'] .= <<< EOT
42 <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
43 <script type="text/javascript">
45 function insertFormatting(BBcode, id) {
46 var tmpStr = $("#comment-edit-text-" + id).val();
48 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
49 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
50 openMenu("comment-edit-submit-wrapper-" + id);
53 textarea = document.getElementById("comment-edit-text-" +id);
54 if (document.selection) {
56 selected = document.selection.createRange();
57 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
58 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
59 var start = textarea.selectionStart;
60 var end = textarea.selectionEnd;
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()
76 function cmtBbOpen(id) {
77 $("#comment-edit-bb-" + id).show();
79 function cmtBbClose(id) {
80 $("#comment-edit-bb-" + id).hide();
85 if ($a->is_mobile || $a->is_tablet){
86 $a->page['htmlhead'] .= <<< EOT
88 $(document).ready(function() {
89 $(".mobile-aside-toggle a").click(function(e){
91 $("aside").toggleClass("show");
93 $(".tabs").click(function(e){
94 $(this).toggleClass("show");
101 // Hide the left menu bar
102 /// @TODO maybe move this static array out where it should belong?
103 if (($a->page['aside'] == "") && in_array($a->argv[0], array("community", "events", "help", "manage", "notifications",
104 "probe", "webfinger", "login", "invite", "credits"))) {
105 $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() && !$admin) {
111 $result = PConfig::get(local_user(), "vier", $key);
112 if ($result !== false) {
117 $result = Config::get("vier", $key);
118 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 = System::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 = (Config::get('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 && 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 && local_user()) {
215 require_once 'include/ForumManager.php';
217 if (x($_GET, 'cid') && intval($_GET['cid']) != 0) {
221 //sort by last updated item
224 $contacts = ForumManager::get_list($a->user['uid'],true,$lastitem, true);
225 $total = count($contacts);
226 $visible_forums = 10;
228 if (count($contacts)) {
232 foreach ($contacts as $contact) {
234 $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
237 'url' => 'network?f=&cid=' . $contact['id'],
238 'external_url' => 'redir/' . $contact['id'],
239 'name' => $contact['name'],
240 'cid' => $contact['id'],
241 'selected' => $selected,
242 'micro' => System::removedBaseUrl(proxy_url($contact['micro'], false, PROXY_SIZE_MICRO)),
249 $tpl = get_markup_template('widget_forumlist_right.tpl');
251 $page .= replace_macros($tpl, array(
252 '$title' => t('Forums'),
253 '$forums' => $entries,
254 '$link_desc' => t('External link to forum'),
256 '$visible_forums' => $visible_forums,
257 '$showmore' => t('show more'),
260 $aside['$page'] = $page;
263 // END Community Page
269 $helperlist = Config::get("vier", "helperlist");
271 $helpers = explode(",",$helperlist);
275 foreach ($helpers AS $index=>$helper) {
279 $query .= "'".dbesc(normalise_link(trim($helper)))."'";
282 $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
285 foreach ($r AS $index => $helper)
286 $r[$index]["url"] = zrl($helper["url"]);
288 $r[] = array("url" => "help/Quick-Start-guide", "name" => t("Quick Start"));
290 $tpl = get_markup_template('ch_helpers.tpl');
295 $helpers['title'] = array("", t('Help'), "", "");
297 $aside['$helpers_items'] = array();
299 foreach ($r as $rr) {
300 $entry = replace_macros($tpl,array(
301 '$url' => $rr['url'],
302 '$title' => $rr['name'],
304 $aside['$helpers_items'][] = $entry;
307 $aside['$helpers'] = $helpers;
312 // connectable services
313 if ($show_services) {
315 /// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
318 if (plugin_enabled("appnet")) {
319 $r[] = array("photo" => "images/appnet.png", "name" => "App.net");
322 if (plugin_enabled("buffer")) {
323 $r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
326 if (plugin_enabled("blogger")) {
327 $r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
330 if (plugin_enabled("dwpost")) {
331 $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
334 if (plugin_enabled("fbpost")) {
335 $r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
338 if (plugin_enabled("ifttt")) {
339 $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
342 if (plugin_enabled("statusnet")) {
343 $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
346 if (plugin_enabled("gpluspost")) {
347 $r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
350 /// @TODO old-lost code (and below)?
351 //if (plugin_enabled("ijpost")) {
352 // $r[] = array("photo" => "images/", "name" => "");
355 if (plugin_enabled("libertree")) {
356 $r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
359 //if (plugin_enabled("ljpost")) {
360 // $r[] = array("photo" => "images/", "name" => "");
363 if (plugin_enabled("pumpio")) {
364 $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
367 if (plugin_enabled("tumblr")) {
368 $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
371 if (plugin_enabled("twitter")) {
372 $r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
375 if (plugin_enabled("wppost")) {
376 $r[] = array("photo" => "images/wordpress.png", "name" => "Wordpress");
379 if (function_exists("imap_open") && !Config::get("system","imap_disabled") && !Config::get("system","dfrn_only")) {
380 $r[] = array("photo" => "images/mail.png", "name" => "E-Mail");
383 $tpl = get_markup_template('ch_connectors.tpl');
385 if (DBM::is_result($r)) {
387 $con_services = array();
388 $con_services['title'] = array("", t('Connect Services'), "", "");
389 $aside['$con_services'] = $con_services;
391 foreach ($r as $rr) {
392 $entry = replace_macros($tpl,array(
394 '$photo' => $rr['photo'],
395 '$alt_text' => $rr['name'],
397 $aside['$connector_items'][] = $entry;
402 //end connectable services
405 $tpl = get_markup_template('communityhome.tpl');
406 $a->page['right_aside'] = replace_macros($tpl, $aside);