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