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 "mod/proxy.php";
24 function vier_init(App $a) {
26 $a->theme_events_in_profile = false;
28 $a->set_template_engine('smarty3');
30 if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) {
31 vier_community_info();
33 $a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
36 if ($a->is_mobile || $a->is_tablet) {
37 $a->page['htmlhead'] .= '<meta name=viewport content="width=device-width, initial-scale=1">'."\n";
38 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen"/>'."\n";
40 /// @todo deactivated since it doesn't work with desktop browsers at the moment
41 //$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
43 $a->page['htmlhead'] .= <<< EOT
44 <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
45 <script type="text/javascript">
47 function insertFormatting(BBcode, id) {
48 var tmpStr = $("#comment-edit-text-" + id).val();
50 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
51 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
52 openMenu("comment-edit-submit-wrapper-" + id);
55 textarea = document.getElementById("comment-edit-text-" +id);
56 if (document.selection) {
58 selected = document.selection.createRange();
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;
63 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
69 function showThread(id) {
70 $("#collapsed-comments-" + id).show()
71 $("#collapsed-comments-" + id + " .collapsed-comments").show()
73 function hideThread(id) {
74 $("#collapsed-comments-" + id).hide()
75 $("#collapsed-comments-" + id + " .collapsed-comments").hide()
78 function cmtBbOpen(id) {
79 $("#comment-edit-bb-" + id).show();
81 function cmtBbClose(id) {
82 $("#comment-edit-bb-" + id).hide();
87 if ($a->is_mobile || $a->is_tablet){
88 $a->page['htmlhead'] .= <<< EOT
90 $(document).ready(function() {
91 $(".mobile-aside-toggle a").click(function(e){
93 $("aside").toggleClass("show");
95 $(".tabs").click(function(e){
96 $(this).toggleClass("show");
103 // Hide the left menu bar
104 /// @TODO maybe move this static array out where it should belong?
105 if (($a->page['aside'] == "") && in_array($a->argv[0], ["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() && !$admin) {
113 $result = PConfig::get(local_user(), "vier", $key);
114 if (!is_null($result)) {
119 $result = Config::get("vier", $key);
120 if (!is_null($result)) {
127 function vier_community_info() {
130 $show_pages = get_vier_config("show_pages", 1);
131 $show_profiles = get_vier_config("show_profiles", 1);
132 $show_helpers = get_vier_config("show_helpers", 1);
133 $show_services = get_vier_config("show_services", 1);
134 $show_friends = get_vier_config("show_friends", 1);
135 $show_lastusers = get_vier_config("show_lastusers", 1);
138 $url = System::baseUrl($ssl_state);
139 $aside['$url'] = $url;
142 if ($show_profiles) {
143 $r = GContact::suggestionQuery(local_user(), 0, 9);
145 $tpl = get_markup_template('ch_directory_item.tpl');
146 if (DBM::is_result($r)) {
148 $aside['$comunity_profiles_title'] = t('Community Profiles');
149 $aside['$comunity_profiles_items'] = [];
151 foreach ($r as $rr) {
152 $entry = replace_macros($tpl,[
154 //'$profile_link' => Profile::zrl($rr['url']),
155 '$profile_link' => 'follow/?url='.urlencode($rr['url']),
156 '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO),
157 '$alt_text' => $rr['name'],
159 $aside['$comunity_profiles_items'][] = $entry;
165 if ($show_lastusers) {
166 $publish = (Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 ");
167 $order = " ORDER BY `register_date` DESC ";
169 $tpl = get_markup_template('ch_directory_item.tpl');
171 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
172 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
173 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ",
176 if (DBM::is_result($r)) {
178 $aside['$lastusers_title'] = t('Last users');
179 $aside['$lastusers_items'] = [];
181 foreach ($r as $rr) {
182 $profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
183 $entry = replace_macros($tpl,[
185 '$profile_link' => $profile_link,
186 '$photo' => $a->remove_baseurl($rr['thumb']),
187 '$alt_text' => $rr['name']]);
188 $aside['$lastusers_items'][] = $entry;
193 //right_aside FIND FRIENDS
194 if ($show_friends && local_user()) {
196 $nv['title'] = ["", t('Find Friends'), "", ""];
197 $nv['directory'] = ['directory', t('Local Directory'), "", ""];
198 $nv['global_directory'] = [get_server(), t('Global Directory'), "", ""];
199 $nv['match'] = ['match', t('Similar Interests'), "", ""];
200 $nv['suggest'] = ['suggest', t('Friend Suggestions'), "", ""];
201 $nv['invite'] = ['invite', t('Invite Friends'), "", ""];
203 $nv['search'] = '<form name="simple_bar" method="get" action="dirfind">
204 <span class="sbox_l"></span>
206 <input type="text" name="search" size="13" maxlength="50">
208 <span class="sbox_r" id="srch_clear"></span>';
213 //Community_Pages at right_aside
214 if ($show_pages && local_user()) {
215 if (x($_GET, 'cid') && intval($_GET['cid']) != 0) {
219 //sort by last updated item
222 $contacts = ForumManager::getList($a->user['uid'], $lastitem, true, true);
223 $total = count($contacts);
224 $visible_forums = 10;
226 if (count($contacts)) {
229 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' => System::removedBaseUrl(proxy_url($contact['micro'], false, PROXY_SIZE_MICRO)),
245 $tpl = get_markup_template('widget_forumlist_right.tpl');
247 $page .= replace_macros(
250 '$title' => t('Forums'),
251 '$forums' => $entries,
252 '$link_desc' => t('External link to forum'),
254 '$visible_forums' => $visible_forums,
255 '$showmore' => t('show more')]
258 $aside['$page'] = $page;
261 // END Community Page
267 $helperlist = Config::get("vier", "helperlist");
269 $helpers = explode(",",$helperlist);
273 foreach ($helpers AS $index=>$helper) {
277 $query .= "'".dbesc(normalise_link(trim($helper)))."'";
280 $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
283 foreach ($r AS $index => $helper)
284 $r[$index]["url"] = Profile::zrl($helper["url"]);
286 $r[] = ["url" => "help/Quick-Start-guide", "name" => t("Quick Start")];
288 $tpl = get_markup_template('ch_helpers.tpl');
293 $helpers['title'] = ["", t('Help'), "", ""];
295 $aside['$helpers_items'] = [];
297 foreach ($r as $rr) {
298 $entry = replace_macros($tpl,[
299 '$url' => $rr['url'],
300 '$title' => $rr['name'],
302 $aside['$helpers_items'][] = $entry;
305 $aside['$helpers'] = $helpers;
310 // connectable services
311 if ($show_services) {
313 /// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
316 if (Addon::isEnabled("appnet")) {
317 $r[] = ["photo" => "images/appnet.png", "name" => "App.net"];
320 if (Addon::isEnabled("buffer")) {
321 $r[] = ["photo" => "images/buffer.png", "name" => "Buffer"];
324 if (Addon::isEnabled("blogger")) {
325 $r[] = ["photo" => "images/blogger.png", "name" => "Blogger"];
328 if (Addon::isEnabled("dwpost")) {
329 $r[] = ["photo" => "images/dreamwidth.png", "name" => "Dreamwidth"];
332 if (Addon::isEnabled("fbpost")) {
333 $r[] = ["photo" => "images/facebook.png", "name" => "Facebook"];
336 if (Addon::isEnabled("ifttt")) {
337 $r[] = ["photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT"];
340 if (Addon::isEnabled("statusnet")) {
341 $r[] = ["photo" => "images/gnusocial.png", "name" => "GNU Social"];
344 if (Addon::isEnabled("gpluspost")) {
345 $r[] = ["photo" => "images/googleplus.png", "name" => "Google+"];
348 /// @TODO old-lost code (and below)?
349 //if (Addon::isEnabled("ijpost")) {
350 // $r[] = array("photo" => "images/", "name" => "");
353 if (Addon::isEnabled("libertree")) {
354 $r[] = ["photo" => "images/libertree.png", "name" => "Libertree"];
357 //if (Addon::isEnabled("ljpost")) {
358 // $r[] = array("photo" => "images/", "name" => "");
361 if (Addon::isEnabled("pumpio")) {
362 $r[] = ["photo" => "images/pumpio.png", "name" => "pump.io"];
365 if (Addon::isEnabled("tumblr")) {
366 $r[] = ["photo" => "images/tumblr.png", "name" => "Tumblr"];
369 if (Addon::isEnabled("twitter")) {
370 $r[] = ["photo" => "images/twitter.png", "name" => "Twitter"];
373 if (Addon::isEnabled("wppost")) {
374 $r[] = ["photo" => "images/wordpress.png", "name" => "Wordpress"];
377 if (function_exists("imap_open") && !Config::get("system","imap_disabled") && !Config::get("system","dfrn_only")) {
378 $r[] = ["photo" => "images/mail.png", "name" => "E-Mail"];
381 $tpl = get_markup_template('ch_connectors.tpl');
383 if (DBM::is_result($r)) {
386 $con_services['title'] = ["", t('Connect Services'), "", ""];
387 $aside['$con_services'] = $con_services;
389 foreach ($r as $rr) {
390 $entry = replace_macros($tpl,[
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);