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