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\Content\ForumManager;
14 use Friendica\Core\Addon;
15 use Friendica\Core\Config;
16 use Friendica\Core\PConfig;
17 use Friendica\Core\System;
18 use Friendica\Database\DBM;
19 use Friendica\Model\GContact;
20 use Friendica\Model\Profile;
22 require_once "include/plugin.php";
23 require_once "mod/proxy.php";
25 function vier_init(App $a) {
27 $a->theme_events_in_profile = false;
29 $a->set_template_engine('smarty3');
31 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) {
32 vier_community_info();
34 $a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
37 if ($a->is_mobile || $a->is_tablet) {
38 $a->page['htmlhead'] .= '<meta name=viewport content="width=device-width, initial-scale=1">'."\n";
39 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen"/>'."\n";
41 /// @todo deactivated since it doesn't work with desktop browsers at the moment
42 //$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
44 $a->page['htmlhead'] .= <<< EOT
45 <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
46 <script type="text/javascript">
48 function insertFormatting(BBcode, id) {
49 var tmpStr = $("#comment-edit-text-" + id).val();
51 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
52 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
53 openMenu("comment-edit-submit-wrapper-" + id);
56 textarea = document.getElementById("comment-edit-text-" +id);
57 if (document.selection) {
59 selected = document.selection.createRange();
60 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
61 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
62 var start = textarea.selectionStart;
63 var end = textarea.selectionEnd;
64 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 /// @TODO maybe move this static array out where it should belong?
106 if (($a->page['aside'] == "") && in_array($a->argv[0], ["community", "events", "help", "manage", "notifications",
107 "probe", "webfinger", "login", "invite", "credits"])) {
108 $a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
112 function get_vier_config($key, $default = false, $admin = false) {
113 if (local_user() && !$admin) {
114 $result = PConfig::get(local_user(), "vier", $key);
115 if (!is_null($result)) {
120 $result = Config::get("vier", $key);
121 if (!is_null($result)) {
128 function vier_community_info() {
131 $show_pages = get_vier_config("show_pages", 1);
132 $show_profiles = get_vier_config("show_profiles", 1);
133 $show_helpers = get_vier_config("show_helpers", 1);
134 $show_services = get_vier_config("show_services", 1);
135 $show_friends = get_vier_config("show_friends", 1);
136 $show_lastusers = get_vier_config("show_lastusers", 1);
139 $url = System::baseUrl($ssl_state);
140 $aside['$url'] = $url;
143 if ($show_profiles) {
144 $r = GContact::suggestionQuery(local_user(), 0, 9);
146 $tpl = get_markup_template('ch_directory_item.tpl');
147 if (DBM::is_result($r)) {
149 $aside['$comunity_profiles_title'] = t('Community Profiles');
150 $aside['$comunity_profiles_items'] = [];
152 foreach ($r as $rr) {
153 $entry = replace_macros($tpl,[
155 //'$profile_link' => Profile::zrl($rr['url']),
156 '$profile_link' => 'follow/?url='.urlencode($rr['url']),
157 '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO),
158 '$alt_text' => $rr['name'],
160 $aside['$comunity_profiles_items'][] = $entry;
166 if ($show_lastusers) {
167 $publish = (Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 ");
168 $order = " ORDER BY `register_date` DESC ";
170 $tpl = get_markup_template('ch_directory_item.tpl');
172 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
173 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
174 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ",
177 if (DBM::is_result($r)) {
179 $aside['$lastusers_title'] = t('Last users');
180 $aside['$lastusers_items'] = [];
182 foreach ($r as $rr) {
183 $profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
184 $entry = replace_macros($tpl,[
186 '$profile_link' => $profile_link,
187 '$photo' => $a->remove_baseurl($rr['thumb']),
188 '$alt_text' => $rr['name']]);
189 $aside['$lastusers_items'][] = $entry;
194 //right_aside FIND FRIENDS
195 if ($show_friends && local_user()) {
197 $nv['title'] = ["", t('Find Friends'), "", ""];
198 $nv['directory'] = ['directory', t('Local Directory'), "", ""];
199 $nv['global_directory'] = [get_server(), t('Global Directory'), "", ""];
200 $nv['match'] = ['match', t('Similar Interests'), "", ""];
201 $nv['suggest'] = ['suggest', t('Friend Suggestions'), "", ""];
202 $nv['invite'] = ['invite', t('Invite Friends'), "", ""];
204 $nv['search'] = '<form name="simple_bar" method="get" action="dirfind">
205 <span class="sbox_l"></span>
207 <input type="text" name="search" size="13" maxlength="50">
209 <span class="sbox_r" id="srch_clear"></span>';
214 //Community_Pages at right_aside
215 if ($show_pages && local_user()) {
216 if (x($_GET, 'cid') && intval($_GET['cid']) != 0) {
220 //sort by last updated item
223 $contacts = ForumManager::getList($a->user['uid'], $lastitem, true, true);
224 $total = count($contacts);
225 $visible_forums = 10;
227 if (count($contacts)) {
230 foreach ($contacts as $contact) {
231 $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
234 'url' => 'network?f=&cid=' . $contact['id'],
235 'external_url' => 'redir/' . $contact['id'],
236 'name' => $contact['name'],
237 'cid' => $contact['id'],
238 'selected' => $selected,
239 'micro' => System::removedBaseUrl(proxy_url($contact['micro'], false, PROXY_SIZE_MICRO)),
246 $tpl = get_markup_template('widget_forumlist_right.tpl');
248 $page .= replace_macros(
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;
262 // END Community Page
268 $helperlist = Config::get("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"] = Profile::zrl($helper["url"]);
287 $r[] = ["url" => "help/Quick-Start-guide", "name" => t("Quick Start")];
289 $tpl = get_markup_template('ch_helpers.tpl');
294 $helpers['title'] = ["", t('Help'), "", ""];
296 $aside['$helpers_items'] = [];
298 foreach ($r as $rr) {
299 $entry = replace_macros($tpl,[
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 (Addon::isEnabled("appnet")) {
318 $r[] = ["photo" => "images/appnet.png", "name" => "App.net"];
321 if (Addon::isEnabled("buffer")) {
322 $r[] = ["photo" => "images/buffer.png", "name" => "Buffer"];
325 if (Addon::isEnabled("blogger")) {
326 $r[] = ["photo" => "images/blogger.png", "name" => "Blogger"];
329 if (Addon::isEnabled("dwpost")) {
330 $r[] = ["photo" => "images/dreamwidth.png", "name" => "Dreamwidth"];
333 if (Addon::isEnabled("fbpost")) {
334 $r[] = ["photo" => "images/facebook.png", "name" => "Facebook"];
337 if (Addon::isEnabled("ifttt")) {
338 $r[] = ["photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT"];
341 if (Addon::isEnabled("statusnet")) {
342 $r[] = ["photo" => "images/gnusocial.png", "name" => "GNU Social"];
345 if (Addon::isEnabled("gpluspost")) {
346 $r[] = ["photo" => "images/googleplus.png", "name" => "Google+"];
349 /// @TODO old-lost code (and below)?
350 //if (Addon::isEnabled("ijpost")) {
351 // $r[] = array("photo" => "images/", "name" => "");
354 if (Addon::isEnabled("libertree")) {
355 $r[] = ["photo" => "images/libertree.png", "name" => "Libertree"];
358 //if (Addon::isEnabled("ljpost")) {
359 // $r[] = array("photo" => "images/", "name" => "");
362 if (Addon::isEnabled("pumpio")) {
363 $r[] = ["photo" => "images/pumpio.png", "name" => "pump.io"];
366 if (Addon::isEnabled("tumblr")) {
367 $r[] = ["photo" => "images/tumblr.png", "name" => "Tumblr"];
370 if (Addon::isEnabled("twitter")) {
371 $r[] = ["photo" => "images/twitter.png", "name" => "Twitter"];
374 if (Addon::isEnabled("wppost")) {
375 $r[] = ["photo" => "images/wordpress.png", "name" => "Wordpress"];
378 if (function_exists("imap_open") && !Config::get("system","imap_disabled") && !Config::get("system","dfrn_only")) {
379 $r[] = ["photo" => "images/mail.png", "name" => "E-Mail"];
382 $tpl = get_markup_template('ch_connectors.tpl');
384 if (DBM::is_result($r)) {
387 $con_services['title'] = ["", t('Connect Services'), "", ""];
388 $aside['$con_services'] = $con_services;
390 foreach ($r as $rr) {
391 $entry = replace_macros($tpl,[
393 '$photo' => $rr['photo'],
394 '$alt_text' => $rr['name'],
396 $aside['$connector_items'][] = $entry;
401 //end connectable services
404 $tpl = get_markup_template('communityhome.tpl');
405 $a->page['right_aside'] = replace_macros($tpl, $aside);