Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

397 lines
12 KiB

  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. require_once("include/plugin.php");
  12. require_once("include/socgraph.php");
  13. require_once("mod/proxy.php");
  14. function vier_init(&$a) {
  15. $a->theme_events_in_profile = false;
  16. set_template_engine($a, 'smarty3');
  17. $baseurl = $a->get_baseurl();
  18. $a->theme_info = array();
  19. if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()) {
  20. vier_community_info();
  21. $a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
  22. }
  23. if ($a->is_mobile || $a->is_tablet) {
  24. $a->page['htmlhead'] .= '<meta name=viewport content="width=device-width, initial-scale=1">'."\n";
  25. $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen"/>'."\n";
  26. }
  27. // deactivated since it doesn't work with desktop browsers at the moment (To-Do)
  28. //$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
  29. $a->page['htmlhead'] .= <<< EOT
  30. <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
  31. <script type="text/javascript">
  32. function insertFormatting(comment,BBcode,id) {
  33. var tmpStr = $("#comment-edit-text-" + id).val();
  34. if(tmpStr == comment) {
  35. tmpStr = "";
  36. $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
  37. $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
  38. openMenu("comment-edit-submit-wrapper-" + id);
  39. $("#comment-edit-text-" + id).val(tmpStr);
  40. }
  41. textarea = document.getElementById("comment-edit-text-" +id);
  42. if (document.selection) {
  43. textarea.focus();
  44. selected = document.selection.createRange();
  45. if (BBcode == "url"){
  46. selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
  47. } else
  48. selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
  49. } else if (textarea.selectionStart || textarea.selectionStart == "0") {
  50. var start = textarea.selectionStart;
  51. var end = textarea.selectionEnd;
  52. if (BBcode == "url"){
  53. textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
  54. } else
  55. textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
  56. }
  57. return true;
  58. }
  59. function showThread(id) {
  60. $("#collapsed-comments-" + id).show()
  61. $("#collapsed-comments-" + id + " .collapsed-comments").show()
  62. }
  63. function hideThread(id) {
  64. $("#collapsed-comments-" + id).hide()
  65. $("#collapsed-comments-" + id + " .collapsed-comments").hide()
  66. }
  67. function cmtBbOpen(id) {
  68. $("#comment-edit-bb-" + id).show();
  69. }
  70. function cmtBbClose(id) {
  71. $("#comment-edit-bb-" + id).hide();
  72. }
  73. </script>
  74. EOT;
  75. if ($a->is_mobile || $a->is_tablet){
  76. $a->page['htmlhead'] .= <<< EOT
  77. <script>
  78. $(document).ready(function() {
  79. $(".mobile-aside-toggle a").click(function(e){
  80. e.preventDefault();
  81. $("aside").toggleClass("show");
  82. });
  83. $(".tabs").click(function(e){
  84. $(this).toggleClass("show");
  85. });
  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. function get_vier_config($key, $default = false, $admin = false) {
  96. if (local_user() AND !$admin) {
  97. $result = get_pconfig(local_user(), "vier", $key);
  98. if ($result !== false)
  99. return $result;
  100. }
  101. $result = get_config("vier", $key);
  102. if ($result !== false)
  103. return $result;
  104. return $default;
  105. }
  106. function vier_community_info() {
  107. $a = get_app();
  108. $show_pages = get_vier_config("show_pages", 1);
  109. $show_profiles = get_vier_config("show_profiles", 1);
  110. $show_helpers = get_vier_config("show_helpers", 1);
  111. $show_services = get_vier_config("show_services", 1);
  112. $show_friends = get_vier_config("show_friends", 1);
  113. $show_lastusers = get_vier_config("show_lastusers", 1);
  114. //get_baseurl
  115. $url = $a->get_baseurl($ssl_state);
  116. $aside['$url'] = $url;
  117. // comunity_profiles
  118. if($show_profiles) {
  119. $r = suggestion_query(local_user(), 0, 9);
  120. $tpl = get_markup_template('ch_directory_item.tpl');
  121. if(count($r)) {
  122. $aside['$comunity_profiles_title'] = t('Community Profiles');
  123. $aside['$comunity_profiles_items'] = array();
  124. foreach($r as $rr) {
  125. $entry = replace_macros($tpl,array(
  126. '$id' => $rr['id'],
  127. //'$profile_link' => zrl($rr['url']),
  128. '$profile_link' => $a->get_baseurl().'/follow/?url='.urlencode($rr['url']),
  129. '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO),
  130. '$alt_text' => $rr['name'],
  131. ));
  132. $aside['$comunity_profiles_items'][] = $entry;
  133. }
  134. }
  135. }
  136. // last 9 users
  137. if($show_lastusers) {
  138. $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 ");
  139. $order = " ORDER BY `register_date` DESC ";
  140. $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`
  141. FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
  142. WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ",
  143. 0, 9);
  144. $tpl = get_markup_template('ch_directory_item.tpl');
  145. if(count($r)) {
  146. $aside['$lastusers_title'] = t('Last users');
  147. $aside['$lastusers_items'] = array();
  148. foreach($r as $rr) {
  149. $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
  150. $entry = replace_macros($tpl,array(
  151. '$id' => $rr['id'],
  152. '$profile_link' => $profile_link,
  153. '$photo' => $a->get_cached_avatar_image($rr['thumb']),
  154. '$alt_text' => $rr['name']));
  155. $aside['$lastusers_items'][] = $entry;
  156. }
  157. }
  158. }
  159. //right_aside FIND FRIENDS
  160. if ($show_friends AND local_user()) {
  161. $nv = array();
  162. $nv['title'] = Array("", t('Find Friends'), "", "");
  163. $nv['directory'] = Array('directory', t('Local Directory'), "", "");
  164. $nv['global_directory'] = Array(get_server(), t('Global Directory'), "", "");
  165. $nv['match'] = Array('match', t('Similar Interests'), "", "");
  166. $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
  167. $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
  168. $nv['search'] = '<form name="simple_bar" method="get" action="'.$a->get_baseurl().'/dirfind">
  169. <span class="sbox_l"></span>
  170. <span class="sbox">
  171. <input type="text" name="search" size="13" maxlength="50">
  172. </span>
  173. <span class="sbox_r" id="srch_clear"></span>';
  174. $aside['$nv'] = $nv;
  175. }
  176. //Community_Pages at right_aside
  177. if($show_pages AND local_user()) {
  178. require_once('include/forums.php');
  179. if(x($_GET['cid']) && intval($_GET['cid']) != 0)
  180. $cid = $_GET['cid'];
  181. //sort by last updated item
  182. $lastitem = true;
  183. $contacts = get_forumlist($a->user['uid'],true,$lastitem, true);
  184. $total = count($contacts);
  185. $visible_forums = 10;
  186. if(count($contacts)) {
  187. $id = 0;
  188. foreach($contacts as $contact) {
  189. $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
  190. $entry = array(
  191. 'url' => z_root() . '/network?f=&cid=' . $contact['id'],
  192. 'external_url' => z_root() . '/redir/' . $contact['id'],
  193. 'name' => $contact['name'],
  194. 'cid' => $contact['id'],
  195. 'selected' => $selected,
  196. 'micro' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
  197. 'id' => ++$id,
  198. );
  199. $entries[] = $entry;
  200. }
  201. $tpl = get_markup_template('widget_forumlist_right.tpl');
  202. $page .= replace_macros($tpl,array(
  203. '$title' => t('Forums'),
  204. '$forums' => $entries,
  205. '$link_desc' => t('External link to forum'),
  206. '$total' => $total,
  207. '$visible_forums' => $visible_forums,
  208. '$showmore' => t('show more'),
  209. ));
  210. $aside['$page'] = $page;
  211. }
  212. }
  213. //END Community Page
  214. //helpers
  215. if($show_helpers) {
  216. $r = array();
  217. $helperlist = get_config("vier", "helperlist");
  218. $helpers = explode(",",$helperlist);
  219. if ($helpers) {
  220. $query = "";
  221. foreach ($helpers AS $index=>$helper) {
  222. if ($query != "")
  223. $query .= ",";
  224. $query .= "'".dbesc(normalise_link(trim($helper)))."'";
  225. }
  226. $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query);
  227. }
  228. foreach ($r AS $index => $helper)
  229. $r[$index]["url"] = zrl($helper["url"]);
  230. $r[] = Array("url" => "help/Quick-Start-guide", "name" => t("Quick Start"));
  231. $tpl = get_markup_template('ch_helpers.tpl');
  232. if ($r) {
  233. $helpers = array();
  234. $helpers['title'] = Array("", t('Help'), "", "");
  235. $aside['$helpers_items'] = array();
  236. foreach($r as $rr) {
  237. $entry = replace_macros($tpl,array(
  238. '$url' => $rr['url'],
  239. '$title' => $rr['name'],
  240. ));
  241. $aside['$helpers_items'][] = $entry;
  242. }
  243. $aside['$helpers'] = $helpers;
  244. }
  245. }
  246. //end helpers
  247. //connectable services
  248. if ($show_services) {
  249. $r = array();
  250. if (plugin_enabled("appnet"))
  251. $r[] = array("photo" => "images/appnet.png", "name" => "App.net");
  252. if (plugin_enabled("buffer"))
  253. $r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
  254. if (plugin_enabled("blogger"))
  255. $r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
  256. if (plugin_enabled("dwpost"))
  257. $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
  258. if (plugin_enabled("fbpost"))
  259. $r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
  260. if (plugin_enabled("ifttt"))
  261. $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
  262. if (plugin_enabled("statusnet"))
  263. $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
  264. if (plugin_enabled("gpluspost"))
  265. $r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
  266. //if (plugin_enabled("ijpost"))
  267. // $r[] = array("photo" => "images/", "name" => "");
  268. if (plugin_enabled("libertree"))
  269. $r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
  270. //if (plugin_enabled("ljpost"))
  271. // $r[] = array("photo" => "images/", "name" => "");
  272. if (plugin_enabled("pumpio"))
  273. $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
  274. if (plugin_enabled("tumblr"))
  275. $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
  276. if (plugin_enabled("twitter"))
  277. $r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
  278. if (plugin_enabled("wppost"))
  279. $r[] = array("photo" => "images/wordpress", "name" => "Wordpress");
  280. if(function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only"))
  281. $r[] = array("photo" => "images/mail", "name" => "E-Mail");
  282. $tpl = get_markup_template('ch_connectors.tpl');
  283. if(count($r)) {
  284. $con_services = array();
  285. $con_services['title'] = Array("", t('Connect Services'), "", "");
  286. $aside['$con_services'] = $con_services;
  287. foreach($r as $rr) {
  288. $entry = replace_macros($tpl,array(
  289. '$url' => $url,
  290. '$photo' => $rr['photo'],
  291. '$alt_text' => $rr['name'],
  292. ));
  293. $aside['$connector_items'][] = $entry;
  294. }
  295. }
  296. }
  297. //end connectable services
  298. //print right_aside
  299. $tpl = get_markup_template('communityhome.tpl');
  300. $a->page['right_aside'] = replace_macros($tpl, $aside);
  301. }