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\L10n;
17 use Friendica\Core\PConfig;
18 use Friendica\Core\Renderer;
19 use Friendica\Core\System;
20 use Friendica\Database\DBA;
22 use Friendica\Model\Contact;
23 use Friendica\Model\GContact;
24 use Friendica\Util\Proxy as ProxyUtils;
25 use Friendica\Util\Strings;
27 function vier_init(App $a)
29 $a->theme_events_in_profile = false;
31 Renderer::setActiveTemplateEngine('smarty3');
33 if (!empty($a->argv[0]) && ($a->argv[0] . ($a->argv[1] ?? '')) === ('profile' . $a->user['nickname']) || $a->argv[0] === 'network' && local_user()) {
34 vier_community_info();
36 $a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
39 if ($a->is_mobile || $a->is_tablet) {
40 $a->page['htmlhead'] .= '<meta name=viewport content="width=device-width, initial-scale=1">'."\n";
41 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen"/>'."\n";
43 /// @todo deactivated since it doesn't work with desktop browsers at the moment
44 //$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
46 $a->page['htmlhead'] .= <<< EOT
47 <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
48 <script type="text/javascript">
49 function showThread(id) {
50 $("#collapsed-comments-" + id).show()
51 $("#collapsed-comments-" + id + " .collapsed-comments").show()
53 function hideThread(id) {
54 $("#collapsed-comments-" + id).hide()
55 $("#collapsed-comments-" + id + " .collapsed-comments").hide()
58 function cmtBbOpen(id) {
59 $("#comment-edit-bb-" + id).show();
61 function cmtBbClose(id) {
62 $("#comment-edit-bb-" + id).hide();
67 if ($a->is_mobile || $a->is_tablet) {
68 $a->page['htmlhead'] .= <<< EOT
70 $(document).ready(function() {
71 $(".mobile-aside-toggle a").click(function(e){
73 $("aside").toggleClass("show");
75 $(".tabs").click(function(e){
76 $(this).toggleClass("show");
83 // Hide the left menu bar
84 /// @TODO maybe move this static array out where it should belong?
85 if (empty($a->page['aside']) && in_array($a->argv[0], ["community", "events", "help", "delegation", "notifications",
86 "probe", "webfinger", "login", "invite", "credits"])) {
87 $a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
91 function get_vier_config($key, $default = false, $admin = false)
93 if (local_user() && !$admin) {
94 $result = PConfig::get(local_user(), "vier", $key);
95 if (!is_null($result)) {
100 $result = Config::get("vier", $key);
101 if (!is_null($result)) {
108 function vier_community_info()
112 $show_pages = get_vier_config("show_pages", 1);
113 $show_profiles = get_vier_config("show_profiles", 1);
114 $show_helpers = get_vier_config("show_helpers", 1);
115 $show_services = get_vier_config("show_services", 1);
116 $show_friends = get_vier_config("show_friends", 1);
117 $show_lastusers = get_vier_config("show_lastusers", 1);
120 $url = System::baseUrl();
121 $aside['$url'] = $url;
124 if ($show_profiles) {
125 $r = GContact::suggestionQuery(local_user(), 0, 9);
127 $tpl = Renderer::getMarkupTemplate('ch_directory_item.tpl');
128 if (DBA::isResult($r)) {
129 $aside['$comunity_profiles_title'] = L10n::t('Community Profiles');
130 $aside['$comunity_profiles_items'] = [];
132 foreach ($r as $rr) {
133 $entry = Renderer::replaceMacros($tpl, [
135 '$profile_link' => 'follow/?url='.urlencode($rr['url']),
136 '$photo' => ProxyUtils::proxifyUrl($rr['photo'], false, ProxyUtils::SIZE_MICRO),
137 '$alt_text' => $rr['name'],
139 $aside['$comunity_profiles_items'][] = $entry;
145 if ($show_lastusers) {
146 $publish = (Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 ");
147 $order = " ORDER BY `register_date` DESC ";
149 $tpl = Renderer::getMarkupTemplate('ch_directory_item.tpl');
151 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
152 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
153 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ",
158 if (DBA::isResult($r)) {
159 $aside['$lastusers_title'] = L10n::t('Last users');
160 $aside['$lastusers_items'] = [];
162 foreach ($r as $rr) {
163 $profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
164 $entry = Renderer::replaceMacros($tpl, [
166 '$profile_link' => $profile_link,
167 '$photo' => DI::baseUrl()->remove($rr['thumb']),
168 '$alt_text' => $rr['name']]);
169 $aside['$lastusers_items'][] = $entry;
174 //right_aside FIND FRIENDS
175 if ($show_friends && local_user()) {
177 $nv['findpeople'] = L10n::t('Find People');
178 $nv['desc'] = L10n::t('Enter name or interest');
179 $nv['label'] = L10n::t('Connect/Follow');
180 $nv['hint'] = L10n::t('Examples: Robert Morgenstein, Fishing');
181 $nv['findthem'] = L10n::t('Find');
182 $nv['suggest'] = L10n::t('Friend Suggestions');
183 $nv['similar'] = L10n::t('Similar Interests');
184 $nv['random'] = L10n::t('Random Profile');
185 $nv['inv'] = L10n::t('Invite Friends');
186 $nv['directory'] = L10n::t('Global Directory');
187 $nv['global_dir'] = get_server();
188 $nv['local_directory'] = L10n::t('Local Directory');
193 //Community_Pages at right_aside
194 if ($show_pages && local_user()) {
195 $cid = $_GET['cid'] ?? null;
197 //sort by last updated item
200 $contacts = ForumManager::getList($a->user['uid'], $lastitem, true, true);
201 $total = count($contacts);
202 $visible_forums = 10;
204 if (count($contacts)) {
207 foreach ($contacts as $contact) {
208 $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
211 'url' => 'network?cid=' . $contact['id'],
212 'external_url' => Contact::magicLink($contact['url']),
213 'name' => $contact['name'],
214 'cid' => $contact['id'],
215 'selected' => $selected,
216 'micro' => System::removedBaseUrl(ProxyUtils::proxifyUrl($contact['micro'], false, ProxyUtils::SIZE_MICRO)),
223 $tpl = Renderer::getMarkupTemplate('widget_forumlist_right.tpl');
225 $page = Renderer::replaceMacros(
228 '$title' => L10n::t('Forums'),
229 '$forums' => $entries,
230 '$link_desc' => L10n::t('External link to forum'),
232 '$visible_forums' => $visible_forums,
233 '$showmore' => L10n::t('show more')]
236 $aside['$page'] = $page;
239 // END Community Page
245 $helperlist = Config::get("vier", "helperlist");
247 $helpers = explode(",", $helperlist);
251 foreach ($helpers as $index => $helper) {
256 $query .= "'".DBA::escape(Strings::normaliseLink(trim($helper)))."'";
259 $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
262 foreach ($r as $index => $helper) {
263 $r[$index]["url"] = Contact::magicLink($helper["url"]);
266 $r[] = ["url" => "help/Quick-Start-guide", "name" => L10n::t("Quick Start")];
268 $tpl = Renderer::getMarkupTemplate('ch_helpers.tpl');
272 $helpers['title'] = ["", L10n::t('Help'), "", ""];
274 $aside['$helpers_items'] = [];
276 foreach ($r as $rr) {
277 $entry = Renderer::replaceMacros($tpl, [
278 '$url' => $rr['url'],
279 '$title' => $rr['name'],
281 $aside['$helpers_items'][] = $entry;
284 $aside['$helpers'] = $helpers;
289 // connectable services
290 if ($show_services) {
291 /// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
294 if (Addon::isEnabled("buffer")) {
295 $r[] = ["photo" => "images/buffer.png", "name" => "Buffer"];
298 if (Addon::isEnabled("blogger")) {
299 $r[] = ["photo" => "images/blogger.png", "name" => "Blogger"];
302 if (Addon::isEnabled("dwpost")) {
303 $r[] = ["photo" => "images/dreamwidth.png", "name" => "Dreamwidth"];
306 if (Addon::isEnabled("ifttt")) {
307 $r[] = ["photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT"];
310 if (Addon::isEnabled("statusnet")) {
311 $r[] = ["photo" => "images/gnusocial.png", "name" => "GNU Social"];
314 /// @TODO old-lost code (and below)?
315 //if (Addon::isEnabled("ijpost")) {
316 // $r[] = array("photo" => "images/", "name" => "");
319 if (Addon::isEnabled("libertree")) {
320 $r[] = ["photo" => "images/libertree.png", "name" => "Libertree"];
323 //if (Addon::isEnabled("ljpost")) {
324 // $r[] = array("photo" => "images/", "name" => "");
327 if (Addon::isEnabled("pumpio")) {
328 $r[] = ["photo" => "images/pumpio.png", "name" => "pump.io"];
331 if (Addon::isEnabled("tumblr")) {
332 $r[] = ["photo" => "images/tumblr.png", "name" => "Tumblr"];
335 if (Addon::isEnabled("twitter")) {
336 $r[] = ["photo" => "images/twitter.png", "name" => "Twitter"];
339 if (Addon::isEnabled("wppost")) {
340 $r[] = ["photo" => "images/wordpress.png", "name" => "Wordpress"];
343 if (function_exists("imap_open") && !Config::get("system", "imap_disabled") && !Config::get("system", "dfrn_only")) {
344 $r[] = ["photo" => "images/mail.png", "name" => "E-Mail"];
347 $tpl = Renderer::getMarkupTemplate('ch_connectors.tpl');
349 if (DBA::isResult($r)) {
351 $con_services['title'] = ["", L10n::t('Connect Services'), "", ""];
352 $aside['$con_services'] = $con_services;
354 foreach ($r as $rr) {
355 $entry = Renderer::replaceMacros($tpl, [
357 '$photo' => $rr['photo'],
358 '$alt_text' => $rr['name'],
360 $aside['$connector_items'][] = $entry;
364 //end connectable services
367 $tpl = Renderer::getMarkupTemplate('communityhome.tpl');
368 $a->page['right_aside'] = Renderer::replaceMacros($tpl, $aside);