Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

116 satır
3.0KB

  1. <?php
  2. require_once('include/text.php');
  3. require_once('include/socgraph.php');
  4. require_once('include/contact_widgets.php');
  5. require_once('mod/proxy.php');
  6. /**
  7. * @brief Controller for /match.
  8. *
  9. * It takes keywords from your profile and queries the directory server for
  10. * matching keywords from other profiles.
  11. *
  12. * @param App $a
  13. * @return void|string
  14. */
  15. function match_content(App $a) {
  16. $o = '';
  17. if (! local_user()) {
  18. return;
  19. }
  20. $a->page['aside'] .= findpeople_widget();
  21. $a->page['aside'] .= follow_widget();
  22. $_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd;
  23. $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
  24. intval(local_user())
  25. );
  26. if (! dbm::is_result($r)) {
  27. return;
  28. }
  29. if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
  30. notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);
  31. return;
  32. }
  33. $params = array();
  34. $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
  35. if($tags) {
  36. $params['s'] = $tags;
  37. if($a->pager['page'] != 1)
  38. $params['p'] = $a->pager['page'];
  39. if(strlen(get_config('system','directory')))
  40. $x = post_url(get_server().'/msearch', $params);
  41. else
  42. $x = post_url(App::get_baseurl() . '/msearch', $params);
  43. $j = json_decode($x);
  44. if($j->total) {
  45. $a->set_pager_total($j->total);
  46. $a->set_pager_itemspage($j->items_page);
  47. }
  48. if(count($j->results)) {
  49. $id = 0;
  50. foreach($j->results as $jj) {
  51. $match_nurl = normalise_link($jj->url);
  52. $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1",
  53. intval(local_user()),
  54. dbesc($match_nurl));
  55. if (!count($match)) {
  56. $jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
  57. $connlnk = App::get_baseurl() . '/follow/?url=' . $jj->url;
  58. $photo_menu = array(
  59. 'profile' => array(t("View Profile"), zrl($jj->url)),
  60. 'follow' => array(t("Connect/Follow"), $connlnk)
  61. );
  62. $contact_details = get_contact_details_by_url($jj->url, local_user());
  63. $entry = array(
  64. 'url' => zrl($jj->url),
  65. 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $jj->url),
  66. 'name' => $jj->name,
  67. 'details' => $contact_details['location'],
  68. 'tags' => $contact_details['keywords'],
  69. 'about' => $contact_details['about'],
  70. 'account_type' => account_type($contact_details),
  71. 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
  72. 'inttxt' => ' ' . t('is interested in:'),
  73. 'conntxt' => t('Connect'),
  74. 'connlnk' => $connlnk,
  75. 'img_hover' => $jj->tags,
  76. 'photo_menu' => $photo_menu,
  77. 'id' => ++$id,
  78. );
  79. $entries[] = $entry;
  80. }
  81. }
  82. $tpl = get_markup_template('viewcontact_template.tpl');
  83. $o .= replace_macros($tpl,array(
  84. '$title' => t('Profile Match'),
  85. '$contacts' => $entries,
  86. '$paginate' => paginate($a),
  87. ));
  88. }
  89. else {
  90. info( t('No matches') . EOL);
  91. }
  92. }
  93. return $o;
  94. }