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\Renderer;
16 use Friendica\Core\Search;
17 use Friendica\Database\DBA;
19 use Friendica\Model\Contact;
20 use Friendica\Model\GContact;
21 use Friendica\Util\Strings;
23 function vier_init(App $a)
25 $a->theme_events_in_profile = false;
27 Renderer::setActiveTemplateEngine('smarty3');
29 if (!empty($a->argv[0]) && ($a->argv[0] . ($a->argv[1] ?? '')) === ('profile' . ($a->user['nickname'] ?? '')) || $a->argv[0] === 'network' && local_user()) {
30 vier_community_info();
32 DI::page()['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
35 if (DI::mode()->isMobile() || DI::mode()->isMobile()) {
36 DI::page()['htmlhead'] .= '<meta name=viewport content="width=device-width, initial-scale=1">'."\n";
37 DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen"/>'."\n";
39 /// @todo deactivated since it doesn't work with desktop browsers at the moment
40 //DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
42 DI::page()['htmlhead'] .= <<< EOT
43 <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
44 <script type="text/javascript">
45 function showThread(id) {
46 $("#collapsed-comments-" + id).show()
47 $("#collapsed-comments-" + id + " .collapsed-comments").show()
49 function hideThread(id) {
50 $("#collapsed-comments-" + id).hide()
51 $("#collapsed-comments-" + id + " .collapsed-comments").hide()
54 function cmtBbOpen(id) {
55 $("#comment-edit-bb-" + id).show();
57 function cmtBbClose(id) {
58 $("#comment-edit-bb-" + id).hide();
63 if (DI::mode()->isMobile() || DI::mode()->isMobile()) {
64 DI::page()['htmlhead'] .= <<< EOT
66 $(document).ready(function() {
67 $(".mobile-aside-toggle a").click(function(e){
69 $("aside").toggleClass("show");
71 $(".tabs").click(function(e){
72 $(this).toggleClass("show");
79 // Hide the left menu bar
80 /// @TODO maybe move this static array out where it should belong?
81 if (empty(DI::page()['aside']) && in_array($a->argv[0], ["community", "events", "help", "delegation", "notifications",
82 "probe", "webfinger", "login", "invite", "credits"])) {
83 DI::page()['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
87 function get_vier_config($key, $default = false, $admin = false)
89 if (local_user() && !$admin) {
90 $result = DI::pConfig()->get(local_user(), "vier", $key);
91 if (!is_null($result)) {
96 $result = DI::config()->get("vier", $key);
97 if (!is_null($result)) {
104 function vier_community_info()
108 $show_pages = get_vier_config("show_pages", 1);
109 $show_profiles = get_vier_config("show_profiles", 1);
110 $show_helpers = get_vier_config("show_helpers", 1);
111 $show_services = get_vier_config("show_services", 1);
112 $show_friends = get_vier_config("show_friends", 1);
113 $show_lastusers = get_vier_config("show_lastusers", 1);
116 $url = DI::baseUrl();
117 $aside['$url'] = $url;
120 if ($show_profiles) {
121 $contacts = Contact::getSuggestions(local_user(), 0, 9);
123 $tpl = Renderer::getMarkupTemplate('ch_directory_item.tpl');
124 if (DBA::isResult($contacts)) {
125 $aside['$comunity_profiles_title'] = DI::l10n()->t('Community Profiles');
126 $aside['$comunity_profiles_items'] = [];
128 foreach ($contacts as $contact) {
129 $entry = Renderer::replaceMacros($tpl, [
130 '$id' => $contact['id'],
131 '$profile_link' => 'follow/?url='.urlencode($contact['url']),
132 '$photo' => Contact::getMicro($contact),
133 '$alt_text' => $contact['name'],
135 $aside['$comunity_profiles_items'][] = $entry;
141 if ($show_lastusers) {
142 $condition = ['blocked' => false];
143 if (!DI::config()->get('system', 'publish_all')) {
144 $condition['publish'] = true;
147 $tpl = Renderer::getMarkupTemplate('ch_directory_item.tpl');
149 $profiles = DBA::selectToArray('owner-view', [], $condition, ['order' => ['register_date' => true], 'limit' => [0, 9]]);
151 if (DBA::isResult($profiles)) {
152 $aside['$lastusers_title'] = DI::l10n()->t('Last users');
153 $aside['$lastusers_items'] = [];
155 foreach ($profiles as $profile) {
156 $profile_link = 'profile/' . ((strlen($profile['nickname'])) ? $profile['nickname'] : $profile['uid']);
157 $entry = Renderer::replaceMacros($tpl, [
158 '$id' => $profile['id'],
159 '$profile_link' => $profile_link,
160 '$photo' => DI::baseUrl()->remove($profile['thumb']),
161 '$alt_text' => $profile['name']]);
162 $aside['$lastusers_items'][] = $entry;
167 //right_aside FIND FRIENDS
168 if ($show_friends && local_user()) {
170 $nv['findpeople'] = DI::l10n()->t('Find People');
171 $nv['desc'] = DI::l10n()->t('Enter name or interest');
172 $nv['label'] = DI::l10n()->t('Connect/Follow');
173 $nv['hint'] = DI::l10n()->t('Examples: Robert Morgenstein, Fishing');
174 $nv['findthem'] = DI::l10n()->t('Find');
175 $nv['suggest'] = DI::l10n()->t('Friend Suggestions');
176 $nv['similar'] = DI::l10n()->t('Similar Interests');
177 $nv['random'] = DI::l10n()->t('Random Profile');
178 $nv['inv'] = DI::l10n()->t('Invite Friends');
179 $nv['directory'] = DI::l10n()->t('Global Directory');
180 $nv['global_dir'] = Search::getGlobalDirectory();
181 $nv['local_directory'] = DI::l10n()->t('Local Directory');
186 //Community_Pages at right_aside
187 if ($show_pages && local_user()) {
188 $cid = $_GET['cid'] ?? null;
190 //sort by last updated item
193 $contacts = ForumManager::getList($a->user['uid'], $lastitem, true, true);
194 $total = count($contacts);
195 $visible_forums = 10;
197 if (count($contacts)) {
200 foreach ($contacts as $contact) {
201 $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
204 'url' => 'network?contactid=' . $contact['id'],
205 'external_url' => Contact::magicLink($contact['url']),
206 'name' => $contact['name'],
207 'cid' => $contact['id'],
208 'selected' => $selected,
209 'micro' => Contact::getMicro($contact),
216 $tpl = Renderer::getMarkupTemplate('widget_forumlist_right.tpl');
218 $page = Renderer::replaceMacros(
221 '$title' => DI::l10n()->t('Forums'),
222 '$forums' => $entries,
223 '$link_desc' => DI::l10n()->t('External link to forum'),
225 '$visible_forums' => $visible_forums,
226 '$showmore' => DI::l10n()->t('show more')]
229 $aside['$page'] = $page;
232 // END Community Page
238 $helperlist = DI::config()->get("vier", "helperlist");
240 $helpers = explode(",", $helperlist);
244 foreach ($helpers as $index => $helper) {
249 $query .= "'".DBA::escape(Strings::normaliseLink(trim($helper)))."'";
252 $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
255 foreach ($r as $index => $helper) {
256 $r[$index]["url"] = Contact::magicLink($helper["url"]);
259 $r[] = ["url" => "help/Quick-Start-guide", "name" => DI::l10n()->t("Quick Start")];
261 $tpl = Renderer::getMarkupTemplate('ch_helpers.tpl');
265 $helpers['title'] = ["", DI::l10n()->t('Help'), "", ""];
267 $aside['$helpers_items'] = [];
269 foreach ($r as $rr) {
270 $entry = Renderer::replaceMacros($tpl, [
271 '$url' => $rr['url'],
272 '$title' => $rr['name'],
274 $aside['$helpers_items'][] = $entry;
277 $aside['$helpers'] = $helpers;
282 // connectable services
283 if ($show_services) {
284 /// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
287 if (Addon::isEnabled("buffer")) {
288 $r[] = ["photo" => "images/buffer.png", "name" => "Buffer"];
291 if (Addon::isEnabled("blogger")) {
292 $r[] = ["photo" => "images/blogger.png", "name" => "Blogger"];
295 if (Addon::isEnabled("dwpost")) {
296 $r[] = ["photo" => "images/dreamwidth.png", "name" => "Dreamwidth"];
299 if (Addon::isEnabled("ifttt")) {
300 $r[] = ["photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT"];
303 if (Addon::isEnabled("statusnet")) {
304 $r[] = ["photo" => "images/gnusocial.png", "name" => "GNU Social"];
307 /// @TODO old-lost code (and below)?
308 //if (Addon::isEnabled("ijpost")) {
309 // $r[] = array("photo" => "images/", "name" => "");
312 if (Addon::isEnabled("libertree")) {
313 $r[] = ["photo" => "images/libertree.png", "name" => "Libertree"];
316 //if (Addon::isEnabled("ljpost")) {
317 // $r[] = array("photo" => "images/", "name" => "");
320 if (Addon::isEnabled("pumpio")) {
321 $r[] = ["photo" => "images/pumpio.png", "name" => "pump.io"];
324 if (Addon::isEnabled("tumblr")) {
325 $r[] = ["photo" => "images/tumblr.png", "name" => "Tumblr"];
328 if (Addon::isEnabled("twitter")) {
329 $r[] = ["photo" => "images/twitter.png", "name" => "Twitter"];
332 if (Addon::isEnabled("wppost")) {
333 $r[] = ["photo" => "images/wordpress.png", "name" => "Wordpress"];
336 if (function_exists("imap_open") && !DI::config()->get("system", "imap_disabled") && !DI::config()->get("system", "dfrn_only")) {
337 $r[] = ["photo" => "images/mail.png", "name" => "E-Mail"];
340 $tpl = Renderer::getMarkupTemplate('ch_connectors.tpl');
342 if (DBA::isResult($r)) {
344 $con_services['title'] = ["", DI::l10n()->t('Connect Services'), "", ""];
345 $aside['$con_services'] = $con_services;
347 foreach ($r as $rr) {
348 $entry = Renderer::replaceMacros($tpl, [
350 '$photo' => $rr['photo'],
351 '$alt_text' => $rr['name'],
353 $aside['$connector_items'][] = $entry;
357 //end connectable services
360 $tpl = Renderer::getMarkupTemplate('communityhome.tpl');
361 DI::page()['right_aside'] = Renderer::replaceMacros($tpl, $aside);
365 * @param int|null $uid
367 * @see \Friendica\Core\Theme::getBackgroundColor()
368 * @TODO Implement this function
370 function vier_get_background_color(int $uid = null)
376 * @param int|null $uid
378 * @see \Friendica\Core\Theme::getThemeColor()
379 * @TODO Implement this function
381 function vier_get_theme_color(int $uid = null)