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