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.

73 lines
1.6 KiB

11 years ago
  1. <?php
  2. function match_content(&$a) {
  3. $o = '';
  4. if(! local_user())
  5. return;
  6. $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
  7. $o .= '<h2>' . t('Profile Match') . '</h2>';
  8. $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
  9. intval(local_user())
  10. );
  11. if(! count($r))
  12. return;
  13. if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
  14. notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);
  15. return;
  16. }
  17. $params = array();
  18. $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
  19. if($tags) {
  20. $params['s'] = $tags;
  21. if($a->pager['page'] != 1)
  22. $params['p'] = $a->pager['page'];
  23. if(strlen(get_config('system','directory_submit_url')))
  24. $x = post_url('http://dir.friendika.com/msearch', $params);
  25. else
  26. $x = post_url($a->get_baseurl() . '/msearch', $params);
  27. $j = json_decode($x);
  28. if($j->total) {
  29. $a->set_pager_total($j->total);
  30. $a->set_pager_itemspage($j->items_page);
  31. }
  32. if(count($j->results)) {
  33. $tpl = get_markup_template('match.tpl');
  34. foreach($j->results as $jj) {
  35. $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
  36. $o .= replace_macros($tpl,array(
  37. '$url' => $jj->url,
  38. '$name' => $jj->name,
  39. '$photo' => $jj->photo,
  40. '$inttxt' => ' ' . t('is interested in:'),
  41. '$conntxt' => t('Connect'),
  42. '$connlnk' => $connlnk,
  43. '$tags' => $jj->tags
  44. ));
  45. }
  46. }
  47. else {
  48. info( t('No matches') . EOL);
  49. }
  50. }
  51. $o .= cleardiv();
  52. $o .= paginate($a);
  53. return $o;
  54. }