]> git.mxchange.org Git - friendica.git/blob - view/theme/vier/theme.php
vier: fix little misspelling
[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                 require_once('include/forums.php');
224
225                 if(x($_GET['cid']) && intval($_GET['cid']) != 0)
226                         $cid = $_GET['cid'];
227
228                 //sort by last updated item
229                 $lastitem = true;
230
231                 $contacts = get_forumlist($a->user['uid'],true,$lastitem, true);
232                 $total = count($contacts);
233                 $visible_forums = 10;
234
235                 if(count($contacts)) {
236
237                         $id = 0;
238
239                         foreach($contacts as $contact) {
240
241                                 $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
242
243                                 $entry = array(
244                                         'url' => z_root() . '/network?f=&cid=' . $contact['id'],
245                                         'external_url' => z_root() . '/redir/' . $contact['id'],
246                                         'name' => $contact['name'],
247                                         'cid' => $contact['id'],
248                                         'selected'      => $selected,
249                                         'micro' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
250                                         'id' => ++$id,
251                                 );
252                                 $entries[] = $entry;
253                         }
254
255
256                         $tpl = get_markup_template('widget_forumlist_right.tpl');
257
258                         $page .= replace_macros($tpl,array(
259                                 '$title'        => t('Forums'),
260                                 '$forums'       => $entries,
261                                 '$link_desc'    => t('External link to forum'),
262                                 '$total'        => $total,
263                                 '$visible_forums' => $visible_forums,
264                                 '$showmore'     => t('show more'),
265                         ));
266
267                         $aside['$page'] = $page;
268                 }
269         }
270         //END Community Page
271
272         //helpers
273         if($show_helpers) {
274                 $r = array();
275
276                 $helperlist = get_config("vier", "helperlist");
277
278                 $helpers = explode(",",$helperlist);
279
280                 if ($helpers) {
281                         $query = "";
282                         foreach ($helpers AS $index=>$helper) {
283                                 if ($query != "")
284                                         $query .= ",";
285
286                                 $query .= "'".dbesc(normalise_link(trim($helper)))."'";
287                         }
288
289                         $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
290                 }
291
292                 foreach ($r AS $index => $helper)
293                         $r[$index]["url"] = zrl($helper["url"]);
294
295                 $r[] = Array("url" => "help/Quick-Start-guide", "name" => t("Quick Start"));
296
297                 $tpl = get_markup_template('ch_helpers.tpl');
298
299                 if ($r) {
300
301                         $helpers = array();
302                         $helpers['title'] = Array("", t('Help'), "", "");
303
304                         $aside['$helpers_items'] = array();
305
306                         foreach($r as $rr) {
307                                 $entry = replace_macros($tpl,array(
308                                         '$url' => $rr['url'],
309                                         '$title' => $rr['name'],
310                                 ));
311                                 $aside['$helpers_items'][] = $entry;
312                         }
313
314                         $aside['$helpers'] = $helpers;
315                 }
316         }
317         //end helpers
318
319         //connectable services
320         if ($show_services) {
321
322                 $r = array();
323
324                 if (plugin_enabled("appnet"))
325                         $r[] = array("photo" => "images/appnet.png", "name" => "App.net");
326
327                 if (plugin_enabled("buffer"))
328                         $r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
329
330                 if (plugin_enabled("blogger"))
331                         $r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
332
333                 if (plugin_enabled("dwpost"))
334                         $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
335
336                 if (plugin_enabled("fbpost"))
337                         $r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
338
339                 if (plugin_enabled("ifttt"))
340                         $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
341
342                 if (plugin_enabled("statusnet"))
343                         $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
344
345                 if (plugin_enabled("gpluspost"))
346                         $r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
347
348                 //if (plugin_enabled("ijpost"))
349                 //      $r[] = array("photo" => "images/", "name" => "");
350
351                 if (plugin_enabled("libertree"))
352                         $r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
353
354                 //if (plugin_enabled("ljpost"))
355                 //      $r[] = array("photo" => "images/", "name" => "");
356
357                 if (plugin_enabled("pumpio"))
358                         $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
359
360                 if (plugin_enabled("tumblr"))
361                         $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
362
363                 if (plugin_enabled("twitter"))
364                         $r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
365
366                 if (plugin_enabled("wppost"))
367                         $r[] = array("photo" => "images/wordpress", "name" => "Wordpress");
368
369                 if(function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only"))
370                         $r[] = array("photo" => "images/mail", "name" => "E-Mail");
371
372                 $tpl = get_markup_template('ch_connectors.tpl');
373
374                 if(count($r)) {
375
376                         $con_services = array();
377                         $con_services['title'] = Array("", t('Connect Services'), "", "");
378                         $aside['$con_services'] = $con_services;
379
380                         foreach($r as $rr) {
381                                 $entry = replace_macros($tpl,array(
382                                         '$url' => $url,
383                                         '$photo' => $rr['photo'],
384                                         '$alt_text' => $rr['name'],
385                                 ));
386                                 $aside['$connector_items'][] = $entry;
387                         }
388                 }
389
390         }
391         //end connectable services
392
393         //print right_aside
394         $tpl = get_markup_template('communityhome.tpl');
395         $a->page['right_aside'] = replace_macros($tpl, $aside);
396 }