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