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\Util\Strings;
22 function vier_init(App $a)
24 $a->theme_events_in_profile = false;
26 Renderer::setActiveTemplateEngine('smarty3');
28 if (!empty($a->argv[0]) && ($a->argv[0] . ($a->argv[1] ?? '')) === ('profile' . ($a->user['nickname'] ?? '')) || $a->argv[0] === 'network' && local_user()) {
29 vier_community_info();
31 DI::page()['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
34 if (DI::mode()->isMobile() || DI::mode()->isMobile()) {
35 DI::page()['htmlhead'] .= '<meta name=viewport content="width=device-width, initial-scale=1">'."\n";
36 DI::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 //DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
41 DI::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">
44 function showThread(id) {
45 $("#collapsed-comments-" + id).show()
46 $("#collapsed-comments-" + id + " .collapsed-comments").show()
48 function hideThread(id) {
49 $("#collapsed-comments-" + id).hide()
50 $("#collapsed-comments-" + id + " .collapsed-comments").hide()
53 function cmtBbOpen(id) {
54 $("#comment-edit-bb-" + id).show();
56 function cmtBbClose(id) {
57 $("#comment-edit-bb-" + id).hide();
62 if (DI::mode()->isMobile() || DI::mode()->isMobile()) {
63 DI::page()['htmlhead'] .= <<< EOT
65 $(document).ready(function() {
66 $(".mobile-aside-toggle a").click(function(e){
68 $("aside").toggleClass("show");
70 $(".tabs").click(function(e){
71 $(this).toggleClass("show");
78 // Hide the left menu bar
79 /// @TODO maybe move this static array out where it should belong?
80 if (empty(DI::page()['aside']) && in_array($a->argv[0], ["community", "events", "help", "delegation", "notifications",
81 "probe", "webfinger", "login", "invite", "credits"])) {
82 DI::page()['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
86 function get_vier_config($key, $default = false, $admin = false)
88 if (local_user() && !$admin) {
89 $result = DI::pConfig()->get(local_user(), "vier", $key);
90 if (!is_null($result)) {
95 $result = DI::config()->get("vier", $key);
96 if (!is_null($result)) {
103 function vier_community_info()
105 $show_pages = get_vier_config("show_pages", 1);
106 $show_profiles = get_vier_config("show_profiles", 1);
107 $show_helpers = get_vier_config("show_helpers", 1);
108 $show_services = get_vier_config("show_services", 1);
109 $show_friends = get_vier_config("show_friends", 1);
110 $show_lastusers = get_vier_config("show_lastusers", 1);
113 $url = DI::baseUrl();
114 $aside['$url'] = $url;
117 if ($show_profiles) {
118 $contacts = Contact\Relation::getSuggestions(local_user(), 0, 9);
120 $tpl = Renderer::getMarkupTemplate('ch_directory_item.tpl');
121 if (DBA::isResult($contacts)) {
122 $aside['$comunity_profiles_title'] = DI::l10n()->t('Community Profiles');
123 $aside['$comunity_profiles_items'] = [];
125 foreach ($contacts as $contact) {
126 $entry = Renderer::replaceMacros($tpl, [
127 '$id' => $contact['id'],
128 '$profile_link' => 'follow/?url='.urlencode($contact['url']),
129 '$photo' => Contact::getMicro($contact),
130 '$alt_text' => $contact['name'],
132 $aside['$comunity_profiles_items'][] = $entry;
138 if ($show_lastusers) {
139 $condition = ['blocked' => false];
140 if (!DI::config()->get('system', 'publish_all')) {
141 $condition['publish'] = true;
144 $tpl = Renderer::getMarkupTemplate('ch_directory_item.tpl');
146 $profiles = DBA::selectToArray('owner-view', [], $condition, ['order' => ['register_date' => true], 'limit' => [0, 9]]);
148 if (DBA::isResult($profiles)) {
149 $aside['$lastusers_title'] = DI::l10n()->t('Last users');
150 $aside['$lastusers_items'] = [];
152 foreach ($profiles as $profile) {
153 $profile_link = 'profile/' . ((strlen($profile['nickname'])) ? $profile['nickname'] : $profile['uid']);
154 $entry = Renderer::replaceMacros($tpl, [
155 '$id' => $profile['id'],
156 '$profile_link' => $profile_link,
157 '$photo' => DI::baseUrl()->remove($profile['thumb']),
158 '$alt_text' => $profile['name']]);
159 $aside['$lastusers_items'][] = $entry;
164 //right_aside FIND FRIENDS
165 if ($show_friends && local_user()) {
167 $nv['findpeople'] = DI::l10n()->t('Find People');
168 $nv['desc'] = DI::l10n()->t('Enter name or interest');
169 $nv['label'] = DI::l10n()->t('Connect/Follow');
170 $nv['hint'] = DI::l10n()->t('Examples: Robert Morgenstein, Fishing');
171 $nv['findthem'] = DI::l10n()->t('Find');
172 $nv['suggest'] = DI::l10n()->t('Friend Suggestions');
173 $nv['similar'] = DI::l10n()->t('Similar Interests');
174 $nv['random'] = DI::l10n()->t('Random Profile');
175 $nv['inv'] = DI::l10n()->t('Invite Friends');
176 $nv['directory'] = DI::l10n()->t('Global Directory');
177 $nv['global_dir'] = Search::getGlobalDirectory();
178 $nv['local_directory'] = DI::l10n()->t('Local Directory');
183 //Community_Pages at right_aside
184 if ($show_pages && local_user()) {
185 $aside['$page'] = ForumManager::widget('network/forum', local_user());;
187 // END Community Page
193 $helperlist = DI::config()->get("vier", "helperlist");
195 $helpers = explode(",", $helperlist);
198 foreach ($helpers as $helper) {
199 $urls[] = Strings::normaliseLink(trim($helper));
201 $r = DBA::selectToArray('contact', ['url', 'name'], ['uid' => 0, 'nurl' => $urls]);
204 foreach ($r as $index => $helper) {
205 $r[$index]["url"] = Contact::magicLink($helper["url"]);
208 $r[] = ["url" => "help/Quick-Start-guide", "name" => DI::l10n()->t("Quick Start")];
210 $tpl = Renderer::getMarkupTemplate('ch_helpers.tpl');
214 $helpers['title'] = ["", DI::l10n()->t('Help'), "", ""];
216 $aside['$helpers_items'] = [];
218 foreach ($r as $rr) {
219 $entry = Renderer::replaceMacros($tpl, [
220 '$url' => $rr['url'],
221 '$title' => $rr['name'],
223 $aside['$helpers_items'][] = $entry;
226 $aside['$helpers'] = $helpers;
231 // connectable services
232 if ($show_services) {
233 /// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
236 if (Addon::isEnabled("buffer")) {
237 $r[] = ["photo" => "images/buffer.png", "name" => "Buffer"];
240 if (Addon::isEnabled("blogger")) {
241 $r[] = ["photo" => "images/blogger.png", "name" => "Blogger"];
244 if (Addon::isEnabled("dwpost")) {
245 $r[] = ["photo" => "images/dreamwidth.png", "name" => "Dreamwidth"];
248 if (Addon::isEnabled("ifttt")) {
249 $r[] = ["photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT"];
252 if (Addon::isEnabled("statusnet")) {
253 $r[] = ["photo" => "images/gnusocial.png", "name" => "GNU Social"];
256 /// @TODO old-lost code (and below)?
257 //if (Addon::isEnabled("ijpost")) {
258 // $r[] = array("photo" => "images/", "name" => "");
261 if (Addon::isEnabled("libertree")) {
262 $r[] = ["photo" => "images/libertree.png", "name" => "Libertree"];
265 //if (Addon::isEnabled("ljpost")) {
266 // $r[] = array("photo" => "images/", "name" => "");
269 if (Addon::isEnabled("pumpio")) {
270 $r[] = ["photo" => "images/pumpio.png", "name" => "pump.io"];
273 if (Addon::isEnabled("tumblr")) {
274 $r[] = ["photo" => "images/tumblr.png", "name" => "Tumblr"];
277 if (Addon::isEnabled("twitter")) {
278 $r[] = ["photo" => "images/twitter.png", "name" => "Twitter"];
281 if (Addon::isEnabled("wppost")) {
282 $r[] = ["photo" => "images/wordpress.png", "name" => "Wordpress"];
285 if (function_exists("imap_open") && !DI::config()->get("system", "imap_disabled") && !DI::config()->get("system", "dfrn_only")) {
286 $r[] = ["photo" => "images/mail.png", "name" => "E-Mail"];
289 $tpl = Renderer::getMarkupTemplate('ch_connectors.tpl');
291 if (DBA::isResult($r)) {
293 $con_services['title'] = ["", DI::l10n()->t('Connect Services'), "", ""];
294 $aside['$con_services'] = $con_services;
296 foreach ($r as $rr) {
297 $entry = Renderer::replaceMacros($tpl, [
299 '$photo' => $rr['photo'],
300 '$alt_text' => $rr['name'],
302 $aside['$connector_items'][] = $entry;
306 //end connectable services
309 $tpl = Renderer::getMarkupTemplate('communityhome.tpl');
310 DI::page()['right_aside'] = Renderer::replaceMacros($tpl, $aside);
314 * @param int|null $uid
316 * @see \Friendica\Core\Theme::getBackgroundColor()
317 * @TODO Implement this function
319 function vier_get_background_color(int $uid = null)
325 * @param int|null $uid
327 * @see \Friendica\Core\Theme::getThemeColor()
328 * @TODO Implement this function
330 function vier_get_theme_color(int $uid = null)