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