5 function follow_widget($value = "") {
7 return replace_macros(get_markup_template('follow.tpl'), array(
8 '$connect' => t('Add New Contact'),
9 '$desc' => t('Enter address or web location'),
10 '$hint' => t('Example: bob@example.com, http://example.com/barbara'),
12 '$follow' => t('Connect')
17 function findpeople_widget() {
18 require_once 'include/Contact.php';
22 if (get_config('system', 'invitation_only')) {
23 $x = get_pconfig(local_user(), 'system', 'invites_remaining');
24 if ($x || is_site_admin()) {
25 $a->page['aside'] .= '<div class="side-link" id="side-invite-remain">'
26 . sprintf( tt('%d invitation available', '%d invitations available', $x), $x)
31 return replace_macros(get_markup_template('peoplefind.tpl'), array(
32 '$findpeople' => t('Find People'),
33 '$desc' => t('Enter name or interest'),
34 '$label' => t('Connect/Follow'),
35 '$hint' => t('Examples: Robert Morgenstein, Fishing'),
36 '$findthem' => t('Find'),
37 '$suggest' => t('Friend Suggestions'),
38 '$similar' => t('Similar Interests'),
39 '$random' => t('Random Profile'),
40 '$inv' => t('Invite Friends')
45 function unavailable_networks() {
50 if (!plugin_enabled("appnet")) {
51 $networks[] = NETWORK_APPNET;
54 if (!plugin_enabled("fbpost") AND !plugin_enabled("facebook")) {
55 $networks[] = NETWORK_FACEBOOK;
58 if (!plugin_enabled("statusnet")) {
59 $networks[] = NETWORK_STATUSNET;
62 if (!plugin_enabled("pumpio")) {
63 $networks[] = NETWORK_PUMPIO;
66 if (!plugin_enabled("twitter")) {
67 $networks[] = NETWORK_TWITTER;
70 if (get_config("system", "ostatus_disabled")) {
71 $networks[] = NETWORK_OSTATUS;
74 if (!get_config("system", "diaspora_enabled")) {
75 $networks[] = NETWORK_DIASPORA;
78 if (!plugin_enabled("pnut")) {
79 $networks[] = NETWORK_PNUT;
82 if (!sizeof($networks)) {
86 $network_filter = implode("','", $networks);
88 $network_filter = "AND `network` NOT IN ('$network_filter')";
90 return $network_filter;
93 function networks_widget($baseurl, $selected = '') {
101 if (!feature_enabled(local_user(), 'networks')) {
105 $extra_sql = unavailable_networks();
107 $r = q("SELECT DISTINCT(`network`) FROM `contact` WHERE `uid` = %d AND `network` != '' $extra_sql ORDER BY `network`",
112 if (dbm::is_result($r)) {
113 require_once 'include/contact_selectors.php';
114 foreach ($r as $rr) {
115 /// @TODO If 'network' is not there, this triggers an E_NOTICE
116 if ($rr['network']) {
117 $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
122 if (count($nets) < 2) {
126 return replace_macros(get_markup_template('nets.tpl'), array(
127 '$title' => t('Networks'),
129 '$sel_all' => (($selected == '') ? 'selected' : ''),
130 '$all' => t('All Networks'),
137 function fileas_widget($baseurl, $selected = '') {
138 if (! local_user()) {
142 if (! feature_enabled(local_user(), 'filing')) {
146 $saved = get_pconfig(local_user(), 'system', 'filetags');
147 if (! strlen($saved)) {
153 $cnt = preg_match_all('/\[(.*?)\]/', $saved, $matches, PREG_SET_ORDER);
155 foreach ($matches as $mtch) {
156 $unescaped = xmlify(file_tag_decode($mtch[1]));
157 $terms[] = array('name' => $unescaped, 'selected' => (($selected == $unescaped) ? 'selected' : ''));
161 return replace_macros(get_markup_template('fileas_widget.tpl'), array(
162 '$title' => t('Saved Folders'),
164 '$sel_all' => (($selected == '') ? 'selected' : ''),
165 '$all' => t('Everything'),
172 function categories_widget($baseurl, $selected = '') {
176 if (! feature_enabled($a->profile['profile_uid'], 'categories')) {
180 $saved = get_pconfig($a->profile['profile_uid'], 'system', 'filetags');
181 if (! strlen($saved)) {
187 $cnt = preg_match_all('/<(.*?)>/', $saved, $matches, PREG_SET_ORDER);
190 foreach ($matches as $mtch) {
191 $unescaped = xmlify(file_tag_decode($mtch[1]));
192 $terms[] = array('name' => $unescaped, 'selected' => (($selected == $unescaped) ? 'selected' : ''));
196 return replace_macros(get_markup_template('categories_widget.tpl'), array(
197 '$title' => t('Categories'),
199 '$sel_all' => (($selected == '') ? 'selected' : ''),
200 '$all' => t('Everything'),
207 function common_friends_visitor_widget($profile_uid) {
211 if (local_user() == $profile_uid) {
217 if (is_array($_SESSION['remote'])) {
218 foreach ($_SESSION['remote'] as $visitor) {
219 if ($visitor['uid'] == $profile_uid) {
220 $cid = $visitor['cid'];
228 $r = q("select id from contact where nurl = '%s' and uid = %d limit 1",
229 dbesc(normalise_link(get_my_url())),
232 if (dbm::is_result($r)) {
235 $r = q("select id from gcontact where nurl = '%s' limit 1",
236 dbesc(normalise_link(get_my_url()))
238 if (dbm::is_result($r))
244 if ($cid == 0 && $zcid == 0) {
248 require_once 'include/socgraph.php';
251 $t = count_common_friends($profile_uid, $cid);
253 $t = count_common_friends_zcid($profile_uid, $zcid);
260 $r = common_friends($profile_uid, $cid, 0, 5, true);
262 $r = common_friends_zcid($profile_uid, $zcid, 0, 5, true);
265 return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
266 '$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
267 '$base' => App::get_baseurl(),
268 '$uid' => $profile_uid,
269 '$cid' => (($cid) ? $cid : '0'),
270 '$linkmore' => (($t > 5) ? 'true' : ''),
271 '$more' => t('show more'),