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_info['events_in_profile'] = false;
26 Renderer::setActiveTemplateEngine('smarty3');
30 if ($args->get(0) === 'profile' && $args->get(1) === ($a->user['nickname'] ?? '') || $args->get(0) === 'network' && local_user()
32 vier_community_info();
34 DI::page()['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
37 if (DI::mode()->isMobile() || DI::mode()->isMobile()) {
38 DI::page()['htmlhead'] .= '<meta name=viewport content="width=device-width, initial-scale=1">'."\n";
39 DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen"/>'."\n";
41 /// @todo deactivated since it doesn't work with desktop browsers at the moment
42 //DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
44 DI::page()['htmlhead'] .= <<< EOT
45 <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
46 <script type="text/javascript">
47 function showThread(id) {
48 $("#collapsed-comments-" + id).show()
49 $("#collapsed-comments-" + id + " .collapsed-comments").show()
51 function hideThread(id) {
52 $("#collapsed-comments-" + id).hide()
53 $("#collapsed-comments-" + id + " .collapsed-comments").hide()
56 function cmtBbOpen(id) {
57 $("#comment-edit-bb-" + id).show();
59 function cmtBbClose(id) {
60 $("#comment-edit-bb-" + id).hide();
65 if (DI::mode()->isMobile() || DI::mode()->isMobile()) {
66 DI::page()['htmlhead'] .= <<< EOT
68 $(document).ready(function() {
69 $(".mobile-aside-toggle a").click(function(e){
71 $("aside").toggleClass("show");
73 $(".tabs").click(function(e){
74 $(this).toggleClass("show");
81 // Hide the left menu bar
82 /// @TODO maybe move this static array out where it should belong?
83 if (empty(DI::page()['aside']) && in_array($args->get(0), ["community", "events", "help", "delegation", "notifications",
84 "probe", "webfinger", "login", "invite", "credits"])) {
85 DI::page()['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
89 function get_vier_config($key, $default = false, $admin = false)
91 if (local_user() && !$admin) {
92 $result = DI::pConfig()->get(local_user(), "vier", $key);
93 if (!is_null($result)) {
98 $result = DI::config()->get("vier", $key);
99 if (!is_null($result)) {
106 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\Relation::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 $aside['$page'] = ForumManager::widget('network/forum', local_user());;
190 // END Community Page
196 $helperlist = DI::config()->get("vier", "helperlist");
198 $helpers = explode(",", $helperlist);
201 foreach ($helpers as $helper) {
202 $urls[] = Strings::normaliseLink(trim($helper));
204 $r = DBA::selectToArray('contact', ['url', 'name'], ['uid' => 0, 'nurl' => $urls]);
207 foreach ($r as $index => $helper) {
208 $r[$index]["url"] = Contact::magicLink($helper["url"]);
211 $r[] = ["url" => "help/Quick-Start-guide", "name" => DI::l10n()->t("Quick Start")];
213 $tpl = Renderer::getMarkupTemplate('ch_helpers.tpl');
217 $helpers['title'] = ["", DI::l10n()->t('Help'), "", ""];
219 $aside['$helpers_items'] = [];
221 foreach ($r as $rr) {
222 $entry = Renderer::replaceMacros($tpl, [
223 '$url' => $rr['url'],
224 '$title' => $rr['name'],
226 $aside['$helpers_items'][] = $entry;
229 $aside['$helpers'] = $helpers;
234 // connectable services
235 if ($show_services) {
236 /// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
239 if (Addon::isEnabled("buffer")) {
240 $r[] = ["photo" => "images/buffer.png", "name" => "Buffer"];
243 if (Addon::isEnabled("blogger")) {
244 $r[] = ["photo" => "images/blogger.png", "name" => "Blogger"];
247 if (Addon::isEnabled("dwpost")) {
248 $r[] = ["photo" => "images/dreamwidth.png", "name" => "Dreamwidth"];
251 if (Addon::isEnabled("ifttt")) {
252 $r[] = ["photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT"];
255 if (Addon::isEnabled("statusnet")) {
256 $r[] = ["photo" => "images/gnusocial.png", "name" => "GNU Social"];
259 /// @TODO old-lost code (and below)?
260 //if (Addon::isEnabled("ijpost")) {
261 // $r[] = array("photo" => "images/", "name" => "");
264 if (Addon::isEnabled("libertree")) {
265 $r[] = ["photo" => "images/libertree.png", "name" => "Libertree"];
268 //if (Addon::isEnabled("ljpost")) {
269 // $r[] = array("photo" => "images/", "name" => "");
272 if (Addon::isEnabled("pumpio")) {
273 $r[] = ["photo" => "images/pumpio.png", "name" => "pump.io"];
276 if (Addon::isEnabled("tumblr")) {
277 $r[] = ["photo" => "images/tumblr.png", "name" => "Tumblr"];
280 if (Addon::isEnabled("twitter")) {
281 $r[] = ["photo" => "images/twitter.png", "name" => "Twitter"];
284 if (Addon::isEnabled("wppost")) {
285 $r[] = ["photo" => "images/wordpress.png", "name" => "Wordpress"];
288 if (function_exists("imap_open") && !DI::config()->get("system", "imap_disabled") && !DI::config()->get("system", "dfrn_only")) {
289 $r[] = ["photo" => "images/mail.png", "name" => "E-Mail"];
292 $tpl = Renderer::getMarkupTemplate('ch_connectors.tpl');
294 if (DBA::isResult($r)) {
296 $con_services['title'] = ["", DI::l10n()->t('Connect Services'), "", ""];
297 $aside['$con_services'] = $con_services;
299 foreach ($r as $rr) {
300 $entry = Renderer::replaceMacros($tpl, [
302 '$photo' => $rr['photo'],
303 '$alt_text' => $rr['name'],
305 $aside['$connector_items'][] = $entry;
309 //end connectable services
312 $tpl = Renderer::getMarkupTemplate('communityhome.tpl');
313 DI::page()['right_aside'] = Renderer::replaceMacros($tpl, $aside);
317 * @param int|null $uid
319 * @see \Friendica\Core\Theme::getBackgroundColor()
320 * @TODO Implement this function
322 function vier_get_background_color(int $uid = null)
328 * @param int|null $uid
330 * @see \Friendica\Core\Theme::getThemeColor()
331 * @TODO Implement this function
333 function vier_get_theme_color(int $uid = null)