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;
23 * This script can be included even when the app is in maintenance mode which requires us to avoid any config call
26 function vier_init(App $a)
28 $a->setThemeInfoValue('events_in_profile', false);
30 Renderer::setActiveTemplateEngine('smarty3');
35 DI::mode()->has(App\Mode::MAINTENANCEDISABLED)
37 $args->get(0) === 'profile' && $args->get(1) === ($a->getLoggedInUserNickname() ?? '')
38 || $args->get(0) === 'network' && local_user()
41 vier_community_info();
43 DI::page()['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
46 if (DI::mode()->isMobile() || DI::mode()->isMobile()) {
47 DI::page()['htmlhead'] .= '<meta name=viewport content="width=device-width, initial-scale=1">'."\n";
48 DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen"/>'."\n";
50 /// @todo deactivated since it doesn't work with desktop browsers at the moment
51 //DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
53 DI::page()['htmlhead'] .= <<< EOT
54 <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
55 <script type="text/javascript">
56 function showThread(id) {
57 $("#collapsed-comments-" + id).show()
58 $("#collapsed-comments-" + id + " .collapsed-comments").show()
60 function hideThread(id) {
61 $("#collapsed-comments-" + id).hide()
62 $("#collapsed-comments-" + id + " .collapsed-comments").hide()
65 function cmtBbOpen(id) {
66 $("#comment-edit-bb-" + id).show();
68 function cmtBbClose(id) {
69 $("#comment-edit-bb-" + id).hide();
74 if (DI::mode()->isMobile() || DI::mode()->isMobile()) {
75 DI::page()['htmlhead'] .= <<< EOT
77 $(document).ready(function() {
78 $(".mobile-aside-toggle a").click(function(e){
80 $("aside").toggleClass("show");
82 $(".tabs").click(function(e){
83 $(this).toggleClass("show");
90 // Hide the left menu bar
91 /// @TODO maybe move this static array out where it should belong?
92 if (empty(DI::page()['aside']) && in_array($args->get(0), ["community", "events", "help", "delegation", "notifications",
93 "probe", "webfinger", "login", "invite", "credits"])) {
94 DI::page()['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
98 function get_vier_config($key, $default = false, $admin = false)
100 if (local_user() && !$admin) {
101 $result = DI::pConfig()->get(local_user(), "vier", $key);
102 if (!is_null($result)) {
107 $result = DI::config()->get("vier", $key);
108 if (!is_null($result)) {
115 function vier_community_info()
117 $show_pages = get_vier_config("show_pages", 1);
118 $show_profiles = get_vier_config("show_profiles", 1);
119 $show_helpers = get_vier_config("show_helpers", 1);
120 $show_services = get_vier_config("show_services", 1);
121 $show_friends = get_vier_config("show_friends", 1);
122 $show_lastusers = get_vier_config("show_lastusers", 1);
125 $url = DI::baseUrl();
126 $aside['$url'] = $url;
129 if ($show_profiles) {
130 $contacts = Contact\Relation::getSuggestions(local_user(), 0, 9);
132 $tpl = Renderer::getMarkupTemplate('ch_directory_item.tpl');
133 if (DBA::isResult($contacts)) {
134 $aside['$comunity_profiles_title'] = DI::l10n()->t('Community Profiles');
135 $aside['$comunity_profiles_items'] = [];
137 foreach ($contacts as $contact) {
138 $entry = Renderer::replaceMacros($tpl, [
139 '$id' => $contact['id'],
140 '$profile_link' => 'follow/?url='.urlencode($contact['url']),
141 '$photo' => Contact::getMicro($contact),
142 '$alt_text' => $contact['name'],
144 $aside['$comunity_profiles_items'][] = $entry;
150 if ($show_lastusers) {
151 $condition = ['blocked' => false];
152 if (!DI::config()->get('system', 'publish_all')) {
153 $condition['publish'] = true;
156 $tpl = Renderer::getMarkupTemplate('ch_directory_item.tpl');
158 $profiles = DBA::selectToArray('owner-view', [], $condition, ['order' => ['register_date' => true], 'limit' => [0, 9]]);
160 if (DBA::isResult($profiles)) {
161 $aside['$lastusers_title'] = DI::l10n()->t('Last users');
162 $aside['$lastusers_items'] = [];
164 foreach ($profiles as $profile) {
165 $profile_link = 'profile/' . ((strlen($profile['nickname'])) ? $profile['nickname'] : $profile['uid']);
166 $entry = Renderer::replaceMacros($tpl, [
167 '$id' => $profile['id'],
168 '$profile_link' => $profile_link,
169 '$photo' => DI::baseUrl()->remove($profile['thumb']),
170 '$alt_text' => $profile['name']]);
171 $aside['$lastusers_items'][] = $entry;
176 //right_aside FIND FRIENDS
177 if ($show_friends && local_user()) {
179 $nv['findpeople'] = DI::l10n()->t('Find People');
180 $nv['desc'] = DI::l10n()->t('Enter name or interest');
181 $nv['label'] = DI::l10n()->t('Connect/Follow');
182 $nv['hint'] = DI::l10n()->t('Examples: Robert Morgenstein, Fishing');
183 $nv['findthem'] = DI::l10n()->t('Find');
184 $nv['suggest'] = DI::l10n()->t('Friend Suggestions');
185 $nv['similar'] = DI::l10n()->t('Similar Interests');
186 $nv['random'] = DI::l10n()->t('Random Profile');
187 $nv['inv'] = DI::l10n()->t('Invite Friends');
188 $nv['directory'] = DI::l10n()->t('Global Directory');
189 $nv['global_dir'] = Search::getGlobalDirectory();
190 $nv['local_directory'] = DI::l10n()->t('Local Directory');
195 //Community_Pages at right_aside
196 if ($show_pages && local_user()) {
197 $aside['$page'] = ForumManager::widget('network/forum', local_user());;
199 // END Community Page
205 $helperlist = DI::config()->get("vier", "helperlist");
207 $helpers = explode(",", $helperlist);
210 foreach ($helpers as $helper) {
211 $urls[] = Strings::normaliseLink(trim($helper));
213 $r = DBA::selectToArray('contact', ['url', 'name'], ['uid' => 0, 'nurl' => $urls]);
216 foreach ($r as $index => $helper) {
217 $r[$index]["url"] = Contact::magicLink($helper["url"]);
220 $r[] = ["url" => "help/Quick-Start-guide", "name" => DI::l10n()->t("Quick Start")];
222 $tpl = Renderer::getMarkupTemplate('ch_helpers.tpl');
226 $helpers['title'] = ["", DI::l10n()->t('Help'), "", ""];
228 $aside['$helpers_items'] = [];
230 foreach ($r as $rr) {
231 $entry = Renderer::replaceMacros($tpl, [
232 '$url' => $rr['url'],
233 '$title' => $rr['name'],
235 $aside['$helpers_items'][] = $entry;
238 $aside['$helpers'] = $helpers;
243 // connectable services
244 if ($show_services) {
245 /// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
248 if (Addon::isEnabled("buffer")) {
249 $r[] = ["photo" => "images/buffer.png", "name" => "Buffer"];
252 if (Addon::isEnabled("blogger")) {
253 $r[] = ["photo" => "images/blogger.png", "name" => "Blogger"];
256 if (Addon::isEnabled("dwpost")) {
257 $r[] = ["photo" => "images/dreamwidth.png", "name" => "Dreamwidth"];
260 if (Addon::isEnabled("ifttt")) {
261 $r[] = ["photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT"];
264 if (Addon::isEnabled("statusnet")) {
265 $r[] = ["photo" => "images/gnusocial.png", "name" => "GNU Social"];
268 /// @TODO old-lost code (and below)?
269 //if (Addon::isEnabled("ijpost")) {
270 // $r[] = array("photo" => "images/", "name" => "");
273 if (Addon::isEnabled("libertree")) {
274 $r[] = ["photo" => "images/libertree.png", "name" => "Libertree"];
277 //if (Addon::isEnabled("ljpost")) {
278 // $r[] = array("photo" => "images/", "name" => "");
281 if (Addon::isEnabled("pumpio")) {
282 $r[] = ["photo" => "images/pumpio.png", "name" => "pump.io"];
285 if (Addon::isEnabled("tumblr")) {
286 $r[] = ["photo" => "images/tumblr.png", "name" => "Tumblr"];
289 if (Addon::isEnabled("twitter")) {
290 $r[] = ["photo" => "images/twitter.png", "name" => "Twitter"];
293 if (Addon::isEnabled("wppost")) {
294 $r[] = ["photo" => "images/wordpress.png", "name" => "Wordpress"];
297 if (function_exists("imap_open") && !DI::config()->get("system", "imap_disabled")) {
298 $r[] = ["photo" => "images/mail.png", "name" => "E-Mail"];
301 $tpl = Renderer::getMarkupTemplate('ch_connectors.tpl');
303 if (DBA::isResult($r)) {
305 $con_services['title'] = ["", DI::l10n()->t('Connect Services'), "", ""];
306 $aside['$con_services'] = $con_services;
308 foreach ($r as $rr) {
309 $entry = Renderer::replaceMacros($tpl, [
311 '$photo' => $rr['photo'],
312 '$alt_text' => $rr['name'],
314 $aside['$connector_items'][] = $entry;
318 //end connectable services
321 $tpl = Renderer::getMarkupTemplate('communityhome.tpl');
322 DI::page()['right_aside'] = Renderer::replaceMacros($tpl, $aside);
326 * @param int|null $uid
328 * @see \Friendica\Core\Theme::getBackgroundColor()
329 * @TODO Implement this function
331 function vier_get_background_color(int $uid = null)
337 * @param int|null $uid
339 * @see \Friendica\Core\Theme::getThemeColor()
340 * @TODO Implement this function
342 function vier_get_theme_color(int $uid = null)