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.

404 lines
11KB

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