3 function follow_widget($value = "") {
5 return replace_macros(get_markup_template('follow.tpl'), array(
6 '$connect' => t('Add New Contact'),
7 '$desc' => t('Enter address or web location'),
8 '$hint' => t('Example: bob@example.com, http://example.com/barbara'),
10 '$follow' => t('Connect')
15 function findpeople_widget() {
16 require_once 'include/Contact.php';
20 if (get_config('system', 'invitation_only')) {
21 $x = get_pconfig(local_user(), 'system', 'invites_remaining');
22 if ($x || is_site_admin()) {
23 $a->page['aside'] .= '<div class="side-link" id="side-invite-remain">'
24 . sprintf( tt('%d invitation available', '%d invitations available', $x), $x)
29 return replace_macros(get_markup_template('peoplefind.tpl'), array(
30 '$findpeople' => t('Find People'),
31 '$desc' => t('Enter name or interest'),
32 '$label' => t('Connect/Follow'),
33 '$hint' => t('Examples: Robert Morgenstein, Fishing'),
34 '$findthem' => t('Find'),
35 '$suggest' => t('Friend Suggestions'),
36 '$similar' => t('Similar Interests'),
37 '$random' => t('Random Profile'),
38 '$inv' => t('Invite Friends')
43 function unavailable_networks() {
48 if (!plugin_enabled("appnet")) {
49 $networks[] = NETWORK_APPNET;
52 if (!plugin_enabled("fbpost") AND !plugin_enabled("facebook")) {
53 $networks[] = NETWORK_FACEBOOK;
56 if (!plugin_enabled("statusnet")) {
57 $networks[] = NETWORK_STATUSNET;
60 if (!plugin_enabled("pumpio")) {
61 $networks[] = NETWORK_PUMPIO;
64 if (!plugin_enabled("twitter")) {
65 $networks[] = NETWORK_TWITTER;
68 if (get_config("system", "ostatus_disabled")) {
69 $networks[] = NETWORK_OSTATUS;
72 if (!get_config("system", "diaspora_enabled")) {
73 $networks[] = NETWORK_DIASPORA;
76 if (!plugin_enabled("pnut")) {
77 $networks[] = NETWORK_PNUT;
80 if (!sizeof($networks)) {
84 $network_filter = implode("','", $networks);
86 $network_filter = "AND `network` NOT IN ('$network_filter')";
88 return $network_filter;
91 function networks_widget($baseurl, $selected = '') {
99 if (!feature_enabled(local_user(), 'networks')) {
103 $extra_sql = unavailable_networks();
105 $r = q("SELECT DISTINCT(`network`) FROM `contact` WHERE `uid` = %d AND `network` != '' $extra_sql ORDER BY `network`",
110 if (dbm::is_result($r)) {
111 require_once 'include/contact_selectors.php';
112 foreach ($r as $rr) {
113 /// @TODO If 'network' is not there, this triggers an E_NOTICE
114 if ($rr['network']) {
115 $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
120 if (count($nets) < 2) {
124 return replace_macros(get_markup_template('nets.tpl'), array(
125 '$title' => t('Networks'),
127 '$sel_all' => (($selected == '') ? 'selected' : ''),
128 '$all' => t('All Networks'),
135 function fileas_widget($baseurl, $selected = '') {
136 if (! local_user()) {
140 if (! feature_enabled(local_user(), 'filing')) {
144 $saved = get_pconfig(local_user(), 'system', 'filetags');
145 if (! strlen($saved)) {
151 $cnt = preg_match_all('/\[(.*?)\]/', $saved, $matches, PREG_SET_ORDER);
153 foreach ($matches as $mtch) {
154 $unescaped = xmlify(file_tag_decode($mtch[1]));
155 $terms[] = array('name' => $unescaped, 'selected' => (($selected == $unescaped) ? 'selected' : ''));
159 return replace_macros(get_markup_template('fileas_widget.tpl'), array(
160 '$title' => t('Saved Folders'),
162 '$sel_all' => (($selected == '') ? 'selected' : ''),
163 '$all' => t('Everything'),
170 function categories_widget($baseurl, $selected = '') {
174 if (! feature_enabled($a->profile['profile_uid'], 'categories')) {
178 $saved = get_pconfig($a->profile['profile_uid'], 'system', 'filetags');
179 if (! strlen($saved)) {
185 $cnt = preg_match_all('/<(.*?)>/', $saved, $matches, PREG_SET_ORDER);
188 foreach ($matches as $mtch) {
189 $unescaped = xmlify(file_tag_decode($mtch[1]));
190 $terms[] = array('name' => $unescaped, 'selected' => (($selected == $unescaped) ? 'selected' : ''));
194 return replace_macros(get_markup_template('categories_widget.tpl'), array(
195 '$title' => t('Categories'),
197 '$sel_all' => (($selected == '') ? 'selected' : ''),
198 '$all' => t('Everything'),
205 function common_friends_visitor_widget($profile_uid) {
209 if (local_user() == $profile_uid) {
215 if (is_array($_SESSION['remote'])) {
216 foreach ($_SESSION['remote'] as $visitor) {
217 if ($visitor['uid'] == $profile_uid) {
218 $cid = $visitor['cid'];
226 $r = q("select id from contact where nurl = '%s' and uid = %d limit 1",
227 dbesc(normalise_link(get_my_url())),
230 if (dbm::is_result($r)) {
233 $r = q("select id from gcontact where nurl = '%s' limit 1",
234 dbesc(normalise_link(get_my_url()))
236 if (dbm::is_result($r))
242 if ($cid == 0 && $zcid == 0) {
246 require_once 'include/socgraph.php';
249 $t = count_common_friends($profile_uid, $cid);
251 $t = count_common_friends_zcid($profile_uid, $zcid);
258 $r = common_friends($profile_uid, $cid, 0, 5, true);
260 $r = common_friends_zcid($profile_uid, $zcid, 0, 5, true);
263 return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
264 '$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
265 '$base' => App::get_baseurl(),
266 '$uid' => $profile_uid,
267 '$cid' => (($cid) ? $cid : '0'),
268 '$linkmore' => (($t > 5) ? 'true' : ''),
269 '$more' => t('show more'),