]> git.mxchange.org Git - friendica.git/blob - view/theme/vier/theme.php
298f0df57f51083d835251e4feb1ea877b0c0551
[friendica.git] / view / theme / vier / theme.php
1 <?php
2 /**
3  * Name: Vier
4  * Version: 1.2
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/
10  */
11
12 use Friendica\App;
13
14 require_once "include/plugin.php";
15 require_once "include/socgraph.php";
16 require_once "mod/proxy.php";
17
18 function vier_init(App $a) {
19
20         $a->theme_events_in_profile = false;
21
22         set_template_engine($a, 'smarty3');
23
24         if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) {
25                 vier_community_info();
26
27                 $a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
28         }
29
30         if ($a->is_mobile || $a->is_tablet) {
31                 $a->page['htmlhead'] .= '<meta name=viewport content="width=device-width, initial-scale=1">'."\n";
32                 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen"/>'."\n";
33         }
34         /// @todo deactivated since it doesn't work with desktop browsers at the moment
35         //$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
36
37         $a->page['htmlhead'] .= <<< EOT
38 <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
39 <script type="text/javascript">
40
41 function insertFormatting(BBcode, id) {
42         var tmpStr = $("#comment-edit-text-" + id).val();
43         if (tmpStr == "") {
44                 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
45                 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
46                 openMenu("comment-edit-submit-wrapper-" + id);
47         }
48
49         textarea = document.getElementById("comment-edit-text-" +id);
50         if (document.selection) {
51                 textarea.focus();
52                 selected = document.selection.createRange();
53                 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
54         } else if (textarea.selectionStart || textarea.selectionStart == "0") {
55                 var start = textarea.selectionStart;
56                 var end = textarea.selectionEnd;
57                 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
58         }
59
60         return true;
61 }
62
63 function showThread(id) {
64         $("#collapsed-comments-" + id).show()
65         $("#collapsed-comments-" + id + " .collapsed-comments").show()
66 }
67 function hideThread(id) {
68         $("#collapsed-comments-" + id).hide()
69         $("#collapsed-comments-" + id + " .collapsed-comments").hide()
70 }
71
72 function cmtBbOpen(id) {
73         $("#comment-edit-bb-" + id).show();
74 }
75 function cmtBbClose(id) {
76         $("#comment-edit-bb-" + id).hide();
77 }
78 </script>
79 EOT;
80
81         if ($a->is_mobile || $a->is_tablet){
82                 $a->page['htmlhead'] .= <<< EOT
83 <script>
84         $(document).ready(function() {
85                 $(".mobile-aside-toggle a").click(function(e){
86                         e.preventDefault();
87                         $("aside").toggleClass("show");
88                 });
89                 $(".tabs").click(function(e){
90                         $(this).toggleClass("show");
91                 });
92         });
93 </script>
94 EOT;
95         }
96
97         // Hide the left menu bar
98         /// @TODO maybe move this static array out where it should belong?
99         if (($a->page['aside'] == "") && in_array($a->argv[0], array("community", "events", "help", "manage", "notifications",
100                         "probe", "webfinger", "login", "invite", "credits"))) {
101                 $a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
102         }
103 }
104
105 function get_vier_config($key, $default = false, $admin = false) {
106         if (local_user() && !$admin) {
107                 $result = get_pconfig(local_user(), "vier", $key);
108                 if ($result !== false) {
109                         return $result;
110                 }
111         }
112
113         $result = get_config("vier", $key);
114         if ($result !== false) {
115                 return $result;
116         }
117
118         return $default;
119 }
120
121 function vier_community_info() {
122         $a = get_app();
123
124         $show_pages      = get_vier_config("show_pages", 1);
125         $show_profiles   = get_vier_config("show_profiles", 1);
126         $show_helpers    = get_vier_config("show_helpers", 1);
127         $show_services   = get_vier_config("show_services", 1);
128         $show_friends    = get_vier_config("show_friends", 1);
129         $show_lastusers  = get_vier_config("show_lastusers", 1);
130
131         // get_baseurl
132         $url = App::get_baseurl($ssl_state);
133         $aside['$url'] = $url;
134
135         // comunity_profiles
136         if ($show_profiles) {
137
138                 $r = suggestion_query(local_user(), 0, 9);
139
140                 $tpl = get_markup_template('ch_directory_item.tpl');
141                 if (dbm::is_result($r)) {
142
143                         $aside['$comunity_profiles_title'] = t('Community Profiles');
144                         $aside['$comunity_profiles_items'] = array();
145
146                         foreach ($r as $rr) {
147                                 $entry = replace_macros($tpl,array(
148                                         '$id' => $rr['id'],
149                                         //'$profile_link' => zrl($rr['url']),
150                                         '$profile_link' => 'follow/?url='.urlencode($rr['url']),
151                                         '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO),
152                                         '$alt_text' => $rr['name'],
153                                 ));
154                                 $aside['$comunity_profiles_items'][] = $entry;
155                         }
156                 }
157         }
158
159         // last 9 users
160         if ($show_lastusers) {
161                 $publish = (get_config('system', 'publish_all') ? '' : " AND `publish` = 1 ");
162                 $order = " ORDER BY `register_date` DESC ";
163
164                 $tpl = get_markup_template('ch_directory_item.tpl');
165
166                 $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
167                                 FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
168                                 WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ",
169                                 0, 9);
170
171                 if (dbm::is_result($r)) {
172
173                         $aside['$lastusers_title'] = t('Last users');
174                         $aside['$lastusers_items'] = array();
175
176                         foreach ($r as $rr) {
177                                 $profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
178                                 $entry = replace_macros($tpl,array(
179                                         '$id' => $rr['id'],
180                                         '$profile_link' => $profile_link,
181                                         '$photo' => $a->remove_baseurl($rr['thumb']),
182                                         '$alt_text' => $rr['name']));
183                                 $aside['$lastusers_items'][] = $entry;
184                         }
185                 }
186         }
187
188         //right_aside FIND FRIENDS
189         if ($show_friends && local_user()) {
190                 $nv = array();
191                 $nv['title'] = array("", t('Find Friends'), "", "");
192                 $nv['directory'] = array('directory', t('Local Directory'), "", "");
193                 $nv['global_directory'] = Array(get_server(), t('Global Directory'), "", "");
194                 $nv['match'] = array('match', t('Similar Interests'), "", "");
195                 $nv['suggest'] = array('suggest', t('Friend Suggestions'), "", "");
196                 $nv['invite'] = array('invite', t('Invite Friends'), "", "");
197
198                 $nv['search'] = '<form name="simple_bar" method="get" action="dirfind">
199                                                 <span class="sbox_l"></span>
200                                                 <span class="sbox">
201                                                 <input type="text" name="search" size="13" maxlength="50">
202                                                 </span>
203                                                 <span class="sbox_r" id="srch_clear"></span>';
204
205                 $aside['$nv'] = $nv;
206         }
207
208         //Community_Pages at right_aside
209         if ($show_pages && local_user()) {
210
211                 require_once 'include/ForumManager.php';
212
213                 if (x($_GET, 'cid') && intval($_GET['cid']) != 0) {
214                         $cid = $_GET['cid'];
215                 }
216
217                 //sort by last updated item
218                 $lastitem = true;
219
220                 $contacts = ForumManager::get_list($a->user['uid'],true,$lastitem, true);
221                 $total = count($contacts);
222                 $visible_forums = 10;
223
224                 if (count($contacts)) {
225
226                         $id = 0;
227
228                         foreach ($contacts as $contact) {
229
230                                 $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
231
232                                 $entry = array(
233                                         'url'          => 'network?f=&cid=' . $contact['id'],
234                                         'external_url' => 'redir/' . $contact['id'],
235                                         'name'         => $contact['name'],
236                                         'cid'          => $contact['id'],
237                                         'selected'     => $selected,
238                                         'micro'        => App::remove_baseurl(proxy_url($contact['micro'], false, PROXY_SIZE_MICRO)),
239                                         'id'           => ++$id,
240                                 );
241                                 $entries[] = $entry;
242                         }
243
244
245                         $tpl = get_markup_template('widget_forumlist_right.tpl');
246
247                         $page .= replace_macros($tpl, array(
248                                 '$title'          => t('Forums'),
249                                 '$forums'         => $entries,
250                                 '$link_desc'      => t('External link to forum'),
251                                 '$total'          => $total,
252                                 '$visible_forums' => $visible_forums,
253                                 '$showmore'       => t('show more'),
254                         ));
255
256                         $aside['$page'] = $page;
257                 }
258         }
259         // END Community Page
260
261         // helpers
262         if ($show_helpers) {
263                 $r = array();
264
265                 $helperlist = get_config("vier", "helperlist");
266
267                 $helpers = explode(",",$helperlist);
268
269                 if ($helpers) {
270                         $query = "";
271                         foreach ($helpers AS $index=>$helper) {
272                                 if ($query != "")
273                                         $query .= ",";
274
275                                 $query .= "'".dbesc(normalise_link(trim($helper)))."'";
276                         }
277
278                         $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
279                 }
280
281                 foreach ($r AS $index => $helper)
282                         $r[$index]["url"] = zrl($helper["url"]);
283
284                 $r[] = array("url" => "help/Quick-Start-guide", "name" => t("Quick Start"));
285
286                 $tpl = get_markup_template('ch_helpers.tpl');
287
288                 if ($r) {
289
290                         $helpers = array();
291                         $helpers['title'] = array("", t('Help'), "", "");
292
293                         $aside['$helpers_items'] = array();
294
295                         foreach ($r as $rr) {
296                                 $entry = replace_macros($tpl,array(
297                                         '$url' => $rr['url'],
298                                         '$title' => $rr['name'],
299                                 ));
300                                 $aside['$helpers_items'][] = $entry;
301                         }
302
303                         $aside['$helpers'] = $helpers;
304                 }
305         }
306         // end helpers
307
308         // connectable services
309         if ($show_services) {
310
311                 /// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
312                 $r = array();
313
314                 if (plugin_enabled("appnet")) {
315                         $r[] = array("photo" => "images/appnet.png", "name" => "App.net");
316                 }
317
318                 if (plugin_enabled("buffer")) {
319                         $r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
320                 }
321
322                 if (plugin_enabled("blogger")) {
323                         $r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
324                 }
325
326                 if (plugin_enabled("dwpost")) {
327                         $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
328                 }
329
330                 if (plugin_enabled("fbpost")) {
331                         $r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
332                 }
333
334                 if (plugin_enabled("ifttt")) {
335                         $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
336                 }
337
338                 if (plugin_enabled("statusnet")) {
339                         $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
340                 }
341
342                 if (plugin_enabled("gpluspost")) {
343                         $r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
344                 }
345
346                 /// @TODO old-lost code (and below)?
347                 //if (plugin_enabled("ijpost")) {
348                 //      $r[] = array("photo" => "images/", "name" => "");
349                 //}
350
351                 if (plugin_enabled("libertree")) {
352                         $r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
353                 }
354
355                 //if (plugin_enabled("ljpost")) {
356                 //      $r[] = array("photo" => "images/", "name" => "");
357                 //}
358
359                 if (plugin_enabled("pumpio")) {
360                         $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
361                 }
362
363                 if (plugin_enabled("tumblr")) {
364                         $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
365                 }
366
367                 if (plugin_enabled("twitter")) {
368                         $r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
369                 }
370
371                 if (plugin_enabled("wppost")) {
372                         $r[] = array("photo" => "images/wordpress.png", "name" => "Wordpress");
373                 }
374
375                 if (function_exists("imap_open") && !get_config("system","imap_disabled") && !get_config("system","dfrn_only")) {
376                         $r[] = array("photo" => "images/mail.png", "name" => "E-Mail");
377                 }
378
379                 $tpl = get_markup_template('ch_connectors.tpl');
380
381                 if (dbm::is_result($r)) {
382
383                         $con_services = array();
384                         $con_services['title'] = array("", t('Connect Services'), "", "");
385                         $aside['$con_services'] = $con_services;
386
387                         foreach ($r as $rr) {
388                                 $entry = replace_macros($tpl,array(
389                                         '$url' => $url,
390                                         '$photo' => $rr['photo'],
391                                         '$alt_text' => $rr['name'],
392                                 ));
393                                 $aside['$connector_items'][] = $entry;
394                         }
395                 }
396
397         }
398         //end connectable services
399
400         //print right_aside
401         $tpl = get_markup_template('communityhome.tpl');
402         $a->page['right_aside'] = replace_macros($tpl, $aside);
403 }