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.
 
 
 
 
 
 

406 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(App $a) {
  15. $a->theme_events_in_profile = false;
  16. set_template_engine($a, 'smarty3');
  17. if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()) {
  18. vier_community_info();
  19. $a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
  20. }
  21. if ($a->is_mobile || $a->is_tablet) {
  22. $a->page['htmlhead'] .= '<meta name=viewport content="width=device-width, initial-scale=1">'."\n";
  23. $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen"/>'."\n";
  24. }
  25. /// @todo deactivated since it doesn't work with desktop browsers at the moment
  26. //$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="view/theme/vier/mobile.css" media="screen and (max-width: 1000px)"/>'."\n";
  27. $a->page['htmlhead'] .= <<< EOT
  28. <link rel='stylesheet' type='text/css' href='view/theme/vier/narrow.css' media='screen and (max-width: 1100px)' />
  29. <script type="text/javascript">
  30. function insertFormatting(BBcode, id) {
  31. var tmpStr = $("#comment-edit-text-" + id).val();
  32. if (tmpStr == "") {
  33. $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
  34. $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
  35. openMenu("comment-edit-submit-wrapper-" + id);
  36. }
  37. textarea = document.getElementById("comment-edit-text-" +id);
  38. if (document.selection) {
  39. textarea.focus();
  40. selected = document.selection.createRange();
  41. if (BBcode == "url") {
  42. selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
  43. } else {
  44. selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
  45. }
  46. } else if (textarea.selectionStart || textarea.selectionStart == "0") {
  47. var start = textarea.selectionStart;
  48. var end = textarea.selectionEnd;
  49. if (BBcode == "url") {
  50. textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
  51. } else {
  52. textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
  53. }
  54. }
  55. return true;
  56. }
  57. function showThread(id) {
  58. $("#collapsed-comments-" + id).show()
  59. $("#collapsed-comments-" + id + " .collapsed-comments").show()
  60. }
  61. function hideThread(id) {
  62. $("#collapsed-comments-" + id).hide()
  63. $("#collapsed-comments-" + id + " .collapsed-comments").hide()
  64. }
  65. function cmtBbOpen(id) {
  66. $("#comment-edit-bb-" + id).show();
  67. }
  68. function cmtBbClose(id) {
  69. $("#comment-edit-bb-" + id).hide();
  70. }
  71. </script>
  72. EOT;
  73. if ($a->is_mobile || $a->is_tablet){
  74. $a->page['htmlhead'] .= <<< EOT
  75. <script>
  76. $(document).ready(function() {
  77. $(".mobile-aside-toggle a").click(function(e){
  78. e.preventDefault();
  79. $("aside").toggleClass("show");
  80. });
  81. $(".tabs").click(function(e){
  82. $(this).toggleClass("show");
  83. });
  84. });
  85. </script>
  86. EOT;
  87. }
  88. // Hide the left menu bar
  89. if (($a->page['aside'] == "") AND in_array($a->argv[0], array("community", "events", "help", "manage", "notifications",
  90. "probe", "webfinger", "login", "invite", "credits"))) {
  91. $a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
  92. }
  93. }
  94. function get_vier_config($key, $default = false, $admin = false) {
  95. if (local_user() AND !$admin) {
  96. $result = get_pconfig(local_user(), "vier", $key);
  97. if ($result !== false)
  98. return $result;
  99. }
  100. $result = get_config("vier", $key);
  101. if ($result !== false)
  102. return $result;
  103. return $default;
  104. }
  105. function vier_community_info() {
  106. $a = get_app();
  107. $show_pages = get_vier_config("show_pages", 1);
  108. $show_profiles = get_vier_config("show_profiles", 1);
  109. $show_helpers = get_vier_config("show_helpers", 1);
  110. $show_services = get_vier_config("show_services", 1);
  111. $show_friends = get_vier_config("show_friends", 1);
  112. $show_lastusers = get_vier_config("show_lastusers", 1);
  113. //get_baseurl
  114. $url = App::get_baseurl($ssl_state);
  115. $aside['$url'] = $url;
  116. // comunity_profiles
  117. if ($show_profiles) {
  118. $r = suggestion_query(local_user(), 0, 9);
  119. $tpl = get_markup_template('ch_directory_item.tpl');
  120. if (dbm::is_result($r)) {
  121. $aside['$comunity_profiles_title'] = t('Community Profiles');
  122. $aside['$comunity_profiles_items'] = array();
  123. foreach ($r as $rr) {
  124. $entry = replace_macros($tpl,array(
  125. '$id' => $rr['id'],
  126. //'$profile_link' => zrl($rr['url']),
  127. '$profile_link' => 'follow/?url='.urlencode($rr['url']),
  128. '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO),
  129. '$alt_text' => $rr['name'],
  130. ));
  131. $aside['$comunity_profiles_items'][] = $entry;
  132. }
  133. }
  134. }
  135. // last 9 users
  136. if ($show_lastusers) {
  137. $publish = (get_config('system','publish_all') ? '' : " AND `publish` = 1 ");
  138. $order = " ORDER BY `register_date` DESC ";
  139. $tpl = get_markup_template('ch_directory_item.tpl');
  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. if (dbm::is_result($r)) {
  145. $aside['$lastusers_title'] = t('Last users');
  146. $aside['$lastusers_items'] = array();
  147. foreach ($r as $rr) {
  148. $profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
  149. $entry = replace_macros($tpl,array(
  150. '$id' => $rr['id'],
  151. '$profile_link' => $profile_link,
  152. '$photo' => $a->remove_baseurl($rr['thumb']),
  153. '$alt_text' => $rr['name']));
  154. $aside['$lastusers_items'][] = $entry;
  155. }
  156. }
  157. }
  158. //right_aside FIND FRIENDS
  159. if ($show_friends AND local_user()) {
  160. $nv = array();
  161. $nv['title'] = Array("", t('Find Friends'), "", "");
  162. $nv['directory'] = Array('directory', t('Local Directory'), "", "");
  163. $nv['global_directory'] = Array(get_server(), t('Global Directory'), "", "");
  164. $nv['match'] = Array('match', t('Similar Interests'), "", "");
  165. $nv['suggest'] = Array('suggest', t('Friend Suggestions'), "", "");
  166. $nv['invite'] = Array('invite', t('Invite Friends'), "", "");
  167. $nv['search'] = '<form name="simple_bar" method="get" action="dirfind">
  168. <span class="sbox_l"></span>
  169. <span class="sbox">
  170. <input type="text" name="search" size="13" maxlength="50">
  171. </span>
  172. <span class="sbox_r" id="srch_clear"></span>';
  173. $aside['$nv'] = $nv;
  174. }
  175. //Community_Pages at right_aside
  176. if ($show_pages AND local_user()) {
  177. require_once('include/ForumManager.php');
  178. if (x($_GET, 'cid') && intval($_GET['cid']) != 0) {
  179. $cid = $_GET['cid'];
  180. }
  181. //sort by last updated item
  182. $lastitem = true;
  183. $contacts = ForumManager::get_list($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' => 'network?f=&cid=' . $contact['id'],
  192. 'external_url' => 'redir/' . $contact['id'],
  193. 'name' => $contact['name'],
  194. 'cid' => $contact['id'],
  195. 'selected' => $selected,
  196. 'micro' => App::remove_baseurl(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. /// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
  250. $r = array();
  251. if (plugin_enabled("appnet")) {
  252. $r[] = array("photo" => "images/appnet.png", "name" => "App.net");
  253. }
  254. if (plugin_enabled("buffer")) {
  255. $r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
  256. }
  257. if (plugin_enabled("blogger")) {
  258. $r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
  259. }
  260. if (plugin_enabled("dwpost")) {
  261. $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
  262. }
  263. if (plugin_enabled("fbpost")) {
  264. $r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
  265. }
  266. if (plugin_enabled("ifttt")) {
  267. $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
  268. }
  269. if (plugin_enabled("statusnet")) {
  270. $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
  271. }
  272. if (plugin_enabled("gpluspost")) {
  273. $r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
  274. }
  275. //if (plugin_enabled("ijpost")) {
  276. // $r[] = array("photo" => "images/", "name" => "");
  277. //}
  278. if (plugin_enabled("libertree")) {
  279. $r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
  280. }
  281. //if (plugin_enabled("ljpost")) {
  282. // $r[] = array("photo" => "images/", "name" => "");
  283. //}
  284. if (plugin_enabled("pumpio")) {
  285. $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
  286. }
  287. if (plugin_enabled("tumblr")) {
  288. $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
  289. }
  290. if (plugin_enabled("twitter")) {
  291. $r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
  292. }
  293. if (plugin_enabled("wppost")) {
  294. $r[] = array("photo" => "images/wordpress.png", "name" => "Wordpress");
  295. }
  296. if (function_exists("imap_open") AND !get_config("system","imap_disabled") AND !get_config("system","dfrn_only")) {
  297. $r[] = array("photo" => "images/mail.png", "name" => "E-Mail");
  298. }
  299. $tpl = get_markup_template('ch_connectors.tpl');
  300. if (dbm::is_result($r)) {
  301. $con_services = array();
  302. $con_services['title'] = Array("", t('Connect Services'), "", "");
  303. $aside['$con_services'] = $con_services;
  304. foreach ($r as $rr) {
  305. $entry = replace_macros($tpl,array(
  306. '$url' => $url,
  307. '$photo' => $rr['photo'],
  308. '$alt_text' => $rr['name'],
  309. ));
  310. $aside['$connector_items'][] = $entry;
  311. }
  312. }
  313. }
  314. //end connectable services
  315. //print right_aside
  316. $tpl = get_markup_template('communityhome.tpl');
  317. $a->page['right_aside'] = replace_macros($tpl, $aside);
  318. }